0% found this document useful (0 votes)
45 views

Unit-3 - C - Resolution in Propositional Logic in Detail

The document discusses resolution in propositional logic as an inference method. It can be used to prove that a knowledge base KB entails a statement α. KB is first converted to conjunctive normal form (CNF). Resolution works by finding two clauses in KB with a literal and its negation, canceling them out and combining the remaining literals. Repeating this process can derive new clauses until a contradiction is reached, proving KB entails α. An example knowledge base about pits and breezes in a game world is provided and resolved to show a statement about pits is entailed.

Uploaded by

Madhav Chaudhary
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Unit-3 - C - Resolution in Propositional Logic in Detail

The document discusses resolution in propositional logic as an inference method. It can be used to prove that a knowledge base KB entails a statement α. KB is first converted to conjunctive normal form (CNF). Resolution works by finding two clauses in KB with a literal and its negation, canceling them out and combining the remaining literals. Repeating this process can derive new clauses until a contradiction is reached, proving KB entails α. An example knowledge base about pits and breezes in a game world is provided and resolved to show a statement about pits is entailed.

Uploaded by

Madhav Chaudhary
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Resolution in Propositional Logic

Inference by Resolution
• KB is represented in CNF
– KB = AND of all the sentences in KB
– KB sentence = clause = OR of literals
– Literal = propositional symbol or its negation

• Find two clauses in KB, one of which contains a literal and the
other its negation
– Cancel the literal and its negation
– Bundle everything else into a new clause
– Add the new clause to KB
– Repeat
Conjunctive Normal Form (CNF)
• Boolean formulae are central to CS
– Boolean logic is the way our discipline works
• Two canonical Boolean formulae representations:
– CNF = Conjunctive Normal Form
Clause
• A conjunct of disjuncts = (AND (OR …) (OR …) )
• “…” = a list of literals (= a variable or its negation)
• CNF is used by Resolution Theorem Proving
– DNF = Disjunctive Normal Form
• A disjunct of conjuncts = (OR (AND …) (AND …) ) Term
• DNF is used by Decision Trees in Machine Learning
• Can convert any Boolean formula to CNF or DNF
Conjunctive Normal Form (CNF)
KB |= 
We’d like to prove:
(This is equivalent to KB    is unsatisfiable.)
 Is the conclusion

We first rewrite KB   into conjunctive normal form (CNF).

literals
A “conjunction of disjunctions”
(A  B)  (B  C  D)

Clause Clause

• Any KB can be converted into CNF.


• In fact, any KB can be converted into CNF-3 using clauses with at most 3 literals.
Review: Equivalence & Implication
• Equivalence is a conjoined double implication

– (X  Y) = [(X  Y)  (Y  X)]

• Implication is (NOT antecedent OR consequent)

– (X  Y) = (X  Y)
Review: de Morgan's rules
• How to bring  inside parentheses
– (1) Negate everything inside the parentheses
– (2) Change operators to “the other operator”

• (X  Y  …  Z) = (X  Y  …  Z)

• (X  Y  …  Z) = (X  Y  …  Z)


Review: Boolean Distributive Laws
• Both of these laws are valid:

• AND distributes over OR


– X  (Y  Z) = (X  Y)  (X  Z)
– (W  X)  (Y  Z) = (W  Y)  (X  Y)  (W  Z)  (X  Z)

• OR distributes over AND


– X  (Y  Z) = (X  Y)  (X  Z)
– (W  X)  (Y  Z) = (W  Y)  (X  Y)  (W  Z)  (X  Z)
Example: Conversion to CNF
Example: B1,1  (P1,2  P2,1)

1. Eliminate  by replacing α  β with (α  β)(β  α).


= (B1,1  (P1,2  P2,1))  ((P1,2  P2,1)  B1,1)

2. Eliminate  by replacing α  β with α β and simplify.


= (B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1)

3. Move  inwards using de Morgan's rules and simplify.


(α  β)  (α  β), (α  β)  (α  β)
= (B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1)

4. Apply distributive law ( over ) and simplify.


= (B1,1  P1,2  P2,1)  (P1,2  B1,1)  (P2,1  B1,1)
Example: Conversion to CNF
Example: B1,1  (P1,2  P2,1)

From the previous slide we had:


= (B1,1  P1,2  P2,1)  (P1,2  B1,1)  (P2,1  B1,1)

5. KB is the conjunction of all of its sentences (all are true),


so write each clause (disjunct) as a sentence in KB:

KB = Often, Won’t Write “” or “”


… (we know they are there)
(B1,1  P1,2  P2,1) (B1,1 P1,2 P2,1)
(P1,2  B1,1) (P1,2 B1,1)
(P2,1  B1,1) (P2,1 B1,1)
… (same)
Inference by Resolution
• KB is represented in CNF
– KB = AND of all the sentences in KB
– KB sentence = clause = OR of literals
– Literal = propositional symbol or its negation

• Find two clauses in KB, one of which contains a literal and the
other its negation
– Cancel the literal and its negation
– Bundle everything else into a new clause
– Add the new clause to KB
– Repeat
Resolution = Efficient Implication
Recall that (A => B) = ( (NOT A) OR B)
and so:
(Y OR X) = ( (NOT X) => Y)
( (NOT Y) OR Z) = (Y => Z)
which yields:
( (Y OR X) AND ( (NOT Y) OR Z) ) |= ( (NOT X) => Z) = (X OR Z)

(OR A B C D) ->Same -> (NOT (OR B C D)) => A


(OR ¬A E F G) ->Same -> A => (OR E F G)
----------------------------- ----------------------------------------------------
(OR B C D E F G) (NOT (OR B C D)) => (OR E F G)
----------------------------------------------------
(OR B C D E F G)

Recall: All clauses in KB are conjoined by an implicit AND (= CNF representation).


Resolution Examples
• Resolution: inference rule for CNF: sound and complete! *
(A  B  C )
( A ) “If A or B or C is true, but not A, then B or C must be true.”

 (B  C )

(A  B  C ) “If A is false then B or C must be true, or if A is true


( A  D  E ) then D or E must be true, hence since A is either true or
false, B or C or D or E must be true.”

 (B  C  D  E )
* Resolution is “refutation complete”
“If A or B is true, and in that it can prove the truth of any
(A  B )
not A or B is true, entailed sentence by refutation.
( A  B ) then B must be true.” * You can start two resolution proofs
 in parallel, one for the sentence and
one for its negation, and see which
 (B  B )  B Simplification
branch returns a correct proof.
is done always.
More Resolution Examples
• (P Q ¬R S) with (P ¬Q W X) yields (P ¬R S W X)
– Order of literals within clauses does not matter.
• (P Q ¬R S) with (¬P) yields (Q ¬R S)
• (¬R) with (R) yields ( ) or FALSE
• (P Q ¬R S) with (P R ¬S W X) yields (P Q ¬R R W X) or (P Q S ¬S W X) or TRUE
• (P ¬Q R ¬S) with (P ¬Q R ¬S) yields None possible
• (P ¬Q ¬S W) with (P R ¬S X) yields None possible
• ( (¬ A) (¬ B) (¬ C) (¬ D) ) with ( (¬ C) D) yields ( (¬ A) (¬ B) (¬ C ) )
• ( (¬ A) (¬ B) (¬ C ) ) with ( (¬ A) C) yields ( (¬ A) (¬ B) )
• ( (¬ A) (¬ B) ) with (B) yields (¬ A)
• (A C) with (A (¬ C) ) yields (A)
• (¬ A) with (A) yields ( ) or FALSE
Only Resolve ONE Literal Pair!
If more than one pair, result always = TRUE.
Useless!! Always simplifies to TRUE!!
No!
(OR A B C D)
No!
(OR A B C D)
(OR ¬A ¬B F G)
(OR ¬A ¬B ¬C )
-----------------------------
-----------------------------
(OR C D F G)
(OR D)
No! This is wrong! No! This is wrong!

Yes! (but = TRUE) Yes! (but = TRUE)


(OR A B C D) (OR A B C D)
(OR ¬A ¬B F G) (OR ¬A ¬B ¬C )
----------------------------- -----------------------------
(OR B ¬B C D F G) (OR A ¬A B ¬B D)
Yes! (but = TRUE) Yes! (but = TRUE)
(Resolution theorem provers routinely pre-scan the two clauses for two
complementary literals, and if they are found won’t resolve those clauses.)
Resolution Algorithm
KB |  equivalent to
• The resolution algorithm tries to prove:
KB   unsatisfiable

• Generate all new sentences from KB and the (negated) query.


• One of two things can happen:

1. We find P  P which is unsatisfiable. I.e.* we can entail the query.

2. We find no contradiction: there is a model that satisfies the sentence


KB   (non-trivial) and hence we cannot entail the query.

* I.e. = id est = that is


Resolution example
Stated in English

• “Laws of Physics” in the Wumpus World:


– “A breeze in B11 is equivalent to a pit in P12 or a
pit in P21.”

• Particular facts about a specific instance:


– “There is no breeze in B11.”

• Goal or query sentence:


– “Is it true that P12 does not have a pit?”
Resolution example
Stated in Propositional Logic

• “Laws of Physics” in the Wumpus World:


– “A breeze in B11 is equivalent to a pit in P12 or a
pit in P21.”
We converted this sentence to CNF in
(B1,1  (P1,2 P2,1)) the CNF example we worked above.

• Particular facts about a specific instance:


– “There is no breeze in B11.”
( B1,1)
• Goal or query sentence:
– “Is it true that P12 does not have a pit?”
(P1,2)
Resolution example
Resulting Knowledge Base stated in CNF

• “Laws of Physics” in the Wumpus World:


(B1,1 P1,2 P2,1)
(P1,2 B1,1)
(P2,1 B1,1)

• Particular facts about a specific instance:


( B1,1)

• Negated goal or query sentence:


(P1,2)
Resolution example
A Resolution proof ending in ( )

• Knowledge Base at start of proof:


(B1,1 P1,2 P2,1)
(P1,2 B1,1)
(P2,1 B1,1)
( B1,1)
(P1,2)

A resolution proof ending in ( ):


• Resolve (P1,2 B1,1) and ( B1,1) to give (P1,2 )
• Resolve (P1,2 ) and (P1,2) to give ( )

• Consequently, the goal or query sentence is entailed by KB.


• Of course, there are many other proofs, which are OK iff correct.
Resolution example
Graphical view of the proof

• KB = (B1,1  (P1,2 P2,1))  B1,1


• α = P1,2
KB  

P2,1 P1,2

True!
A sentence in KB is not “used up” when it is used in a False in
resolution step. It is true, remains true, and is still in KB. all worlds
Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if
it is not mythical, then it is a mortal mammal. If the unicorn is
either immortal or a mammal, then it is horned. The unicorn is
magical if it is horned.
Prove that the unicorn is both magical and horned.

Problem 7.2, R&N page 280. (Adapted from Barwise and


Etchemendy, 1993.)

Note for non-native-English speakers: immortal = not mortal


Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either immortal or a
mammal, then it is horned. The unicorn is magical if it is horned.
Prove that the unicorn is both magical and horned.

• First, Ontology: What do we need to describe and reason about?

• Use these propositional variables (“immortal” = “not mortal”):


Y = unicorn is mYthical R = unicorn is moRtal
M = unicorn is a maMmal H = unicorn is Horned
G = unicorn is maGical
Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either immortal or a
mammal, then it is horned. The unicorn is magical if it is horned.
Prove that the unicorn is both magical and horned.
Y = unicorn is mYthical R = unicorn is moRtal
M = unicorn is a maMmal H = unicorn is Horned
G = unicorn is maGical

• Second, translate to Propositional Logic, then to CNF:


• Propositional logic (prefix form, aka Polish notation):
– (=> Y (NOT R) ) ; same as ( Y => (NOT R) ) in infix form
• CNF (clausal form) ; recall (A => B) = ( (NOT A) OR B)
– ( (NOT Y) (NOT R) ) Prefix form is often a better representation for a
parser, since it looks at the first element of the list
and dispatches to a handler for that operator token.
Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either immortal or a
mammal, then it is horned. The unicorn is magical if it is horned.
Prove that the unicorn is both magical and horned.
Y = unicorn is mYthical R = unicorn is moRtal
M = unicorn is a maMmal H = unicorn is Horned
G = unicorn is maGical

• Second, translate to Propositional Logic, then to CNF:


• Propositional logic (prefix form):
– (=> (NOT Y) (AND R M) ) ;same as ( (NOT Y) => (R AND M) ) in infix form
• CNF (clausal form)
– (M Y)
If you ever have to do this “for real” you will likely
– (R Y)
invent a new domain language that allows you to
state important properties of the domain --- then
parse that into propositional logic, and then CNF.
Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either immortal or a
mammal, then it is horned. The unicorn is magical if it is horned.
Prove that the unicorn is both magical and horned.
Y = unicorn is mYthical R = unicorn is moRtal
M = unicorn is a maMmal H = unicorn is Horned
G = unicorn is maGical

• Second, translate to Propositional Logic, then to CNF:


• Propositional logic (prefix form):
– (=> (OR (NOT R) M) H) ; same as ( (Not R) OR M) => H in infix form

• CNF (clausal form)


– (H (NOT M) )
– (H R)
Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either immortal or a
mammal, then it is horned. The unicorn is magical if it is horned.
Prove that the unicorn is both magical and horned.
Y = unicorn is mYthical R = unicorn is moRtal
M = unicorn is a maMmal H = unicorn is Horned
G = unicorn is maGical

• Second, translate to Propositional Logic, then to CNF:


• Propositional logic (prefix form)
– (=> H G) ; same as H => G in infix form
• CNF (clausal form)
– ( (NOT H) G)
Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either immortal or a
mammal, then it is horned. The unicorn is magical if it is horned.
Prove that the unicorn is both magical and horned.
Y = unicorn is mYthical R = unicorn is moRtal
M = unicorn is a maMmal H = unicorn is Horned
G = unicorn is maGical

• Current KB (in CNF clausal form) =

( (NOT Y) (NOT R) ) (M Y) (R Y) (H (NOT M) )


(H R) ( (NOT H) G)
Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either immortal or a
mammal, then it is horned. The unicorn is magical if it is horned.
Prove that the unicorn is both magical and horned.
Y = unicorn is mYthical R = unicorn is moRtal
M = unicorn is a maMmal H = unicorn is Horned
G = unicorn is maGical

• Third, negated goal to Propositional Logic, then to CNF:


• Goal sentence in propositional logic (prefix form)
– (AND H G) ; same as H AND G in infix form
• Negated goal sentence in propositional logic (prefix form)
– (NOT (AND H G) ) = (OR (NOT H) (NOT G) )
• CNF (clausal form)
– ( (NOT G) (NOT H) )
Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either immortal or a
mammal, then it is horned. The unicorn is magical if it is horned.
Prove that the unicorn is both magical and horned.
Y = unicorn is mYthical R = unicorn is moRtal
M = unicorn is a maMmal H = unicorn is Horned
G = unicorn is maGical

• Current KB + negated goal (in CNF clausal form) =

( (NOT Y) (NOT R) ) (M Y) (R Y) (H (NOT M) )


(H R) ( (NOT H) G) ( (NOT G) (NOT H) )
Detailed Resolution Proof Example
• In words: If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either immortal or a
mammal, then it is horned. The unicorn is magical if it is horned.
Prove that the unicorn is both magical and horned.
( (NOT Y) (NOT R) ) (M Y) (R Y) (H (NOT M) )
(H R) ( (NOT H) G) ( (NOT G) (NOT H) )

• Fourth, produce a resolution proof ending in ( ):


• Resolve (¬H ¬G) and (¬H G) to give (¬H)
• Resolve (¬Y ¬R) and (Y M) to give (¬R M)
• Resolve (¬R M) and (R H) to give (M H)
• Resolve (M H) and (¬M H) to give (H)
• Resolve (¬H) and (H) to give ( )

• Of course, there are many other proofs, which are OK iff correct.
Detailed Resolution Proof Example
Graph view of proof

( ¬ Y ¬ R ) ( Y R ) ( Y M ) ( R H ) ( ¬ M H ) ( ¬ H G ) (¬ G ¬ H )

( ¬R M ) (¬H)

(HM)

(H)

( )
Detailed Resolution Proof Example
Graph view of a different proof

• ( ¬ Y ¬ R ) ( Y R ) ( Y M ) ( R H ) ( ¬ M H ) ( ¬ H G ) (¬ G ¬ H )

(¬H)

(¬M)

(Y)

(¬R)

(H)

( )

You might also like