General
Material
Lecture 1
 Slides Practical Session
Lecture 2
 Slides Practical Session
Lecture 3
 Slides Practical Session
Lecture 4
 Slides Practical Session
Lecture 5
 Slides Practical Session

# Constructing lambda terms

For this exercise, you should already know something about semantic construction. In particular, you should be familiar with lambda calculus. The second week course on computational semantics by Koller, Burchardt and Walter will start at this point: they will tell you about semantic construction using lambda calculus and how to do it in Prolog.

We can use the same mechanism that we used for constructing parse trees to build lambda terms representing the semantics of the parsed expression.

Here is a way of representing lambda terms as Prolog terms:

• Let's use a two place complex term with the functor `l` for representing lambda abstraction. That is, we represent λx.Formula as `l(X,Formula)`. For example, the semantics associated with the verb kills, i.e., the lambda term λx.λy.kill(y,x), would look like this in our Prolog representation: `l(X,l(Y,kill(Y,X)))`
• Let's use a two place complex term with the functor `'@'` to represent functional application. That is, λx.λy.kill(y,x)(bill) is ```'@'(l(X,l(Y,kill(Y,X))), bill)``` in our representation.

First, use this simple grammar and add a semantic representation to all lexical entries.
Solution

Second, extend the rules so that the semantics representation is build while processing the input phrase. The mechanism is exactly the same as the one that we used for building the parse tree. Use the `'@'` symbol to express that one expression is applied to another. That means, the output will be a lambda term which is not beta-reduced. For example, the lambda representation for the sentence `[the,nurse,whistles]` is ```'@'('@'(l(R,l(S, exists(X,'@'(R,X),'@'(S,X)))),l(Y,nurse(Y))),l(Z,whistles(Z)))```.
Solution