next up previous


CSE 5361 Spring 1999

Homework 6

Due: April 27, 1999, 7:00pm (April 28, 1999, 7:00pm for -10%)

Write a Definite Clause Grammar augmented with semantics to translate wumpus-world sentences into a logical equivalent. Your grammar should utilize phrase structure, be as general as possible, and handle at least the translations below (where X and Y represent any digit from 1 to 9). You should not need to use curly-brace augmentations.

Sentence Meaning
``the wumpus is in X Y'' wumpus(X,Y)
``the agent is in X Y'' agent(X,Y)
``a pit is in X Y'' pit(X,Y)
``the gold is in X Y'' gold(X,Y)
``the agent grabbed the gold'' grabbed(agent,gold)
``the agent shot the wumpus'' shot(agent,wumpus)
``the wumpus ate the agent'' ate(wumpus,agent)
``the agent fell into a pit'' fell(agent,pit)
``the agent turned left'' turned(agent,left)
``the agent turned right'' turned(agent,right)
``the agent moved forward'' moved(agent,forward)
``there is a pit in X Y'' pit(X,Y)
``there is a gold piece in location X Y'' gold(X,Y)
``the wumpus is behind the agent'' behind(wumpus,agent)
``the agent is facing the wumpus'' facing(agent,wumpus)
``the agent climbed out of the cave'' climbed(agent,cave)
``the extent of the world is X'' extent(X)
``the agent perceived a stench'' perceived(agent,stench)
``there is a breeze in X Y'' breeze(X,Y)
``the agent felt a breeze'' felt(agent,breeze)
``the agent heard a scream'' heard(agent,scream)
``the agent bumped into a wall'' bumped(agent,wall)

In the hw6 directory of the class directory on gamma2, there is a partial grammar (in the file grammar) to get you started. This grammar is written in a syntax that can be read directly into a Prolog interpreter. Variables begin with uppercase characters, terminals are contained in square brackets, and everything else is a non-terminal. Auxiliary code at the bottom of this file allows you to test your grammar. The following example shows you how this is possible on gamma2, where you type the queries at the ?- prompt (and do not forget the period at the end).

Email your completed grammar in Prolog format to me (holder@cse.uta.edu).

Example Run:

     gamma2> /public/cse/5361-501/BinProlog5.75/bp

     BinProlog 5.75 Copyright (C) Paul Tarau 1992-1997
     by FTP from:   clement.info.umoncton.ca
     E-MAIL to  : binprolog@info.umoncton.ca
     (C-ified standalone)
     (with heap GC enabled) 
     Finished loading system C-code (40327 instructions).
     Finished loading user C-code (4 instructions).
     ?- consult('/public/cse/5361-501/hw6/grammar').
     consulting(/public/cse/5361-501/hw6/grammar)
     consulted(/public/cse/5361-501/hw6/grammar)
     time(consulting = 10,quick_compiling = 0,static_space = 0)
     yes
     ?- meaning("the wumpus is in 1 3",M).
     M=wumpus(1,3)                           % just hit 'enter' here
                                             % or ';' for alternate parse
     yes
     ?- meaning("the wumpus is in 2 2",M).
     M=wumpus(2,2)

     yes
     ?- meaning("the pit is in 3 1",M).
     no
     ?- halt.

     Prolog execution halted(0). CPU time = 0.90s

     gamma2>


next up previous