Download presentation

Presentation is loading. Please wait.

Published byRobert Stevenson Modified over 2 years ago

1
Artificial Intelligence 8. The Resolution Method Course V231 Department of Computing Imperial College, London Jeremy Gow

2
Soundness & Completeness Want to prove theorem T from Axioms Ax Chosen a set of inference rules R A B means B is entailed by A A B means B is derived from A using R R should be sound: if A B then A B Want R to be complete: if A B then A B

3
Choose Your Search Space Soundness and completeness of R isnt enough We want a reasonable search space – R determines operators, so influences the space – Can I see where Im going? (Heuristic measure) – Can I restrict options at each state? (Branching) Three main approaches – Forwards chaining: no heuristic guidance – Backwards chaining: large branching (many things entail KB) – Proof by refutation: clear goal (false), forwards inference

4
Proof by Refutation Proof by contradiction, reductio ad absurdum 1. Negate the theorem & add to axioms (¬T,Ax) 2. Use rules of inference to derive the False So sentences (¬T,Ax) cant all be true (unsatisfiable) But the axioms Ax are true Hence the negated theorem ¬T must be false Hence the theorem T must be true

5
The Resolution Method Proof by refutation with a single inference rule – No need to worry about choice of rule – Just how we apply the one rule Resolution is complete for FOL – Refutation-complete [Robinson 1965] If (¬T,Ax) unsatisfiable it will derive a contradiction – So if will prove any true theorem of FOL Even so, it might take a long time (> universe) – Even fairly trivial theorems can take a long time – Can use search heuristics to speed it up (next lecture) – No guarantees if its not a theorem

6
Binary Resolution (Propositional) Unit resolution rule (last lecture) A B, ¬B A Binary resolution rule A B, ¬B C A C The literals B and ¬B are resolved

7
Binary Resolution (First-Order) Binary resolution rule A B, ¬C D Subst(, A D) if substitution s.t. Subst(,B) = Subst(,C) The literals B and ¬C are resolved – B and C have been made the same by

8
Resolution in FOL (This Lecture) What if KB contains non-disjuncts? – Preprocessing step: rewrite to CNF How do we find substitution ? – The unification algorithm But what if more than two disjuncts? – Extend binary resolution to full resolution

9
Conjunctive Normal Form A conjunction of clauses – Each clause is a disjunction of literals – Prop. literal: proposition or negated proposition – FO literal: predicate or negated predicate No quantifiers (all variables implicitly universal) Example FO clause likes(george, X) ¬likes(tony, houseof(george)) ¬is_mad(maggie) Any FO sentence can be rewritten as CNF

10
Converting FOL to CNF (see notes) 1. Eliminate implication/equivalence (rewrite) 2. Move ¬ inwards (rewrite) 3. Rename variables apart (substitution) 4. Move quantifiers outwards (rewrite) 5. Skolemise existential variables (substitution) 6. Distribute over (rewrite) 7. Flatten binary connectives (rewrite) 8. (Optional: Reintroduce implications)

11
Example CNF Conversion Propositional example (B (A C)) (B ¬A) 1. Remove implication: ¬(B (A C)) (B ¬A) 2. Move ¬ inwards (De Morgans x 2): (¬B ¬(A C)) (B ¬A) (¬B (¬A ¬C)) (B ¬A) (Skip 3 to 5 as no variables.)

12
Example CNF Conversion (Contd) (¬B (¬A ¬C)) (B ¬A) 6. Distribute over : (¬B (B ¬A)) ((¬A ¬C) (B ¬A)) 7. Flatten connectives (¬B B ¬A) (¬A ¬C B ¬A) Drop 1st clause (¬B B), remove duplicate from 2nd: ¬A ¬C B

13
Kowalski Normal Form Can reintroduce to CNF, e.g. ¬A ¬C B becomes (A C) B Kowalski form (A 1 … A n ) (B 1 … B n ) Binary resolution… A B, B C A C Resembles Horn clauses (basis for Prolog)

14
Skolemisation Replace V with a something term – If no preceeding U use fresh Skolem constant – Otherwise fresh Skolem function parameterised by all preceeding U X Y (person(X) has(X, Y) heart(Y)) to person(X) has(X, f(X)) heart(f(X)) (The particular heart f(X) depends on person X)

15
Substitutions & Inference Rules Propositional inference rules used in first-order logic But in FOL we can make substitutions – Sometimes a substitution can allow a rule to be applied – cf. FO binary resolution knows(john, X) hates(john, X) knows(john, mary) Substitution + Modus Ponens: infer hates(john, mary) Need to find substitution that makes literals equal – Known as a unifier

16
Unifying Predicates We unified these two predicates: knows(john, X) and knows(john, mary) By saying that X should be substituted by mary – Why? Because john = john and can {X\mary} For knows(jack, mary) and knows(john, X) – john doesnt match jack – So we cannot unify the two predicates – Hence we cannot use the rule of inference

17
Unification Want an algorithm which: – Takes two FOL sentences as input – Outputs a substitution {X/mary, Y/Z, etc.} Which assigns terms to variables in the sentences So that the first sentence looks exactly like the second – Or fails if there is no way to unify the sentences Example: Unify( knows(john, X), knows(john,mary) ) = {X/mary} Unify( knows(john, X), knows(jack,mary) ) = Fail

18
Functions Within the Unify Algorithm isa_variable(x) – checks whether x is a variable isa_list(x) – checks whether x is a list head(x) – outputs the head of a list (first term) e.g., head([a,b,c]) = a tail(x) – outputs the elements other than the head in a list e.g., tail([a,b,c]) = [b,c]

19
More Internal Functions (Compound Expressions) isa_compound(x) – checks whether x is compound expression – (either a predicate, a function or a connective) args(x) – finds the subparts of the compound expression x arguments of a predicate, function or connective – Returns the list of arguments op(x) – predicate name/function name/connective symbol

20
Two Parts of the Unification Algorithm Algorithm is recursive (it calls itself) – Passes around a set of substitutions, called mu – Making sure that new substitutions are consistent with old ones unify(x,y) = unify_internal(x,y,{}) – x and y are either a variable, constant, list, or compound unify_internal(x,y,mu) – x and y are sentences, mu is a set of substitutions – finds substitutions making x look exactly like y unify_variable(var,x,mu) – var is a variable – finds a single substitution (which may be in mu already)

21
unify_internal unify_internal(x,y,mu) Cases 1.if (mu=failure) then return failure 2.if (x=y) then return mu. 3.if (isa_variable(x)) then return unify_variable(x,y,mu) 4.if (isa_variable(y)) then return unify_variable(y,x,mu) 5.if (isa_compound(x) and isa_compound(y)) then return unify_internal(args(x),args(y),unify_internal(op(x),op(y),mu)) 6.if (isa_list(x) and isa_list(y)) then return unify_internal(tail(x),tail(y),unify_internal(head(x),head(y),mu)) 7.return failure

22
unify_variable unify_variable(var,x,mu) Cases 1. if (a substitution var/val is in mu) then return unify_internal(val,x,mu) 2. if (a substitution x/val is in mu) then return unify_internal(var,val,mu) 3. if (var occurs anywhere in x) return failure 4. add var/x to mu and return

23
Notes on the Unification Algorithm unify_internal will not match a constant to a constant, unless they are equal (case 2) Case 5 in unify_internal checks that two compound operators are the same (e.g. same predicate name) Case 6 in unify_internal causes the algorithm to recursivly unify the whole list Cases 1 and 2 in unify_variable check that neither inputs have already been substituted

24
The Occurs Check Suppose we needed to substitute X with f(X,Y) – This would give us f(X,Y) instead of X – But there is still an X in there, so the substitution isnt complete: we need f(f(X,Y),Y), then f(f(f(X,Y),Y),Y) and so on We need to avoid this situation – Otherwise the algorithm wont stop – Case 3 in unify_variable checks this – Known as the occurs check Occurs check slows the algorithm down – Order (n 2 ), where n is size of expressions being unified

25
An Example Unification Suppose we want to unify these sentences: 1. p(X,tony) q(george,X,Z) 2. p(f(tony),tony) q(B,C,maggie) By inspection, this is a good substitution: – {X/f(tony), B/george, C/f(tony), Z/maggie} This makes both sentences become: – p(f(tony),tony) q(george, f(tony), maggie) Note that we want to substitute X for C – But we have substituted f(tony) for X already See the notes for this as a worked example – Using the unification algorithm – Requires five iterations!

26
Binary Resolution (First-Order) Binary resolution rule (using unification) A B, ¬C D Subst(, A D) if Unify(B, C) = Unification algorithm finds Most General Unifier (MGU) – Dont substitute any more than need to

27
The Full Resolution Rule If Unify(P j, ¬Q k ) = (¬ makes them unifiable) P 1 … P m, Q 1 … Q n Subst(, P 1 … (no P j ) … P m Q 1 … (no Q k )... Q n ) P j and Q k are resolved Arbitrary number of disjuncts Relies on preprocessing into CNF

28
Using Full Resolution Sentences already in CNF Pick two clauses – Pick positive literal P from first – Pick negative literal N from second – Find MGU of ¬P and N – Write both clauses as one big disjunction With P and N missing Apply to the new clause

29
Resolution Proof Search Keep on resolving clause pairs – Eventually result in zero-length clause – This indicates that some literal K was true at the same time as the literal ¬K Only way to reduce sentence to be empty – Hence there was an inconsistency – Which proves the theorem Topic of the next lecture

30
Coursework: War of Life Two player version of Game of Life – Implement several strategies in Prolog – Run a tournament On CATE this afternoon Submit via CATE (more to follow…) Deadline: 3 weeks today

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google