Getting started with lambda prolog


Contents
Setup
Running samples
Queries

Setup

First, be sure to add the line

  source /farm/village/setup

to the end of your .cshrc file. See the Village lab sun guide for more details about setup.

Running sample programs

Here's how you can run the sample programs we'll be discussing.

The sample programs are stored online in the directory

  /farm/village/logic/agents

So life will be simpler if you start with the command

  cd /farm/village/logic/agents

which makes this directory your current directory.

Next, to start the lambda prolog interpreter, type

  Terzo

It'll take a second to get started, then it will show you the Terzo prompt: Terzo>.

To load in a file, the command is

  #load filename.

Note that name of the file should be in quotes, and the whole line should end with a period. (You'll soon get very sick of things ending with a period!) For example, the first file of agent definitions that we discussed is called basic.lp so you can load this in with the command

  #load "basic.lp".

If there's a problem with the file, Terzo will spew out error messages at this stage. Otherwise, Terzo will read in the file successfully, and print out the final module name that's defined in the file. (In this case, it says module A4.)

To run a program, you start up a query loop in some module. For example, in basic.lp there are four modules, each corresponding to a different version of our video game agent. These modules are called A1, A2, A3 and A4. To start a query loop, say:

  #query module.

For example,

  #query A1.

The prompt will change to the query prompt ?- and what you type will be interpreted as a query.

At any time you can hit control-C to interrupt. This will end the current query process and take you back to top level. You can use #query to start something new. Or you can type

  #quit.

To quit.

Queries

For basic.lp, there's really only one query that you'll be interested in:

  agitate start.

This runs a simulation of the agent. The simulator will ask

  What does the agent see?

For A1 and A3, you can respond in one of three ways:

  monster.
  nothing.
  jewel.

For A4, you can also respond

  package.

For A2, you can respond in these three ways:

  monstery.
  nothingy.
  jewely.

Yes you need the period in all cases. The simulator will get the agent's decision, report it and continue.