Modus Ponens Claudia Chirita School of Informatics, University of - - PowerPoint PPT Presentation

modus ponens
SMART_READER_LITE
LIVE PREVIEW

Modus Ponens Claudia Chirita School of Informatics, University of - - PowerPoint PPT Presentation

Modus Ponens 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 11 Unifjcation


slide-1
SLIDE 1

Informatics 2D ⋅ Agents and Reasoning ⋅ 2019/2020

Lecture 11 ⋅ Unifjcation and Generalised Modus Ponens

Claudia Chirita

School of Informatics, University of Edinburgh

6th February 2020

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

slide-2
SLIDE 2

Outline

  • Reducing fjrst-order inference to propositional inference
  • Unifjcation
  • Generalized Modus Ponens

2 / 26

slide-3
SLIDE 3

Substitutions

Let (𝐺, 𝑄) be a FOL signature and 𝑌, 𝑍 sets of variables. A substitution of variables from 𝑌 with terms over 𝑍 is a function 𝜄∶ 𝑌 → 𝑈(𝑍). A substitution 𝜄 can be extended to

𝜄∶ 𝑈(𝑌) → 𝑈(𝑍):

  • 𝜄(𝜏(𝑢, … , 𝑢) = 𝜏(

𝜄(𝑢), … , 𝜄(𝑢))

for 𝜏 ∈ 𝐺, 𝑢, … , 𝑢 ∈ 𝑈(𝑌). In particular,

𝜄(𝜏) = 𝜏 for 𝜏 ∈ 𝐺. {𝑦/𝑢, … , 𝑦/𝑢} is a notation for 𝜄∶ 𝑌 → 𝑈(𝑍) where

  • 𝑍 is the set of all variables occuring in the terms 𝑢
  • 𝜄(𝑦) = 𝑢, for 𝑗 = 1, … , 𝑜, and 𝜄(𝑦) = 𝑦 for 𝑦 ≠ 𝑦

3 / 26

slide-4
SLIDE 4

Substitutions

Let (𝐺, 𝑄) be a FOL signature and 𝑌, 𝑍, 𝑎 sets of variables. Applying substitutions to sentences We denote by 𝜒 𝜄 the result of applying the substitution

𝜄∶ 𝑌 → 𝑈(𝑍) to the sentence 𝜒: 𝜒 𝜄 = ⎧ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎩ 𝜌( 𝜄(𝑢), … , 𝜄(𝑢))

for 𝜒 = 𝜌(𝑢, … , 𝑢)

  • 𝜄(𝑢) =

𝜄(𝑢)

for 𝜒 = (𝑢 = 𝑢)

¬(𝜒 𝜄)

for 𝜒 = ¬𝜒

(𝜒 𝜄) ∧ (𝜒 𝜄)

for 𝜒 = 𝜒 ∧ 𝜒

… ∀𝑎.(𝜒 𝜄)

for 𝜒 = ∀𝑎.𝜒

4 / 26

slide-5
SLIDE 5

Substitutions ⋅ Composition

Let (𝐺, 𝑄) be a FOL signature and 𝑌, 𝑍, 𝑎 sets of variables. Composing substitutions 𝜄∶ 𝑌 → 𝑈(𝑍) and 𝜀∶ 𝑍 → 𝑈(𝑎):

𝜄 ; 𝜀∶ 𝑌 → 𝑈(𝑎), with (𝜄 ; 𝜀)(𝑦) = (𝜄 ; 𝜀)(𝑦).

The composition of substitutions is associative. The composition of substitutions is not commutative, sometimes not even well defjned.

5 / 26

slide-6
SLIDE 6

Universal instantiation

Every instantiation of a universally quantifjed sentence 𝜒 is entailed by it:

∀𝑦.𝜒 𝜒{𝑦/𝑢}

for any variable 𝑦 and ground term 𝑢 (without variables). Example

∀𝑦.King(𝑦) ∧ Greedy(𝑦) → Evil(𝑦)

King(John) ∧ Greedy(John) → Evil(John) King(Richard) ∧ Greedy(Richard) → Evil(Richard) King(Father(John)) ∧ Greedy(Father(John)) → Evil(Father(John))

6 / 26

slide-7
SLIDE 7

Existential instantiation

For any sentence 𝜒, variable 𝑦, and some constant 𝜏 that does not appear elsewhere in the knowledge base:

∃𝑦.𝜒 𝜒{𝑦/𝜏}

Example

∃𝑦.Crown(𝑦) ∧ OnHead(𝑦, John) yields Crown(𝐷) ∧ OnHead(𝐷, John)

with 𝐷 a new constant symbol, called a Skolem constant.

7 / 26

slide-8
SLIDE 8

Reduction to propositional inference

Consider a KB containing just the following:

∀𝑦.King(𝑦) ∧ Greedy(𝑦) → Evil(𝑦) King(John), Greedy(John), Brother(Richard, John)

Instantiating the universal sentence in all possible ways (using substitutions {𝑦/John} and {𝑦/Richard}) we obtain:

King(John) ∧ Greedy(John) → Evil(John) King(Richard) ∧ Greedy(Richard) → Evil(Richard)

The universal sentence can then be discarded. The new KB is essentially propositional if we view the atomic sentences King(John), Greedy(John), Evil(John), King(Richard),… as propositional symbols.

8 / 26

slide-9
SLIDE 9

Reduction to propositional inference

Every fjrst-order KB and query can be propositionalized such that entailment is preserved. A ground sentence is entailed by the new KB ifg it is entailed by the original KB. Idea Propositionalise KB and query and apply DPLL (or some

  • ther complete propositional method).

Problem If the KB includes a function symbol, the set of possible ground-term substitutions is infjnite.

  • Eg. infjnitely many nested terms such as

Father(Father(Father(John)))

9 / 26

slide-10
SLIDE 10

Herbrand’s theorem

Theorem (Herbrand, 1930). If a sentence 𝜒 is entailed

by a fjrst-order KB, then it is entailed by a fjnite subset of the propositionalised KB. Idea for 𝑜 = 0 to ∞ do create a propositional KB by instantiating with depth-𝑜 terms see if 𝜒 is entailed by this KB Problem Works if 𝜒 is entailed, loops forever if it is not entailed.

10 / 26

slide-11
SLIDE 11

Semidecidability

Theorem (Turing, 1936. Church, 1936).

Entailment for fjrst-order logic is semidecidable. Algorithms exist that say yes to every entailed sentence, but no algorithm exists that also says no to every non-entailed sentence.

11 / 26

slide-12
SLIDE 12

Problems with propositionalisation

Propositionalisation is ineffjcient; it generates irrelevant sentences. Example The inference of Evil(John) from

∀𝑦.King(𝑦) ∧ Greedy(𝑦) → Evil(𝑦) King(John) ∀𝑧.Greedy(𝑧) Brother(Richard, John)

seems obvious, but propositionalisation produces irrelevant facts such as Greedy(Richard). For 𝑞 𝑙-ary predicates and 𝑜 constants, there are 𝑞 ⋅ 𝑜 instantiations.

12 / 26

slide-13
SLIDE 13

Unifjcation

We can get the inference immediately if we can fjnd a substitution 𝜄 such that King(𝑦) and Greedy(𝑦) match

King(John) and Greedy(𝑧). 𝜄 = {𝑦/John, 𝑧/John} works.

Intuitively, the unifjcation of two sentences means to fjnd a substitution such that the sentences become identical under its application.

𝜄 ∈ Unify(𝛽, 𝛾) ifg 𝛽𝜄 = 𝛾𝜄. 𝛽 𝛾 𝜄

Knows(John, 𝑦) Knows(John, Jane) {𝑦/Jane} Knows(John, 𝑦) Knows(𝑧, OJ) {𝑦/OJ, 𝑧/John} Knows(John, 𝑦) Knows(𝑧, Mother(𝑧)) {𝑧/John, 𝑦/Mother(John)} Knows(John, 𝑦) Knows(𝑦, Richard) [fail]

13 / 26

slide-14
SLIDE 14

Term unifjcation

An equation is a pair of terms (𝑢, 𝑢) with 𝑢, 𝑢 ∈ 𝑈(𝑌). We denote the equation (𝑢, 𝑢) as 𝑢 ?

= = 𝑢.

A unifjcation problem is a fjnite set of equations

𝑉 = {𝑢 ?

= = 𝑢

, … , 𝑢 ?

= = 𝑢

}

A unifjer (solution) for 𝑉 is a substitution 𝜄∶ 𝑌 → 𝑈(𝑍) s.t. 𝜄(𝑢) = 𝜄(𝑢

), for 𝑗 = 1, … , 𝑜.

We denote by Unify(𝑉) the set of unifjers for 𝑉. If 𝜄 = {𝑦/𝑢, … , 𝑦/𝑢} then

𝑉{𝑦/𝑢, … , 𝑦/𝑢} = {𝜄(𝑢) ?

= = 𝜄(𝑢) ∣ 𝑢 ? = = 𝑢 ∈ 𝑉}. 14 / 26

slide-15
SLIDE 15

Most general unifjer

Example To unify Knows(John, 𝑦) and Knows(𝑧, 𝑨),

𝜄 = {𝑧/John, 𝑦/𝑨} or 𝜄 = {𝑧/John, 𝑦/John, 𝑨/John}.

The fjrst unifjer is more general than the second. A unifjer 𝜄 ∈ Unify(𝑉) is more general than 𝜀 ∈ Unify(𝑉) if there is a substitution 𝜐 s.t. 𝜀 = 𝜄 ; 𝜐. A unifjer 𝜄 ∈ Unify(𝑉) is a most general unifjer (mgu) if for any 𝜀 ∈ Unify(𝑉) there is a substitution 𝜐 s.t. 𝜀 = 𝜄 ; 𝜐. There is a single most general unifjer that is unique up to renaming of variables. Example

mgu({John ?

= = 𝑧, 𝑦 ? = = 𝑨}) = {𝑧/John, 𝑦/𝑨} 15 / 26

slide-16
SLIDE 16

Example

What is the most general unifjer of the following equations?

  • Loves(John, 𝑦) ?

= = Loves(𝑧, Mother(𝑧))

  • Loves(John, Mother(𝑦)) ?

= = Loves(𝑧, 𝑧) 16 / 26

slide-17
SLIDE 17

Example ⋅ Solution

  • Loves(John, 𝑦) ?

= = Loves(𝑧, Mother(𝑧))

{𝑦/Mother(John), 𝑧/John}

  • Loves(John, Mother(𝑦)) ?

= = Loves(𝑧, 𝑧)

Fail

17 / 26

slide-18
SLIDE 18

Unifjcation

Let 𝑆 = {𝑦 ?

= = 𝑢, … , 𝑦 ? = = 𝑢} be a unifjcation problem with

variables from 𝑌, and 𝑍 the set of variables occurring in 𝑢. We say that 𝑆 is solved if 𝑦 ≠ 𝑦 for 𝑗 ≠ 𝑘 and 𝑦 ∉ 𝑍. Any solved problem 𝑆 defjnes a substitution 𝜄

𝜄 = {𝑦/𝑢, … , 𝑦/𝑢} 𝜄 ∈ Unify(𝑆)

The following algorithm transforms a non-ground unifjcation problem 𝑉 into another non-ground unifjcation problem 𝑆. If

𝑆 = ∅, then 𝑉 has no unifjers. Otherwise, 𝑆 is solved, and

the substitution 𝜄 determined by 𝑆 is an mgu for 𝑉. What happens if 𝑉 is ground?

18 / 26

slide-19
SLIDE 19

Unifjcation algorithm

Input: 𝑉 = {𝑢 ?

= = 𝑢

, … , 𝑢 ?

= = 𝑢

} a non-ground unifjcation problem

Initialise: 𝑆 = 𝑉 Execute non-deterministically the steps: Delete: 𝑆 ∪ {𝑢 ?

= = 𝑢} ⇒ 𝑆 if 𝑢 is ground

Switch: 𝑆 ∪ {𝑢 ?

= = 𝑦} ⇒ 𝑆 ∪ {𝑦 ? = = 𝑢} if 𝑦 is a variable, and 𝑢 is not

Decomposition:

𝑆 ∪ {𝑔(𝑢, … , 𝑢) ?

= = 𝑔(𝑢

, … , 𝑢 )} ⇒ 𝑆 ∪ {𝑢 ?

= = 𝑢

, … , 𝑢 ?

= = 𝑢

}

Confmict: 𝑆 ∪ {𝑔(𝑢, … , 𝑢) ?

= = 𝑕(𝑢

, … , 𝑢 )} ⇒ ∅ if 𝑔 ≠ 𝑕

Eliminate: 𝑆 ∪ {𝑦 ?

= = 𝑢} ⇒ {𝑦 ? = = 𝑢} ∪ 𝑆{𝑦/𝑢} if 𝑦 is a variable that

  • ccurs in 𝑆 but not in 𝑢, and 𝑢 is not a variable

Occurs check: 𝑆 ∪ {𝑦 ?

= = 𝑢} ⇒ ∅ if 𝑦 is a variable that occurs in 𝑢

and 𝑢 ≠ 𝑦 Coalesce: 𝑆 ∪ {𝑦 ?

= = 𝑧} ⇒ {𝑦 ? = = 𝑧} ∪ 𝑆{𝑦/𝑧} if 𝑦 and 𝑧 are variables

  • ccurring in 𝑆

Output: if 𝑆 = ∅, then there are no solutions for problem 𝑉 if 𝑆 ≠ ∅, then 𝑆 is an mgu for 𝑉

19 / 26

slide-20
SLIDE 20

Example

𝑉 = 𝑆 = {Loves(John, 𝑦) ?

= = Loves(𝑧, Mother(𝑧))}

⇓ Decompose 𝑆 = {John ?

= = 𝑧, 𝑦 ? = = Mother(𝑧)}

⇓ Switch 𝑆 = {𝑧 ?

= = John, 𝑦 ? = = Mother(𝑧)}

⇓ Eliminate 𝑆 = {𝑧 ?

= = John, 𝑦 ? = = Mother(John)} 20 / 26

slide-21
SLIDE 21

Generalized Modus Ponens (GMP)

For the atomic sentences 𝑞, … , 𝑞, 𝑞

, … , 𝑞 , 𝑟, and

a unifjer 𝜄 s.t. 𝑞

𝜄 = 𝑞𝜄 for all 𝑗, we have the inference rule:

𝑞

, 𝑞 , … , 𝑞

  • (𝑞 ∧ 𝑞 ∧ … ∧ 𝑞 → 𝑟)

𝑟𝜄

GMP is used with KB of defjnite clauses (one positive literal). All variables are assumed universally quantifjed. Example

𝑞

is King(John)

𝑞

is Greedy(𝑧)

𝑞 is King(𝑦) 𝑞 is Greedy(𝑦) 𝑟 is Evil(𝑦) 𝜄 is (𝑦/John, 𝑧/John) 𝑟𝜄 is Evil(John)

21 / 26

slide-22
SLIDE 22

GMP ⋅ Soundness

We need to show that 𝑞

, … , 𝑞 , (𝑞 ∧ … ∧ 𝑞 → 𝑟) ⊧ 𝑟𝜄,

provided that 𝑞

𝜄 = 𝑞𝜄, for all 𝑗 and 𝜄 a unifjer.

Proof. For any sentence 𝑞, we have that 𝑞 ⊧ 𝑞𝜄 by the Universal Instantiation rule. Using this, we have:

  • 1. (𝑞∧…∧𝑞 → 𝑟) ⊧ (𝑞∧…∧𝑞 → 𝑟)𝜄 = (𝑞𝜄∧…∧𝑞𝜄 → 𝑟𝜄)
  • 2. 𝑞

, … , 𝑞 ⊧ 𝑞 ∧ … ∧ 𝑞 ⊧ (𝑞 ∧ … ∧ 𝑞 )𝜄 = 𝑞 𝜄 ∧ … ∧ 𝑞 𝜄

= 𝑞𝜄 ∧ … ∧ 𝑞𝜄

because by the defjnition of generalized modus ponens we have that 𝑞

𝜄 = 𝑞𝜄, for all 𝑗.

  • 3. From the previous two steps, and by applying modus

ponens, 𝑟𝜄 follows.

22 / 26

slide-23
SLIDE 23

Example ⋅ Winnie-the-Pooh

It is known in The Hundred-Acre Wood that if someone who is very fond of food gives a treat to one of their friends, they must be really generous. Eeyore, the sad donkey, has some hunny that he has received for his birthday from Winnie-the-Pooh, who, as we know, is very fond of food. Prove that Winnie-the-Pooh is generous.

23 / 26

slide-24
SLIDE 24

Example ⋅ Winnie-the-Pooh

It is an act of generosity for someone very fond of food to share treats with his friends.

VeryFondOfFood(𝑦) ∧ Treat(𝑧) ∧ Friend(𝑨) ∧ Gives(𝑦, 𝑧, 𝑨) → Generous(𝑦)

Eeyore has some hunny.

∃𝑦.Owns(Eeyore, 𝑦) ∧ Hunny(𝑦)

He must have received the hunny from Winnie-the-Pooh.

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

24 / 26

slide-25
SLIDE 25

Example ⋅ Winnie-the-Pooh

Hunny is a treat.

Hunny(𝑦) → Treat(𝑦)

Residents of The Hundred-Acre Wood are friends.

Resident(𝑦, HundredAcreWood) → Friend(𝑦)

Eeyore is a resident of The Hundred-Acre Wood.

Resident(Eeyore, HundredAcreWood)

Pooh is very fond of food.

VeryFondOfFood(Pooh)

25 / 26

slide-26
SLIDE 26

Summary

  • Rules for quantifjers
  • Reducing FOL to PL
  • Unifjcation as equation solving
  • Generalized modus ponens

26 / 26