cs1502 formal methods in computer science lecture notes 10 resolution and horn sentences
Post on 24-Dec-2015
223 Views
Preview:
TRANSCRIPT
CS1502 Formal Methods in CS1502 Formal Methods in Computer Science Computer Science
Lecture Notes 10
Resolutionand Horn Sentences
Resolution Theorem ProvingResolution Theorem Proving
Method for searching for proofs automaticallyMethod for searching for proofs automaticallySentences are translated into CNF, and then to Sentences are translated into CNF, and then to sets of clausessets of clausesAt each step, a new clause is derived from two At each step, a new clause is derived from two clauses you already haveclauses you already haveProof steps all use the same ruleProof steps all use the same rule
If reach If reach (_|_), sentences were not satisfiable (_|_), sentences were not satisfiable
Start: premises + negation of goalStart: premises + negation of goal
End: if reach End: if reach , premises |= goal, premises |= goal
Resolution Theorem ProvingResolution Theorem Proving
Method for searching for proofs automaticallyMethod for searching for proofs automaticallySentences are translated into CNF, and then to Sentences are translated into CNF, and then to sets of clausessets of clausesAt each step, a new clause is derived from two At each step, a new clause is derived from two clauses you already haveclauses you already haveProof steps all use the same ruleProof steps all use the same rule
If reach If reach (_|_), sentences were not satisfiable (_|_), sentences were not satisfiable
Start: premises + negation of goalStart: premises + negation of goal
End: if reach End: if reach , premises |= goal, premises |= goal
Conversion to Clausal FormConversion to Clausal Form
UseUse P P Q Q equivequiv ~P v Q ~P v Q to removeto remove UseUse P P Q Q equivequiv ((~P v Q) ^ (~Q v P)) ((~P v Q) ^ (~Q v P)) to removeto remove
New 1st Step! We hadn’t done conditionals yetNew 1st Step! We hadn’t done conditionals yet
Use Use DeMorgan’s lawsDeMorgan’s laws and and ~Elim~Elim to move to move ~~ as far inward as far inward as possible as possible (gives NNF)(gives NNF)
Use the Use the distributive lawsdistributive laws until the sentence is in until the sentence is in CNFCNF
Clausal FormClausal Form
Given a sentence S written in CNFGiven a sentence S written in CNF S = ( ) S = ( ) ( ) ( ) . . . . . . ( ) ( )
Convert each ( ) into a clause - a set Convert each ( ) into a clause - a set consisting of each of the literals in ( ).consisting of each of the literals in ( ).
Example: Example: S=S= (A) (A) ( (B B C C D) D) ( (AA D) D)Clauses are: Clauses are: {A}, {{A}, { B, C, D}, { B, C, D}, { A, D} A, D}
Resolution Theorem ProvingResolution Theorem Proving
Method for searching for proofs automaticallyMethod for searching for proofs automatically
Sentences are translated into CNF, and then to sets of Sentences are translated into CNF, and then to sets of clausesclauses
At each step, a new clause is derived from two clauses At each step, a new clause is derived from two clauses you already haveyou already have
Proof steps all use the same ruleProof steps all use the same rule
If reach If reach (_|_), sentences were not (_|_), sentences were not satisfiablesatisfiableStart: premises + negation of goalStart: premises + negation of goal
End: if reach End: if reach , premises |= goal, premises |= goal
Satisfying a Set of ClausesSatisfying a Set of Clauses
Assigning truth-values to the atomic Assigning truth-values to the atomic sentences so the CNF sentence the set sentences so the CNF sentence the set corresponds to is true.corresponds to is true.
{{A, {{A, C, D}, {C},{C, D}, {C},{A},{A, D}}A},{A, D}} is satisfied by is satisfied by
A = FalseA = False C = True C = True D = True D = True
Empty ClauseEmpty Clause
{} denoted by {} denoted by . �. �The empty clause is not satisfiableThe empty clause is not satisfiableWe want We want {{A}, {{{A}, { A}} A}} to lead to to lead to {}{} ( ( ��))The basic resolution step involves “canceling” The basic resolution step involves “canceling” pos and neg matching literals from two clausespos and neg matching literals from two clauses
So, we derive So, we derive {}{} ( ( ��) from ) from {{A}, {{{A}, { A}} A}}
Example: not satisfiableExample: not satisfiable
P P Q Q PP
{P, Q} {P}
{Q}
{P, Q} {P} {Q}
Resolution Theorem ProvingResolution Theorem Proving
Method for searching for proofs automaticallyMethod for searching for proofs automatically
Sentences are translated into CNF, and then to Sentences are translated into CNF, and then to sets of clausessets of clauses
At each step, a new clause is derived from two At each step, a new clause is derived from two clauses you already haveclauses you already have
Proof steps all use the same ruleProof steps all use the same ruleIf reach If reach (_|_), sentences were not satisfiable (_|_), sentences were not satisfiable
Start: premises + negation of goalStart: premises + negation of goal
End: if reach End: if reach , premises |= goal, premises |= goal
Resolution StepResolution Step
Res. Step with Larger ClausesRes. Step with Larger Clauses
ResolventResolvent
Clause R is a resolvent of clauses CClause R is a resolvent of clauses C11 and and
CC22 if there is a literal in C if there is a literal in C11 whose negation whose negation
is in Cis in C22 and R consists of all the remaining and R consists of all the remaining
literals in either clause.literals in either clause.
Example:Example: {A,{A, C C , , D} D} andand {B, {B, CC} } havehave
resolventresolvent { {A, B, A, B, DD}}
Resolution Theorem ProvingResolution Theorem Proving
Method for searching for proofs automaticallyMethod for searching for proofs automaticallySentences are translated into CNF, and then to Sentences are translated into CNF, and then to sets of clausessets of clausesAt each step, a new clause is derived from two At each step, a new clause is derived from two clauses you already haveclauses you already haveProof steps all use the same ruleProof steps all use the same rule
If reach If reach (_|_), sentences were not (_|_), sentences were not satisfiablesatisfiableStart: premises + negation of goalStart: premises + negation of goalEnd: if reach End: if reach , premises |= goal, premises |= goal
Resolution TheoremResolution Theorem
For any set of clauses that are For any set of clauses that are not not satisfiablesatisfiable, it is possible to arrive at the , it is possible to arrive at the empty clause by using successive empty clause by using successive resolutions.resolutions.
Resolution Theorem ProvingResolution Theorem Proving
Method for searching for proofs automaticallyMethod for searching for proofs automatically
Sentences are translated into CNF, and then to sets of Sentences are translated into CNF, and then to sets of clausesclauses
At each step, a new clause is derived from two clauses At each step, a new clause is derived from two clauses you already haveyou already have
Proof steps all use the same ruleProof steps all use the same rule
If reach If reach (_|_), sentences were not satisfiable (_|_), sentences were not satisfiable
Start: premises + negation of goalStart: premises + negation of goal
End: if reach End: if reach , premises |= goal, premises |= goal
Using Resolution to Determine Validity of Using Resolution to Determine Validity of ArgumentsArguments
QQ is a logical consequence of is a logical consequence of P1, P2, …, P1, P2, …, Pn Pn iff iff P1 ^ P2 ^ … ^ PnP1 ^ P2 ^ … ^ Pn ^ ~Q^ ~Q is not is not satisfiablesatisfiableFor sentences in clausal form: For sentences in clausal form: Q Q is a logical consequence of a set of is a logical consequence of a set of clauses clauses SS iff iff SS { {Q} Q} is not satisfiable.is not satisfiable.
So, convert premises + negation of goal to So, convert premises + negation of goal to clausal form, and do resolution steps, trying to clausal form, and do resolution steps, trying to reach {} (reach {} () �) �
Is this Argument Valid?Is this Argument Valid?
B v C~C v ~DA v D~B v ~DA
ExampleExample
Show Show A A (B (B C) C) ( (C C D) D) (A (A D) D) ( (B B D)D) is not is not satisfiable.satisfiable.
Clauses: Clauses: {{ A}, {B, C}, { A}, {B, C}, {C, C, D}, {A, D}, {D}, {A, D}, {B, B, D}.D}.
{ {AA} {} {AA,D} {B,,D} {B,CC} {} {CC, , D}D}
{ {DD} {} {BB, , D} {D} {BB, , D}D}
{ {DD}}
��
ExampleExample
Modus PonesModus PonesPPQ Q PPQ or {Q or {P,Q}P,Q}
P P {P}{P}
Q negate to get Q negate to get {{Q}Q}
Apply resolution: Apply resolution: {{PP,Q} {,Q} {PP}}
{ {QQ} {} {QQ}}
What is a Horn sentence?What is a Horn sentence?
A A positive literalpositive literal is any literal that is not is any literal that is not preceded with a preceded with a . . For example, Cube(b) For example, Cube(b) and P are positive literals.and P are positive literals.
A sentence S is a A sentence S is a Horn sentenceHorn sentence if and if and only if it is only if it is in CNFin CNF and every conjunct has and every conjunct has at most one positive literal.at most one positive literal.
ExamplesExamples
(A (A B B C) C) ( (A A B)B)
(A (A B B C) C) (D) (D)
(A (A B) B) ( (C C D)D)
Horn sentence
Not Horn sentence
(A C) (B C) (A D) (B D)
Horn sentence
Alternate Form of Horn Alternate Form of Horn ConjunctConjunct
AA11 AA22...... AAnn B B
(A1 A2 ... An) B
(A1 A2 ... An) B Conditional Formof
Horn sentence
B :- A1, A2, …, An. In Prolog:
Rule
B if A1, A2, …, An
Special CasesSpecial Cases
No positive literalNo positive literalAA11 AA22...... AAnn
No negative literalsNo negative literalsBB
(A1 A2 ... An) False
True BIn Prolog, this
is a fact!
In Prolog, thisis a query!
Why are Horn sentences Why are Horn sentences important?important?
Very efficient algorithms exist for determining if a Very efficient algorithms exist for determining if a set of Horn sentences is satisfiableset of Horn sentences is satisfiable
CNF to PROLOGCNF to PROLOG
A A B B C is C is (A(AC) C) B is (A B is (A C) C)B B
B :- A, C.B :- A, C.A.A.C.C.
Query: :- B.Query: :- B.Answer: Yes.Answer: Yes.
Example Prolog ProgramExample Prolog Program
grandfather(X,Y) :-grandfather(X,Y) :- father(X,Z), father(X,Z), father(Z,Y). father(Z,Y).
grandfather(X,Y) :-grandfather(X,Y) :- father(X,Z), father(X,Z), mother(Z,Y). mother(Z,Y).
mother(ann,bill).mother(ann,bill).father(carl,ed).father(carl,ed).father(nick,ann).father(nick,ann).father(ed,sam).father(ed,sam).
top related