Professional Documents
Culture Documents
Chapter 08
Instructors Information
LE Thanh Sach, Ph.D.
Office: Department of Computer Science, Faculty of Computer Science and Engineering, HoChiMinh City University of Technology. Office Address: 268 LyThuongKiet Str., Dist. 10, HoChiMinh City, Vietnam. E-mail: LTSACH@cse.hcmut.edu.vn E-home: http://cse.hcmut.edu.vn/~ltsach/ Tel: (+84) 83-864-7256 (Ext: 5839)
Artificial Intelligence: Predicate Logic Slide: 2
Acknowledgment
The slides in this PPT file are composed using the materials supplied by
Prof. Stuart Russell and Peter Norvig: They are currently from University of California, Berkeley. They are also the author of the book Artificial Intelligence: A Modern Approach, which is used as the textbook for the course Prof. Tom Lenaerts, from Universit Libre de Bruxelles
Artificial Intelligence: Predicate Logic Slide: 3
Outline
Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL
Slide: 4
meaning of B1,1 P1,2 is derived from meaning of B1,1 and of P1,2 (unlike natural language, where meaning depends on context)
Meaning in propositional logic is context-independent Propositional logic has very limited expressive power
(unlike natural language) E.g., cannot say "pits cause breezes in adjacent squares
except by writing one sentence for each square
Slide: 5
Slide: 6
Disadvantages: 1. Socrates and Plato are human, but the representation is not similar 2. Can not state that each person is mortal Difficult for reasoning.
Slide: 7
Slide: 8
Conclusion mortal(socrates)
Slide: 9
Representation
man(socrates) X (man(X) mortal(X))
Rule
Axiom Axiom 2, X= socrates, UI 1,3, MP
Socrates is mortal.
Artificial Intelligence: Predicate Logic Slide: 10
Predicates Functions:
Variables:
x, y, a, b,...
Connectives:
, , , ,
Equality:
=
Quantifiers:
Atomic sentences
Term : function (term1,...,termn) or constant or variable
E.g.,
Brother(KingJohn,RichardTheLionheart) > (Length(LeftLegOf(Richard)), Length(LeftLegOf(KingJohn)))
Slide: 12
Complex sentences
Complex sentences are made from atomic sentences using connectives, examples:
S S1 S2 S1 S2 S1 S2 S1 S2
An atomic sentence predicate(term1,...,termn) is true iff the objects referred to by term1,...,termn are in the relation referred to by predicate
Slide: 14
Universal quantification
<variables> <sentence> Everyone at NUS is smart: x At(x,NUS) Smart(x) x P is true in a model m iff P is true with x being each possible object in the model Roughly speaking, equivalent to the conjunction of instantiations of P
... At(KingJohn,NUS) Smart(KingJohn) At(Richard,NUS) Smart(Richard) At(NUS,NUS) Smart(NUS)
Slide: 15
Slide: 16
Existential quantification
<variables> <sentence> Someone at NUS is smart: x At(x,NUS) Smart(x)$ x P is true in a model m iff P is true with x being some possible object in the model Roughly speaking, equivalent to the disjunction of instantiations of P
At(KingJohn,NUS) Smart(KingJohn) At(Richard,NUS) Smart(Richard) At(NUS,NUS) Smart(NUS) ...
Slide: 17
Slide: 18
Properties of quantifiers
x y is the same as y x x y is the same as y x x y is not the same as y x x y Loves(x,y) y x Loves(x,y)
There is a person who loves everyone in the world Everyone in the world is loved by at least one person
Quantifier duality: each can be expressed using the other x Likes(x,IceCream) x Likes(x,IceCream) x Likes(x,Broccoli) x Likes(x,Broccoli)
Slide: 19
Equality
term1 = term2 is true under a given interpretation if and only if term1 and term2 refer to the same object E.g., definition of Sibling in terms of Parent:
x,y Sibling(x,y) [(x = y) m,f (m = f) Parent(m,x) Parent(f,x) Parent(m,y) Parent(f,y)]
Slide: 20
Using FOL
The kinship domain:
Brothers are siblings
x,y Brother(x,y) Sibling(x,y)
Sibling is symmetric
x,y Sibling(x,y) Sibling(y,x)
Slide: 21
Slide: 22
Slide: 23
or mean exclusive or - XOR: X: Roman(X) or: X: Roman(X) [ (loyalto(X, Caesar) ^ hate(X, Caesar)) v (loyalto(X, Caesar) ^ hate(X, Caesar))] [ (loyalto(X, Caesar) v hate(X, Caesar)) ^ (loyalto(X, Caesar) ^ hate(X, Caesar))]
Slide: 24
Slide: 25
Slide: 26
Slide: 27
ruler(Caesar) (4)
Slide: 29
Slide: 30
Slide: 31
X: Pompeian(X) Caesar)
Artificial Intelligence: Predicate Logic
Slide: 32
Exception
Slide: 33
Slide: 34
Slide: 35
Slide: 37
Slide: 38
Slide: 39
Slide: 40
alive(Marcus, now) (9, Substitute) dead(Marcus, now) (10, Substitute) died(Marcus, T1) (5, Substitute) Pompeian(Marcus) gt(now, T1)
*s
(2)
Slide: 42
for any variable v and ground term g E.g., x King(x) Greedy(x) Evil(x) yields:
King(John) Greedy(John) Evil(John) King(Richard) Greedy(Richard) Evil(Richard) King(Father(John)) Greedy(Father(John)) Evil(Father(John))
. . .
Slide: 43
E.g., x Crown(x) OnHead(x,John) yields: Crown(C1) OnHead(C1,John) provided C1 is a new constant symbol, called a Skolem constant
Slide: 44
Slide: 45
Reduction contd.
Every FOL KB can be propositionalized so as to preserve entailment (A ground sentence is entailed by new KB iff entailed by original KB) Idea: propositionalize KB and query, apply resolution, return result Problem: with function symbols, there are infinitely many ground terms,
e.g., Father(Father(Father(John)))
Slide: 46
Resolution
Convert to clause form, example: All Romans who know Marcus either hate Caesar or think that anyone who hates anyone is crazy X: [roman(X) ^ know(X, Marcus)] [hate(X, Ceasar) v (Y: Z: hate(Y,Z) thinkcrazy(X,Y))]
Slide: 47
Resolution
1. Remove using the equivalence: a b = a v b
Slide: 48
Resolution
1. Remove using the equivalence: a
X:
b = a v b
= X:
Resolution
2. Move next to terms: Using the following equivalence:
a. Double negative: (p) = p b. DeMorgan: (a v b) = a ^ b (a ^ b) = a v b c. Equivalence of qualifiers : X: P(X) = X: P(X) X: P(X) = X: P(X)
Artificial Intelligence: Predicate Logic Slide: 50
Resolution
2. Move next to terms:
X: [roman(X) ^ know(X, Marcus)] v [hate(X, Ceasar) v (Y: (Z: hate(Y,Z)) v thinkcrazy(X,Y))]
=
X: [roman(X) v know(X, Marcus)]v [hate(X, Ceasar) v (Y: Z: hate(Y,Z) v thinkcrazy(X,Y))]
Artificial Intelligence: Predicate Logic Slide: 51
Resolution
3. Change name of variables as follows: X: P(X) v X: Q(X) = X: P(X) v Y: Q(Y)
Slide: 52
Resolution
4. Move qualifier to left, dont change the their order
X: [roman(X) v know(X, Marcus)]v [hate(X, Ceasar) v (Y: Z: hate(Y,Z) v thinkcrazy(X,Y))]
=
X:Y:Z: [roman(X) v know(X, Marcus)] v [hate(X, Ceasar) v (hate(Y,Z) v thinkcrazy(X,Y))]
Slide: 53
Resolution
5. Replace existence qualifier using Skolem function, as follows: Skolem Function: X: Y: Z : P(X,Y,Z) = X: Y: P(X,Y,f(X,Y))
Variable of existence qualifier = function of all the preceding variables in the every qualifier
Artificial Intelligence: Predicate Logic Slide: 54
Resolution
6. Remove every qualifiers (the default qualifier is every)
X:Y:Z: [roman(X) v know(X, Marcus)] v [hate(X, Ceasar) v (hate(Y,Z) v thinkcrazy(X,Y))]
=
[roman(X) v know(X, Marcus)] v [hate(X, Ceasar) v (hate(Y,Z) v thinkcrazy(X,Y))]
Artificial Intelligence: Predicate Logic Slide: 55
Resolution
7. Convert to CNF. Using distribution rule of v and ^ Examples:
(a ^ b) v c (a ^ b) v (c ^ d) = (a v c) ^ (b v c) = (a v c) ^ (a v d) ^ (b v c) ^ (b v d)
Slide: 56
Resolution
7. Convert to CNF.
[roman(X) v know(X, Marcus)] v [hate(X, Ceasar) v (hate(Y,Z) v thinkcrazy(X,Y))]
=
roman(X) v know(X, Marcus) v hate(X, Ceasar) v hate(Y,Z) v thinkcrazy(X,Y)
Slide: 57
Resolution
8. Separate clauses.
If having the clause form: (a v b) ^ (a v c v d) ^ (a v c v e) Then: 1. (a v b) 2. (a v c v d) 3. (a v c v e)
Slide: 58
Resolution
9. Add every qualifier to clause: That is: (X: P(X) ^ Q(X) ) = X: P(X) ^ X: Q(X)
Slide: 59
Resolution
Exercises: Convert to clause form for sentences in previous example. Convert to clause form for: 1. 2. 3. 4. 5. X A(X) v X B(X) XC(X) ^ X D(X) X (p(X) v q(X)) X p(X) v X q(X) X p(X) ^ X q(X) X(p(X) ^ q(X)) X Y p(X,Y) Y X p(X,Y) X (p(X, f(X)) p(X,Y))
Slide: 60
Slide: 61
Union of and
E is a expression then: E() = (E)
Slide: 62
Slide: 63
Slide: 64
Slide: 66
Slide: 67
Slide: 68
Slide: 69
1. Set K =0 and 0 = . Goto 2 2. Compute Sk . If it is a set having single element stop: mgu = k. Else Dk = dis-set(Sk). Goto 3. 3. If Dk contains variable V and a term t, and V is not in term t, Then compute k+1 = k {V/t} , set K = K + 1. Goto 2.
Artificial Intelligence: Predicate Logic Slide: 70
Slide: 71
L1 v ... v L k v C M 1 v ... v M n v D (C - N) v (D - N)
N = Li = Mj
Slide: 72
Slide: 74
or
Slide: 76
Proof
# Clauses Note P P P P P P P P P 5,9: X2= Marcus 3,10: X1 = Marcus
1 2 3 4 5 6 7 8 9
10 11
man(Marcus) Pompiean(Marcus) Pompiean(X1) v Roman(X1) Ruler(Caesar) Roman(X2) v loyalto(X2, Caesar) v hate(X2, Caesar) Loyalto(X3, f1(X3)) man(X4) v ruler(Y1) v tryassassinate(X4, Y1) v loyalto(X4, Y1) Tryassassinate(Marcus, Caesar) hate(Marcua, Ceasar). Roman(Marcus) v loyalto(Marcus, Caesar) Pompiean(Marcus) v loyalto(Marcus, Caesar)
Slide: 77
Proof
STT 12 13 14 15 16 Clauses loyalto(Marcus, Ceasar) Ghi ch 2,11: 12,7:X4=Marcus, y1=Ceasar 13,1 14,4 15,8
Slide: 78
Homeworks
Slide: 79
Exercises
You know:
All people living in PMH are rich. Rich people have much money People who work only in government sector (or called government staff) do not have much money. An is a government staff
Prove:
An does not live in PMH.
Artificial Intelligence: Predicate Logic Slide: 80