Claudia Chirita School of Informatics, University of Edinburgh Based on slides by: Jacques Fleuriot, Michael Rovatsos, Michael Herrmann, Vaishak Belle Informatics 2D ⋅ Agents and Reasoning ⋅ 2019/2020 Lecture 12 ⋅ Resolution-Based Inference 7 th February 2020
Previously on INF2D The Hundred-Acre Wood 2 / 34 VeryFondOfFood (𝑦)∧ Treat (𝑧)∧ Friend (𝑨)∧ Gives (𝑦, 𝑧, 𝑨) → Generous (𝑦) ∃𝑦. Owns ( Eeyore , 𝑦) ∧ Hunny (𝑦) Owns ( Eeyore , J ) ∧ Hunny ( J ) Hunny (𝑦) ∧ Owns ( Eeyore , 𝑦) → Gives ( Pooh , 𝑦, Eeyore ) Hunny (𝑦) → Treat (𝑦) Resident (𝑦, HundredAcreWood ) → Friend (𝑦) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
Outline 3 / 34 • Forward chaining • Backward chaining • Resolution
Forward chaining algorithm 4 / 34
5 / 34 Example ⋅ Forward chaining proof VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) ∧ Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
6 / 34 Example ⋅ Forward chaining proof VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) ∧ Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
7 / 34 Example ⋅ Forward chaining proof VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) ∧ Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
Properties of forward chaining FC is sound and complete for fjrst-order defjnite clauses (exactly one positive literal). Datalog = fjrst-order defjnite clauses + no functions. FC terminates for Datalog in a fjnite number of iterations. This is unavoidable: entailment with defjnite clauses is semi-decidable. 8 / 34 May not terminate in general if the query 𝑟 is not entailed.
Effjciency of forward chaining Matching itself can be expensive: Incremental forward chaining: no need to match a rule on Forward chaining is widely used in deductive databases. Pattern Matching 9 / 34 positive literal. iteration 𝑙 if a premise wasn’t added on iteration 𝑙 − 1 ⇒ match each rule whose premise contains a newly added Database indexing allows 𝑃(1) retrieval of known facts. e.g. query Hunny (𝑦) retrieves Hunny (𝐾) • for each 𝜄 s.t. SUBST (𝜄, 𝑞 � ∧ … ∧ 𝑞 � ) = SUBST (𝜄, 𝑞 � � ∧ … ∧ 𝑞 � � ) for some 𝑞 � � , … , 𝑞 � � in KB • Finding all possible unifjers can be very expensive.
Effjciency of forward chaining Example Can fjnd each object owned by Eeyore in constant time and then check if it is a jar of hunny. But what if Eeyore owns many objects but very few jars? Conjunct Ordering: Better (cost-wise) to fjnd all jars of hunny fjrst and then check whether they are owned by Eeyore. Optimal ordering is NP-hard. Heuristics available: MRV from CSP if each conjunct is viewed as a constraint on its variables. 10 / 34 Hunny (𝑦) ∧ Owns ( Eeyore , 𝑦) → Gives ( Pooh , 𝑦, Eeyore )
Every fjnite domain CSP can be expressed as a single defjnite Hard matching example clause + ground facts. Colourable is inferred ifg the CSP has a solution. CSPs include 3SAT as a special case, hence matching is NP-hard. 11 / 34 Diff ( WA , NT ) ∧ Diff ( WA , SA ) ∧ Diff ( NT , Q )∧ Diff ( NT , SA ) ∧ Diff ( Q , NSW ) ∧ Diff ( Q , SA )∧ Diff ( NSW , V ) ∧ Diff ( NSW , SA )∧ Diff ( V , SA ) → Colourable Diff ( Red , Blue ) , Diff ( Red , Black ) Diff ( Black , Red ) , Diff ( Black , Blue ) Diff ( Blue , Red ) , Diff ( Blue , Black )
Backward chaining algorithm 12 / 34
13 / 34 Example ⋅ Backward chaining VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) and Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
14 / 34 Example ⋅ Backward chaining VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) and Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
15 / 34 Example ⋅ Backward chaining VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) and Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
16 / 34 Example ⋅ Backward chaining VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) and Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
17 / 34 Example ⋅ Backward chaining VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) and Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
18 / 34 Example ⋅ Backward chaining VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) and Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
19 / 34 Example ⋅ Backward chaining VeryFondOfFood (�) ∧ Treat (�) ∧ Friend (�) ∧ Gives (�, �, �) → Generous (�) Owns ( Eeyore , J ) and Hunny ( J ) Hunny (�) ∧ Owns ( Eeyore , �) → Gives ( Pooh , �, Eeyore ) Hunny (�) → Treat (�) Resident (�, HundredAcreWood ) → Friend (�) Resident ( Eeyore , HundredAcreWood ) VeryFondOfFood ( Pooh )
Properties of backward chaining Depth-fjrst recursive proof search: space is linear in size of proof. Incomplete due to infjnite loops. – partial fjx by checking current goal against every goal on stack Ineffjcient due to repeated subgoals (both success and failure). – fjx using caching of previous results (extra space) 20 / 34 Widely used in logic programming languages.
Logic programming “What’s past is Prolog.” The Tempest , Act II, scene i 21 / 34
Resolution A method for telling whether a propositional formula is satisfjable and for proving that a fjrst-order formula is unsatisfjable. If a set of clauses if unsatisfjable, then the resolution closure of those clauses contains the empty clause (propositional logic). 22 / 34 Yields a complete inference algorithm.
Ground Binary Resolution Soundness empty clause, i.e. false . 23 / 34 𝐷 ∨ 𝑄 𝐸 ∨ ¬𝑄 𝐷 ∨ 𝐸 𝐷 ∨ 𝑄 ifg ¬𝐷 → 𝑄 𝐸 ∨ ¬𝑄 ifg 𝑄 → 𝐸 Therefore, ¬𝐷 → 𝐸 , which is equivalent to 𝐷 ∨ 𝐸 . Note: if both 𝐷 and 𝐸 are empty, then resolution deduces the
that they share no variables. Non-Ground Binary Resolution Soundness 24 / 34 𝐸 ∨ ¬𝑄 � 𝐷 ∨ 𝑄 (𝐷 ∨ 𝐸) 𝜄 where 𝜄 is the mgu of 𝑄 and 𝑄 � . The two clauses are assumed to be standardized apart so Apply 𝜄 to premises, then appeal to ground binary resolution. 𝐷𝜄 ∨ 𝑄𝜄 𝐸𝜄 ∨ ¬𝑄𝜄 𝐷𝜄 ∨ 𝐸𝜄
Example 25 / 34 ¬ HasHunny (𝑦) ∨ Happy (𝑦) HasHunny ( Pooh ) Happy ( Pooh ) with 𝜄 = {𝑦/ Pooh }
Factoring Soundness – by universal instantiation and deletion of duplicates. 26 / 34 𝐷 ∨ 𝑄 � ∨ … ∨ 𝑄 � (𝐷 ∨ 𝑄 � ) 𝜄 where 𝜄 is the mgu of the 𝑄 � .
Soundness Full Resolution – by combination of factoring and binary resolution. Complete for FOL, if using full resolution or binary resolution + factoring. 27 / 34 𝐸 ∨ ¬𝑄 � � ∨ … ∨ ¬𝑄 � 𝐷 ∨ 𝑄 � ∨ … ∨ 𝑄 � � (𝐷 ∨ 𝐸) 𝜄 where 𝜄 is the mgu of all 𝑄 � and 𝑄 � � . To prove 𝛽 , apply resolution steps to CNF ( KB ∧ ¬𝛽) .
Recommend
More recommend