Title: CS1502 Formal Methods in Computer Science
1CS1502 Formal Methods in Computer Science
Lecture Notes 10 Resolutionand Horn Sentences
2Resolution Theorem Proving
- Method for searching for proofs automatically
- Sentences are translated into CNF, and then to
sets of clauses - At each step, a new clause is derived from two
clauses you already have - Proof steps all use the same rule
- If reach (__), sentences were not satisfiable
- Start premises negation of goal
- End if reach , premises goal
3Resolution Theorem Proving
- Method for searching for proofs automatically
- Sentences are translated into CNF, and then to
sets of clauses - At each step, a new clause is derived from two
clauses you already have - Proof steps all use the same rule
- If reach (__), sentences were not satisfiable
- Start premises negation of goal
- End if reach , premises goal
4Conversion to Clausal Form
- Use P ? Q equiv P v Q to remove ?
- Use P ?? Q equiv ((P v Q) (Q v P)) to
remove ?? - New 1st Step! We hadnt done conditionals yet
- Use DeMorgans laws and Elim to move as far
inward as possible (gives NNF) - Use the distributive laws until the sentence is
in CNF
5Clausal Form
- Given a sentence S written in CNF S ( ) ?( )
? . . . ? ( ) - Convert each ( ) into a clause - a set consisting
of each of the literals in ( ).Example S (A)
? (?B ? C ? D) ? (?A? D)Clauses are A, ?
B, C, D, ? A, D
6Resolution Theorem Proving
- Method for searching for proofs automatically
- Sentences are translated into CNF, and then to
sets of clauses - At each step, a new clause is derived from two
clauses you already have - Proof steps all use the same rule
- If reach (__), sentences were not satisfiable
- Start premises negation of goal
- End if reach , premises goal
7Satisfying a Set of Clauses
- Assigning truth-values to the atomic sentences so
the CNF sentence the set corresponds to is true. - A, ?C, D, C,?A,A, D is satisfied by
- A False
C True D True
8Empty Clause
- denoted by .
- The empty clause is not satisfiable
- We want A, ? A to lead to ()
- The basic resolution step involves canceling
pos and neg matching literals from two clauses - So, we derive () from A, ? A
9Example not satisfiable
?P, Q
P
?Q
10Resolution Theorem Proving
- Method for searching for proofs automatically
- Sentences are translated into CNF, and then to
sets of clauses - At each step, a new clause is derived from two
clauses you already have - Proof steps all use the same rule
- If reach (__), sentences were not satisfiable
- Start premises negation of goal
- End if reach , premises goal
11Resolution Step
12Res. Step with Larger Clauses
13Resolvent
- Clause R is a resolvent of clauses C1 and C2 if
there is a literal in C1 whose negation is in C2
and R consists of all the remaining literals in
either clause.Example A, C , ?D and B, ?C
have resolvent A, B, ?D
14Resolution Theorem Proving
- Method for searching for proofs automatically
- Sentences are translated into CNF, and then to
sets of clauses - At each step, a new clause is derived from two
clauses you already have - Proof steps all use the same rule
- If reach (__), sentences were not satisfiable
- Start premises negation of goal
- End if reach , premises goal
15Resolution Theorem
- For any set of clauses that are not satisfiable,
it is possible to arrive at the empty clause by
using successive resolutions.
16Resolution Theorem Proving
- Method for searching for proofs automatically
- Sentences are translated into CNF, and then to
sets of clauses - At each step, a new clause is derived from two
clauses you already have - Proof steps all use the same rule
- If reach (__), sentences were not satisfiable
- Start premises negation of goal
- End if reach , premises goal
17Using Resolution to Determine Validity of
Arguments
- Q is a logical consequence of P1, P2, , Pn iff
P1 P2 Pn Q is not satisfiable - For sentences in clausal form Q
is a logical consequence of a set of clauses S
iff S ? ?Q is not satisfiable. - So, convert premises negation of goal to
clausal form, and do resolution steps, trying to
reach ()
18Is this Argument Valid?
B v C C v D A v D B v D A
19Example
- Show ?A ? (B ? C) ? (?C ? ?D) ? (A ? D) ? (?B ?
?D) is not satisfiable.Clauses ? A, B, C,
?C, ?D, A, D, ?B, ?D. ?A A,D
B,C ?C, ?D D
B, ?D ?B,
?D
?D -
20Example
- Modus PonesP?Q ?P?Q or
?P,QP
PQ negate to get ?QApply
resolution ?P,Q P
Q
?Q
?
21What is a Horn sentence?
- A positive literal is any literal that is not
preceded with a ?. For example, Cube(b) and P are
positive literals. - A sentence S is a Horn sentence if and only if it
is in CNF and every conjunct has at most one
positive literal.
22Examples
- (A ? ?B ? ?C) ? (?A ? ?B)
- (A ? ?B ? C) ? (D)
- (A ? B) ? (?C ? ?D)
Horn sentence
Not Horn sentence
Horn sentence
(A ? ?C) ? (B ? ?C) ? (A ? ?D) ? (B ? ?D)
23Alternate Form of Horn Conjunct
?(A1 ? A2 ?... ? An) ? B
(A1 ? A2 ?... ? An) ? B
B - A1, A2, , An. In PrologRule
Conditional Form of Horn sentence
B if A1, A2, , An
24Special Cases
- No positive literal?A1? ?A2?...? ?An
- No negative literalsB
In Prolog, this is a query!
(A1 ? A2 ?... ? An) ? False
In Prolog, this is a fact!
True ? B
25Why are Horn sentences important?
- Very efficient algorithms exist for determining
if a set of Horn sentences is satisfiable
26CNF to PROLOG
- ?A ? B ? ?C is ?(A?C) ? B is (A ?
C)?B B - A, C.A.C.Query - B.Answer
Yes.
27Example Prolog Program
- grandfather(X,Y) - father(X,Z),
father(Z,Y).grandfather(X,Y) -
father(X,Z), mother(Z,Y).
mother(ann,bill).father(carl,ed).father(nick,a
nn).father(ed,sam).