SlideShare a Scribd company logo
1 of 27
CS1502 Formal Methods in
   Computer Science
        Lecture Notes 10
           Resolution
       and Horn Sentences
Resolution 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
Resolution 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
Conversion 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 hadn’t done conditionals yet

Use DeMorgan’s laws and ~Elim to move ~ as far inward
as possible (gives NNF)

Use the distributive laws until the sentence is in CNF
Clausal 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}
Resolution 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
Satisfying 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
Empty 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}}
Example: not satisfiable

¬P ∨ Q         {¬P, Q}
P               {P}
¬Q             {¬Q}

     {¬P, Q}   {P}   {¬Q}
Resolution 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
Resolution Step
Res. Step with Larger Clauses
Resolvent
Clause R is a resolvent of clauses C 1 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}
Resolution 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
Resolution Theorem
For any set of clauses that are not
satisfiable, it is possible to arrive at the
empty clause by using successive
resolutions.
Resolution 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
Using 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 {} ()
Is this Argument Valid?
BvC
~C v ~D
AvD
~B v ~D
A
Example

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}

                          
Example
Modus Pones
P→Q        ¬P∨Q or     {¬P,Q}
P                        {P}
Q   negate to get          {¬Q}


Apply resolution: {¬P,Q}      { P}

                           { Q}      { ¬Q}
What 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.
Examples
(A ∨ ¬B ∨ ¬C) ∧ (¬A ∨ ¬B)              Horn sentence


(A ∨ ¬B ∨ C) ∧ (D)                   Not Horn sentence


(A ∧ B) ∨ (¬C ∧ ¬D)                    Horn sentence



 (A ∨ ¬C) ∧ (B ∨ ¬C) ∧ (A ∨ ¬D) ∧ (B ∨ ¬D)
Alternate Form of Horn
            Conjunct
¬A1∨ ¬A2∨...∨ ¬An∨ B


 ¬(A1 ∧ A2 ∧... ∧ An) ∨ B


  (A1 ∧ A2 ∧... ∧ An) → B    B :- A1, A2, …, An.
                             Conditional Form
                                  In Prolog:
                                      of
                               HornRule
                                      sentence

        B if A1, A2, …, An
Special Cases
No positive literal
¬A1∨ ¬A2∨...∨ ¬An                In Prolog, this
                                   is a query!
(A1 ∧ A2 ∧... ∧ An) → False


No negative literals
B
                              In Prolog, this
 True → B
                                 is a fact!
Why are Horn sentences
            important?
Very efficient algorithms exist for determining if a
set of Horn sentences is satisfiable
CNF to PROLOG
¬A ∨ B ∨ ¬C    is ¬(A∧C) ∨ B   is   (A ∧ C)→B

B :- A, C.
A.
C.

Query: :- B.
Answer: Yes.
Example 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,ann).
father(ed,sam).

More Related Content

What's hot

CMSC 56 | Lecture 2: Propositional Equivalences
CMSC 56 | Lecture 2: Propositional EquivalencesCMSC 56 | Lecture 2: Propositional Equivalences
CMSC 56 | Lecture 2: Propositional Equivalencesallyn joy calcaben
 
Logic and proof
Logic and proofLogic and proof
Logic and proofSuresh Ram
 
Understanding Dynamic Programming through Bellman Operators
Understanding Dynamic Programming through Bellman OperatorsUnderstanding Dynamic Programming through Bellman Operators
Understanding Dynamic Programming through Bellman OperatorsAshwin Rao
 
2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting Poster2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting PosterChelsea Battell
 
Kernel for Chordal Vertex Deletion
Kernel for Chordal Vertex DeletionKernel for Chordal Vertex Deletion
Kernel for Chordal Vertex DeletionAkankshaAgrawal55
 
A new practical algorithm for volume estimation using annealing of convex bodies
A new practical algorithm for volume estimation using annealing of convex bodiesA new practical algorithm for volume estimation using annealing of convex bodies
A new practical algorithm for volume estimation using annealing of convex bodiesVissarion Fisikopoulos
 
Automata
AutomataAutomata
AutomataGaditek
 
Polynomial Kernel for Interval Vertex Deletion
Polynomial Kernel for Interval Vertex DeletionPolynomial Kernel for Interval Vertex Deletion
Polynomial Kernel for Interval Vertex DeletionAkankshaAgrawal55
 
Computer aided design free ebooks download INDEX for engineering
Computer aided design free ebooks download INDEX for engineeringComputer aided design free ebooks download INDEX for engineering
Computer aided design free ebooks download INDEX for engineeringveeru011
 

What's hot (18)

CMSC 56 | Lecture 2: Propositional Equivalences
CMSC 56 | Lecture 2: Propositional EquivalencesCMSC 56 | Lecture 2: Propositional Equivalences
CMSC 56 | Lecture 2: Propositional Equivalences
 
Logic and proof
Logic and proofLogic and proof
Logic and proof
 
Tsp is NP-Complete
Tsp is NP-CompleteTsp is NP-Complete
Tsp is NP-Complete
 
Understanding Dynamic Programming through Bellman Operators
Understanding Dynamic Programming through Bellman OperatorsUnderstanding Dynamic Programming through Bellman Operators
Understanding Dynamic Programming through Bellman Operators
 
2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting Poster2015 CMS Winter Meeting Poster
2015 CMS Winter Meeting Poster
 
AI Lesson 13
AI Lesson 13AI Lesson 13
AI Lesson 13
 
Lex analysis
Lex analysisLex analysis
Lex analysis
 
Fsa
FsaFsa
Fsa
 
Ch02
Ch02Ch02
Ch02
 
Kernel for Chordal Vertex Deletion
Kernel for Chordal Vertex DeletionKernel for Chordal Vertex Deletion
Kernel for Chordal Vertex Deletion
 
Function
Function Function
Function
 
Ambiguty
AmbigutyAmbiguty
Ambiguty
 
A new practical algorithm for volume estimation using annealing of convex bodies
A new practical algorithm for volume estimation using annealing of convex bodiesA new practical algorithm for volume estimation using annealing of convex bodies
A new practical algorithm for volume estimation using annealing of convex bodies
 
Algorithum Analysis
Algorithum AnalysisAlgorithum Analysis
Algorithum Analysis
 
Automata
AutomataAutomata
Automata
 
Polynomial Kernel for Interval Vertex Deletion
Polynomial Kernel for Interval Vertex DeletionPolynomial Kernel for Interval Vertex Deletion
Polynomial Kernel for Interval Vertex Deletion
 
Computer aided design free ebooks download INDEX for engineering
Computer aided design free ebooks download INDEX for engineeringComputer aided design free ebooks download INDEX for engineering
Computer aided design free ebooks download INDEX for engineering
 
Fine Grained Complexity
Fine Grained ComplexityFine Grained Complexity
Fine Grained Complexity
 

Viewers also liked

14 pro resolution
14 pro resolution14 pro resolution
14 pro resolutionTianlu Wang
 
Introduction to AI - Eight Lecture
Introduction to AI - Eight LectureIntroduction to AI - Eight Lecture
Introduction to AI - Eight LectureWouter Beek
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up ParsingGerwin Ocsena
 
Fuzzy Logic in the Real World
Fuzzy Logic in the Real WorldFuzzy Logic in the Real World
Fuzzy Logic in the Real WorldBCSLeicester
 

Viewers also liked (6)

14 pro resolution
14 pro resolution14 pro resolution
14 pro resolution
 
Introduction to AI - Eight Lecture
Introduction to AI - Eight LectureIntroduction to AI - Eight Lecture
Introduction to AI - Eight Lecture
 
Java Concurrency
Java ConcurrencyJava Concurrency
Java Concurrency
 
Minimax
MinimaxMinimax
Minimax
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up Parsing
 
Fuzzy Logic in the Real World
Fuzzy Logic in the Real WorldFuzzy Logic in the Real World
Fuzzy Logic in the Real World
 

Similar to Lec10

Similar to Lec10 (20)

CPSC 125 Ch 1 sec 2
CPSC 125 Ch 1 sec 2CPSC 125 Ch 1 sec 2
CPSC 125 Ch 1 sec 2
 
L03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicL03 ai - knowledge representation using logic
L03 ai - knowledge representation using logic
 
Proposition Logic in Discrete Structure
Proposition Logic in Discrete StructureProposition Logic in Discrete Structure
Proposition Logic in Discrete Structure
 
AI Lesson 15
AI Lesson 15AI Lesson 15
AI Lesson 15
 
Truth, deduction, computation; lecture 5
Truth, deduction, computation;  lecture 5Truth, deduction, computation;  lecture 5
Truth, deduction, computation; lecture 5
 
C2.0 propositional logic
C2.0 propositional logicC2.0 propositional logic
C2.0 propositional logic
 
Algorithmic foundations.docx
Algorithmic foundations.docxAlgorithmic foundations.docx
Algorithmic foundations.docx
 
Slides
SlidesSlides
Slides
 
Mcs 013 solve assignment
Mcs 013 solve assignmentMcs 013 solve assignment
Mcs 013 solve assignment
 
Math Assignment Help
Math Assignment HelpMath Assignment Help
Math Assignment Help
 
practice-final-soln.pdf
practice-final-soln.pdfpractice-final-soln.pdf
practice-final-soln.pdf
 
Discrete structures & optimization unit 1
Discrete structures & optimization unit 1Discrete structures & optimization unit 1
Discrete structures & optimization unit 1
 
DISMATH_Part1
DISMATH_Part1DISMATH_Part1
DISMATH_Part1
 
Discrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order LogicDiscrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order Logic
 
14th Athens Colloquium on Algorithms and Complexity (ACAC19)
14th Athens Colloquium on Algorithms and Complexity (ACAC19)14th Athens Colloquium on Algorithms and Complexity (ACAC19)
14th Athens Colloquium on Algorithms and Complexity (ACAC19)
 
Math 189 Exam 1 Solutions
Math 189 Exam 1 SolutionsMath 189 Exam 1 Solutions
Math 189 Exam 1 Solutions
 
AI Lesson 16
AI Lesson 16AI Lesson 16
AI Lesson 16
 
DM(1).pptx
DM(1).pptxDM(1).pptx
DM(1).pptx
 
Course notes1
Course notes1Course notes1
Course notes1
 
lecture 30
lecture 30lecture 30
lecture 30
 

Lec10

  • 1. CS1502 Formal Methods in Computer Science Lecture Notes 10 Resolution and Horn Sentences
  • 2. Resolution 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
  • 3. Resolution 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
  • 4. Conversion 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 hadn’t done conditionals yet Use DeMorgan’s laws and ~Elim to move ~ as far inward as possible (gives NNF) Use the distributive laws until the sentence is in CNF
  • 5. Clausal 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}
  • 6. Resolution 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
  • 7. Satisfying 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
  • 8. Empty 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}}
  • 9. Example: not satisfiable ¬P ∨ Q {¬P, Q} P {P} ¬Q {¬Q} {¬P, Q} {P} {¬Q}
  • 10. Resolution 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
  • 12. Res. Step with Larger Clauses
  • 13. Resolvent Clause R is a resolvent of clauses C 1 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}
  • 14. Resolution 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
  • 15. Resolution Theorem For any set of clauses that are not satisfiable, it is possible to arrive at the empty clause by using successive resolutions.
  • 16. Resolution 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
  • 17. Using 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 {} ()
  • 18. Is this Argument Valid? BvC ~C v ~D AvD ~B v ~D A
  • 19. Example 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} 
  • 20. Example Modus Pones P→Q ¬P∨Q or {¬P,Q} P {P} Q negate to get {¬Q} Apply resolution: {¬P,Q} { P} { Q} { ¬Q}
  • 21. What 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.
  • 22. Examples (A ∨ ¬B ∨ ¬C) ∧ (¬A ∨ ¬B) Horn sentence (A ∨ ¬B ∨ C) ∧ (D) Not Horn sentence (A ∧ B) ∨ (¬C ∧ ¬D) Horn sentence (A ∨ ¬C) ∧ (B ∨ ¬C) ∧ (A ∨ ¬D) ∧ (B ∨ ¬D)
  • 23. Alternate Form of Horn Conjunct ¬A1∨ ¬A2∨...∨ ¬An∨ B ¬(A1 ∧ A2 ∧... ∧ An) ∨ B (A1 ∧ A2 ∧... ∧ An) → B B :- A1, A2, …, An. Conditional Form In Prolog: of HornRule sentence B if A1, A2, …, An
  • 24. Special Cases No positive literal ¬A1∨ ¬A2∨...∨ ¬An In Prolog, this is a query! (A1 ∧ A2 ∧... ∧ An) → False No negative literals B In Prolog, this True → B is a fact!
  • 25. Why are Horn sentences important? Very efficient algorithms exist for determining if a set of Horn sentences is satisfiable
  • 26. CNF to PROLOG ¬A ∨ B ∨ ¬C is ¬(A∧C) ∨ B is (A ∧ C)→B B :- A, C. A. C. Query: :- B. Answer: Yes.
  • 27. Example 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,ann). father(ed,sam).