110 likes | 286 Views
Knowledge Representation & Reasoning. Lecture 6: Logic Programming in First Order Logic (FOL). By : SHEREENA ARIF Room : T2//8, BLOK 4 Email : shereen@ftsm.ukm.my OR shereen.ma@gmail.com. Conversion to CNF. Conjunctive Normal Form : a conjunction of clauses
E N D
Knowledge Representation & Reasoning Lecture 6: Logic Programming in First Order Logic (FOL) By : SHEREENA ARIF Room : T2//8, BLOK 4 Email : shereen@ftsm.ukm.my OR shereen.ma@gmail.com
Conversion to CNF • Conjunctive Normal Form : • a conjunction of clauses • Where each clause is a disjunction of literals • Example : x. American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) Criminal(x) • In CNF (implication elimination rule): ¬American(x) ∨¬Weapon(y) ∨¬Sells(x,y,z) ∨¬Hostile(z) ∨ Criminal(x) TP2623 by Shereena Arif
Conversion to CNF • 1. Convert to negated normal form • a) Eliminate biconditional & implications • b) Move inwards using negation rules • 2. Standardize variables e.g (x y)to(x ∨ y) (x y)to((x y) ∧(y x)) • ∃x. p becomes∀x. p OR • ∀x. p becomes∃x. p • ( x) to x == double elimination(x ∧y)to (x)∨( y) == De Morgan 1(x ∨y) to (x)∧( y) == De Morgan 2 (∀x P(x)) ∨ (∃x Q(x)) == change the name of one of the variables to avoid confusion (i.ex) TP2623 by Shereena Arif
3. Skolemize : remove existential quantifiers by elimination. • Translate [xP(x)] into P(A), A is the new constant. • Each existential variable is replaced by a Skolem function of the enclosing universally quantified variables • 4. Drop universal quantifiers: • 5. Distribute over (or vice versa) using rules given: • x[y Animal(y) ∧ Loves(x, y)] ∨[z Loves(z,x)] becomesx[Animal(F(x)) ∧ Loves(x, F(x))] ∨ [Loves(G(x),x)] • [Animal(F(x)) ∧ Loves(x, F(x))] ∨ [Loves(G(x),x)] • [Animal(F(x)) ∨Loves(G(x),x)] ∧ [Loves(x, F(x))∨Loves(G(x),x)] TP2623 by Shereena Arif
What we have in the KB ... 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) CNF : ¬American(x) ∨¬Weapon(y) ∨ ¬Sells(x,y,z) ∨¬Hostile(z) ∨ Criminal(x) Nono … has some missiles, i.e., x Owns(Nono,x) Missile(x): Owns(Nono,M1) and Missile(M1)… already in CNF … all of its missiles were sold to it by Colonel West Missile(x) ∧ Owns(Nono,x) Sells(West,x,Nono) CNF :¬Missile(x) ∨¬Owns(Nono,x) ∨ Sells(West,x,Nono) Missiles are weapons: Missile(x) Weapon(x) CNF : ¬Missile(x) ∨ Weapon(x) An enemy of America counts as "hostile“: Enemy(x,America) Hostile(x) CNF : ¬Enemy(x,America) ∨ Hostile(x) West, who is American … American(West) … already in CNF The country Nono, an enemy of America … Enemy(Nono,America) … already in CNF
Resolution proof: backward chaining TP2623 by Shereena Arif
Example • All ducks are bird • All birds can fly • If it quacks, it is a duck • Daffy quacks Question : Use resolution to prove that Daffy can fly… TP2623 by Shereena Arif
Latihan • Diberipredicate & constantsberikutdalam FOL : • G(x) : x ialahseorang guru disekolah • S(x) : x ialahseorangmuriddisekolah • M(x) : x menghadirimesyuaratkecemerlanganmurid • A(x, y) : x disertaioleh y • P(x,y) : y ialahbapakepada x • Mariamialahseorangmurid • Suriaialahseorangmurid TP2623 by Shereena Arif
Tuliskanpernyataanberikutdalam FOL : • A) Semuamuriddan guru menghadirimesyuaratkecemerlangan • B) Tidakseorang pun murid yang menghadirimesyuaratkecemerlangandisertaiolehbapamereka • C)Beberapaorangbapadaripadamuridtidakmenghadirimesyuaratkecemerlangan. • D) Jikasemua guru menghadirimesyuaratkecemerlangan, makasebahagianmuridsahaja yang disertaiolehbapamereka. • MariamdanSuriamenghadirimesyuaratkecemerlangan, tetapitidakseorangpundiantaramereka yang disertaiolehbapamasing-masing. TP2623 by Shereena Arif
Terjemahkanayat FOL berikutkedalambentuk CNF : • ∃x.∀y. p(x)⇒ r(x,y) • ∀x. ∃y. p(x)∧r(x,y) • ¬∀x. ∃y. p(x)∧r(x,y) TP2623 by Shereena Arif