Lecture 12 Resolution-Based Inference 7 th February 2020 Previously - - PowerPoint PPT Presentation

lecture 12 resolution based inference
SMART_READER_LITE
LIVE PREVIEW

Lecture 12 Resolution-Based Inference 7 th February 2020 Previously - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

Informatics 2D ⋅ Agents and Reasoning ⋅ 2019/2020

Lecture 12 ⋅ Resolution-Based Inference

Claudia Chirita

School of Informatics, University of Edinburgh

7th February 2020

Based on slides by: Jacques Fleuriot, Michael Rovatsos, Michael Herrmann, Vaishak Belle

slide-2
SLIDE 2

Previously on INF2D

The Hundred-Acre Wood

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)

2 / 34

slide-3
SLIDE 3

Outline

  • Forward chaining
  • Backward chaining
  • Resolution

3 / 34

slide-4
SLIDE 4

Forward chaining algorithm

4 / 34

slide-5
SLIDE 5

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)

5 / 34

slide-6
SLIDE 6

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

slide-7
SLIDE 7

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

slide-8
SLIDE 8

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. May not terminate in general if the query 𝑟 is not entailed. This is unavoidable: entailment with defjnite clauses is semi-decidable.

8 / 34

slide-9
SLIDE 9

Effjciency of forward chaining

Incremental forward chaining: no need to match a rule on iteration 𝑙 if a premise wasn’t added on iteration 𝑙 − 1

⇒ match each rule whose premise contains a newly added

positive literal. Matching itself can be expensive: Database indexing allows 𝑃(1) retrieval of known facts. e.g. query Hunny(𝑦) retrieves Hunny(𝐾) Forward chaining is widely used in deductive databases. Pattern Matching

  • for each 𝜄 s.t. SUBST(𝜄, 𝑞 ∧ … ∧ 𝑞) = SUBST(𝜄, 𝑞

∧ … ∧ 𝑞 )

for some 𝑞

, … , 𝑞 in KB

  • Finding all possible unifjers can be very expensive.

9 / 34

slide-10
SLIDE 10

Effjciency of forward chaining

Example

Hunny(𝑦) ∧ Owns(Eeyore, 𝑦) → Gives(Pooh, 𝑦, Eeyore)

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

slide-11
SLIDE 11

Hard matching example

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)

Every fjnite domain CSP can be expressed as a single defjnite 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

slide-12
SLIDE 12

Backward chaining algorithm

12 / 34

slide-13
SLIDE 13

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)

13 / 34

slide-14
SLIDE 14

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

slide-15
SLIDE 15

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

slide-16
SLIDE 16

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

slide-17
SLIDE 17

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

slide-18
SLIDE 18

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

slide-19
SLIDE 19

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

slide-20
SLIDE 20

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) Widely used in logic programming languages.

20 / 34

slide-21
SLIDE 21

Logic programming

“What’s past is Prolog.” The Tempest, Act II, scene i

21 / 34

slide-22
SLIDE 22

Resolution

A method for telling whether a propositional formula is satisfjable and for proving that a fjrst-order formula is unsatisfjable. Yields a complete inference algorithm. If a set of clauses if unsatisfjable, then the resolution closure

  • f those clauses contains the empty clause (propositional logic).

22 / 34

slide-23
SLIDE 23

Ground Binary Resolution

𝐷 ∨ 𝑄 𝐸 ∨ ¬𝑄 𝐷 ∨ 𝐸

Soundness

𝐷 ∨ 𝑄 ifg ¬𝐷 → 𝑄 𝐸 ∨ ¬𝑄 ifg 𝑄 → 𝐸

Therefore, ¬𝐷 → 𝐸, which is equivalent to 𝐷 ∨ 𝐸. Note: if both 𝐷 and 𝐸 are empty, then resolution deduces the empty clause, i.e. false.

23 / 34

slide-24
SLIDE 24

Non-Ground Binary Resolution

𝐷 ∨ 𝑄 𝐸 ∨ ¬𝑄 (𝐷 ∨ 𝐸) 𝜄

where 𝜄 is the mgu of 𝑄 and 𝑄. The two clauses are assumed to be standardized apart so that they share no variables. Soundness Apply 𝜄 to premises, then appeal to ground binary resolution.

𝐷𝜄 ∨ 𝑄𝜄 𝐸𝜄 ∨ ¬𝑄𝜄 𝐷𝜄 ∨ 𝐸𝜄

24 / 34

slide-25
SLIDE 25

Example

¬HasHunny(𝑦) ∨ Happy(𝑦) HasHunny(Pooh) Happy(Pooh)

with 𝜄 = {𝑦/Pooh}

25 / 34

slide-26
SLIDE 26

Factoring

𝐷 ∨ 𝑄 ∨ … ∨ 𝑄 (𝐷 ∨ 𝑄) 𝜄

where 𝜄 is the mgu of the 𝑄. Soundness – by universal instantiation and deletion of duplicates.

26 / 34

slide-27
SLIDE 27

Full Resolution

𝐷 ∨ 𝑄 ∨ … ∨ 𝑄 𝐸 ∨ ¬𝑄

∨ … ∨ ¬𝑄

  • (𝐷 ∨ 𝐸) 𝜄

where 𝜄 is the mgu of all 𝑄 and 𝑄

.

Soundness – by combination of factoring and binary resolution. To prove 𝛽, apply resolution steps to CNF(KB ∧ ¬𝛽). Complete for FOL, if using full resolution or binary resolution + factoring.

27 / 34

slide-28
SLIDE 28

Conversion to CNF ⋅ Example

Everyone who loves all animals is loved by someone.

∀𝑦.[∀𝑧.Animal(𝑧) → Loves(𝑦, 𝑧)] → [∃𝑧.Loves(𝑧, 𝑦)]

  • Eliminate all implications and biconditionals.

∀𝑦.¬[∀𝑧.¬Animal(𝑧) ∨ Loves(𝑦, 𝑧)] ∨ [∃𝑧.Loves(𝑧, 𝑦)]

  • Move ¬ inwards, using ¬∀𝑦.𝜒 ≡ ∃𝑦.¬𝜒, ¬∃𝑦.𝜒 ≡ ∀𝑦.¬𝜒.

∀𝑦.[∃𝑧.¬(¬Animal(𝑧) ∨ Loves(𝑦, 𝑧))] ∨ [∃𝑧.Loves(𝑧, 𝑦)] ∀𝑦.[∃𝑧.¬¬Animal(𝑧) ∧ ¬Loves(𝑦, 𝑧)] ∨ [∃𝑧.Loves(𝑧, 𝑦)] ∀𝑦.[∃𝑧.Animal(𝑧) ∧ ¬Loves(𝑦, 𝑧)] ∨ [∃𝑧.Loves(𝑧, 𝑦)]

28 / 34

slide-29
SLIDE 29

Conversion to CNF ⋅ Example

  • Standardize variables: each quantifjer should use a

difgerent one.

∀𝑦.[∃𝑧.Animal(𝑧) ∧ ¬Loves(𝑦, 𝑧)] ∨ [∃𝑨.Loves(𝑨, 𝑦)]

  • Skolemize: a more general form of existential
  • instantiation. Each existential variable is replaced by a

Skolem function of the enclosing universally quantifjed variables.)

∀𝑦.[Animal(𝐺(𝑦)) ∧ ¬Loves(𝑦, 𝐺(𝑦))] ∨ Loves(𝐻(𝑦), 𝑦)

)No enclosing universal quantifjer? Just replace with Skolem constant.

29 / 34

slide-30
SLIDE 30

Conversion to CNF ⋅ Example

  • Drop universal quantifjers.

[Animal(𝐺(𝑦)) ∧ ¬Loves(𝑦, 𝐺(𝑦))] ∨ Loves(𝐻(𝑦), 𝑦)

  • Distribute ∨ over ∧.

[Animal(𝐺(𝑦)) ∨ Loves(𝐻(𝑦), 𝑦)] ∧ [¬Loves(𝑦, 𝐺(𝑦)) ∨ Loves(𝐻(𝑦), 𝑦)]

30 / 34

slide-31
SLIDE 31

Resolution algorithm

31 / 34

slide-32
SLIDE 32

Example ⋅ Winnie-the-Pooh CNF

¬VeryFondOfFood(𝑦) ∨ ¬Treat(𝑧) ∨ ¬Friend(𝑨) ∨ ¬Gives(𝑦, 𝑧, 𝑨) ∨ Generous(𝑦) Hunny(J) Owns(Eeyore, J) ¬Hunny(𝑦) ∨ ¬Owns(Eeyore, 𝑦) ∨ Gives(Pooh, 𝑦, Eeyore) ¬Hunny(𝑦) ∨ Treat(𝑦) ¬Resident(𝑦, HundredAcreWood) ∨ Friend(𝑦) Resident(Eeyore, HundredAcreWood) VeryFondOfFood(Pooh)

32 / 34

slide-33
SLIDE 33

Example ⋅ Resolution proof

33 / 34

slide-34
SLIDE 34

Summary

  • Forward chaining
  • Backward chaining
  • Resolution

34 / 34