Pengantar Intelijensia buatan
Pertemuan 13
What’s wrong with Prepositional
Logic ??
Untuk menyelesaikan suatu permasalahan
kita membutuhkan banyak prepositional
logic. Banyak sekali…
Inti permasalahannya adalah bahwa
prepositional logic tidak bisa memodelkan
relasi.
Itulah sebabnya kita menggunakan FOL …
FOL (First Order Logic)
First Order logic adalah salah satu bentuk
knowledge representation language
First order logic memodelkan dunia
menjadi banyak
yang masing
masing memiliki
yang berbeda
dan relasi
yang mungkin ada
diantaranya yang bisa merupakan fungsi
FOL model
Object Bear Ranger property Relation Shoot BIG CunningFOL syntax
Constants
Bear, Ranger, bike,……
Predicates
Brother, >, Big , Cunning,…
Function
Sqrt(), Shoot(),…
Variable
x, y, a, b,….
Connectives
Equality
=
Quantifiers
,
,
,
,
,
Syntax and Semantic
<Sentence> := <AtomicSentence>
| <Sentence> <Connective> <Sentence> | <Quantifier> <Variable>,... <Sentence> | <Sentence>
| (<Sentence>)
<Atomic Sentence> := <Predicate>(<Term>,...)
| <Term> = <Term> <Term> := <Function>(<Term>,...) | <Constant> | <Variable> <Connective> := ^ | v | <=> | => <Quantifier> := |
<Constant> := Martin | 59302 | Cat | X | ... <Variable> := a | x | s | ...
<Predicate> := Before | Likes | Raining | Fails | ... <Function> := Father | Hairof | 304gradefor | ...
Atomic sentences
Atomic sentence = predicate (term
1,...,term
n)
or term
1= term
2Term =
function (term
1,...,term
n)
or constant or variable
Atomic sentence bernilai benar jika relasi yang
ditunjukkan oleh simbol predikat sesuai dengan obyek
yang ditunjukkan oleh argumen/term-nya.
E.g.,
Brother(KingJohn,RichardTheLionheart)
Complex sentences
Complex sentences dibuat dari gabungan
atomic sentences menggunakan
connectives
S, S
1S
2, S
1S
2, S
1S
2, S
1S
2,
E.g.
Sibling(KingJohn,Richard) Sibling(Richard,KingJohn) Brother(KingJohn,RichardTheLionheart) Married(FatherOf(Richard), MotherOf(KingJohn))) >(1,2) ≤ (1,2) >(1,2) >(1,2)Universal Quantifier
sentence
var
Semua mahasiswa maranatha pintar
)
(
)
,
(
,
Univ
x
maranatha
Smart
x
x
Pernyataan di atas dikatakan benar jika pernyataan tersebut benar
untuk semua kemungkinan x yang ada.,atau dengan kata lain pernyataan diatas ekivalent dengan gabungan semua pernyataan dengan instansiasi x
...
)
(
)
,
(
)
(
)
,
(
)
(
)
,
(
C
Smart
maranatha
C
Univ
B
Smart
maranatha
B
Univ
A
Smart
maranatha
A
Univ
Common mistakes
Biasanya
adalah penghubung yang umumnya
digunakan untuk
Kesalahan umum yang perlu dihindari
adalah menggunakan dengan :
Contoh :
x Univ(x,maranatha) Smart (x)
Jadi memiliki arti semua orang beruniversitas di
maranatha dan semua orang pintar
Existential quantifier
sentence
var
Ada mahasiswa maranatha yang pintar
)
(
)^
,
(
,
Univ
x
maranatha
Smart
x
x
Pernyataan di atas dikatakan benar jika pernyataan tersebut benar untuk minimal 1 kemungkinan x yang ada
...
)
(
)
,
(
)
(
)
,
(
)
(
)
,
(
C
Smart
maranatha
C
Univ
B
Smart
maranatha
B
Univ
A
Smart
maranatha
A
Univ
Common mistakes
Biasanya
adalah penghubung yang
umumnya digunakan untuk
Kesalahan umum yang perlu dihindari adalah
menggunakan
dengan
:
Misalnya:
x Univ (x, Maranatha)
Smart (x)
yang benar bahkan jika ada seseorang yang
tidak berkuliah di Maranatha
FOL Sentences
Semua bebek bisa berenang
A baby toy is a toy played by a baby
Ada Tanaman yang berduri
Penguins are birds that can not fly
x Tanaman(x)
^ Berduri(x)
x Penguin(x)
bird(x) fly(x)
x bebek(x)
berenang(x)
Exercise (1)
Kucing adalah mamalia
◦
x. Kucing(x) Mamalia(x)
SBY adalah pejabat tinggi di suatu negara
◦
x. PejabatTinggi(SBY) ^ Negara(x)
Setiap orang mencintai seseorang
◦
x y. Mencintai(x, y)
Seorang cucu adalah anaknya dari anak
◦
x y. x = Cucu(y) z. x = Anaknya(z) ^ z =
Anaknya(y)
Exercise (II)
Tidak ada seorangpun yang mencintai Udin
◦
x. Mencintai(x, Udin)
◦
x. Mencintai(x, Udin)
Semua orang memiliki ayah
◦
x y. Ayah(y, x)
Semua orang memiliki ayah dan ibu
◦
x y z. Ayah(y, x) ^ Ibu(z, x)
Siapapun yang memiliki ayah pasti memiliki
ibu
Terminological fact
Disjointness : menyatakan satu predikat menegasikan predikat yg lain
e.g. x Man (x) Woman (x)
Subtypes: specialization
e.g. x Surgeon (x) Doctor (x)
Exhaustiveness:
e.g. x Adult(x) (Man (x) Woman (x))
Symmetry:
e.g. x, y Sibling (x, y) Sibling (y, x)
Inverse:
e.g. x, y ChildOf (x, y) ParentOf (y, x)
Type Restrictions:
How to infer fact in KB ??
Menggunakan
◦
Modus ponens,
◦
And-elimination,
◦
And-introduction,
◦
Or-introduction,
◦
Resolution.
Bagaimana dengan quantifier ?
, , i n a a a a a1 2 3 ... n i a a a a a ... 3 2 1 n n a a a a a a a a ... ,..., , , 3 2 1 3 2 1 , ,
Additional rules
SUBST{Ө,α}
substitute Ө to sentence α
◦
ex : subs {(x/Sam,y/Pam),likes(x,y)}
Likes(Sam,Pam)
Untuk menangani quantifier, kita
Additional rules (1)
Universal elimination :
)
,
(
,
likes
x
IceCream
x
}
/
{
x
Ben
}
),
/
{(
,
g
v
SUBST
v
)
,
(
Ben
IceCream
likes
Additional rule (2)
Existential elimination:
)
,
(
,
Kill
x
victim
x
}
/
{
x
Ben
}
),
/
{(
,
k
v
SUBST
v
)
,
(
Ben
victim
Kills
Additional rule (3)
Existential introduction:
}
),
/
{(
,
SUBST
g
v
v
)
,
(
,
likes
x
IceCream
x
)
,
(
Ben
IceCream
likes
An example proof
The law says that it is a crime for an American
to sell weapon to hostile nations.
The Nation nono , an enemy of America, has
some missiles,and all of its missile were sold to
it by colonel west, who is an American
Who is the criminal ?
West is a criminal …
Example proof(2)
It is a crime for an American to sell weapons to
hostile nation
)
Criminal(x
z)
y,
Sells(x,
Hostile(z)
Nation(z)
Weapon(y)
)
American(x
z,
y,
x,
Example proof(3)
Nono… has some missile
x)
Owns(Nono,
Missile(x)
x,
Example proof(4)
All of its missile were sold to it by colonel west
x)
Nono,
,
Sells(West
x)
Owns(Nono,
Missile(x)
x,
Example proof(5)
Missile are weapons
Weapon(x)
Missile(x)
Example proof(6)
Enemy of America counts as hostile.
Hostile(x)
America)
Enemy(x,
x,
Example proof(7)
West is an american .
est)
American(W
Nono is a country
no)
Country(No
Example proof(7)
Nono is an enemy of America:
America)
,
Enemy(Nono
America is a country:
erica)
Country(Am
Example proof(8) –
The Complete KB and Facts
)
Criminal(x
z)
y,
Sells(x,
Hostile(z)
Nation(z)
Weapon(y)
)
American(x
z,
y,
x,
x)
Owns(Nono,
Missile(x)
x,
x)
Nono,
,
Sells(West
x)
Owns(Nono,
Missile(x)
x,
Weapon(x)
Missile(x)
x,
Hostile(x)
America)
Enemy(x,
x,
est)
American(W
no)
Country(No
America)
,
Enemy(Nono
erica)
Country(Am
1 2 3 4 5 6 8 9 7Inference
1.
Existential elimination (rule 4)
)
,
(
)
(
,
Missile
x
Owns
Nono
x
x
)
1
,
(
)
1
(
M
Owns
Nono
M
Missile
Inference
2.
And elimination (slide inference 1)
)
1
,
(
)
1
(
M
Owns
Nono
M
Missile
)
1
(M
Missile
)
1
,
(
Nono
M
Owns
Inference
3.
Universal elimination (rule 2)
)
(
)
(
,
Missile
x
Weapon
x
x
)
1
(
)
1
(
M
Weapon
M
Missile
Inference
4.
Modus Ponens (slide inference 2 dan 3)
)
1
(M
Weapon
)
1
(M
Missile
)
1
(
)
1
(
M
Weapon
M
Missile
Inference
5.
Universal elimination (rule 6 dan slide inference 2)
)
,
,
(
)
,
(
)
(
,
x
Nono
West
Sells
x
Nono
Owns
x
Missile
x
)
,Nono,M
Sells(West
)
M
Owns(Nono,
)
Missile(M
1
1
1
Inference
6.
Modus Ponens (slide inference 1 dan 5)
M1)
Owns(Nono,
)
Missile(M1
M1)
Nono,
,
Sells(West
M1)
Owns(Nono,
)
Missile(M1
)
1
,
,
(
West
Nono
M
Sells
Inference
7.
Universal elimination (rule 1, inf. slide 4, rule 9, inf. slide 6)
)
Criminal(x
z)
y,
Sells(x,
Hostile(z)
Country(z)
weapon(y)
)
American(x
z,
y,
x,
est)
Criminal(W
M1)
Nono,
,
Sells(West
no)
Hostile(No
no)
Country(No
Weapon(M1)
est)
American(W
Inference
8.
Universal elimination (rule 6 dan 9)
)
(
)
,
(
,
Enemy
x
America
Hostile
x
x
)
(
)
,
(
Nono
America
Hostile
Nono
Enemy
Inference
9.
Modus Ponens (rule 7 dan inf. slide 8)
)
,
(
Nono
America
Enemy
)
(
)
,
(
Nono
America
Hostile
Nono
Enemy
)
(Nono
Inference
10.
And introduction (semua fakta untuk rule premis 1
tersedia)
)
1
,
,
(
West
Nono
M
Sells
)
(nono
Hostile
Weapon(M1)
)
(West
American
Country
(nono
)
)
1
,
,
(
)
(
)
(
)
1
(
)
(
M
Nono
West
Sells
Nono
Hostile
Nono
Country
M
Weapon
West
American
Inference
11.
Modus Ponens (inf. slide 10 dan consequence rule 1)
) Criminal(x z) y, Sells(x, Hostile(z) Country(z) Weapon(y) ) American(x z, y, x,
)
,Nono,M
Sells(West
no)
Hostile(No
no)
Country(No
)
Weapon(M
est)
American(W
1
1
est)
Criminal(W
Subs(x \ West)
Problems FOL ??
Semakin besar knowledge base maka semakin besar
branching factor, dan mengakibatkan inferensi semakin
rumit
Universal elimination sendiri memiliki branching factor yang
sangat besar, karena kita bisa mengganti variable dengan
semua nilai yang mungkin
Kita menghabiskan waktu mengabungkan atomic sentence
dalam bentuk conjunction, universal elimination dan modus
ponens terus menerus
Sistem Pakar Investasi (1)
Knowledge Base: 1. jumlah_tabungan(mencukupi) investasi(menabung) 2. jumlah_tabungan(mencukupi) ^ penghasilan(memadai) investasi(stok) 3. jumlah_tabungan(mencukupi) ^ penghasilan(memadai) investasi(kombinasi) 4. X saldo_tabungan(X) ^ Y (jumlah_tertanggung(Y) ^ lebih_besar(X, minimal_tabungan(Y))) jumlah_tabungan(mencukupi) 5. X saldo_tabungan(X) ^ Y (jumlah_tertanggung(Y) ^ lebih_besar(X, minimal_tabungan(Y))) jumlah_tabungan(mencukupi)6. X pendapatan(X, tetap) ^ Y (jumlah_tertanggung(Y) ^
lebih_besar(X, minimal_penghasilan(Y))) penghasilan(memadai)
Sistem Pakar Investasi (II)
7. X pendapatan(X, tetap) ^ Y (jumlah_tertanggung(Y) ^
lebih_besar(X, minimal_penghasilan(Y))) penghasilan(memadai)
8. X pendapatan(X, tetap) penghasilan(memadai) 9. minimal_tabungan(X) = 5000 * X, dimana X = jumlah
tertanggung
10. minimal_penghasilan = 15000 + (4000 * X), dimana X = jumlah
tertanggung Facts:
1. saldo_tabungan(22000) 2. pendapatan(25000, tetap) 3. jumlah_tertanggung(3)
Sistem Pakar Investasi (III) - SOAL
Terjemahkan setiap aturan dan fakta pada
slide sebelumnya menjadi kalimat biasa
Lakukan inferensi untuk mencari jenis
investasi sesuai dengan basis pengetahuan di
atas:
a. Unifikasikan fakta nomor 2 dan 3 dengan aturan nomor 7.
b. Gunakan modus ponens dari a. untuk membentuk fakta baru.
c. Unifikasikan fakta nomor 1 dan 3 dengan aturan nomor 4.
d. Gunakan modus ponens dari c. untuk membentuk fakta baru.
e. Simpulkan jenis investasi apakah yang harus dilakukan ? Aturan nomor 1, 2 atau 3 ?