csa4050: advanced topics in nlp
DESCRIPTION
CSA4050: Advanced Topics in NLP. Semantics III Quantified Sentences. Language Sentences Determiners Noun Phrases Syntactic Structure. Logic Generalised Quantifiers Higher order functions Translation into Prolog. Outline. Syntax-Semantics Interface. - PowerPoint PPT PresentationTRANSCRIPT
October 2004 CSA4050: Semantics III 1
CSA4050:Advanced Topics in NLP
Semantics III
• Quantified Sentences
October 2004 CSA4050: Semantics III 2
Outline
Language• Sentences• Determiners• Noun Phrases• Syntactic Structure
Logic• Generalised
Quantifiers• Higher order
functions• Translation into
Prolog
Syntax-Semantics Interface
October 2004 CSA4050: Semantics III 3
Determiners and Quantifiers in Language and Logic
A dog barked x dog(x) & bark(x)
Every dog barked x dog(x) bark(x)
Fido chased a cat x cat(x) & chase(fido,x)
Every dog chased
a cat
x dog(x) (y cat(x) & chase(x,y)))
October 2004 CSA4050: Semantics III 4
Syntactic Shape vs.Semantic Shape
• John walks
semantics:walk(suzie).
• Every man talkssemantics:all(X, man(X) talk(X))
S
NP VPSuzie walks
S
NP VP
Det N talks Every man
October 2004 CSA4050: Semantics III 5
Problem
• Similar syntactic shape
• Dissimilar semantic shape
• How is this possible if the syntax drives the combination of semantic fragments as per rule-to-rule hypothesis?
• Answer: be creative about logical forms and semantic combination rules
October 2004 CSA4050: Semantics III 6
Montague Solution
• Reorganising the semantic combination rules operating between VP and NP in rules such ass(S) --> np(NP), vp(VP).
• We will be considering [NP]([VP]) versus [VP]([NP]).
• NPs as higher order functions
• Analyse LF of quantified sentences
October 2004 CSA4050: Semantics III 7
LF of Quantified Sentences
• LF of quantified sentences has a general shape involving– a restrictor predicate R– a scope predicate S
• R restricts the set of things we are talking about• S says something further about set element(s)
– a logical quantifier Q– a bound variable V– a logical operator O connecting R and S
October 2004 CSA4050: Semantics III 8
Examples
All lecturers are lazy
x lecturer(x) lazy(x)
• Restrictor = lecturers• Scope = lazy• Quantifier = All• Operator = implies• Bound Variable = x
October 2004 CSA4050: Semantics III 9
Examples
There is a lazy lecturer
x lecturer(x) & lazy(x)
• Restrictor = lecturers• Scope = lazy• Quantifier = exist• Operator = and• Bound Variable = x
October 2004 CSA4050: Semantics III 10
Anatomy of Quantified Sentences
Logic Q V R O S
x m(x) w(x) x m(x) w(x)
x d(x) & b(x) x d(x) & b(x)
x d(x) (h(x) & b(x))
x d(x) h(x) & b(x)
October 2004 CSA4050: Semantics III 11
Generalized Quantifiers
• We adopt the following generalized quantifier representation for LF in which quantifier is a 3-place predicate:Q(<variable>,<restrictor>,<scope>)
• Operator is omitted.• Examples
all(X,man(X),walk(X))exist(X,man(X),walk(X))the(X,man(X),climbed(X,everest))most(X,lecturer(X),poor(X))
October 2004 CSA4050: Semantics III 12
NP as higher order function
NP
Q^all(X,man(X),Q)
every man
VP
Y^walk(Y)
walks
S
all(X,man(X),walk(X))
October 2004 CSA4050: Semantics III 13
Encoding in Prolog
• The VP remains as before, ieX^walks(X)
• The quantified NP every man will be of the formQ^all(X,man(X) => Q)
• The semantic rule for S now ensures that the NP function is applied to the VP function.s(S)--> np(NP),vp(VP), {reduce(NP,VP,S)}
October 2004 CSA4050: Semantics III 14
DCG with QuantificationProgram 1
% grammar
s(S) --> np(NP), vp(VP), {reduce(NP,VP,S)}
vp(VP) --> v(V).
% lexicon
v(X^walk(X)) --> [walks].
np(Q^all(X,man(X),Q)) --> [every,man].
October 2004 CSA4050: Semantics III 15
Result?- s(X,[every,man,walks],[]).
X = all(_G397, man(_G397), _G405^walk(_G405))
all(x, man(x)=> y^walk(y))
• What is wrong with this?
• How can we fix it?
October 2004 CSA4050: Semantics III 16
Result
?- s(X,[every,man,walks],[]).X = all(_G397, man(_G397), _G405^walk(_G405))
all(x, man(x)=> y^walk(y))• What is wrong with this?
– The variables _G397 and _G405 are distinct. They should be identical.
– The consequent of the implication is a λ expression• How can we fix it?
– We need to force the variables to be identical using reduce
October 2004 CSA4050: Semantics III 17
DCG with QuantificationProgram 2
% grammars(S) --> np(NP), vp(VP), {reduce(VP,NP,S)}vp(VP) --> v(V).
% lexiconv(X^walk(X)) --> [walks].np(Q^all(X,man(X) => P)) --> [every,man], {reduce(Q,X,P)}.
October 2004 CSA4050: Semantics III 18
Result
?- s(X,[every,man,walks],[]).
X = all(_G397, man(_G397),walk(_G397))
• The effect of the reduce clause is– to identify the appropriate variables– to remove the λ variable
October 2004 CSA4050: Semantics III 19
Handling Quantified NPs
• Before we cheated by having every man as a lexical item.np(Q^all(X,man(X) => P))--> [every,man], { reduce(Q,X,P)}.
• Now we see what is involved in analysing the NP from its parts.
• Step 1 is to write a new syntactic rulenp(NP) --> d(D), n(N).
• How does the semantics work?
October 2004 CSA4050: Semantics III 20
LF of determiners• Key idea is determiner has LF of a 2-argument
function corresponding to R and S which become bound during processing.
λR.λS.Q(V,R,S)
where Q is associated with the particular determiner
• When we apply this function to the adjacent noun, we obtain the LF of the NP.
October 2004 CSA4050: Semantics III 21
How NP is created
D
R^S^all(X,R,S)
every
N
Y^man(Y)
man
NP
S^all(X,man(X),S)
October 2004 CSA4050: Semantics III 22
Fitting the Semantics Together
• Handle the quantified NPnp(NP) --> d(D), n(N), {reduce(D,N,NP)}.
• Add lexical entry for every• d(RL^SL^all(X,R => S)) -->[every], {reduce(RL,X,R), reduce(SL,X,S) }.
October 2004 CSA4050: Semantics III 23
DCG with QuantificationProgram 3
% grammars(S) --> np(NP), vp(VP), {reduce(NP,VP,S)}.np(NP) --> d(D), n(N), {reduce(D,N,NP) }.vp(VP) --> v(VP).
% lexiconv(X^walk(X)) --> [walks].n(X^man(X)) --> [man].d(RL^SL^all(X,R => S) --> [every], {reduce(RL,X,R), reduce(SL,X,S) }.
October 2004 CSA4050: Semantics III 24
Trace
>: (7) s(_G510, [every, man, walks], [])>: (8) np(_L183, [every, man, walks], _L184)>: (9) d(_L205, [every, man, walks], _L206)<: (9) d((X^R)^ (X^S)^all(X, R, S), [every, man, walks], [man, walks])>: (9) n(_L207, [man, walks], _L208)<: (9) n(Z^man(Z), [man, walks], [walks])>: (9) reduce((X^R)^ (X^S)^all(X, R, S), Z^man(Z), _L183)<: (9) reduce((X^man(X))^ (X^S)^all(X, man(X), S), X^man(X), (X^S)^all(X, man(X), S))<: (8) np((X^S)^all(X, man(X), S), [every, man, walks], [walks])>: (8) vp(_L185, [walks], _L186)>: (9) v(_L185, [walks], _L186)<: (9) v(Y^walk(Y), [walks], [])<: (8) vp(Y^walk(Y), [walks], [])>: (8) reduce((X^S)^all(X, man(X), S), Y^walk(Y), _G510)<: (8) reduce((X^walk(X))^all(X, man(X), walk(X)), X^walk(X), all(X, man(X), walk(X)))<: (7) s(all(X, man(X), walk(X)), [every, man, walks], [])