Project 2: write an iterative deepening depth-first search procedure for resolution
refutation (i.e., proof by contradiction) using the set-of-support strategy
1. Define a function
(DEFUN IDDFSRR (Axioms NegatedSentence MaxDB) … )
Axioms is a list of axioms, each axiom is a list of (disjoined) propositions, so
Axioms = ( ( (not s) p) ( (not u) s) (u) ((not w) r) (w) ((not m) (not n) (not v) ) )
Note that the input AXIOMS is essentially in CNF, with AND and OR being implicit
These are logically equivalent, but syntactically incorrect as input to IDDFSRR
(AND (or (not s) p) (or (not u) s) (u) (or (not w) r) (w) (or (not m) (not n) (not v) ) )
(~s or p) and (~u or s) and (u) and … and (~m or ~n or ~v)
NegatedSentence has exactly the same format as Axioms (so we are assuming
that the statement to be proved has already been negated and converted to CNF. So
NegatedSentence = ( ((not p) (not q) ) ( (not p) (not r) ) ) represents (~p or ~q), (~p or ~r)
MaxDB is the absolute deepest that you will search (it’s your ‘give up point)
You might start with the DFS pseudocode from the text or elsewhere, and write “auxiliary” functions
Clause Resolve (Clause1, Clause2)
a depth-bounded DFS routine (do you exit this routine because depth bound was
encountered, or because no “progress” was made along any path?)
in support of the top-level function for which you were given a prototype
IDDFSRR (Axioms NegatedSentence MaxDB)
should return a proof, if one exists, as a sequence of resolution steps. For example, if
Axioms = ( ( (not s) p) ( (not u) s) (u) ((not w) r) (w) ((not m) (not n) (not v) ) )
NegatedSentence = ( ((not p) (not q) ) ((not p) (not r) ) )
Then (assuming MaxDB was large enough), IDDFSRR would return a proof such as
1. ((not s) p) , ((not p) (not r)) |- ((not s) (not r))
2. ((not s) (not r)) , ((not u) s) |- ((not r) (not u))
3. ((not r) (not u)) , (u) |- ((not r))
4. ((not r)) , ((not w) r) |- ((not w))
5. ((not w)) , (w) |- () contradiction
If no proof is found because MaxDB was reached, then print
No proof due to depth bound limit
If no proof was found because only dead ends (including repeated states) were found, then print
No proof
You might also write a separate formatting function to produce appropriate output.
2. Define another function (DEFUN CNF (Sentence) …) which takes a propositional sentence that can include
logical operators NOT, AND, OR (inclusive), IMPLIES (implication), and EQUIV (equivalence) and returns a list
of sentences in conjunctive normal form that are equivalent to the input sentence (and that are formatted for input
to IDDFSRR, as either the Axioms argument or the NegatedSentence argument). Note that in the input to CNF
all ANDs and ORs will be explicit; whereas ANDs and ORs do not explicitly appear in the output.
The input Sentence is in prefix form, so that “(p and q) implies r” would actually be given as “(implies (and p q) r)”
(CNF ‘(implies (and p q) r)) è (((not p) (not q) r))
3. Define a function (DEFUN CNF-ALL (Sentences) …) that takes a list of sentences, and calls CNF on each.
CNF-ALL returns a list that is the union of all results returned by the repeated calls to CNF. (I say ‘union’, but
you need not check for duplicates across the results of calls to CNF)
If MY-AXIOMS are arbitrary propositional axioms (defined over AND, OR, NOT, IMPLIES, and EQUIV) and
MY-HYPOTHESIS is a statement being offered for proof, then the following call should return a result as
described on the previous page:
(IDDFSRR (CNF-ALL MY-AXIOMS) (CNF (CONS ‘not MY-HYPOTHESIS)) 10)
Some test cases for project 2.
You will show results for each of the test problems below and any other's you'd like.
Some of the statements the system will attempt to prove, are in fact not provable (or disprovable). In NO case should your MaxDB parameter
value be less than 3, but in some cases you may want to make it greater based on your knowledge of the solution depth.
Problem 1:
axioms: p, q
prove: p
Problem 2:
axioms: p, q
prove: p and q
Problem 3:
axioms: p, ~q, ~p or ~r or q
prove: ~r
Problem 4:
axioms: p or ~q, ~p or q, ~p or ~q
prove: ~p and ~q
Problem 5:
axioms:
prove: (p implies (q implies r)) implies ((p implies q) implies (p implies r))
Problem 6:
axioms: p, (p and q) implies r, (s or w) implies q, w
prove: r
Problem 7:
axioms: p or q or r, p or ~q or ~r
prove: p
Problem 8:
axioms: s implies p, u implies s, u, w implies r, w
prove: ~(p and q) implies (p and r)
Turn in the file with all code (commented) named project.2.lsp. Your name should be at the top of the file, in comments, with results of test
runs (those supplied to you and those you developed yourself) in comments after the main code listing. List results from test cases that you are
given before listing results from test cases you develop yourself.
Depth-first search(0-level resolvants)
for each resolvant, R
P = DFS(R, 0-level resolvants)
if P indicates success (contradiction found) then exit success
exit failure
Distinguish axioms and clauses of negated sentence and
Axioms and set-of-support
DFS(R, resolvants)
if R a contradiction then exit/return (proposition true)
for each resolvant, S
x=resolve(R,S)
Add x to set-of-support for recursive calls to DFS
if x NOT IN resolvants
P = DFS(x, resolvants+x)
if P indicates success (contradiction found) then exit success
exit failure (no contradiction found)
Return proof steps, not simply success or failure
Background
(including examples of
DFS resolution refutation and set of support)
This NOT Set of Support
{~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants
(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)
(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……………..
(p or ~s or ~u) ……. (p or ~u) …………………………………………… ~w ……………..
NULL
Set of Support (each resolution step involves a sentence
resulting from negated hypothesis, or a descendent:
Following strict resolution rule, this not
generated because no complementary literals
{~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants
(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)
(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……………..
(p or ~s or ~u) ……. (p or ~u) …………………………………………… ~w ……………..
NULL
After more search:
{~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants
(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)
(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……~u or ~r………..
(p or ~s or ~u) ……. (p or ~u) …………………………………………… ~w ……………..
NULL
After more search:
{~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants
(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)
(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……~u or ~r………..
(p or ~s or ~u) ……. (p or ~u) …………………………………………… ~w ………~r……..
NULL
After more search:
{~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants
(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)
(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……~u or ~r………..
(p or ~s or ~u) ……. (p or ~u) …………………………………………… ~w ………~r……..
NULL
~w
After more search:
{~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants
(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)
(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……~u or ~r………..
(p or ~s or ~u) ……. (p or ~u) …………………………………………… ~w ………~r……..
NULL
~w
NULL
You might be tempted to think from the last example, that in a DFS we need only
resolve the current clause (R is pseudocode earlier) with the 0-level clauses
(axioms + negated sentence). If you restricted yourself to this, then your algorithm
would certainly not be complete.
Consider the following axioms ~p or q, p or ~q, ~p or ~q
Prove: ~p and ~q Negation: ~(~p and ~q) equivalent to (p or q)
Attempt a DFS proof in which the current clause is always paired with a level-0
clause
p or q
~p or q
p or ~q ~p or ~q
q
p
~q
~p Start repeating and conclude no proof after much search
You might be tempted to think from the last example, that in a DFS we need only
resolve the current clause (R is pseudocode earlier) with the 0-level clauses
(axioms + negated sentence). If you restricted yourself to this, then your algorithm
would certainly not be complete.
Consider the following axioms ~p or q, p or ~q, ~p or ~q
Prove: ~p and ~q Negation: ~(~p and ~q) equivalent to (p or q)
Attempt a DFS proof in which the current clause is always paired with a level-0
clause
p or q
~p or q
p or ~q ~p or ~q
q
p or q
~p or q
p or ~q ~p or ~q
q
p
p
~q
~q
~p
Start repeating and conclude no proof after much search
NULL
These in resolvants
Set too
Set of support strategy: at least one resolvant is a clause of the original negated
sentence or a descendent of such a clause. The DFS-generated proofs of the
previous pages satisfy the set-of-support constraint, as does the proof below, but
the one below might not have been found by DFS, but would have been found
by IDDFSRR.
{~s or p, ~u or s, u, ~w or r, w, ~p or ~q, ~p or ~r } 0-level resolvants
(p or ~u) (~s or p or u) (~s or p or ~w or r) (~s or p or w) (~s or ~q) (~s or ~r) s … (~p or ~q or ~r)
(p or ~s or ~u) (p or ~u or s) p … (p or ~s) (p or ~u or ~s or ~w or r) …. ~r ……………..
(p or ~s or ~u) ……. (p or ~u) …………………………………………… ~w ……………..
NULL
© Copyright 2026 Paperzz