School of Informatics, University of Edinburgh 13/02/18 Slide Credits: Jacques Fleuriot, Michael Rovatsos, Michael Herrmann
Last lecture: Forward and backward chaining Backward chaining: If Goal is known (goal directed) Can query for data Forward chaining: If specific Goal is not known, but system needs to react to new facts (data driven) Can make suggestions Also relevant: Combination of forward and backward chaining: Opportunistic reasoning What do users expect from the system? Which direction has the larger branching factor?
Limitations (due to restriction to definite clauses) In order to apply GMP: Premises of all rules contain only non-negated symbols Conclusions of all rules is a non-negated symbol Facts are non-negated propositions Possible solution: Introduce more variables, e.g. Q := P What about: If we cannot prove A, then A is true? (works only if there is a rule for each variable)
Last lecture: Resolution Negate query α Convert everything to CNF Repeat: Choose clauses and resolve (based on unification) If resolution results in empty clause, α is proved Return all substitutions (or Fail)
Mid-lecture question Is the following sentence unsatisfiable? P (x, t), P (s, x) with x: variable, s t: constants
Answer Is the following set of clauses unsatisfiable? P (x, t), P (s, x) Not necessarily, if this was a propositionalisation of x. (P (x, t) P (s, x)) It is unsatisfiable, if this was a propositionalisation of ( x. P (x, t)), ( x. P (s, x)) Here we can standardise-away the clash of the variablex (which we should have done in the first place!) and obtain a contradiction by instantiation.
Binary Resolution and Modus Ponens Ground binary resolution Suppose C = False C P D P C D P P D D i.e. P and P D entails D. Modus ponens is a special case of binary resolution.
Full Resolution and Generalised Modus Ponens GMP with p i θ p iθ i p 1,..., p n (p 1 p n q) qθ p 1,..., p n q p 1 p n qθ Full resolution with θ MGU of all P i and P i θ P iθ i C P 1... P m D P 1... P n (C D) θ
Resolution in Implication Form Ground binary resolution Set C = A C P D P C D A P P D A D
Example: Quacks and Doctors Some patients like all doctors F 1 x. P (x) y. D (y) Likes (x, y) No patient likes any quack F 2 x. P (x) y. Q (y) Likes (x, y) Show: No doctor is a quack F x. D (x) Q (x)
Example: Quacks and Doctors CNF F 1 x. P (x) y. D (y) Likes (x, y) x. P (x) y. D (y) Likes (x, y) F 2 x. P (x) y. Q (y) Likes (x, y) x. P (x) y. Q (y) Likes (x, y) F x. D (x) Q (x) x. D (x) Q (x)
Example: Quacks and Doctors Propositionalisation F 1 x. P (x) y. D (y) Likes (x, y) P (G) ( D (y) Likes (G, y)) F 2 x. P (x) y. Q (y) Likes (x, y) P (w) Q (z) Likes (w, z) F x. D (x) Q (x) D (x) Q (x)
Example: Quacks and Doctors Unification F 1 P (G) D (y) Likes (G, y) F 2 P (w) Q (z) Likes (w, z) w/g P (G) Q (z) Likes (G, z) Negation of proof goal ( D (x) Q (x)) D (x) Q (x)
Example: Quacks and Doctors Resolution P (G) D (y) Likes (G, y), P (G) Q (z) Likes (G, z), D (x) Q (x) Clauses: P (G), D (y), Q (z), D (y) Likes (G, y), Q (z) Likes (G, z) D (y) Likes (G, z) Q (z) Likes (G, z) D (y) Q (z) Substitute y/x and z/x D (x) Q (x) D (x) Q (x) and Q (x) Q (x) Therefore: D (x) Q (x), i.e. D (x) Q (x) for any x such that x. D (x) Q (x)
Example: Quacks and Doctors (Variant) Some patients like all doctors F 1 x. P (x) y. D (y) Likes (x, y) No patient likes any quack F 2 x. P (x) y. Q (y) Likes (x, y) Show: No doctor is a quack F x. D (x) Q (x)
Example: Quacks and Doctors (Variant) CNF F 1 x. P (x) y. D (y) Likes (x, y) x. P (x) y. D (y) Likes (x, y) F 2 x. P (x) y. Q (y) Likes (x, y) x. P (x) y. Q (y) Likes (x, y) F x. D (x) Q (x) x. D (x) Q (x)
Example: Quacks and Doctors (Variant) Propositionalisation F 1 x. P (x) y. D (y) Likes (x, y) P (G) ( D (y) Likes (G, y)) F 2 x. P (x) y. Q (y) Likes (x, y) P (w) Q (z) Likes (w, z) F x. D (x) Q (x) D (x) Q (x)
Example: Quacks and Doctors (Variant) Unification F 1 P (G) D (y) Likes (G, y) F 2 P (w) Q (z) Likes (w, z) w/g P (G) Q (z) Likes (G, z) Negation of proof goal ( D (x) Q (x)) D (x) Q (x)
Example: Quacks and Doctors (Variant) Resolution P (G) D (y) Likes (G, y), P (G) Q (z) Likes (G, z), D (x) Q (x) Clauses: P (G), D (y), Q (z), D (y) Likes (G, y), P (G) Q (z) Likes (G, z) P (G) P (G) Q (z) Likes (G, z) Q (z) Likes (G, z) D (y) Likes (G, z) Q (z) Likes (G, z) D (y) Q (z) Substitute y/x and z/x D (x) Q (x) D (x) Q (x) and Q (x) Q (x) Therefore: D (x) Q (x), i.e. D (x) Q (x) for any x such that x. D (x) Q (x)
Resolution: Soundness and completeness Resolution is sound and complete: If a set of clauses is unsatisfiable, then one can derive an empty clause from this set. Soundness is evident since the conclusion of any inference rule is a logical consequence of its premises. Completeness can be proved using completeness of propositional resolution and lifting (see the following slides, but full proof is beyond the scope of this course).
Reminder: Factoring More generally where θ is the MGU of the P i A B A B A A C P 1... P m (C P 1 ) θ Soundness: by universal instantiation and deletion of duplicates.
Resolvent Let C 1 and C 2 be two clauses. A resolvent is a binary resolvent of C 1 and C 2 binary resolvent of a factor of C 1 and C 2 binary resolvent of C 1 and a factor of C 2 binary resolvent of a factor of C 1 and a factor of C 2
Factoring example C 1 = P (x) P (f (y)) R (g (y)) C 2 = P (f (g (a))) Q (b) C 1 = P (f (y)) R (g (y)) is a factor of C 1 C = R (g (g (a))) Q (b) is a resolvent of C 1and C 2 and thus a resolvent of C 1 and C 2. Choose θ = {x/f (y), y/g (a)}
The lifting lemma If C 1 and C 2 are two clauses with no shared variables and C 1 and C 2 their respective instances and C is a resolvent of C 1 and C 2, then there exists a clause C such that both C is a resolvent of C 1 and C 2 and C is and instance of C. C 1, C 2 C 1 C 2 C C Instantiation C 1, C 2 Lifting C 1 C 2 C Instantiation C
Lifting lemma: Example Clauses C 1 = P (x) Q (x) C 2 = P (f (y)) R (y) Resolving C 1 and C 2 gives C = Q (f (y)) R (y) Instances: C 1 C 2 = P (f (a)) Q (f (a)) using x/f (a) = P (f (a)) R (a) using y/a Resolving C 1 and C 2 gives C = Q (f (a)) R (a) C is an instance of C as predicted by the Lifting Lemma!
Remark: Resolution for 3SAT (X i X j X k ) (X j X r X s ) ( X k X l X m ) }{{} M clauses with i, j, k, r, s, l, m, {1,..., N} Assuming X i = 0: First two clauses: X i X i X j X k X j X k (we can t really use the (negated) goal at this stage) X j X k X j X r X s X k X r X s More assumptions? More symbols per clause?
Efficient algorithms for resolution Heuristics to make resolution more efficient (compare DPLL!) Unit preference: Prefer clauses with only one symbol Pure clauses: Pure clauses contains symbol A which does not occur in any other clause: Cannot lead to contradiction. Tautology: Clauses containing A and A Set of support: Identify useful rules and ignore the rest. Input resolution: Intermediately generated sentences can only be combined with original inputs or original rules. Subsumption: If a clause contains another one, use only the shorter clause. Prune unnecessary facts from the database. Including heuristics, resolution is more efficient than DPLL.
Summary Forward chaining Backward chaining Resolution