4.3.2 Implementing combine/2 for Functional Application

Implementation of the combine/2 predicate.

Using the predicate combine/2, we have factored the task of combining semantic representations out of the syntax rules. Let's illustrate what we've achieved at an example. As a case study, we will implement the combination technique we've got used to by now: Functional application. So the task is simply building the obvious ``apply the function to the argument statements'' expressed with the help of @. How do we have to define combine/2 for this purpose? Take a look at the s-rule of our grammar:

englishGrammar.pl: View Download

s1(S1)--> np2(NP2), vp2(VP2), {combine(s1:S1,[np2:NP2,vp2:VP2])}.

Look at the call to combine/2 in the curly brackets. The first argument contains the semantics of the sentence (tagged s1), the second argument contains a list with the semantics of the NP and the VP (tagged np1 and vp1 respectively).

The purpose of the tags contained within these arguments is to select an appropriate clause of the predicate combine/2. We define the combine/2 predicate for lambda calculus in lambda.pl. So let us start by looking the first clause of combine/2 that goes with the syntax rule given above. It unifies S with NP@VP. This looks as follows:

combine(s1:(NP@VP),[np2:NP,vp2:VP]).

The clause of combine/2 that goes with the np rule

np1(NP1)--> det(Det), noun2(N2), {combine(np1:NP1,[det:Det,n2:N2])}.

is similarily straightforward:

combine(np1:(DET@N),[det:DET,n2:N]).

The unary rules, of course, are even simpler, for they merely pass the input representation up to the mother node. For example:

combine(np2:X,[np1:X]).

goes with

np2(NP2)--> np1(NP1), {combine(np2:NP2,[np1:NP1])}.

For all combine rules see lambda.pl: View Download

Note again the advantage of using a list of tagged semantic representations as the second argument (i.e. the input) of combine/2: We've been able to uniformly give clauses for one and the same (binary) predicate for combining the two input representations in the binary s and np-rules, as well as for passing on the single input representation in the unary np-rule. Guided by matching the tags and lengths of the input lists, Prolog will always select the right clause for us automatically.

?- Question!

Recall our first attempt at semantic construction with extended DCGs. There, we used the predicate insertArgs/2 to postprocess terms glued together with +. Doesn't the predicate combine/2 here do exactly the same with -terms? Why don't we run into the same trouble as with insertArgs/2?


Aljoscha Burchardt, Stephan Walter, Alexander Koller, Michael Kohlhase, Patrick Blackburn and Johan Bos
Version 1.2.5 (20030212)