Pengantar Kecerdasan Buatan First Order Logic 1 Rules
Pengantar Kecerdasan Buatan First Order Logic (1): Rules, GMP, CNF
2 What’s wrong with Prepositional Logic ? • A lot of prepositional logic sentences. • There are no relation in prepositional logic. Example Rule : "Pits cause breezes in adjacent squares" B 2, 1 (P 1, 1 P 2, 2 P 3, 1) “A square is breezy if and only if there is an adjacent pit” x, y, a, b Adjacent([x, y], [a, b]) [a, b] {[x+1, y], [x-1, y], [x, y+1], [x, y-1]} OSCAR KARNALIM, S. T. , M. T.
3 First-order Logic • Whereas propositional logic assumes the world contains facts, first-order logic (like natural language) assumes the world contains: Objects: people, houses, numbers, colors, baseball games, wars, … • Relations: bigger than, part of, comes between, … • Functions: father of, teacher of, best friend, … • OSCAR KARNALIM, S. T. , M. T.
4 First-order Logic (Cont) �The BIG bear smash my bike �My bike is BROKEN �The forest ranger saves my life �The forest ranger shoot the BIG bear arm noun object = variable verb/noun: relation/function adverb/adjective PROPERTIES verb: predicate = action OSCAR KARNALIM, S. T. , M. T.
5 Models for FOL: Example BIG Bear Cunning Ranger Shoot Object property Relation OSCAR KARNALIM, S. T. , M. T.
6 Models for FOL: Example (Cont) OSCAR KARNALIM, S. T. , M. T.
7 Syntax of FOL: Basic Elements • Constants Bear, Ranger, bike, …… • Predicates • Function Sqrt(), Shoot(), … • Variable x, y, a, b, …. • Connectives • Equality • Quantifiers Brother, >, Big , Cunning, … = OSCAR KARNALIM, S. T. , M. T.
8 Atomic Sentences • Atomic sentence • predicate (term 1, . . . , termn) or term 1 = term 2 • Term • function (term 1, . . . , termn) or constant or variable • E. g. , • Brother(King. John, Richard. The. Lionheart) • > (Length(Left. Leg. Of(Richard)), Length(Left. Leg. Of(King. John))) OSCAR KARNALIM, S. T. , M. T.
9 Complex Sentences • Complex sentences are made from atomic sentences using connectives S, S 1 S 2, E. g. Sibling(King. John, Richard) Sibling(Richard, King. John) >(1, 2) ≤ (1, 2) >(1, 2) OSCAR KARNALIM, S. T. , M. T.
10 Universal Quantification • <variables> <sentence> Everyone at Maranatha is smart: x At(x, Maranatha) 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(King. John, Maranatha) Smart(King. John) At(Richard, Maranatha) Smart(Richard) At(NUS, Maranatha) Smart(NUS) . . . • Typically, is the main connective with OSCAR KARNALIM, S. T. , M. T.
11 Existential Quantification • <variables> <sentence> Someone at Maranatha is smart: x At(x, Maranatha) 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(King. John, Maranatha) Smart(King. John) At(Richard, Maranatha) Smart(Richard) At(NUS, Maranatha) Smart(NUS) . . . • Typically, is the main connective with OSCAR KARNALIM, S. T. , M. T.
12 Properties of Quantifiers • x y is the same as y x • x y is not the same as y x x y Loves(x, y) “There is a person who loves everyone in the world” y x Loves(x, y) “Everyone in the world is loved by at least one person” • Quantifier duality: each can be expressed using the other Semua menyukai ice cream Tidak ada satupun orang yang tidak menyukai ice cream x Likes(x, Ice. Cream) Ada yang menyukai brokoli Tidak semua orang menyukai brokoli x Likes(x, Broccoli) OSCAR KARNALIM, S. T. , M. T.
13 Equality • term 1 = term 2 is true under a given interpretation if and only if term 1 and term 2 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)] untuk semua x yang bersaudara dengan y, x berbeda dengan y, ada m dan f dimana m berbeda dengan f, m dan f adalah orangtua x dan y OSCAR KARNALIM, S. T. , M. T.
14 Using FOL The kinship domain: • Brothers are siblings x, y Brother(x, y) Sibling(x, y) • One's mother is one's female parent m, c Mother(c) = m (Female(m) Parent(m, c)) • “Sibling” is symmetric x, y Sibling(x, y) Sibling(y, x) OSCAR KARNALIM, S. T. , M. T.
15 Interacting with FOL KBs • Suppose a wumpus-world agent is using an FOL KB and perceives a smell and a breeze (but no glitter) at t=5: Tell(KB, Percept([Smell, Breeze, None], 5)) Ask(KB, a Best. Action(a, 5)) • Does the KB entail some best action at t=5? • Answer: Yes, {a/Shoot} OSCAR KARNALIM, S. T. , M. T.
16 Knowledge Base for The Wumpus World • Perception • • t, s, b Percept([s, b, Glitter], t) Glitter(t) Reflex • t Glitter(t) Best. Action(Grab, t) OSCAR KARNALIM, S. T. , M. T.
17 Deducing Hidden Properties • x, y, a, b Adjacent([x, y], [a, b]) [a, b] {[x+1, y], [x-1, y], [x, y+1], [x, y-1]} Properties of squares: • s, t At(Agent, s, t) Breeze(t) Breezy(s) Squares are breezy near a pit: • Diagnostic rule ---infer cause from effect s r Breezy(s) Adjacent(r, s) Pit(r) • Causal rule ---infer effect from cause r Pit(r) [ s Adjacent(r, s) Breezy(s)] OSCAR KARNALIM, S. T. , M. T.
18 Knowledge Engineering in FOL 1. Identify the task 2. Assemble the relevant knowledge 3. Decide on a vocabulary of predicates, functions, and constants 4. Encode general knowledge about the domain 5. Encode a description of the specific problem instance 6. Pose queries to the inference procedure and get answers 7. Debug the knowledge base OSCAR KARNALIM, S. T. , M. T.
19 Infer Facts in FOL • • Use prepositional logic rules • modus ponens • and elimination • and introduction • or introduction • resolution More rules: • SUBS{Ө, α} subtitude Ө to sentence α • • UNIFY(p, q) = Ө; where SUBST(Ө, p) = SUBST(Ө, q) • • ex : SUBS {(x/Sam, y/Pam), likes(x, y)} Likes(Sam, Pam) ex: In order to deal with quantifier we would need 3 additional rules : OSCAR KARNALIM, S. T. , M. T.
20 Infer Facts in FOL (Cont) Universal elimination Existential elimination OSCAR KARNALIM, S. T. , M. T.
21 Infer Facts in FOL (Cont) Existential introduction OSCAR KARNALIM, S. T. , M. T.
22 A Case Example • Knowledge Base : 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 • We have an answer, i. e. : West is a criminal … how do we infer this fact from the KB ? OSCAR KARNALIM, S. T. , M. T.
23 Knowledge Base for Nono Problem • It is a crime for an American to sell weapons to hostile nation • Nono… has some missile OSCAR KARNALIM, S. T. , M. T.
24 Knowledge Base for Nono Problem (Cont) • All of its missile were sold to it by Colonel West • Missile are weapons • Enemy of America counts as hostile OSCAR KARNALIM, S. T. , M. T.
25 Knowledge Base for Nono Problem (Cont) • West is an American • Nono is a country • Nono is an enemy of America • America is a country OSCAR KARNALIM, S. T. , M. T.
26 Knowledge Base for Nono Problem (Cont) OSCAR KARNALIM, S. T. , M. T.
27 Generalized Modus Ponens (GMP) • For each atomic sentence p 1', p 2', … pn' and q , we will have a subtitution Ө, so that SUBST(Ө, p 1')=SUBST(Ө, p 1), for all n : OSCAR KARNALIM, S. T. , M. T.
28 Generalized Modus Ponens (Cont) • Contoh : P 1’ is Missile(M 1) P 1 is Missile(x) P 2’ is Owns(y, M 1) P 2 is Owns(Nono, x) Ө is {x/M 1, y/Nono} q is Sells(West, Nono, x) Then SUBST(Ө, q) is Sells (West, Nono, M 1) OSCAR KARNALIM, S. T. , M. T.
29 Canonical Form / Horn Clause • In GMP all sentences in KB are atomic sentences , i. e. an implication: conjunction at the left hand side • an atomic sentence at the right hand side. • • We call this horn sentences or canonical form. • We need to translate all sentences in a KB into their canonical form OSCAR KARNALIM, S. T. , M. T.
30 Exercise = Homework (1) 1. ∀x kelinci(x) ⇒ lucu(x) 2. ∀x mahasiswa(x) ∧ kuliah (x, PKB) ⇒ jagoan(x) 3. ∀x makanindomie(x) ⇒ mahasiswa(x) ∨ krisis(x) 4. ∃s ∀p mahasiswa(s) ∧ kuliah(s, PKB) ∧ praktikum(p, PKB) ∧ ¬membenci(s, p) 5. Ubah ke dalam bentuk kalimat: OSCAR KARNALIM, S. T. , M. T.
31 Exercise = Homework (2) • Diketahui relasi sebagai berikut: • Terjemahkan kalimat berikut ke dalam FOL: OSCAR KARNALIM, S. T. , M. T.
32 Reference • Russell, Stuart J. & Norvig, Peter. Artificial Intelligence: A Modern Approach (3 rd ed. ). Prentice Hall. 2009 • Luger, George F. Artificial Intelligence: Structures and Strategies for Complex Problem Solving. 6 th Edition. Addison Wesley. 2008. • Watson, Mark. , Practical Artificial Intelligence Programming in Java, Open Content – Free e. Book (CC License), 2005. OSCAR KARNALIM, S. T. , M. T.
- Slides: 33