11.2 Inferensi pada FOL AI
Artificial Intelligence
1. Mengubah FOL inference ke PL inference
2. Unification
3. Inference Rule untuk FOL
4. Forward chaining
5. Backward chaining
6. Resolution ( The Next )
Ide tahun 60-an :
o Kita sudah melihat mekanisme inference untuk propositional logic
Inference rule : Modus Ponens Normal form : Horn clause Algoritma : Forward chaining, Backward chaining
Inference rule : Resolution Normal form : Clause Normal Form (CNF) Algoritma : Proof-by-contradiction
Instantiation : o Ground term : sebuah term tanpa variable, mis: Ani, Ayah(Anto),
2007
o Instantiation : kalimat di mana sebuah variable diganti dengan
sebuah ground term (diperoleh dengan mengaplikasikan sebuah substitution) o
Contoh :
α = ∀ x mahasiswa(x , PTIIKUB) Genius(x ) ⇒ β =
∃ x mahasiswa(x , Gundar ) pintar (x ) ∧
Universal Instantiation :
o Sebuah kalimat dengan universal quantifier ( ) meng-entail
∀
semua instantiation-nya:
___ v α _________ ∀ SUBST ({v /g},α)
o
untuk sembarang variable v dan ground term g
o Contoh :
x King(x ) Greedy (x ) Evil (x ) meng-entail : ∧ ⇒ ∀
Existential Instantiation :
o Untuk sembarang variable v, kalimat α dan constant k yang tidak
muncul di knowledge-base : ___ v α _________ ∃ SUBST ({v / k},α)
o Contoh :
:
∃ x Crown(x ) OnHead (x , John) meng-entail ∧
- Crown(C ) OnHead (C ∧ , John), dengan syarat C adalah 1 1 1
Menghilangkan quantifier dan variable :
o Menghilangkan : ∀
Universal instantiation bisa digunakan berkali-kali untuk menambahkan kalimat baru.
KB yang baru logically equivalent dengan yang lama. o Menghilangkan :
∃
Existential instantiation cukup digunakan sekali untuk menggantikan kalimat existential.
Contoh : o Andaikan KB berisi kalimat-kalimat berikut : ∀ x King(x) Greedy (x) Evil (x) y Greedy (y) ∧ ⇒ ∀
King(John) Brother (Richard , John) o Jika kita mengambil semua kemungkinan instantiation dari kalimat universal, kita dapatkan KB sbb : King(John) Greedy (John) Evil (John)
∧ ⇒ King(Richard) Greedy (Richard ) Evil (Richard) ∧ ⇒
Inference FOL menggunakan inference PL : o Ide dasar : ubah KB + query dari FOL menjadi PL, lalu gunakan resolution. o Masalah : dengan adanya function , jumlah ground term menjadi infinite .
Greedy (Father (John)), Greedy (Father (Father (John))) Greedy (Father (Father (Father (John)))), dst. o Teorema Herbrand (1930) : jika FOL KB |= α, ada sebuah finite subset PL KB |= α.
Masalah dengan propositionalization : o Propositionalization menghasilkan banyak kalimat irelevan.
o Contohnya, dari KB berikut :
∀ x King(x) Greedy (x) Evil (x) ∧ ⇒
∀ y Greedy (y)
King(John)
Brother (Richard , John) manusia bisa cepat mengerti kalau Evil (John) , namun
Isi KB : o ∀ x King(x) Greedy (x) Evil (x) ∧ ⇒ o ∀ y Greedy (y) o King(John) o Brother (Richard , John) Inference bahwa KB |= Evil (John) bisa langsung disimpulkan jika kita bisa mencari substitution θ sehingga King(x) dan Greedy
(x) bisa “dicocokkan” dengan King(John) dan Greedy (y).
Contoh unification : P q θ Sayang(Anto, x ) Sayang(Anto, Ani ) {x /Ani }
Sayang(Anto, x ) Sayang(y , Ani ) {x /Ani , y /Anto}
Sayang(Anto, x ) Sayang(y , Ibu (y )) {y /Anto, x /Ibu (Anto) Sayang(Anto, x ) Sayang(x , Ani ) fail Generalized Modus Ponens (GMP) :
o Inference rule GMP : p ’, p ’, . . . , p ’, (p p ∧ . . . p ∧ ∧ q) ⇒ 1 2 n 1 2 n qθ di mana p ’θ = p θ untuk semua i. i i p ’ = King(John) p = King(x) 1 1 p ’ = Greedy(y) p = Greedy(x) 2 2 θ = {x /John, y /John} q = Evil(x) qθ = Evil (John)
Contoh knowledge base :
o Kalimat : “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.” o
Kalimat : “Hukum mengatakan bahwa, suatu kejahatan bagi orang Amerika yang menjual senjata ke negara-negara yang bermusuhan. Negara Nono dalah musuh Amerika, yang memiliki beberapa rudal, dan semua rudalnya dari yang dijual oleh
Contoh knowledge base : o Kalimat : “ 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 .”
Buktikan bahwa Col. West adalah criminal! o Penyelesaian : o . . . 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)
∧ ∧ ∧ ⇒ o Nono . . . has some missiles : x Owns(Nono, x ) Missile(x )
∃ ∧ Owns(Nono, M 1 ) and Missile(M 1 ) (Skolemization) o . . . all of its missiles were sold to it by Colonel West : Missile(x ) Owns(Nono, x ) Sells(West, x , Nono)
∧ ⇒
Forward chaining pada FOL dengan GMP : o Mirip dengan forward chaining pada PL. o Mulai dari fakta yang diketahui (clause tanpa premise), mis :
Owns(Nono, M ), Missile(M ) 1 1 o “Aktifkan” (trigger) rule yang premise-nya diketahui (satisfied)
→ tambahkan kesimpulan rule ke KB, mis : Missile(x ) Owns(Nono, x ) Sells(West, x , Nono) ∧ ⇒ o Ulangi sampai query terbukti, atau tidak ada fakta baru yang
Algoritma forward chaining :
Contoh Forward Chaining FOL : American(x ) Weapon(y) Sells(x , y , z ) Hostile(z ) o. . . it is a crime for an American to sell weapons to hostile nations : Criminal(x) ∧ ∧ ∧ ⇒ oNono . . . has some missiles : x Owns(Nono, x ) Missile(x ) ∃ ∧ Owns(Nono, M ) and Missile(M ) (Skolemization) 1 1 Missile(x ) Owns(Nono, x ) Sells(West, x , Nono) ∧ ⇒ o. . . all of its missiles were sold to it by Colonel West : oMissiles are weapons : Missile(x ) Weapon(x) ⇒ Enemy (x , America) Hostile(x ) oAn enemy of America counts as “hostile” :
⇒ American(West) oWest, who is American . . . : oThe country Nono, an enemy of America . . . :
Contoh Forward Chaining FOL : American(x ) Weapon(y) Sells(x , y , z ) Hostile(z ) o. . . it is a crime for an American to sell weapons to hostile nations : Criminal(x) ∧ ∧ ∧ ⇒ oNono . . . has some missiles : x Owns(Nono, x ) Missile(x ) ∃ ∧ Owns(Nono, M ) and Missile(M ) (Skolemization) 1 1 o. . . all of its missiles were sold to it by Colonel West : Missile(x ) Owns(Nono, x ) Sells(West, x , Nono) ∧ ⇒ oMissiles are weapons : Missile(x ) Weapon(x) ⇒ oAn enemy of America counts as “hostile” : Enemy (x , America) Hostile(x )
⇒ American(West) oWest, who is American . . . : oThe country Nono, an enemy of America . . . :
Contoh Forward Chaining FOL :
o Datalog = first-order definite clause tanpa function . o Sifat Forward Chaining : Time complexity FC pada Datalog → polynomial Sound dan complete untuk first-order definite clause. o o Proses pattern matching pada premise NP-hard. Tapi pada kasus umum, bisa infinite loop kalau α tidak di-entail. (Konsekuensi dari teorema Church-Turing : entailment adalah semidecidable)
Pattern matching premise NP-hard(Non-deterministic Polynomial-time hard)? ∧ ∧ Diff(wa, nt ) Diff(wa, sa)
Diff(nt , q) Diff(nt , sa) ∧ ∧ Diff(q, nsw ) Diff(q, sa) ∧ ∧ Diff(nsw , v ) Diff(nsw , sa) ∧ ∧
Backward chaining pada FOL dengan GMP :
Contoh Backward Chaining FOL :
Contoh Backward Chaining FOL :
Contoh Backward Chaining FOL :
Contoh Backward Chaining FOL :
Contoh Backward Chaining FOL :
Contoh Backward Chaining FOL :
Contoh Backward Chaining FOL :
Sifat Backward Chaining : o Depth-first search :
linear space complexity
incomplete (infinite loop) repeated state o Prinsip dasar Logic Programming
Resolution pada FOL : o
Resolution inference rule pada FOL (lifting resolution PL) :
di mana o Contoh : Mengubah FOL ke CNF : “Everyone who loves all animals is loved by someone:”
∀ x [ y Animal (y ) = Loves(x , y )] = [ y Loves(y , x )] ∀ ⇒ ⇒ ∃ oEliminasi implikasi dan biimplikasi
∀ x [¬ y ¬Animal (y ) Loves(x , y )] [ y Loves(y , x )] ∀ ∨ ∨ ∃ oPindahkan ¬ ke “dalam”: ¬ x , p ≡ x ¬p, ¬ x , p ≡ x ¬p : ∀ ∃ ∃ ∀
∀ x [ y ¬(¬Animal (y ) Loves(x , y ))] [ y Loves(y , x )] ∃ ∨ ∨ ∃ ∀ x [ y ¬¬Animal (y ) ¬Loves(x , y )] [ y Loves(y , x )] ∃ ∧ ∨ ∃ ∀ x [ y Animal (y ) ¬Loves(x , y )] [ y Loves(y , x )] ∃ ∧ ∨ ∃ oStandardize variables: setiap quantifier variable-nya beda
∀ x [ y Animal (y ) ¬Loves(x , y )] [ z Loves(z , x )] ∃ ∧ ∨ ∃
Contoh pembuktian dengan resolution :