• Tidak ada hasil yang ditemukan

Inference First Order Logic

N/A
N/A
Protected

Academic year: 2021

Membagikan "Inference First Order Logic"

Copied!
44
0
0

Teks penuh

(1)

Inference First Order Logic

Chastine Fatichah

Teknik Informatika

Institut Teknologi Sepuluh Nopember

(2)

Pokok Bahasan

Mengubah First Order Logic ke Propotional

Logic

Unification

Generalized Modus Ponens

Forward chaining

Backward chaining

Resolution

(3)

Sejarah Reasoning

450b.c.

Stoics

propositional logic,

inference

322b.c.

Aristotle

“syllogisms" (inference rules), quantifiers

1565

Cardano

probability theory (propositional logic +

uncertainty)

1847

Boole

propositional logic (again)

1879

Frege

logic

1922

Wittgenstein

proof by truth tables

1930

Gӧdel

 complete algorithm for FOL

1930

Herbrand

complete algorithm for FOL (reduce to

propositional)

1931

Gӧdel

 complete algorithm for arithmetic

(4)

Pokok Bahasan

Mengubah First Order Logic ke Propotional

Logic

Unification

Generalized Modus Ponens

Forward chaining

Backward chaining

Resolution

(5)

Universal instantiation (UI)

Semua kalimat dengan universal quantifier (

) meng-entail

semua instantiation-nya:

v

α

Subst({v/g}, α)

untuk sembarang variabel v and ground term g

x King(x)

Greedy(x)

Evil(x) meng-entail:

King(John) 

Greedy(John)

Evil(John)

King(Richard) 

Greedy(Richard)

Evil(Richard)

Contoh

(6)

Existential instantiation (EI)

Untuk sembarang kalimat α, variabel v, and konstanta k

yang tidak muncul di knowledge-base:

v

α

Subst({v/k}, α)

x Crown(x) 

OnHead(x,John) meng-entail:

Crown(C

1

)

OnHead(C

1

,John)

Dengan syarat C

1

adalah konstanta baru, disebut konstanta

Skolem

(7)

Existential instantiation (EI)

Universal instantiation bisa digunakan

berkali-kali

untuk menambahkan kalimat baru.

KB yang baru logically equivalent dengan yang

lama.

Existential instantiation cukup digunakan

sekali

untuk menggantikan kalimat existential.

KB yang baru

tidak

logically equivalent dengan

yang lama, tetapi satisfiable iff KB yang lama

juga satisfiable  inferentially equivalent

(8)

Mengubah ke Propositional Inference

Misalkan KB berisi kalimat-kalimat berikut:

Dan jika kita mengambil semua kemungkinan instantiation dari kalimat

universal, maka kita dapatkan KB sbb:

KB yang baru disebut

propositionalized

: proposition symbolnya adalah:

King(John), Greedy(John), Evil(John), King(Richard), dll.

x King(x)

Greedy(x)

Evil(x)

King(John)

Greedy(John)

Brother(Richard,John)

King(John)

Greedy(John)

Evil(John)

King(Richard)

Greedy(Richard)

Evil(Richard)

King(John)

Greedy(John)

(9)

Mengubah ke Propositional

Inference

Klaim : Setiap FOL KB dapat di propositional kan

sebagai entailment

Klaim: Kalimat ground di entail dengan KB baru jika dan

hanya jika entail terhadap original KB

Idea: propositionalize KB dan query, lalu gunakan

resolution

Problem: dengan adanya

function

, ground terms menjadi

infinite

.

(10)

Masalah dengan propositionalization

Propositionalization

menghasilkan banyak kalimat irrelevant.

Contoh:

x King(x)

Greedy(x)

Evil(x)

King(John)

y Greedy(y)

Brother(Richard,John)

manusia bisa cepat mengerti kalau Evil(John), namun

propositionalization menghasilkan:

King(Richard)

Greedy(Richard)

Evil(Richard)

Greedy(Richard)

yang irrelevant

(11)

Pokok Bahasan

Mengubah First Order Logic ke Propotional

Logic

Unification

Generalized Modus Ponens

Forward chaining

Backward chaining

Resolution

(12)

Unification

Inference : Substitution θ sedemikian hingga

King(x)

dan

Greedy(x)

cocok dengan

King(John)

dan

Greedy(y)

θ = {x/John,y/John}

Unify(α,β) = θ jika αθ = βθ

p

q

θ

Knows(John,x) Knows(John,Jane)

Knows(John,x) Knows(y,OJ)

Knows(John,x) Knows(y,Mother(y))

Knows(John,x) Knows(x,OJ)

(13)

Unification

Inference : Substitution θ sedemikian hingga

King(x)

dan

Greedy(x)

cocok dengan

King(John)

dan

Greedy(y)

θ = {x/John,y/John}

Unify(α,β) = θ jika αθ = βθ

p

q

θ

Knows(John,x) Knows(John,Jane)

{x/Jane}}

Knows(John,x) Knows(y,OJ)

Knows(John,x) Knows(y,Mother(y))

Knows(John,x) Knows(x,OJ)

(14)

Unification

Inference : Substitution θ sedemikian hingga

King(x)

dan

Greedy(x)

cocok dengan

King(John)

dan

Greedy(y)

θ = {x/John,y/John}

Unify(α,β) = θ jika αθ = βθ

p

q

θ

Knows(John,x) Knows(John,Jane)

{x/Jane}}

Knows(John,x) Knows(y,OJ)

{x/OJ,y/John}}

Knows(John,x) Knows(y,Mother(y))

Knows(John,x) Knows(x,OJ)

(15)

Unification

Inference : Substitution θ sedemikian hingga

King(x)

dan

Greedy(x)

cocok dengan

King(John)

dan

Greedy(y)

θ = {x/John,y/John}

Unify(α,β) = θ jika αθ = βθ

p

q

θ

Knows(John,x) Knows(John,Jane)

{x/Jane}}

Knows(John,x) Knows(y,OJ)

{x/OJ,y/John}}

Knows(John,x) Knows(y,Mother(y))

{y/John,x/Mother(John)}}

(16)

Unification

Inference : Substitution θ sedemikian hingga

King(x)

dan

Greedy(x)

cocok dengan

King(John)

dan

Greedy(y)

θ = {x/John,y/John}

Unify(α,β) = θ jika αθ = βθ

p

q

θ

Knows(John,x) Knows(John,Jane)

{x/Jane}}

Knows(John,x) Knows(y,OJ)

{x/OJ,y/John}}

Knows(John,x) Knows(y,Mother(y))

{y/John,x/Mother(John)}}

Knows(John,x) Knows(x,OJ)

{fail}

• Standardizing apart

variable menghilangkan overlap, contoh

(17)

Pokok Bahasan

Mengubah First Order Logic ke Propotional

Logic

Unification

Generalized Modus Ponens

Forward chaining

Backward chaining

Resolution

(18)

Generalized Modus Ponens

(GMP)

p

1

' is King(John)

p

1

is King(x)

p

2

' is Greedy(y)

p

2

is Greedy(x)

θ is {x/John,y/John}

q is Evil(x)

q θ is Evil(John)

GMP dengan KB yang berisi

definite clauses:

p

1

p

2

p

n

q

Semua variabel diasumsikan

universally quantified

p

1

', p

2

', … , p

n

', ( p

1

 p

2

 …  p

n

 q)

dimana p

i

'θ = p

i

θ untuk semua i

Inference Rule GMP

(19)

Soundness pada GMP

Perlu menunjukkan bahwa

p

1

', …, p

n

', (p

1

p

n

q) ╞ qθ

dimana

p

i

'θ = p

i

θ

untuk semua i

Lemma: Untuk setiap definite clause p, terdapat

p ╞ pθ

dengan Universal instantiation (UI)

1.

(p

1

p

n

q) ╞ (p

1

p

n

q)θ = (p

1

θ

p

n

θ

qθ)

2.

p

1

', …, p

n

' ╞ p

1

'

p

n

' ╞ p

1

p

n

(20)

Contoh Knowledge Base

Buktikan bahwa Colonel West is a criminal !!

“ The law says that it is a crime for an American to sell weapons to

hostile nations. The country Nono, an enemy of America, has

some missiles, and all of its missiles were sold to it by Colonel

West, who is American. “

(21)

Contoh Knowledge Base

... it is a crime for an American to sell weapons to hostile nations:

American(x)

Weapon(y)

Sells(x,y,z)

Hostile(z)

Criminal(x)

Nono … has some missiles:

x Owns(Nono,x)

Missile(x):

Owns(Nono,M

1

) and Missile(M

1

)

… all of its missiles were sold to it by Colonel West

Missile(x)

Owns(Nono,x)

Sells(West,x,Nono)

Missiles are weapons:

Missile(x)

Weapon(x)

An enemy of America counts as "hostile“:

Enemy(x,America)

Hostile(x)

West, who is American …

(22)

Pokok Bahasan

Mengubah First Order Logic ke Propotional

Logic

Unification

Generalized Modus Ponens

Forward chaining

Backward chaining

Resolution

(23)

Forward chaining FOL

dengan GMP

(24)
(25)
(26)
(27)

Forward chaining properti

Sound dan complete untuk first-order definite clauses

Datalog

= first-order definite clauses + tanpa function

Time complexity FC pada Datalog  polynomial

Tapi pada kasus umum, bisa infinite loop kalau tidak

di-entail.

(28)

Pokok Bahasan

Mengubah First Order Logic ke Propotional

Logic

Unification

Generalized Modus Ponens

Forward chaining

Backward chaining

Resolution

(29)

Algoritma backward chaining

Backward chaining FOL

dengan GMP

(30)
(31)
(32)
(33)
(34)
(35)
(36)
(37)
(38)

Backward chaining properti

Depth-first search:

linear space complexity

incomplete (infinite loops)

i

nefficient (repeated subgoals)

(39)

Logic programming: Prolog

Logic programming

Ordinary programming

1. Identify problem

Identify problem

2. Assemble information

Assemble information

3. Tea break

Figure out solution

4. Encode information in KB

Program solution

5. Encode problem instance as facts

Encode problem instance as data

6. Ask queries

Apply program to data

7. Find false facts

Debug procedural errors

(40)

Prolog

• Appending two lists to produce a third:

append([],Y,Y).

append([X|L],Y,[X|Z]) :- append(L,Y,Z).

• query:

append(A,B,[1,2]) ?

• answers:

A=[] B=[1,2]

A=[1] B=[2]

A=[1,2] B=[]

(41)

Konversi ke CNF

• Everyone who loves all animals is loved by

someone:

x [

y Animal(y)

Loves(x,y)]

[

y Loves(y,x)]

• 1. Eliminasi biconditionals dan implikasi

x [



y

Animal(y)

Loves(x,y)]

[

y Loves(y,x)]

• 2. Pindah  inwards: x p ≡ x p,  x p ≡

x p

x [

y

(

Animal(y)

Loves(x,y))]

[

y Loves(y,x)]

(42)

Konversi ke CNF.

3.

Standarisasi variabel:

x [

y Animal(y)

Loves(x,y)]

[

z Loves(z,x)]

4.

Skolemize: bentuk umum pada existential instantiation.

Setiap variabel existential diganti dengan

Skolem function

pada universally

quantified variables:

x [Animal(F(x))

Loves(x,F(x))]

Loves(G(x),x)

5.

Hapus semua universal quantifiers:

[Animal(F(x))

Loves(x,F(x))]

Loves(G(x),x)

6.

Distribusi  over  :

(43)
(44)

Sumber :

1.Slide perkuliahan Stuart Russell's (Berkeley)

http://aima.cs.berkeley.edu/

2.Slide perkuliahan Sistem Cerdas Ruli Manurung (Universitas Indonesia)

Referensi

Dokumen terkait

Dalam kaitannya dengan metode pengajaran dalam pendidikan Islam, dapat di- katakan pembiasaan adalah sebuah cara yang dapat dilakukan untuk membiasakan anak didik

Di dalam proses kampanye mereka diharuskan untuk menggunakan strategi yang tepat, memaksimalkan sumber daya politik yang ada, dan menyiasati menguatnya praktik patronase

Pemenuhan HAM adalah salah satu indikator sebuah Negara Hukum, Indonesia se- bagai Negara hukum mengamanatkan didalam batang tubuh UUD NRI 1945 tentang

Silabus Seleksi Olimpiade Sains Nasional Bidang Informatika/Komputer halaman 4 Di tingkat propinsi pada dasarnya sama dengan di tingkat kabupaten/kota kecuali komposisi

Jika dibandingkan secara makro dengan Provinsi Papua, perkembangan Kabupaten Jayapura setelah pemekaran memiliki kecenderungan yang positif jika dari aspek ekonomi, sosial penduduk,

Beberapa yang termasuk jenis paper engineering adalah pop up (pada halaman terdapat lipatan kertas atau potongan yang dapat berdiri atau berbentuk tiga dimensi), pull

Pada laporan kasus ini pasien adalah seorang wanita berusia 27 tahun dengan peningkatan TIO pada kedua mata (OD 23 mmHg, OS 48 mmHg), sudut bilik mata depan terbuka melalui

Siswa tidak dapat melakukan pelafalan/ pengucapan dengan baik dan benar.