Resolution Theorem Proving Assignment for CPSC 420-500 - Prof. Y. Choe, Study Guides, Projects, Research of Computer Science

Instructions for a programming assignment where students are required to write a resolution theorem prover for first-order logic in lisp. How to represent clauses, the resolution algorithm, and some additional instructions. Students are expected to replace variables with new symbols before unifying or resolving clauses and use the provided unification algorithm. The document also suggests implementing linear resolution and unit preference, and provides submission instructions.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 02/10/2009

koofers-user-a6g
koofers-user-a6g 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPSC 420-500 Program #3
Resolution Theorem Prover Due 11/30/07 Friday Midnight
(11:59pm)
Submit using csnet turnin
Yoonsuck Choe
November 2, 2007
1 Introduction
In this programming assignment, you will write a resolution theorem prover for first-order logic in Lisp.
2 Representation of clauses
Use a list of clauses, where each clause is in the following form:
"(" <clause-num> <pos-lit-list> <neg-lit-list> ")"
where <clause-num>is an integer, <pos-lit-list>is a list of positive literals and <neg-lit-list>
is a list of negative literals. Variables are represented as single symbols (atomic terms) such as X, Y, etc.,
and constants are represented as (A), (B), i.e., a single atom list. Predicates and functions are represented in
the usual prefix notation: P(X) is (P X), and F(X) is (F X).
For example, P(x, y) ¬Q(x, a)R(f(x)) where xis a variable ais a constant, and f(·)is a function, can
be expressed as below.
Positive literals: (P X Y) (R (F X))
Negative literal: (Q (A))
Resulting clause: (1 ( (P X Y) (R (F X)) ) ( (Q X (A)) ) )
A whole theorem will contain a list of such clauses. For example,
(
(1 ( (P X Y) (R (F X)) ) ( (Q X (A)) ) )
(2 ( (R (F Z)) ) ( (P Z (A)) ) )
(3 ( (Q W V) ) ( ) )
)
1
pf3
pf4
pf5

Partial preview of the text

Download Resolution Theorem Proving Assignment for CPSC 420-500 - Prof. Y. Choe and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

CPSC 420-500 Program

Resolution Theorem Prover Due 11/30/07 Friday Midnight

(11:59pm)

Submit using csnet turnin

Yoonsuck Choe

November 2, 2007

1 Introduction

In this programming assignment, you will write a resolution theorem prover for first-order logic in Lisp.

2 Representation of clauses

Use a list of clauses, where each clause is in the following form:

"(" <clause-num> <pos-lit-list> <neg-lit-list> ")"

where <clause-num> is an integer, <pos-lit-list> is a list of positive literals and <neg-lit-list> is a list of negative literals. Variables are represented as single symbols (atomic terms) such as X, Y, etc., and constants are represented as (A), (B), i.e., a single atom list. Predicates and functions are represented in the usual prefix notation: P(X) is (P X), and F(X) is (F X).

For example, P (x, y) ∨ ¬Q(x, a) ∨ R(f (x)) where x is a variable a is a constant, and f (·) is a function, can be expressed as below.

Positive literals: (P X Y) (R (F X)) Negative literal: (Q (A)) Resulting clause: (1 ( (P X Y) (R (F X)) ) ( (Q X (A)) ) )

A whole theorem will contain a list of such clauses. For example,

(1 ( (P X Y) (R (F X)) ) ( (Q X (A)) ) )

(2 ( (R (F Z)) ) ( (P Z (A)) ) )

(3 ( (Q W V) ) ( ) )

Note that if the given clause only contains positive or negative literals but not both, the empty one should be represented as ( ), such as in clause 3 above (which would be simply Q(w, v)).

Initially, the list will contain the premise clauses, followed by clauses derived from the negated conclusion. As resolvents are generated from these clauses, they are added to the end of the list. For simplicity, you may assume that the sets of symbols used as predicate names, function names, and variable names are unique in any given problem (as in the example above), i.e. you can do all the necessary pre-processing by hand before feeding in the problem to the prover. For example, clauses 1, 2, and 3 above do not have any shared variable.

However, as you go along with resolution, you may have to check if the two clauses drawn from the set of clauses have overlapping variables. To check this, you may have to extract all the arguments of the literals. For this, use mapcan, which applies a function on each element of a given list and concatenates the result. There are other map.. functions that may be of interest to you as well, such as mapcar.

  • (mapcan #’cdr ’((p x y) (r (f x)))) (X Y (F X))

  • (mapcar #’cdr ’((p x y) (r (f x)))) ((X Y) ((F X)))

Basically what you are doing above is (cdr ’(p x y)) which gives you (x y) and (cdr ’(r (f x))) which gives you ((f x)), which is then appended (for mapcan). See the next section for some more details on renaming variables to avoid confusion.

3 Coding the Resolution Algorithm

3.1 General instructions

Here are some general instructions you should follow:

  1. Print out each input clause and each clause that is produced by resolution; number the printed clauses and show the numbers of the clauses from which they are derived. Remember that more than one resolution of a given pair of clauses may be possible. However, we will not worry about resolving on factors of clauses.
  2. A unification algorithm is provided in the file sunify.lsp. The clauses must first be rewritten so that they have no variables in common in case there are repeated variables across two clauses. To avoid any confusion, simply replace every variable in a clause with a new symbol (do it consistently so that the same variable is replaced with the same new symbol) before you unify/resolve. For example,
  • (load "sunify.lsp")

; Loading #p"/user/choe/sunify.lsp". T

  • (unify ’(p x) ’(p (a)))

( 1 ( (P X) (P (A)) ) ( (Q X) ) ) ; clause 1 ( 2 ( ) ( (P (A)) ) ) ; clause 2

In this case, in the first clause, there are two (P ·)s, so, what you do is produce two clauses, by first unifying (P X) and (P (A)) to get

( 3 ( (P (A) ) ( (Q (A)) ) ) ; clause 3

and next, resolving (P (A)) and (P (A)) to get the following.

( 4 ( (P X) ) ( (Q X) ) ) ; clause 4

So, you will get two clauses (clauses 3 and 5) by resolving the clauses clause 1 and 2.

For duplicate checks, simply use the (dupe ...) function in dupeclause.l in the src/ directory. This is a really simplistic, literal duplicate checker, so it will say certain clauses are not duplicates when they really are (logically), but that’s fine. For example, try this:

  • (dupe^ ’(1 ((q x) (p y)) ()) ’(2 ((p y) (q x)) ()))

T

  • (dupe^ ’(1 ((q x) (p y)) ()) ’(2 ((p y) (q (a))) ()))

NIL

  • (dupe^ ’(1 ((q x) (p y)) ()) ’(2 ((p y) (q z)) ()))

NIL

3.3 Linear Resolution

Implement linear resolution, and compare the performance in:

  • the number of resolution steps taken to derive False, and/or
  • if it ever reaches the answer or not.

3.4 Unit preference

Implement unit preference, and compare the performance in:

  • the number of resolution steps taken to derive False, and/or
  • if it ever reaches the answer or not.

4 Submission Instruction

4.1 Testing your prover

Run your provers on these three problems and summarize the results (see the file theorems.lsp):

  1. Howling hound,
  2. Drug dealer and customs official, and
  3. Coyote and roadrunner.

Do all of these reduce to False?

In addition to the above:

  1. Convert the Harmonia example in slide04.pdf, page 133, into a resolution problem format in Lisp, and run the prover. Once you have derived False, manually examine the resolution steps printed out by your prover and find out at which point the question could have been answered (who is a grandparent of Harmonia?). You don’t need to write a program to do this – simply report your analysis.

4.2 Submitting

Name and run your prover like this:

  • (two-pointer problem 6)
  • (linear problem 6)
  • (unit-preference problem)

where (^) problem is a global variable pointing to the list of clauses (e.g. (^) howl-hound), and 6 is the first clause of the negated conclusion (assume that the clause number begins with 1).

Submit the code prover.lsp, README using the csnet turnin page.

The README file should contain the following:

  1. The Harmonia theorem represented in Lisp.
  2. Test results of two-pointer and unit-preference on the four theorems (howling hound, customs official, roadrunner, and Harmonia). - Draw a table where the rows are the theorems and the columns are the three theorem proving methods. Thus, you’ll get 8 results in all. - In each cell, enter the number of resolution steps taken to derive False.