1.5.7 Running the Program

We've already seen a first run of our semantically annotated DCG, and we've now implemented a module for -conversion. So let's plug them together in a driver predicate go/0 to get our first real semantic construction system:

go :-
        readLine(Sentence),
        resetVars,
        s(Formula,Sentence,[]),
        nl, print(Formula),
        betaConvert(Formula,Converted),
        nl, print(Converted).

This predicate first converts the keyboard input into a list of Prolog atoms. Next, it does some cleaning up that is needed to manage the creation of variable names during lexicon retrieval (see Section 1.5.3). Then it uses the semantically annotated DCG from semanticDCG.pl and tries to parse a sentence.

Next, it prints the unreduced -expression produced by the DCG. Finally, the -expression is -converted by our predicate betaConvert/2 and the resulting formula is printed out, too.

In order to run the program, consult runningLambda.pl at a Prolog prompt:

1 ?- [runningLambda].
%   comsemOperators compiled into comsemLib 0.00 sec, 520 bytes
%  comsemLib compiled into comsemLib 0.01 sec, 7,612 bytes
%   comsemOperators compiled into betaConversion 0.00 sec, 216 bytes
%  betaConversion compiled into betaConversion 0.00 sec, 1,604 bytes
%   comsemOperators compiled into runningLambda 0.00 sec, 216 bytes
%  semanticDCG compiled into runningLambda 0.01 sec, 4,336 bytes
%  comsemOperators compiled 0.00 sec, 136 bytes
% runningLambda compiled into runningLambda 0.02 sec, 14,848 bytes
 
Yes
2 ?- go.
 
> harry flies.
 
lambda(v1, v1@harry)@lambda(v2, fly(v2))
fly(harry)
 
Yes

Code For This Chapter

Here's a listing of the files needed:

semanticDCG.pl: View Download

The semantically annotated DCG.

runningLambda.pl: View Download

The driver predicate.

betaConversion.pl: View Download

-conversion.

comsemOperators.pl: View Download

Definitions of operators used in semantic representations

comsemLib.pl: View Download

Auxiliary predicates.

Further Reading

The approach we discussed here is a simplified implementation of Richard Montague's ideas (see [Mon74]).


Aljoscha Burchardt, Alexander Koller and Stephan Walter
Version 1.2.5 (20030212)