



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 6
This page cannot be seen from the preview
Don't miss anything!




In this programming assignment, you will write a resolution theorem prover for first-order logic in Lisp.
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,
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
Here are some general instructions you should follow:
; Loading #p"/user/choe/sunify.lsp". T
( 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:
T
NIL
NIL
Implement linear resolution, and compare the performance in:
Implement unit preference, and compare the performance in:
4 Submission Instruction
Run your provers on these three problems and summarize the results (see the file theorems.lsp):
Do all of these reduce to False?
In addition to the above:
Name and run your prover like this:
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: