0% found this document useful (0 votes)
60 views

Chapter 5

This document discusses predicate logic and resolution theorem proving. It begins with an introduction to representing knowledge with predicate logic, including the use of constants, variables, predicates, functions, and quantifiers. It then covers converting a formula to clause form, which is required for resolution theorem proving. Resolution theorem proving is described as a way to determine if a statement is logically implied by a knowledge base through attempting to derive a contradiction. An example knowledge base and statement are provided to illustrate the resolution process.

Uploaded by

Prabhat Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Chapter 5

This document discusses predicate logic and resolution theorem proving. It begins with an introduction to representing knowledge with predicate logic, including the use of constants, variables, predicates, functions, and quantifiers. It then covers converting a formula to clause form, which is required for resolution theorem proving. Resolution theorem proving is described as a way to determine if a statement is logically implied by a knowledge base through attempting to derive a contradiction. An example knowledge base and statement are provided to illustrate the resolution process.

Uploaded by

Prabhat Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Using Predicate Logic

Chapter 5

Using Propositional Logic


Representing simple facts
It is raining RAINING It is sunny SUNNY It is windy WINDY If it is raining, then it is not sunny RAINING SUNNY

Cao Hoang Tru CSE Faculty - HCMUT

2 26 March, 2009

Using Propositional Logic


Theorem proving is decidable Cannot represent objects and quantification

Cao Hoang Tru CSE Faculty - HCMUT

3 26 March, 2009

Using Predicate Logic


Can represent objects and quantification Theorem proving is semi-decidable

Cao Hoang Tru CSE Faculty - HCMUT

4 26 March, 2009

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)

Cao Hoang Tru CSE Faculty - HCMUT

5 26 March, 2009

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)
Cao Hoang Tru CSE Faculty - HCMUT 6 26 March, 2009

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)

Cao Hoang Tru CSE Faculty - HCMUT

7 26 March, 2009

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

Cao Hoang Tru CSE Faculty - HCMUT

8 26 March, 2009

Using Predicate Logic


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

Cao Hoang Tru CSE Faculty - HCMUT

9 26 March, 2009

Using Predicate Logic


1. man(Marcus) Marcus was a man.

Cao Hoang Tru CSE Faculty - HCMUT

10 26 March, 2009

Using Predicate Logic


2. Pompeian(Marcus) Marcus was a Pompeian.

Cao Hoang Tru CSE Faculty - HCMUT

11 26 March, 2009

Using Predicate Logic


3. x: Pompeian(x) Roman(x) All Pompeians were Romans.

Cao Hoang Tru CSE Faculty - HCMUT

12 26 March, 2009

Using Predicate Logic


4. ruler(Caesar) Caesar was a ruler.

Cao Hoang Tru CSE Faculty - HCMUT

13 26 March, 2009

Using Predicate Logic


5. inclusive-or All Pompeians were either loyal to Caesar or hated him. 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))

Cao Hoang Tru CSE Faculty - HCMUT

14 26 March, 2009

Using Predicate Logic


6. x: y: loyalto(x, y) Every one is loyal to someone. y: x: loyalto(x, y)

Cao Hoang Tru CSE Faculty - HCMUT

15 26 March, 2009

Using Predicate Logic


7. People only try to assassinate rulers they are not loyal to.

x: y: person(x) ruler(y) tryassassinate(x, y) loyalto(x, y)

Cao Hoang Tru CSE Faculty - HCMUT

16 26 March, 2009

Using Predicate Logic


7. People only try to assassinate rulers they are not loyal to.

x: y: person(x) ruler(y) tryassassinate(x, y) loyalto(x, y)

Cao Hoang Tru CSE Faculty - HCMUT

17 26 March, 2009

Using Predicate Logic


8. tryassassinate(Marcus, Caesar) Marcus tried to assassinate Caesar.

Cao Hoang Tru CSE Faculty - HCMUT

18 26 March, 2009

Using Predicate Logic


Was Marcus loyal to Caesar? man(Marcus) ruler(Caesar)

tryassassinate(Marcus, Caesar)

loyalto(Marcus, Caesar)

x: man(x) person(x)

Cao Hoang Tru CSE Faculty - HCMUT

19 26 March, 2009

Using Predicate Logic


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

Cao Hoang Tru CSE Faculty - HCMUT

20 26 March, 2009

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

Is Marcus alive?

Cao Hoang Tru CSE Faculty - HCMUT

21 26 March, 2009

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

erupted(volcano, 79) x: Pompeian(x) died(x, 79) now = 2008

Cao Hoang Tru CSE Faculty - HCMUT

22 26 March, 2009

Reasoning
1. 2. 3. Pompeian(Marcus) Marcus was a Pompeian. All Pompeians died when the volcano erupted in 79 A.D. It is now 2008 A.D. x: t1: t2: died(x, t1) greater-than(t2, t1) dead(x, t2)

erupted(volcano, 79) x: Pompeian(x) died(x, 79) now = 2008

Cao Hoang Tru CSE Faculty - HCMUT

23 26 March, 2009

Reasoning
Obvious information may be necessary for reasoning We may not know in advance which statements to
deduce (P or P).

Cao Hoang Tru CSE Faculty - HCMUT

24 26 March, 2009

Reasoning
KB |= ( is a logical consequence of KB) How to prove it automatically?

Cao Hoang Tru CSE Faculty - HCMUT

25 26 March, 2009

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

Cao Hoang Tru CSE Faculty - HCMUT

26 26 March, 2009

Resolution
Proof by refutation KB |= KB |= false (empty clause)

Cao Hoang Tru CSE Faculty - HCMUT

27 26 March, 2009

Resolution
Resolution inference rule ( ) ( ) premise ( ) conclusion

Cao Hoang Tru CSE Faculty - HCMUT

28 26 March, 2009

Resolution in Propositional Logic


1. Convert all the propositions of KB to clause form (S).

L1 L2 Ln
P or P

Cao Hoang Tru CSE Faculty - HCMUT

29 26 March, 2009

Resolution in Propositional Logic


1. 2. 3. Negate and convert it to clause form. Add it to S. Convert all the propositions of KB to clause form (S). 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.

Cao Hoang Tru CSE Faculty - HCMUT

30 26 March, 2009

Resolution in Propositional Logic


Example:
KB = {P, (P Q) R, (S T) Q, T} =R

Cao Hoang Tru CSE Faculty - HCMUT

31 26 March, 2009

Resolution in Predicate Logic


Example:
KB = {P(a), x: (P(x) Q(x)) R(x), y: (S(y) T(y)) Q(y), T(a)} = R(a)

Cao Hoang Tru CSE Faculty - HCMUT

32 26 March, 2009

Resolution in Predicate Logic


Unification:
UNIFY(p, q) = unifier where (p) = (q)

Cao Hoang Tru CSE Faculty - HCMUT

33 26 March, 2009

Resolution in Predicate Logic


Unification:
x: knows(John, x) hates(John, x) knows(John, Jane) y: knows(y, Leonid) y: knows(y, mother(y)) x: knows(x, Elizabeth)

Cao Hoang Tru CSE Faculty - HCMUT

34 26 March, 2009

Resolution in Predicate Logic


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
Cao Hoang Tru CSE Faculty - HCMUT 35 26 March, 2009

Unification:

Resolution in Predicate Logic


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

Cao Hoang Tru CSE Faculty - HCMUT

36 26 March, 2009

Resolution in Predicate Logic


Unification: Occur check
UNIFY(knows(x, x), knows(y, mother(y))) = FAIL

Cao Hoang Tru CSE Faculty - HCMUT

37 26 March, 2009

Resolution in Predicate Logic


Unification: 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}

Cao Hoang Tru CSE Faculty - HCMUT

38 26 March, 2009

Conversion to Clause Form


1. 2. Eliminate . P Q P Q 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))

Cao Hoang Tru CSE Faculty - HCMUT

39 26 March, 2009

Conversion to Clause Form


4. 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)): dont move!
x: P(x) P(c) x: y P(x, y) x: P(x, f(x))

5. 6. 7. 8.

Eliminate (Skolemization). Drop .

Skolem constant Skolem function

Convert the formula into a conjunction of disjuncts. Create a separate clause corresponding to each conjunct.
(P Q) R (P R) (Q R)

x: P(x) P(x)

9.

Cao Hoang Tru CSE Faculty - HCMUT

Standardize apart the variables in the set of obtained clauses.

40 26 March, 2009

1.

2.

Eliminate .

Conversion to Clause Form

3.

4. 5.

Standardize variables so that each quantifier binds a unique variable.

Reduce the scope of each to a single term.

Move all quantifiers to the left without changing their relative order. Drop . Eliminate (Skolemization).

6.

7.

8.

Convert the formula into a conjunction of disjuncts.

9.

Create a separate clause corresponding to each conjunct.

Standardize apart the variables in the set of obtained clauses.


41 26 March, 2009

Cao Hoang Tru CSE Faculty - HCMUT

Resolution in Predicate Logic


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

a. Select two clauses ( p(t1, t2, , tn)) and ( p(t1, t2, , tn)). c. Add the resolvent ( ) to S. b. = mgu(p(t1, t2, , tn), p(t1, t2, , tn))

Cao Hoang Tru CSE Faculty - HCMUT

42 26 March, 2009

Resolution in Predicate Logic


Example:
KB = {P(a), x: (P(x) Q(x)) R(x), y: (S(y) T(y)) Q(y), T(a)} = R(a)

Cao Hoang Tru CSE Faculty - HCMUT

43 26 March, 2009

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

Cao Hoang Tru CSE Faculty - HCMUT

44 26 March, 2009

Example
1. 2. Man(Marcus). 3. Pompeian(Marcus). ruler(Caesar). x: Pompeian(x) Roman(x). x: Roman(x) loyalto(x, Caesar) hate(x, Caesar). x: y: loyalto(x, y). x: y: person(x) ruler(y) tryassassinate(x, y) tryassassinate(Marcus, Caesar).
45 26 March, 2009

5. 7. 8.

4. 6.

loyalto(x, y).

Cao Hoang Tru CSE Faculty - HCMUT

Example
Prove:
hate(Marcus, Caesar)

Cao Hoang Tru CSE Faculty - HCMUT

46 26 March, 2009

Question Answering
1. 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?

Cao Hoang Tru CSE Faculty - HCMUT

47 26 March, 2009

Soundness and Completeness


Soundness of a reasoning algorithm/system R: if KB derives using R, then KB |=

Cao Hoang Tru CSE Faculty - HCMUT

48 26 March, 2009

Soundness and Completeness


Completeness of a reasoning algorithm/system R: if KB |= , then KB derives using R

Cao Hoang Tru CSE Faculty - HCMUT

49 26 March, 2009

Soundness and Completeness


Resolution algorithm is sound and complete

Cao Hoang Tru CSE Faculty - HCMUT

50 26 March, 2009

Soundness and Completeness


In general:
Soundness: any returned answer is a correct answer. Completeness: all correct answers are returned.

Cao Hoang Tru CSE Faculty - HCMUT

51 26 March, 2009

Programming in Logic
PROLOG: Only Horn sentences are acceptable A B1, B2, , Bm A B1 B2 Bm A, Bi: atoms

Cao Hoang Tru CSE Faculty - HCMUT

52 26 March, 2009

Programming in Logic
PROLOG: The occur-check is omitted from the unification: unsound test P(x, x) P(x, f(x))

Cao Hoang Tru CSE Faculty - HCMUT

53 26 March, 2009

Programming in Logic
PROLOG: Backward chaining with depth-first search: incomplete P(x, y) Q(x, y) P(x, x) Q(x, y) Q(y, x)

Cao Hoang Tru CSE Faculty - HCMUT

54 26 March, 2009

Programming in Logic
PROLOG: Unsafe cut: incomplete A B, C B D, !, E D
B, C A

D, !, E, C !, E, C
Cao Hoang Tru CSE Faculty - HCMUT 55 26 March, 2009

Programming in Logic
PROLOG: Negation as failure: P if fails to prove P

Cao Hoang Tru CSE Faculty - HCMUT

56 26 March, 2009

Homework
Exercises
1-13, Chapter 5, Rich&Knight AI Textbook Chapter 4 of the Vietnamese Textbook

Cao Hoang Tru CSE Faculty - HCMUT

57 26 March, 2009

You might also like