## CS 5541 Program 3 - Propositional Logic (Wumpus World) Due December 7, 2010 40 points

### Introduction

The Wumpus World operates by rules as laid out in the text book and in class. In this program we will practice a bit with representing knowledge in propositional logic. We will make use of a set of lisp routines defined for the textbook called the aima-lisp package. To make sure the routines needed will work with clisp I have created a zip file of the routines you will need at prog3.zip. These lisp routines once loaded provide a basic propositional logic interface. It provides basic propositional routines including tell and ask which allow a user to assert a proposition and to make a query. For example, you might do the following with this code:

T
[2]>
T
[3]>
T
[4]>
T
[5]>
T
[6]>
T

;; CREATE AN INITIAL KNOWLEDGE BASE
[7]>(setf kb (make-prop-kb))
#S(PROP-KB :SENTENCE (AND))

;; ASSERT THAT A IS TRUE
[8]> (tell kb "A")
T

;; ASSERT THAT RULE A AND B => C IS TRUE
[9]> (tell kb "A & B => C")
T

;; ASK IF C IS TRUE (NIL INDICATES FALSE)
NIL

;; ASSERT B IS TRUE
[11]> (tell kb "B")
T

;; ASK IF C IS TRUE (T INDICATES TRUE)
T

;; ASSERT RULE (A OR D) => E
[13]> (tell kb "A | D => E")
T

;; ASK IF E IS TRUE (T INDICATES TRUE)
T

### Implementation

For this program you should write the following routines:

• set_state <kb> <item_list> - takes a list of observations of the form (<percept> <row> <col>) where <percept> is one of NONE, SMEL or, BREEZE and <row> and <col> are the row and column of this observation and adds the appropriate propositions to the given knowledge base <kb>. So, if the player visits square 2,3 and detects neither a smell or breeze then the list would contain (NONE 2 3). If the player visited 3,5 and detected both a SMELL and a BREEZE then the list would contain both (SMELL 3 5) and (BREEZE 3 5).
• available_moves <kb> - should return a list of the places that a user might move to based on the knowledge in the <kb>. Places that can be safely moved to would be next to places that have been visited (any location next to a location with an observation of NONE, SMELL or BREEZE) and is safe (there is no WUMPUS or PIT at thtat location). Your list should look something like this ((1 1) (2 3) (3 5)) which would indicate that 1,1, 2,3 and 3,5 are positions that have not been visited and are safe to go to.

Notes

• The routine random returns a random number between 0 and n-1.
• You will need to determine a convention for representing facts (you will need individual proposition names for each fact, for example, how to represent a smell at position 2,3).
• You will need to add to the knowledge base a set of proposition rules appropriate to the domain (e.g., add a rule that a wumpus at each position indicates a smell at the four surrounding positions).
• Once you have these rules and assert the facts associated with the list of facts you then simply need to query each position to see if it is unvisited, next to a visited state and safe and add that position to the list of available positions.

### Testing

Generate at least four sample sets of facts with at least ten facts in each case using wumpus worlds of different sizes and then test your routine using these samples. Then run your routines to represent those wumpus worlds and print out what the available spots to move are in that world using only logical queries.

### What To Hand In

Hand in clean, nicely commented copies of all of your code (make sure to include the class code so we can tell if anything is changed). In addition, print out the data used to test your code and the corresponding results. Finally, email your code to me at rmaclin@d.umn.edu.