Chapter 5
Chapter 5
Chapter 5
2 26 March, 2009
3 26 March, 2009
4 26 March, 2009
Variable symbols: x, y, z,
to represent unknown objects
5 26 March, 2009
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
7 26 March, 2009
If and are sentences, then so are , , , and If is a sentence, then so are and
8 26 March, 2009
9 26 March, 2009
10 26 March, 2009
11 26 March, 2009
12 26 March, 2009
13 26 March, 2009
14 26 March, 2009
15 26 March, 2009
16 26 March, 2009
17 26 March, 2009
18 26 March, 2009
tryassassinate(Marcus, Caesar)
loyalto(Marcus, Caesar)
x: man(x) person(x)
19 26 March, 2009
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?
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.
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)
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).
24 26 March, 2009
Reasoning
KB |= ( is a logical consequence of KB) How to prove it automatically?
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.
26 26 March, 2009
Resolution
Proof by refutation KB |= KB |= false (empty clause)
27 26 March, 2009
Resolution
Resolution inference rule ( ) ( ) premise ( ) conclusion
28 26 March, 2009
L1 L2 Ln
P or P
29 26 March, 2009
30 26 March, 2009
31 26 March, 2009
32 26 March, 2009
33 26 March, 2009
34 26 March, 2009
Unification:
36 26 March, 2009
37 26 March, 2009
38 26 March, 2009
3.
39 26 March, 2009
5. 6. 7. 8.
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.
40 26 March, 2009
1.
2.
Eliminate .
3.
4. 5.
Move all quantifiers to the left without changing their relative order. Drop . Eliminate (Skolemization).
6.
7.
8.
9.
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))
42 26 March, 2009
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.
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).
Example
Prove:
hate(Marcus, Caesar)
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?
47 26 March, 2009
48 26 March, 2009
49 26 March, 2009
50 26 March, 2009
51 26 March, 2009
Programming in Logic
PROLOG: Only Horn sentences are acceptable A B1, B2, , Bm A B1 B2 Bm A, Bi: atoms
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))
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)
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
56 26 March, 2009
Homework
Exercises
1-13, Chapter 5, Rich&Knight AI Textbook Chapter 4 of the Vietnamese Textbook
57 26 March, 2009