57
Using Predicate Logic Chapter 5 Chapter 5 Chapter 5 Chapter 5

Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

Using Predicate LogicChapter 5Chapter 5Chapter 5Chapter 5

Page 2: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

2

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Propositional LogicRepresenting simple facts

It is rainingRAINING

It is sunnySUNNY

It is windyWINDY

If it is raining, then it is not sunnyRAINING → ¬SUNNY

Page 3: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

3

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Propositional Logic• Theorem proving is decidable

• Cannot represent objects and quantification

Page 4: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

4

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic• Can represent objects and quantification

• Theorem proving is semi-decidable

Page 5: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

5

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Predicate Logic Syntax• Constant symbols: a, b, c, John, …

to represent primitive objects

• Variable symbols: x, y, z, …

to represent unknown objects

• Predicate symbols: safe, married, love, …

to represent relations

married(John)

love(John, Mary)

Page 6: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

6

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Predicate Logic Syntax• Function symbols: square, father, …

to represent simple objects

safe(square(1, 2))

love(father(John), mother(John))

• Terms:

to represent complex objects

– Constant symbols

– If f is a function symbol, and t1, t2, …, tn are terms,

then so is f(t1, t2, …, tn)

love(mother(father(John)), John)

Page 7: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

7

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Predicate Logic Syntax• Logical connectives: ¬, ∧, ∨, ⇒, ⇔

• Universal quantifier: ∀x: p(x)

∀x: love(father(x), mother(x))

• Existential quantifier: ∃x: p(x) ≡ ¬∀x: ¬p(x)

∃x: ¬married(x)

Page 8: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

8

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Predicate Logic Syntax• Sentences:

– Atomic sentences: p(t1, t2, …, tn)– If α is a sentence, then so are ¬α and (α)– If α and β are sentences, then so are α ∧ β, α ∨ β, α ⇒ β,

and α ⇔ β

– If α is a sentence, then so are ∀α and ∃α

Page 9: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

9

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic1. Marcus was a man.2. Marcus was a Pompeian.3. All Pompeians were Romans.4. Caesar was a ruler.5. All Pompeians were either loyal to Caesar or hated him.6. Every one is loyal to someone.7. People only try to assassinate rulers they are not loyal to.8. Marcus tried to assassinate Caesar.

Page 10: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

10

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic1. Marcus was a man.

man(Marcus)

Page 11: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

11

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic2. Marcus was a Pompeian.

Pompeian(Marcus)

Page 12: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

12

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic3. All Pompeians were Romans.

∀x: Pompeian(x) → Roman(x)

Page 13: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

13

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic4. Caesar was a ruler.

ruler(Caesar)

Page 14: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

14

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic5. All Pompeians were either loyal to Caesar or hated him.

inclusive-or∀x: Roman(x) → loyalto(x, Caesar) ∨ hate(x, Caesar)

exclusive-or∀x: Roman(x) → (loyalto(x, Caesar) ∧ ¬hate(x, Caesar)) ∨

(¬loyalto(x, Caesar) ∧ hate(x, Caesar))

Page 15: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

15

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic6. Every one is loyal to someone.

∀x: ∃y: loyalto(x, y) ∃y: ∀x: loyalto(x, y)

Page 16: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

16

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic7. People only try to assassinate rulers they are not loyal to.

∀x: ∀y: person(x) ∧ ruler(y) ∧ tryassassinate(x, y) → ¬loyalto(x, y)

Page 17: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

17

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic7. People only try to assassinate rulers they are not loyal to.

∀x: ∀y: person(x) ∧ ruler(y) ∧ tryassassinate(x, y) → ¬loyalto(x, y)

Page 18: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

18

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic8. Marcus tried to assassinate Caesar.

tryassassinate(Marcus, Caesar)

Page 19: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

19

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate LogicWas Marcus loyal to Caesar?

man(Marcus)ruler(Caesar)tryassassinate(Marcus, Caesar)

⇓ ∀x: man(x) → person(x)¬loyalto(Marcus, Caesar)

Page 20: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

20

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Using Predicate Logic• Many English sentences are ambiguous.• There is often a choice of how to represent knowledge.

Page 21: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

21

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Reasoning1. Marcus was a Pompeian.2. All Pompeians died when the volcano erupted in 79 A.D.3. It is now 2008 A.D.

Is Marcus alive?

Page 22: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

22

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Reasoning1. Marcus was a Pompeian.

Pompeian(Marcus)2. All Pompeians died when the volcano erupted in 79 A.D.

erupted(volcano, 79) ∧ ∀x: Pompeian(x) → died(x, 79)3. It is now 2008 A.D.

now = 2008

Page 23: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

23

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Reasoning1. Marcus was a Pompeian.

Pompeian(Marcus)2. All Pompeians died when the volcano erupted in 79 A.D.

erupted(volcano, 79) ∧ ∀x: Pompeian(x) → died(x, 79)3. It is now 2008 A.D.

now = 2008∀x: ∀t1: ∀t2: died(x, t1) ∧ greater-than(t2, t1) → dead(x, t2)

Page 24: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

24

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Reasoning• Obvious information may be necessary for reasoning• We may not know in advance which statements to

deduce (P or ¬P).

Page 25: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

25

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

ReasoningKB ||||==== α (α is a logical consequence of KB)

How to prove it automatically?

Page 26: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

26

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

ResolutionRobinson, J.A. 1965. A machine-oriented logic based on the resolution principle. Journal of ACM 12 (1): 23-41.

Page 27: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

27

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

ResolutionProof by refutation

KB ||||==== α ⇔⇔⇔⇔ KB ∧∧∧∧ ¬¬¬¬α ||||==== false (empty clause)

Page 28: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

28

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

ResolutionResolution inference rule

(α ∨∨∨∨ ¬¬¬¬β) ∧∧∧∧ (γ ∨∨∨∨ β) premise

(α ∨∨∨∨ γ) conclusion

Page 29: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

29

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Propositional Logic1. Convert all the propositions of KB to clause form (S).

L1 ∨∨∨∨ L2 ∨∨∨∨ … ∨∨∨∨ Ln

P or ¬¬¬¬P

Page 30: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

30

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Propositional Logic1. Convert all the propositions of KB to clause form (S).2. Negate α and convert it to clause form. Add it to S.3. Repeat until either a contradiction is found or no progress can

be made:a. Select two clauses (α ∨∨∨∨ ¬¬¬¬P) and (γ ∨∨∨∨ P).b. Add the resolvent (α ∨∨∨∨ γ) to S.

Page 31: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

31

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Propositional LogicExample:

KB = {P, (P ∧∧∧∧ Q) →→→→ R, (S ∨∨∨∨ T) →→→→ Q, T}α = R

Page 32: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

32

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Predicate LogicExample:KB = {P(a), ∀∀∀∀x: (P(x) ∧∧∧∧ Q(x)) →→→→ R(x), ∀∀∀∀y: (S(y) ∨∨∨∨ T(y)) →→→→ Q(y), T(a)}α = R(a)

Page 33: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

33

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Predicate LogicUnification:

UNIFY(p, q) = unifier θ where θ(p) = θ(q)

Page 34: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

34

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Predicate LogicUnification:∀∀∀∀x: knows(John, x) →→→→ hates(John, x)knows(John, Jane)∀∀∀∀y: knows(y, Leonid)∀∀∀∀y: knows(y, mother(y))∀∀∀∀x: knows(x, Elizabeth)

Page 35: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

35

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Predicate LogicUnification:∀∀∀∀x: knows(John, x) →→→→ hates(John, x)knows(John, Jane)∀∀∀∀y: knows(y, Leonid)∀∀∀∀y: knows(y, mother(y))∀∀∀∀x: knows(x, Elizabeth)

UNIFY(knows(John, x), knows(John, Jane)) = {Jane/x}UNIFY(knows(John, x), knows(y, Leonid)) = {Leonid/x, John/y}UNIFY(knows(John, x), knows(y, mother(y))) = {John/y, mother(John)/x}UNIFY(knows(John, x), knows(x, Elizabeth)) = FAIL

Page 36: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

36

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Predicate LogicUnification: Standardization

UNIFY(knows(John, x), knows(y, Elizabeth)) = {John/y, Elizabeth/x}

Page 37: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

37

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Predicate LogicUnification: Occur check

UNIFY(knows(x, x), knows(y, mother(y))) = FAIL

Page 38: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

38

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Predicate LogicUnification: Most general unifier

UNIFY(knows(John, x), knows(y, z)) = {John/y, John/x, John/z}= {John/y, Jane/x, Jane/z}= {John/y, v/x, v/z}= {John/y, z/x, Jane/v}= {John/y, z/x}

Page 39: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

39

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Conversion to Clause Form1. Eliminate →.

P → Q ≡ ¬P ∨ Q

2. Reduce the scope of each ¬ to a single term.¬(P ∨ Q) ≡ ¬P ∧ ¬Q¬(P ∧ Q) ≡ ¬P ∨ ¬Q¬∀x: P ≡ ∃x: ¬P¬∃x: p ≡ ∀x: ¬P¬¬ P ≡ P

3. Standardize variables so that each quantifier binds a unique variable.

(∀x: P(x)) ∨ (∃x: Q(x)) ≡ (∀x: P(x)) ∨ (∃y: Q(y))

Page 40: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

40

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Conversion to Clause Form4. Move all quantifiers to the left without changing their relative order.

∀x: (P(x) ∨ ∃y: Q(y)) ≡ ∀x: ∃y: (P(x) ∨ (Q(y))

(∀x: P(x)) ∨ (∃y: Q(y)): don’t move!

5. Eliminate ∃ (Skolemization).∃x: P(x) ≡ P(c) Skolem constant∀x: ∃y P(x, y) ≡ ∀x: P(x, f(x)) Skolem function

6. Drop ∀.∀x: P(x) ≡ P(x)

7. Convert the formula into a conjunction of disjuncts.(P ∧ Q) ∨ R ≡ (P ∨ R) ∧ (Q ∨ R)

8. Create a separate clause corresponding to each conjunct.9. Standardize apart the variables in the set of obtained clauses.

Page 41: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

41

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Conversion to Clause Form1. Eliminate →.2. Reduce the scope of each ¬ to a single term.3. Standardize variables so that each quantifier binds a unique

variable.4. Move all quantifiers to the left without changing their relative

order.5. Eliminate ∃ (Skolemization).6. Drop ∀.7. Convert the formula into a conjunction of disjuncts.8. Create a separate clause corresponding to each conjunct.9. Standardize apart the variables in the set of obtained clauses.

Page 42: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

42

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Predicate Logic1. Convert all the propositions of KB to clause form (S).2. Negate α and convert it to clause form. Add it to S.3. Repeat until a contradiction is found:

a. Select two clauses (α ∨∨∨∨ ¬¬¬¬ p(t1, t2, …, tn)) and (γ ∨∨∨∨ p(t’1, t’2, …, t’n)).b. θ = mgu(p(t1, t2, …, tn), p(t’1, t’2, …, t’n))c. Add the resolvent θ(α ∨∨∨∨ γ) to S.

Page 43: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

43

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Resolution in Predicate LogicExample:KB = {P(a), ∀∀∀∀x: (P(x) ∧∧∧∧ Q(x)) →→→→ R(x), ∀∀∀∀y: (S(y) ∨∨∨∨ T(y)) →→→→ Q(y), T(a)}α = R(a)

Page 44: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

44

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Example1. Marcus was a man.2. Marcus was a Pompeian.3. All Pompeians were Romans.4. Caesar was a ruler.5. All Pompeians were either loyal to Caesar or hated him.6. Every one is loyal to someone.7. People only try to assassinate rulers they are not loyal to.8. Marcus tried to assassinate Caesar.

Page 45: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

45

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Example1. Man(Marcus).2. Pompeian(Marcus).3. ∀x: Pompeian(x) → Roman(x).4. ruler(Caesar).5. ∀x: Roman(x) → loyalto(x, Caesar) ∨ hate(x, Caesar).6. ∀x: ∃y: loyalto(x, y).7. ∀x: ∀y: person(x) ∧ ruler(y) ∧ tryassassinate(x, y)

→ ¬loyalto(x, y).8. tryassassinate(Marcus, Caesar).

Page 46: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

46

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

ExampleProve:

hate(Marcus, Caesar)

Page 47: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

47

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Question Answering1. When did Marcus die?2. Whom did Marcus hate?3. Who tried to assassinate a ruler?4. What happen in 79 A.D.?. 5. Did Marcus hate everyone?

Page 48: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

48

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Soundness and Completeness• Soundness of a reasoning algorithm/system R:

if KB derives α using R, then KB |=|=|=|= α

Page 49: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

49

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Soundness and Completeness• Completeness of a reasoning algorithm/system R:

if KB |=|=|=|= α, then KB derives α using R

Page 50: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

50

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Soundness and CompletenessResolution algorithm is sound and complete

Page 51: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

51

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Soundness and Completeness• In general:

– Soundness: any returned answer is a correct answer.

– Completeness: all correct answers are returned.

Page 52: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

52

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Programming in LogicPROLOG:• Only Horn sentences are acceptable

A ← B1, B2, …, Bm ≡ A ∨∨∨∨ ¬B1 ∨∨∨∨ ¬B2 ∨∨∨∨ … ∨∨∨∨ ¬Bm

A, Bi: atoms

Page 53: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

53

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Programming in LogicPROLOG:• The occur-check is omitted from the unification: unsound

test ← P(x, x)

P(x, f(x))

Page 54: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

54

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Programming in LogicPROLOG:• Backward chaining with depth-first search: incomplete

P(x, y) ← Q(x, y)

P(x, x)

Q(x, y) ← Q(y, x)

Page 55: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

55

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Programming in LogicPROLOG:• Unsafe cut: incomplete

A ← B, C ← A

B ← D, !, E

D ← ← B, C

← D, !, E, C

← !, E, C

Page 56: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

56

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

Programming in LogicPROLOG:• Negation as failure: ¬P if fails to prove P

Page 57: Using Predicate Logiccse.hcmut.edu.vn/~tru/AI/chapter5.pdf · 4 26 March, 2009 Cao Hoang Tru CSE Faculty - HCMUT Using Predicate Logic • Can represent objects and quantification

57

26 March, 2009

Cao Hoang Tru

CSE Faculty - HCMUT

HomeworkExercises 1-13, Chapter 5, Rich&Knight AI TextbookChapter 4 of the Vietnamese Textbook