Title: Computational Semantics http://www.coli.uni-sb.de/cl/projects/milca/esslli
1Computational Semanticshttp//www.coli.uni-sb.de/
cl/projects/milca/esslli
- Aljoscha Burchardt,
- Alexander Koller,
- Stephan Walter,
- Universität des Saarlandes,
- Saarbrücken, Germany
- ESSLLI 2004, Nancy, France
2Computational Semantics
- How can we compute the meaning of e.g. an English
sentence? - What do we mean by meaning?
- What format should the result have?
- What can we do with the result?
3The Big Picture
- Sentence John smokes.
- Syntactic Analyses S
- NP VP
- John smokes
- Semantics Construction smoke(j)
- Inference ?x.smoke(x)?snore(x),smoke(j)
- gt snore(j)
4Course Schedule
- Monday - Thursday Semantics Construction
- Mon.Tue. Lambda-Calculus
- Wed.Thu. Underspecification
- Friday Inference
- (Semantic) Tableaux
5The Book
- If you want to read more about computational
semantics, see the forthcoming book Blackburn
Bos, Representation and Inference A first
course in computational semantics. CSLI Press.
6Today (Monday)
- Meaning Representation in FOL
- Basic Semantics Construction
- ?-Calculus
- Semantics Construction with Prolog
7Meaning Representations
- Meaning representations of NL sentences
- First Order Logic (FOL) as formal language
- John smokes.
- gt smoke(j)
- Sylvester loves Tweety.
- gt love(s,t)
- Sylvester loves every bird.
- gt ?x.(bird(x) ? love(s,x))
8In the Background Model Theory
- ?x.(bird(x) ? love(s,x)) is a string again!
- Mathematically precise model representation,
e.g. cat(s), bird(t), love(s,t), granny(g),
own(g,s), own(g,t) - Inspect formula w.r.t. to the model Is it true?
- Inferences can extract information Is anyone not
owned by Granny?
9FOL Syntax (very briefly)
- FOL Formulae, e.g. ?x.(bird(x) ? love(s,x))
- FOL Language
- Vocabulary (constant symbols and
predicate/relation symbols) - Variables
- Logical Connectives
- Quantifiers
- Brackets, dots.
10What we have done so far
- Meaning Representation in FOL ?
- Basic Semantics Construction
- ?-Calculus
- Semantics Construction with Prolog
11Syntactic Analyses
- Basis Context Free Grammar (CFG)
- Grammar Rules
- S ? NP VP
- VP ? TV NP
- TV ? love
- NP ? john Lexical Rules / Lexicon
- NP ? mary
- ...
12Example Syntactic Analyses
13Example Semantic Lexicon
14Example Semantics Construction
15Example Semantics Construction
16Compositionality
- The meaning of the sentence is constructed from
- The meaning of the words john, mary, love(?,?)
(lexicon) - Paralleling the syntactic construction (semantic
rules)
17Systematicity
- How do we know that e.g. the meaning of the VP
loves Mary is constructed as - love(?,mary) and not as
- love(mary,?) ?
- Better How can we specify in which way the bits
and pieces combine?
18Systematicity (ctd.)
- Parts of formulae (and terms), e.g. for the VP
love Mary? - love(?,mary) bad not FOL
- love(x,mary) bad no control over free
variable - Familiar well-formed formulae (sentences)
- ?x.love(x,mary) Everyone loves Mary.
- ?x.love(mary,x) Mary loves someone.
19Using Lambdas (Abstraction)
- Add a new operator to bind free variables
- ?x.love(x,mary) to love Mary
- The new meta-logical symbol ? marks missing
information in the object language (?-)FOL - We abstract over x.
- How do we combine these new formulae and terms?
20Super Glue
- Glueing together formulae/terms with a special
symbol _at_ - ?x.love(x,mary) john
- ?x.love(x,mary)_at_john
- Often written as ?x.love(x,mary)(john)
- How do we get back to the familiar
love(john,mary)?
21Functional Application
- Glueing is known as Functional Application
- FA has the Form Functor_at_Argument
- ?x.love(x,mary)_at_john
- FA triggers a very simple operation
- Replace the ?-bound variable by the argument.
- ?x.love(x,mary)_at_john
- gt love(john,mary)
22?-Reduction/Conversion
- Strip off the ?-prefix,
- Remove the argument (and the _at_),
- Replace all occurences of the ?-bound variable by
the argument. - ?x.love(x,mary)_at_john
- love(x,mary)_at_john
- love(x,mary)
- love(john,mary)
23Semantics Construction with Lambdas
- S John loves Mary
- (?y?x.love(x,y)_at_mary)_at_john
NP John john
VP loves Mary ?y?x.love(x,y)_at_mary
TV loves ?y?x.love(x,y)
NP Mary mary
24Example Beta-Reduction
- (?y?x.love(x,y)_at_mary)_at_john
- ?gt (?x.love(x,mary))_at_john
- ?gt love(john,mary)
25In the Background
- ?-Calculus
- A logical standard technique offering more than
?-abstraction, functional _at_pplication and
ß-reduction. - Other Logics
- Higher Order Logics
- Intensional Logics
- ...
- For linguistics Richard Montague (early
seventies)
26What we have done so far
- Meaning Representation in FOL ?
- Basic Semantics Construction ?
- ?-Calculus ?
- Semantics Construction with Prolog
27Plan
- Next, we
- Introduce a Prolog represenation.
- Specify a syntax fragment with DCG.
- Add semantic information to the DCG.
- (Implement ß-reduction.)
28Prolog Representation Terms and Formulae
- (man(john)((love(mary,john))))
- (happy(john)gt(happy(mary)v(happy(fido)))
- forall(x,happy(x))
- exists(y,(man(y)((happy(y))))
- lambda(x,)
29Prolog RepresentationOperator Definitions
Binding Strength
- -Â op(950,yfx,_at_). Â application
- -Â op(900,yfx,gt). Â implication
- - op(850,yfx,v).   disjunction
- - op(800,yfx,).    conjunction
- - op(750, fy,).    negation
- forall(x,man(x)love(x,mary)gthate(mary,x))
- (Mary hates every man that doesnt love her.)
30Definite Clause Grammar
- Prologs built-in grammar formalism
- Example grammar
- s --gt np,vp.
- vp --gt iv.
- vp --gt tv,np.
- ...
- np --gt john.
- iv --gt smokes.
- Call s(john,smokes,).
31Adding Semantics to DCG
- Adding an argument to each DCG rule to collect
semantic information. - Phrase rules of our first semantic DCG
- s(VP_at_NP) --gt np(NP),vp(VP).
- vp(IV) --gt iv(IV).
- vp(TV_at_NP) --gt tv(TV),np(NP).
-
32Lexicon Of Our First Semantic DCG
- np(john) --gt john.
- np(mary) --gt mary.
- iv(lambda(X,smoke(X))) --gt
- smokes,vars2atoms(X).
- tv(lambda(X,lambda(Y,love(Y,X)))) --gt
- loves,vars2atoms(X),
- vars2atoms(Y).
33Running Our First Semantics Constrution
- ?- s(Sem,mary,smokes,).
- Sem lambda(v1, smoke(v1))_at_mary
- ?- , betaConvert(Sem,Result).
- Result smoke(mary)
- Note that we use some special predicates of
freely available SWI Prolog (http//www.swi-prolog
.org/).
34betaConvert(Formula,Result) 1/2
- betaConvert(Functor_at_Arg,Result)-betaConvert(Funct
or,lambda(X,Formula)),!,substitute(Arg,X,Formula
,Substituted),betaConvert(Substituted,Result). - The input expression is of the form Functor_at_Arg.
- The functor has (recursively) been reduced to
lambda(X,Formula). - Note that the code displayed in the reader is
wrong. Corrected pages can be downloaded.
35betaConvert(Formula,Result) 2/2
- betaConvert(Formula,Result)-
- compose(Formula,Functor,Formulas),
- betaConvertList(Formulas,Converted), compose(Re
sult,Functor,Converted). - Formula exists(x,man(x)(lambda(z),walk(z)_at_x))
- Functor exists
- Formulas x,man(x)(lambda(z),walk(z)_at_x))
- Converted x,man(x)walk(x)
- Result exists(x,man(x)walk(x))
36Helper Predicates
- betaConvertList(,).
- betaConvertList(FR,F_ResR_Res)-Â Â Â Â Â Â Â Â bet
aConvert(F,F_Res),        betaConvertList(R,R_Res
). - compose(Term,Symbol,Args)-
- Term .. SymbolArgs.
- substitute() (Too much for a slide.)
37Wrapping It Up
- go -
- resetVars,
- readLine(Sentence),
- s(Formula,Sentence,),
- nl, print(Formula),
- betaConvert(Formula,Converted),
- nl, print(Converted).
38Adding More Complex NPs
- NP A man gt ?x.man(x)
- S A man loves Mary
-
- Lets try it in a system demo!
39Tomorrow
- S A man loves Mary
- gt love(?x.man(x),mary)
- How to fix this.
- A DCG for a less trivial fragment of English.
- Real lexicon.
- Nice system architecture.