Docsity

Understanding Prolog: Logic Programming and Syntactic Structure, Slides of Formal Semantics

Toggle sidebar
bg1
Last Time
• Important Concepts
– English to logic
•facts
– e.g. Mary is a baseball fan.➔baseball_fan(mary).
–predicate: baseball_fan
–argument: mary
– e.g. Mary likes John ➔likes(mary,john).
–multiple arguments: express relations
•inference rules
– e.g. snoring presupposes sleeping ➔
sleeping(X) :- snoring(X).
–logic variable: X
–if: :-
– note: basically expresses idea... snoring(X) ⇒sleeping(X)
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Understanding Prolog: Logic Programming and Syntactic Structure and more Slides Formal Semantics in PDF only on Docsity!

Last Time

-^ Important Concepts– English to logic -^ facts^ – e.g. Mary is a baseball fan.

➔^ baseball_fan(mary).

-^ predicate

: baseball_fan

-^ argument

: mary

  • e.g. Mary likes John

➔^ likes(mary,john).

-^ multiple arguments

: express

relations

-^ inference rules^ – e.g. snoring presupposes sleeping

➔

sleeping(X) :- snoring(X).

-^ logic variable

: X

-^ if : :-– note:

basically expresses idea

... snoring(X)

⇒^ sleeping(X)

Last Time

-^ Important Concepts–

Prolog database^ •^

the database represents a

scenario

or^ possible world

-^ initially, the world is empty•^ we can

assert

and^ retract

facts and rules

  • e.g. ?- assert(baseball_fan(mary)).• asserted facts and rules are true in that world• Closed World Assumption

:

  • things that are not asserted or inferable are false (in this world)• can’t have negated facts (or head of rules) in the database– e.g. ?- assert((+ baseball_fan(mary))).

is not allowed

  • e.g. ?- assert((+ baseball_fan(X) :- hates(X,baseball)).

is not

allowed – e.g. ?- assert((baseball_fan(X) :- + hates(X,baseball)).

is^ allowed

Last Time

-^ Important Concepts–

negated queries

are ok

-^ (though they return no answer other than Yes/No)– query^

?- + baseball_fan(X). is

true if

-^ subquery

?- baseball_fan(X).

is not true

-^ ?- baseball_fan(X). would be not true for all possible worlds wherethere are no baseball fans–^ i.e. no baseball_fan/1 facts–^ and

we have no rules that could be used to concludebaseball_fan/1 is true from

logical inference

-^ e.g. no world like•

baseball_fan(X) :- loves(X,baseball).• loves(john,baseball).• loves(john,football).

Larger Picture

-^ Computer Lab homework– asks you to write Prolog facts, rules and queries

corresponding to a series of English sentencesand questions

-^ examples:– Mary is a student– Pete is a baseball fan– who is both a student and a baseball fan?– who is a baseball fan and not a student?

Larger Picture

-^ Goal: Formalize language so this can be done stepby step Mary is astudentwho is astudent?

student(mary).?- student(X).

Larger Picture

-^ In just a few more lectures, we’ll be able to dothis... •^ ...

quick demo to do this we have to be able to(1) parse, and(2) assign meaning to the English input we’ll be developing the tools and techniques to do this

Syntactic Structure

-^ A formal grammar enables us to logically break downa sentence into its constituent parts

X-bar phrase structure constituent labelsC2 = CP = S-bar (clause)I2 = S (sentence)VP = Verb PhraseV = VerbNP = Noun PhraseDET = determinerN1 = Noun (bar level 1)

Syntactic Structure

-^ A formal grammar enables us to logically break downa sentence into its constituent parts

X-bar phrase structure subject: [

[^ I2^ NP

john] I1 ]

VP:^ is a student copula:

is complement of VP:[^ [^ NP^ DET

a][^ N

student]] (predicate NP)

Syntactic Structure

-^ A formal grammar enables us to logically break downa sentence into its constituent parts

X-bar phrase structure specifier of CP: [

[^ CP^ NP

who] C1 ]

head of CP: C: auxiliary verb

is

subject: [

[^ I2^ NP

trace] I1 ]

subject is coindexed [1] withspecifier of CPVP: [

trace]V

a student verb (trace) is coindexed [2] with is complement of VP:[^ [^ NP^ DET

a][^ N

student]]

Syntactic Structure

-^ We could but don’t have to specifically use X-barphrase structure to diagram sentences–

idea that all phrases have regular internal structure – [^ XP^ specifier

[^ [^ X1^ X

head

]^ complement

]]

  • X = {C,I,V,N,A,P,..}– so long as we’re able to identify (recover)configurations and (implied) grammatical positions• subject• object• verb (predicate)

Phrase Structure Rules

-^ Simple rules: •^ SBar

→^ S

•^ S

→^ NP VP

•^ VP

→^ V NP

•^ V

→^ is

-^ NP

→^ DET N

•^ NP

→^ ProperNoun

-^ ProperNoun

→^ John

-^ DET

→^ a

-^ N

→^ student

subjectobject

  • John is a [

student]pred^

  • John [

likes] Marypred^

  • John is [

happy]pred^

-^ which is the

predicate

  • V (main verb:

likes

)

  • Vaux

is^ (copula carries (^) little meaning)

  • complement of copula isthe predicate• Note:–^ gotta be careful – John is

the^

student

Phrase Structure Rules

-^ Rules

-^ SBar

→^ WhNoun Aux S

-^ WhNoun

→^ who

-^ Aux

→^ is

-^ S

→^ NPtrace VP

-^ NPtrace

→ε

-^ VP

→^ Vtrace NP

-^ Vtrace

→ε

-^ NP

→^ DET N

-^ DET

→^ a

-^ N

→^ student

subject^ empty

object

plus associations by coindexation betweentraces and contentful items

Reading Assignment(s)

-^ for later this week– handout– Chapter 2:

Putting a Meaning Together from Pieces

  • we will discuss it on Thursday• are you comfortable diagramming sentences?– if not, grab any grammar/syntax book– or search the web:•

http://en.wikipedia.org/wiki/Phrase_structure_rules

-^ Thursday– there will be a 15 minute quiz at the end of class