3.6 Running the Program

Driver Predicate and Code Summary for this Chapter.

We've already seen a first run of our semantically annotated DCG, and we've implemented a module for -conversion. Now we shall put them together in a predicate firstLambda/0 to get our first real semantic construction system. Here's the code of firstLambda/0:

firstLambda :-
        readLine(Sentence),
        s(Formula,Sentence,[]),
        resetVars,vars2atoms(Formula),
        betaConvert(Formula,Converted),
        printRepresentations([Converted]).

This predicate first converts the keyboard input into a list of Prolog atoms (using readLine/0 form comsemLib.pl). Then it uses the semantically annotated DCG from firstLambda.pl and tries to parse a sentence.

So far, so good. But what are the two calls resetVars,vars2atoms(Formula) for? The reason why we have to include them is that we've broken our representational convention for variables (we've explained why in Section 3.5.7). Hence the Formula coming from the call s(Formula,Sentence,[]) may still contain Prolog variables. For instance when we construct the semantics for the sentence ``John walks'', we will get something like lambda(_G365,_G365@john)@lambda(_G371,walk(_G371)).

Undo Variable Cheat

So we undo our little cheat before going on. Calling resetVars,vars2atoms(Formula) (see Section ``vars2atoms/1'') instantiates the Prolog variables in Formula with new (and consistently distinct) variables-as-atoms, according to our convention. Finally, the resulting -expression is -converted by our predicate betaConvert/2. In the last step, the resulting formula is printed out (the predicate printRepresentations/1 used for this purpose is documented here).

Before we turn to the exercises for this chapter, we give a listing of the files that contain the code discussed in this chapter. You run our -based semantic construction program by:

  1. Consulting the file runningFirstLambda.pl, which contains the driver predicate we've just seen:

    ?- [runningFirstLambda].

  2. Calling the driver predicate:

    ?- firstLambda.

  3. Entering a sentence of your choice at the prompt.

Code For This Chapter

usingDCG.pl: View Download

Our very first experimantal DCG.

firstAttempt.pl: View Download

The code for our first attempt at semantic construction, using the +-operator and insertArgs/2.

firstLambda.pl: View Download

DCG for semantic construction using -calculus.

betaConversion.pl: View Download

-conversion.

runningFirstLambda.pl: View Download

Driver predicate for our first lambda approach.

signature.pl: View Download

Generating new variables

comsemLib.pl: View Download

Auxiliaries.

comsemOperators.pl: View Download

Operator definitions.


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