1 / 55

Knowledge Representation & Reasoning

Knowledge Representation & Reasoning. Lecture 4 & 5 : Predicate Logic or First Order Logic (FOL). Propositional logic is declarative Propositional logic allows partial/disjunctive/negated information (unlike most data structures and databases) Propositional logic is compositional :

warner
Download Presentation

Knowledge Representation & Reasoning

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Knowledge Representation & Reasoning Lecture 4 & 5 : Predicate Logic or First Order Logic (FOL)

  2. Propositional logic is declarative • Propositional logic allows partial/disjunctive/negated information • (unlike most data structures and databases) • Propositional logic is compositional: • meaning of B1,1 P1,2 is derived from meaning of B1,1 and of P1,2 • Meaning in propositional logic is context-independent • (unlike natural language, where meaning depends on context) • Propositional logic has very limited expressive power • (unlike natural language) • E.g., cannot say “pits cause breezes in adjacent squares” • except by writing one sentence for each square TP2623, shereen@ftsm.ukm.my Motivation

  3. Let's consider the statements: Mariam is female Johan is male Mary and John are siblings • In propositional logic the above statements are atomic propositions: P = Mariam-is-female Q = Johan-is-male R = Mariam-and-Johan-are-siblings • In FOL atomic statements use predicates, with constants as argument: female(mariam) male(johan) siblings(mariam,johan) TP2623, shereen@ftsm.ukm.my Predicates and Constants

  4. Let's consider the statements: Everybody is male or female A male is not a female • In FOL predicates may have variables as arguments, whose value is bounded by quantifiers: • x. Male(x)  Female(x) • x. Male(x)  Female(x) • Deduction (why?): Mariam is not male male(mariam) TP2623, shereen@ftsm.ukm.my Variables and Quantifiers

  5. Let’s consider the statement: • The father of a person is male In FOL, objects of the domain may be denoted by functions applied to (other) objects: x. male(father(x)) TP2623, shereen@ftsm.ukm.my Functions

  6. User define these primitives • Constant symbols (i.e. the “individuals” in the world), e.g. Mariam, 3 • Function symbols (mapping individuals to individuals), e.g. father-of(mariam)=johan; colour-of(sky)=blue • Predicate symbols (mapping from individuals to truth value), e.g. greater(5,3), green(grass), colour(grass,green) TP2623, shereen@ftsm.ukm.my FOL Syntax

  7. FOL supplies these primitives • Variable symbols. e.g. x, y • Connectives. Same as PL • Quantifiers: Universal () and existential () •  corresponds to conjunction () •  corresponds to disjunction () •  usually used with “implies” to form (if then rules) •  usually used with “and” to specify a list of properties or facts about an individual • Switching the order of  does not change the meaning • Switching the order of  does not change the meaning • Switching the order of  and  does change the meaning TP2623, shereen@ftsm.ukm.my FOL Syntax

  8. Constants Mariam, 2, UKM,... • Predicates Brother, >,... • Functions Sqrt, LeftSideOf,... • Variables x, y, a, b,... • Connectives , , , ,  • Equality = • Quantifiers ,  TP2623, shereen@ftsm.ukm.my Summary of FOL Syntax: Basic Elements

  9. Sentences are built from terms and atoms: • A term is a logical expression that refers to an object Term = function (term1,...,termn) or constant or variable • An atomic sentence is an n-place predicate of n terms Atomic sentence = predicate (term1,...,termn) or term1 = term2 • A well formed formula (wff) is an atomic sentence containing no free variables, i.e. all variables are “bound” by universal or existential quantifiers. TP2623, shereen@ftsm.ukm.my Atomic Sentences

  10. Atomic sentence can have complex terms Friend-of(Father(Ahmad), Father(Ali)) Ahmad’s father is a friend of Ali’s father • We can use logical connectives to construct more complex sentences x (Pemandu(x)  ⌐Penumpang(x)) Untuksetiap yang menjadipemandumerekaadalahbukanpenumpang x,y (Melatih(x,y)  (Jurulatih(x)  Pelatih(y))) x,y (DrivingExperience(x,y)  (Driver(x)  Passenger(y))) Untuksetiap yang melatihorang lain, seorangakanmenjadijurulatihdanseoranglagimenjadipelatih TP2623, shereen@ftsm.ukm.my Atomic sentence

  11. <variables> <sentence> Everyone at UKM is smart: x. At(x,UKM)  Smart(x) • x P is true in a model m,iffP is true with x being each possible object in the model • Roughly speaking, equivalent to the conjunction of instantiations of P At(Ahmad,UKM)  Smart(Ahmad)  At(Ali, UKM)  Smart(Ali)  At(Aminah, UKM)  Smart(Aminah)  ... TP2623, shereen@ftsm.ukm.my Universal quantification

  12. Typically,  is the main connective with  • Common mistake: using  as the main connective with : x At(x,UKM)  Smart(x) means “Everyone is at UKM and everyone is smart” TP2623, shereen@ftsm.ukm.my A common mistake to avoid

  13. <variables> <sentence> • Someone at UKM is smart: • x At(x,UKM)  Smart(x) • xP 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(Ahmad,UKM)  Smart(Ahmad)  At(Ali,UKM)  Smart(Ali)  At(Aminah,UKM)  Smart(Aminah)  ... TP2623, shereen@ftsm.ukm.my Existential quantification

  14. Typically,  is the main connective with  • Common mistake: using  as the main connective with : x At(x,UKM)  Smart(x) is true if there is anyone who is not at UKM! Also means that some people at UKM are smart, but also say that some people who are not at UKM are also smart. TP2623, shereen@ftsm.ukm.my Another common mistake to avoid

  15. x y is the same as yx • 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 • x Likes(x,IceCream) x Likes(x,IceCream) • Everyone likes ice cream There is no one who does not like ice cream • x Likes(x,Broccoli) xLikes(x,Broccoli) • Someone likes broccoli not all people does not like broccoli TP2623, shereen@ftsm.ukm.my Properties of quantifiers

  16. term1 = term2is true under a given interpretation if and only if term1and term2refer to the same object • E.g., definition of Sibling in terms of Parent: x,ySibling(x,y)  [(x = y)  m,f  (m = f)  Parent(m,x)  Parent(f,x)  Parent(m,y)  Parent(f,y)] TP2623, shereen@ftsm.ukm.my Equality

  17. Semua petani suka matahari Semua cendawan ungu adalah beracun Tiada cendawan ungu yang beracun Terdapat dua cendawan ungu Ali tidak tinggi TP2623, shereen@ftsm.ukm.my Translating language to FOL

  18. Hubungankeluarga • Ibu, suami, isteri, IbuBapa(parent) dll • IbukepadaindividuadalahmerupakanIbuBapaperempuanindividutersebut m,cIbu(c) = m (Perempuan(m) IbuBapa(m,c)) • Lelaki & perempuanadalahhubungan disjoint xLelaki(x) Perempuan(x) • IbuBapadananakadalahhubungan inverse(berbalik) p,cIbuBapa(p,c)Child(c,p) • DatokialahIbuBapakepadaIbuBapaseorangindividu g,cDatok(g,c) p IbuBapa(g,p) ∧IbuBapa(p,c) TP2623, shereen@ftsm.ukm.my Example FOL

  19. Every normal bird can fly An ostrich is a bird and not a normal bird A whirlybird is not a normal bird A whirlybird is not a bird Every object that is not a bird that is not normal is either a normalbird or a whirlybird Tweety is a bird Tweety is not a normal bird Tweety has her wings clipped There are precisely two individuals that are parents of Tweety,and they are both normal birds. TP2623, shereen@ftsm.ukm.my Bird Example

  20. TP2623, shereen@ftsm.ukm.my Interpreting the Bird Example • Domain • {birds whirlybird} • Assign Constants • Tweety • Assign Functions • none • Assign Predicate Symbols • Bird(x) • Normal(x) • Can-fly(x) • Ostrich(x) • Whirlybird(x) • Clipped-wings(x) • Parent(x, Tweety) • Equals(x, y) • Every normal bird can fly • An ostrich is a bird and not a normal bird • A whirlybird is not a normal bird • A whirlybird is not a bird • Every object that is not a bird that is not normal is either a normalbird or a whirlybird • Tweety is a bird • Tweety is not a normal bird • Tweety has her wings clipped • There are precisely two individuals that are parents of Tweety,and they are both normal birds.

  21. Every normal bird can fly x [ (Bird(x) Normal(x))  Can-fly(x) ] An ostrich is a bird and not a normal bird x [ (Ostrich(x)  (Bird(x) Normal (x)) ] A whirlybird is not a normal bird x [ (Whirlybird(x)  (Bird(x)  Normal (x) ) ] A whirlybird is not a bird x [ (Whirlybird(x)  Bird(x)) ] TP2623, shereen@ftsm.ukm.my Bird Example

  22. Every object that is not a bird that is not normal is either a normal bird or a whirlybird x [(Bird(x)  Normal(x))  ((Normal (x) (Bird(x))  Whirlybird(x))] • Tweety is a bird Bird(Tweety) • Tweety is not a normal bird (Normal (Tweety) Bird(Tweety)) • Tweety has her wings clipped Clipped-wings(Tweety) TP2623, shereen@ftsm.ukm.my Bird Example

  23. There are precisely two individuals that are parents of Tweety, and they are both normal birds. x y [Equals(x, y) Parent(x, Tweety)  Parent(y, Tweety) [z (parent(z, Tweety) (equals (z, x)  Equals (z, y))) ] ] x [ (Parent(x, Tweety)  (normal(x)  Bird (x)) ] TP2623, shereen@ftsm.ukm.my Bird Example

  24. Translate the following sentences into FOL • Everything is bitter or sweet. (Semua benda adalah pahit atau manis) • Either everything is bitter or everything is sweet. (Sama ada semua pahit atau semua benda manis) • There is somebody who is loved by everyone. (Ada seseorang yang disukai oleh semua) • If someone is noisy, everybody is annoyed.(Jika seseorang bising, maka semua orang lain akan marah) TP2623, shereen@ftsm.ukm.my Exercise

  25. Inference Rules for FOL

  26. Inference rules for PL apply to FOL. For example: modus ponens, and-introduction, and-elimination • New rules for use with quantifiers: • Universal instantiation • Existential instantiation • Existential elimination TP2623, shereen@ftsm.ukm.my Background

  27. Reducing first-order inference to propositional inference • Unification • First-order inference algorithms • Forward chaining • Deductive database and production systems • Backward chaining and logic programming • Resolution-based theorem proving TP2623, shereen@ftsm.ukm.my INFERENCE IN FIRST-ORDER LOGIC

  28. Inference rules for quantifiers • Infer the following sentences: King(John) ^ Greedy(John) => Evil(John) King(Richard) ^ Greedy(Richard) => Evil(Richard) King(Father(John)) ^ Greedy(Father(John)) => Evil(Father(John)) … TP2623, shereen@ftsm.ukm.my Propositional vs First-Order Inference

  29. Infer any sentence obtained by substituting a ground term for the variable. • Ground term: a term without variables (i.e g). Where Subst(θ,α) is the result of applying the substitution θ to the sentence α for any variable v and ground term g • E.g. The three sentences given earlier: {x/John}, {x/Richard}, and {x/Father(John)} TP2623, shereen@ftsm.ukm.my Universal Instantiation (UI) Rule

  30. For any sentence α, variable v, and constant symbol k that does not appear elsewhere in KB, E.g. yields Crown(C1) OnHead(C1, John) Provided that C1 is a new constant symbol, called a Skolem constant. The existential sentence says that there is some object satisfying a condition, and the instantiation process is just giving a name to the object. TP2623, shereen@ftsm.ukm.my Existential Instantiation (EI) Rule

  31. UI can be applied several times to add new sentences; the new KB is logically equivalent to the old. EI can be applied once to replace the existential sentence; the new KB is not logically equivalent to the old, but is satisfiable iff the old KB is satisfiable, called inferentially equivalent. TP2623, shereen@ftsm.ukm.my Inference rules for quantifiers (Cont’d)

  32. Suppose the KB contains just the following: King(John) Greedy(John) Brother(Richard, John) Apply UI to the first sentence using all possible ground term substitution from the vocabulary of the KB, e.g. {x/John} and {x/Richard}: King(John) ^ Greedy(John) => Evil(John) King(Richard) ^ Greedy(Richard) => Evil(Richard) And discard the universally quantified sentence. TP2623, shereen@ftsm.ukm.my Reduction to Propositional inference

  33. Unification is a process of finding substitutions that make different logical expressions look identical. • UNIFY algorithm takes two sentences and return a unifier for them if one exist: UNIFY(p,q) = θ where SUBST(θ,p) = SUBST(θ,q) • We can get the inference immediately if we can find a substitution θ such that: King(x) and Greedy(x) match King(John) and Greedy(y) θ = {x/John, y/John} TP2623, shereen@ftsm.ukm.my Unification

  34. Unification (Cont’d) TP2623, shereen@ftsm.ukm.my • E.g. Query: Knows(John, x): • Whom does John know? • Answers: Find all sentences in the KB that unify with Knows(John, x). • Results of unification with four diff sentences in KB: • Standardizing apart eliminates overlap of variables, e.g. Knows(z17, Elizabeth)

  35. First-order inference rule King(John) Greedy(John) • Inference process for John is evil: • Find some x such that x is a king and x is greedy • Infer that this x is evil • If there is some substitution θ that makes the premise of the implication identical to the sentences already in the KB, then assert the conclusion of the implication, after applying θ. TP2623, shereen@ftsm.ukm.my Generalized Modus Ponens (GMP)

  36. More general inference step, where everyone is also greedy: • Conclusion: Evil(John) • John is a king • John is greedy (because everyone is greedy) • For atomic sentences pi, pi’, and q, where there is a substitution θ such that SUBST(θ,pi’) = SUBST(θ, pi), for all i, TP2623, shereen@ftsm.ukm.my GMP (Cont’d)

  37. There are n+1 premises to this rule: • n atomic sentences pi’ • 1 implication • The conclusion is the result of applying the substitution θ to the consequent q. • E.g.: p1’ is King(John) p1 is King(x) p2’ is Greedy(y) p2 is Greedy(x) θ is {x/John, y/John} q is Evil(x) SUBST(θ,q) is Evil(John) TP2623, shereen@ftsm.ukm.my GMP (Cont’d)

  38. 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. • Prove that Col. West is a criminal TP2623, shereen@ftsm.ukm.my Example knowledge base

  39. ... 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, i.e., x Owns(Nono,x) Missile(x) Owns(Nono,M1) Missile(M1) … 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 … American(West) The country Nono, an enemy of America … Enemy(Nono,America) TP2623, shereen@ftsm.ukm.my Example knowledge base contd.

  40. TP2623, samn@ftsm.ukm.my Forward chaining algorithm

  41. TP2623, shereen@ftsm.ukm.my Forward chaining proof

  42. TP2623, shereen@ftsm.ukm.my Forward chaining proof

  43. TP2623, shereen@ftsm.ukm.my Forward chaining proof

  44. Sound and complete for first-order definite clauses • Datalog = first-order definite clauses + no functions • FC terminates for Datalog in finite number of iterations • May not terminate in general if α is not entailed Forward chaining is widely used in deductive databases TP2623, shereen@ftsm.ukm.my Properties of forward chaining

  45. SUBST(COMPOSE(θ1, θ2), p) = SUBST(θ2, SUBST(θ1, p)) TP2623, shereen@ftsm.ukm.my Backward chaining algorithm

  46. TP2623, shereen@ftsm.ukm.my Backward chaining example

  47. TP2623, shereen@ftsm.ukm.my Backward chaining example

  48. TP2623, shereen@ftsm.ukm.my Backward chaining example

  49. TP2623, shereen@ftsm.ukm.my Backward chaining example

  50. TP2623, shereen@ftsm.ukm.my Backward chaining example

More Related