Matakuliah
Tahun
Versi
: T0264/Inteligensia Semu
: Juli 2006
:2/2
Pertemuan 7
Using Predicate logic
continue….
1
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa
akan mampu :
• << TIK-99 >>
• << TIK-99>>
2
Outline Materi
•
•
•
•
•
Materi 1
Materi 2
Materi 3
Materi 4
Materi 5
3
5.4 Resolution
• PENGERTIAN
RESOLUSI merupakan teknik pembuktian
yang lebih efisien, karena fakta-fakta akan
diubah terlebih dulu kebentuk KLAUSA.
Pembuktian kebenaran suatu pernyataan
dilakukan dengan cara menegasikan
pernyataan tersebut, kemudian dicari
kontradiksi dari pernyataan-pernyataan
yang sudah ada.
4
5.4.1 Conversion to Clause Form
Algorithm : Convert to Clause Form
1. Eliminate ,using : a b= a b.
2. Reduce the scope of each to a single term,
using :
(p) = p
de morgan’s laws : (ab) = a b
(ab) = a b
x : P(x) =x : P(x)
x : P(x) = x : P(x)
3. Standardize variables.
4. Move all quantifiers to the left of the formula
without changing their relative order.
5
Algorithm : Convert to Clause Form
5. Eliminate existential quantifiers by inserting
Skolem functions.
6. Drop the prefix.
7. Convert the matrix into a conjuction of disjuncts,
using associativity and distributivity.
8. Create a separate clause for each conjuct.
9. Standardize the variables in the set of clauses
generated in step 8, using the fact that
(x ; P(x)Q(x)) = x :P(x) x : Q(x)
6
Contoh 1 : KONVERSI KE BENTUK KLAUSA
Pernyataan “ Setiap orang yang mengenal
Hitler, maka ia akan menyukainya atau
berfikir bahwa orang yang membunuh
orang lain itu gila”
Bentuk wff kalimat tersebut adalah :
x : [orang(x) kenal(x,Hitler)]
[suka(x,Hitler) (y:z: bunuh(y,z)
gila(x,y)]
7
PENERAPAN ALGORITMA
x : [orang(x) kenal(x,Hitler)]
[suka(x,Hitler) (y:z: bunuh(y,z) gila(x,y)]
2. x : [orang(x) kenal(x,Hitler)]
[suka(x,Hitler) (y: (z: bunuh(y,z)) gila(x,y))]
1.
3.
4.
5.
6.
7.
8.
9.
Sudah sesuai
x : y : z : [orang(x) kenal(x,Hitler)]
[suka(x,Hitler) (bunuh(y,z)) gila(x,y)]
Sudah sesuai
[orang(x) kenal(x,Hitler)] [suka(x,Hitler)
(bunuh(y,z)) gila(x,y)]
orang(x) kenal(x,Hitler) suka(x,Hitler)
bunuh(y,z) gila(x,y)
Sudah sesuai
Sudah sesuai
8
Examples 2 : Conversion to Clause Form
• Suppose we know that all Romans who know Marcus
either hate Caesar or think that anyone who hates
anyone is crazy.
• Represent these sentences to wff form :
x : [Roman(x) know(x,Marcus)]
[hate(x,Caesar) (y :z : hate(y,z) thinkcrazy(x,y))]
• Algorithm applications
1. Eliminate
x :[Roman(x)know(x,Marcus)]
[hate(x,Caesar) (y : (z : hate(y,z)) thinkcrazy(x,y))]
2. Reduce scope of
x :Roman(x) know(x,Marcus)] [hate(x,Caesar)
(y : z : hate(y,z) thinkcrazy(x,y))]
9
Examples of Conversion to Clause Form
3. Standardize variables.
x : P(x) x : Q(x)
will be convert to
x : P(x) y : Q(y)
4. Move quantifiers.
x : y : z :[Roman(x) know(x,Marcus)]
[hate(x,Caesar) (hate(y,z) thinkcrazy(x,y))]
5. Eliminate existential quantifiers.
y : President(y)
will be convert to
President(S1)
while
x : y : father-of(y,x)
will be converted to
x : father-of(S2(x),x)
10
Examples of Conversion to Clause Form
6. Drop the prefix.
[Roman(x) know(x,Marcus)]
[hate(x,Caesar)
(hate(y,z) thinkcrazy(x,y))]
7. Convert to a conjuction of disjuncts.
Roman(x) know(x,Marcus) hate(x,Caesar)
hate(y,z) thinkcrazy(x,y)
11
Formula of Conversion to Clause Form
• Problem :
x:[Roman(x)know(x,Marcus)]
[hate(x,Caesar)
(y:z:hate(y,z)thinkcrazy(x,y)]
• Solution :
Flatten
Separate out quantifiers
• Conjunctive Normal Form :
Roman(x)know(x,Marcus)
hate(x,Caesar) hate(y,z)
thinkcrazy(x,z)
• Clause Form is defined to be a wff in Conjunctive
Normal Form but with no instances of conector of
12
5.4.2 The Basis of Resolution
Resolusi adalah proses iterasi yang sederhana. Pada
setiap
langkah, 2 klausa yang disebut sebagai klausa parent
dibandingkan (resolve) dengan dan menghasilkan
klausa
baru (resolvent).
Andaikan ada 2 klausa sbb :
winter summer
winter cold
Antara winter dan winter salah satu pasti bernilai
benar, maka klausa baru adalah :
summer cold
13
5.4.3 Resolution in Propositional Logic
A Few Facts in Propositional Logic
Given Axioms
Clause Form
P
P
(1)
(P Q)R
P Q R
(2)
(S T)Q
S Q
(3)
T Q
(4)
T
(5)
T
14
Resolution in Propositional Logic
15
5.4.4 The Unification Algorithm
Algorithm : Unify(L1,L2)
1.
If L1 or L2 are both variables or constant, then :
(a) If L1 and L2 is a variable, then return NIL.
(b) Else if L1 is a variable, then if L1 occurs in L2 then
return {FAIL} else return(L2/L1).
(c) Else if L2 is a variable, then if L2 occurs in L1 then
return {FAIL} else return(L1/L2).
(d) Else return {FAIL}.
2. If the initial predictive symbols in L1 and L2 are not
identical, then return {FAIL}.
3. IF L1 and L2 have a different number of arguments,
then return {FAIL}
4. Set SUBST to NIL. (At the end of this procedure,
SUBST will contain all the substitutions used to unify
L1 and L2.
16
The Unification Algorithm
5. For i 1 to number of arguments in L1 :
(a) Call Unify with the ith argument of L1
and
the ith argument of L2, putting result in S.
(b) If S contains FAIL then return {FAIL}
(c) If S is not equal to NIL then :
i) Apply S to the remainder of both L1 and L2
ii) SUBST := APPEND(S,SUBST).
6. Return SUBST.
17
The Unification Algorithm
Q(x)
P(x)
FAIL
P(x)
P(y)
x/y
P(Marcus)
P(y)
Marcus/y
P(Marcus)
P(Julius)
FAIL
P(x,x)
P(y,z)
(y/x)
P(y,y)
(z/y)(y/x)
18
Finding General Substitution
Given :
hate(x,y)
hate(Marcus,z)
We could produce :
(Marcus/x, z/y)
(Marcus/x, y/z)
(Marcus/x, Caesar/y, Caesar/z)
(Marcus/x, Polonius/y, Polonius/z)
19
5.4.5 Resolution in Predicate Logic
• Cara yang mudah untuk menentukan bahwa
dua pernyataan dikatakan kontradiksi adalah
jika salah satu dari pernyataan tersebut dapat
dijadikan sebagai negasinya.
• Dalam hal penggunaan resolusi untuk ekspresi
dalam predicate logic, maka digunakan
algoritma unifikasi untuk meletakan pasangan
dari pernyataan yang dapat ditolak (cancel).
20
Resolution in Predicate Logic
Copntoh :
1. man(Marcus)
2. man(x1) mortal(x1)
Dengan substitusi :
Marcus/x1
Tidak menghasilkan resolvent :
mortal(x1)
Aplikasi proses unifikasi terhadap resolvent dihasilkan :
mortal(Marcus)
21
Algorithm : Resolution
1. Convert all the proposition of F to clause form.
2. Negate P and convert the result to clause form.
Add it to the set of clause in step
3. Repeat until either a contradiction is found or no
progress can be made,or a predetermined
amount of effort has been expended.
a. Select two clause. Call these the parent
clauses.
22
Algorithm : Resolution
b. Resolve them together. The resolvent will be the
disjunction of all of the literals of both parent
clauses with appropriate substitutions performed
and with the following exception: If there is one
pairs of literals T1 and T2 such
that one of
the parent clauses contains T1 and the other
contains T2 and if T1 and T2 are
unifiable,then neither T1 nor T2 should appear
in the resolvent.If there is more than one pair of
complementary literals,only one pair should be
ommitted from the resolvent.
23
Algorithm : Resolution
c. If the resolvent is the empty clause, then a
contradiction has been found. If it is not, then
add it to the set of clause available to the
procedure.
24
Contoh Resolusi Pada Predicate Logic
Pernyataan-pernyataan dalam bentuk klausa :
1. mahasiswa (Chandra)
2. Informatika (Chandra)
3. informatika(x1) v Fasilkom(x1)
4. sulit(Algoritma)
5. Fasilkom(x2) v suka(x2,Algoritma) v
benci(x2,Algoritma)
6. suka(x3,f(x3))
7. mahasiswa(x4) v sulit(y1) v hadir(x4,y1) v
suka(x4,y1)
8. hadir(Chandra,Algoritma)
25
Buktikan apakah Chnadra benci Algoritma
dengan Resolusi
benci(Chandra,Algoritma)
5
Chandra/x2
3
Fasilkom(Chandra) v suka(Chandra,Algoritma)
Chandra/x1
2
Informatika(Chandra) v suka(Chandra,Algoritma)
7
suka(Chandra,Algoritma)
Chandra/x4 ; Algoritma/y1
1
mahasiswa(Chandra) v sulit(Algoritma) v hadir(Chandra,Algoritma)
sulit(Algoritma) v hadir(Chandra,Algoritma)
hadir(chandra,Algoritma)
4
8
null
26
5.4.6 The Need to Try Several Substitutions
•
•
•
Resolusi merupakan metoda sangat bagus
untuk membuktikan tanpa harus mencoba
semua substitusi. Tetapi hal ini tidak selalu
dengan melakukan eliminasi terhadap satu
atau lebih substitusi.
Sebagai contoh :
a) benci(Chandra,Joni)
b) benci(Chandra,Juli)
Jika ingin dibuktikan bahwa Chandra
membenci berbagai aturan, maka akan
dicoba semua substitusi (a) dan (b) sebelum
mendapatkan kontradiksinya.
27
5.4.7. Question Answering
Perhatikan pernyatan-pernyataan dalam bentuk KLAUSA
berikut ini :
1. laki-laki(Mangun)
2. Jawa(Mangun)
3. lahir(Mangun,1840)
4. man(x1) v mortal(x1)
5. Jawa(x2) v mati(x2,1879)
6. meletus(Merapi,1879)
7. pastimati(x3) v lahir(x3,t1) v lb(t2 – t1,150) v
mati(x3,t2)
8. Sekarang = 2006
9a. hidup(x4,t3) v mati(x4,t3)
9b. Mati(x5,t4) v hidup(x5,t4)
10. mati(x6,t5) v lb(t6,t5) v mati(x6,t6)
28
Question Answering
•
Bagaimana teknik resolusi dapat digunakan
untuk menjawab YA atau TIDAK dari pertanyaan
yang diberikan seperti :
Apakah Mangun masih hidup ?
mati(Mangun, ??)
Bisa dibuktikan juga untuk pertanyaan :
Kapan Mangun mati ?
mati(Mangaun,1879)
29
Ekstraksi Jawaban Menggunakan Resolusi
t : mati(Mangun,t) mati(Mangun,t)
Jawa(x1) V mati(x1,1879)
mati(Mangun,t)
1879/t,Mangun/x1
Jawa(Mangun)
Jawa(Mangun)
30
Ekstraksi Jawaban Menggunakan Resolusi
Jawa(x1) V mati(x1,1879)
mati(Mangun,t) V mati(Mangun,t)
1879/t,Mangun/x1
Jawa(Mangun) V mati(Mangun,1879)
Jawa(Mangun)
mati(Mangun,1879)
31
5.5 Natural Deduction
Resolusi dapat diimplementasikan sebagai prosedur
pembuktian untuk representasi yang uniform.
Contoh :
x : judge(x) crooked(x) educated(x)
Bentuk KLAUSA :
judge(x) v crooked(x) v educated(x)
Untuk membuktikan seseorang not judge dengan
membuktikan not crooked dan not educated.
Pembuktian menggunakan human theorem proving
dan didefinisikan sebagai natural deduction.
32
<< CLOSING>>
End of Pertemuan 7
Good Luck
33
© Copyright 2025 Paperzz