Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial...

32
Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow

Transcript of Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial...

Page 1: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Artificial Intelligence 9. Resolution Theorem Proving

Course V231

Department of Computing

Imperial College

Jeremy Gow

Page 2: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

The Full Resolution Rule

If Unify(Pj, ¬Qk) = (¬ makes them unifiable)

P1 … Pm, Q1 … Qn

Subst(, P1 … (no Pj) … Pm Q1 … (no Qk) ... Qn)

Pj and Qk are resolved Arbitrary number of disjuncts Relies on preprocessing into CNF

Page 3: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

A More Concise Version

E.g. for A = {1, 2, 7} first clause is L1 L2 L7

Page 4: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Resolution Proving

Knowledge base of clauses– Start with the axioms and negation of theorem in CNF

Resolve pairs of clauses– Using single rule of inference (full resolution)– Resolved sentence contains fewer literals

Proof ends with the empty clause– Signifies a contradiction– Must mean the negated theorem is false

(Because the axioms are consistent)

– Therefore the original theorem was true

Page 5: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Empty Clause means False

Resolution theorem proving ends– When the resolved clause has no literals (empty)

This can only be because:– Two unit clauses were resolved

One was the negation of the other (after substitution)

– Example: q(X) and ¬q(X) or: p(X) and ¬p(bob)

Hence if we see the empty clause– This was because there was an inconsistency– Hence the proof by refutation

Page 6: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Resolution as Search

Initial State: Knowledge base (KB) of axioms and negated theorem in CNF

Operators: Resolution rule picks 2 clauses and adds new clause

Goal Test: Does KB contain the empty clause?

Search space of KB states We want proof (path) or just checking (artefact)

Page 7: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Aristotle’s Example (Again)

Socrates is a man and all men are mortal Therefore Socrates is mortal

Initial state1) is_man(socrates)

2) is_man(X) is_mortal(X)

3) ¬is_mortal(socrates) (negation of theorem)

Resolving (1) & (2) gives new state(1)-(3) & 4) is_mortal(socrates)

Page 8: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Aristotle’s Example: Search Space

1) is_man(socrates)2) is_man(X) is_mortal(X)3) ¬is_mortal(socrates) 4) is_mortal(socrates)

1) is_man(socrates)2) ¬is_man(X) is_mortal(X)3) ¬is_mortal(socrates) 4) ¬is_man(socrates)

1) is_man(socrates)2) is_man(X) is_mortal(X)3) ¬is_mortal(socrates)

1) is_man(socrates)2) is_man(X) is_mortal(X)3) ¬is_mortal(socrates) 4) is_mortal(socrates)5) False

1) is_man(socrates)2) is_man(X) is_mortal(X)3) ¬is_mortal(socrates) 4) ¬is_man(socrates)5) False

Page 9: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Resolution Proof Tree (Proof 1)

Page 10: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Resolution Proof Tree (Proof 2)

Page 11: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Reading Proof Tree 2

You said that all men were mortal. That means that for all things X, either X is not a man, or X is mortal [CNF step]. If we assume that Socrates is not mortal, then, given your previous statement, this means Socrates is not a man [first resolution step]. But you said that Socrates is a man, which means that our assumption was false [second resolution step], so Socrates must be mortal.

Page 12: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Russell & Norvig Example

Page 13: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Reminder: Kowalski NF

Can reintroduce to CNF, e.g.¬A ¬C B becomes (A C) B

Kowalski normal form

(A1 … An) (B1 … Bn) Resolve in KNF using ‘KNF style’ rules

– e.g. Binary resolution…

AB, BCAC

Page 14: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

R&N Example: Kowalski NF

Page 15: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

R&N Example: Proof Tree

Page 16: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

R&N Example: Prover9 Input

Page 17: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

R&N Example: Prover9 Proof

Page 18: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Equality Axioms

is_pres(obama) and is_pres(b_obama)– will not unify (syntactically different)

unification algorithm does not allow this

– Even if we add to the knowledge base: obama = b_obama

Solution: add equality axioms to KB– X=X, X=YY=X, etc.– Special axiom for every predicate/function:

X = Y P(X) = P(Y)

Page 19: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Equality & Demodulation

Alternative solution: rewrite with equalities Demodulation inference rule

X=Y, A[S]

Subst(, A[Y])

– Two input clauses (one an equality X=Y)– Unify X with a subterm S of other– Apply unifier to clause with subterm Y (not S)– Also works unifying with Y and putting in X

Unify(X, S) =

Page 20: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Heuristic Strategies

Pure resolution search tends to be slow For interesting problems

– Many clauses in the initial knowledge base– Each step adds a new clause (which can be used)– Num. of possible resolution combinations explodes

Selection Heuristics– Intelligently choose which pair to resolve

Pruning Heuristics– Forbid certain pairs

Page 21: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Unit Preference Strategy

Prefer to resolve unit clauses– Contain only a single literal– Selection heuristic

Searching for smallest (empty) clause– Resolving with the unit clauses keeps small

Very effective early on for simple problems– Doesn’t reduce branching rate for medium problems

Page 22: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Set of Support Strategy

Distinguished subset of KB clauses– Set of support (SOS) clauses– Every step must involve SOS (pruning heuristic)

Must be careful not to lose completeness

Example SOS strategy:– Initial SOS is negated theorem– Add new clauses to SOS– Hence False will be deduced (strategy is complete)

Many provers use SOS, e.g. Prover9

Page 23: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Input Resolution Strategy

Special case of SOS strategy– SOS = clauses in the initial knowledge base

Clearly reduces search space– Every resolution must involve an original clause– So number of possible resolutions grows slowly

Not complete for first order logic But complete for Horn-clauses, e.g. Prolog

Page 24: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Subsumption

Clause C subsumes clause D– if C is more ‘general’ (D is more specific)

Naive check for subsumption– Select C2, a subset of literals of C– Find Unify(C2, D) = does not add anything to D (only renames vars)

Example:– p(george) q(X) subsumed by p(A) q(B) r(C)∨ ∨ ∨– Substitution: {A/george, X/B}– Second clause is more general

Page 25: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Subsumption Strategy

Check each new clause is not subsumed by KB Complete strategy

– Specific clauses can be inferred from general ones– So we can throw specific clauses away– Reduced search space still contains False

Can be inefficient– expense must be outweighed by the reduction in the

search space

Page 26: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Applications: Axioms for Algebras

Bill McCune and Larry Wos– Argonne National Laboratories– FO resolution provers: EQP, Otter, Prover9

Robbins Problem (axioms of Boolean algebras)– Stated 60+ years ago, mathematicians failed– 1996: EQP solved in 8 days in 1996 (+human work)

General application to algebraic axiomatisations– Generate possible axioms for algebras– Prove new axioms equivalent to old

Page 27: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Applications: Theory Formation

Simon’s HR system: Automated Theory Formation– Used in mathematical (and bioinformatics) domains

Theories = concepts, examples, conjectures, proofs HR uses Otter to prove conjectures it makes Effective in algebraic domains

– See notes for anti-associative algebra results Otter not so effective in number theory

– Used as a ‘triviality’ filter (discard theorems it can prove)– Example conjectures made by HR (and proved by Simon):

Sum of divisors is prime → number of divisors is prime Sum of divisors of a square is an odd number Perfect numbers are pernicious [and many more…..]

Page 28: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Inductive Theorem Proving

Deduction by mathematical induction

Induction over many different structures Allows reasoning about recursion/iteration

– Useful for hardware/software verification Don’t confuse inductive learning (next lecture)

Page 29: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Interactive Theorem Proving

Necessary to interact with humans in order to prove theorems of any difficulty

Mathematician’s assistant– Let a theorem prover do simple tasks while you

develop a theory (e.g., Buchberger’s Theorema)

Guided theorem prover– User follows and guides computer proof attempt– Needs visualisation tools for proof trees

Page 30: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Higher Order Theorem Proving

Deduction in higher order logics– See lecture 4– Allows more natural and succinct statements– Logics much less well-behaved

HOL theorem prover – Larry Paulson’s group in Cambridge– Has been used for verification tasks

E.g. verification of crytographic protocols

– Uses induction and interactive control

Page 31: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Proof Planning

Initially Alan Bundy’s group in Edinburgh Human proofs often follow a similar structure

– Express this as a outline plan– Methods represent a patterns of deduction

Outline plan guides proof search– Results in specific plan for theorem– Critics deal with common problems

Particularly useful for inductive theorems– Proof of base case and step case follow pattern

Page 32: Artificial Intelligence 9. Resolution Theorem Proving Course V231 Department of Computing Imperial College Jeremy Gow.

Databases & Competitions

TPTP library (Sutcliffe & Suttner)– Thousands of Problems for Theorem Provers– Benchmarks for first order provers– HR is only non-human to add to this library

Annual CASC competition (Sutcliffe et al.)– Which is fastest/most accurate FO prover on planet? – Uses blind selection from the TPTP library– 2002-08 champion: Vampire (Voronkov & Riazonov)