1 / 41

Chapter 6

King Saud University College of Computer and Information Sciences Information Technology Department IT422 - Intelligent systems . Chapter 6. Knowledge Representation & Reasoning (part 2) First Order Logic. Introduction. Propositional logic pros:

trory
Download Presentation

Chapter 6

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. King Saud University College of Computer and Information Sciences Information Technology Department IT422 - Intelligent systems Chapter 6 Knowledge Representation & Reasoning (part 2) First Order Logic

  2. Introduction • Propositional logic pros: • Propositional logic is declarative: Knowledge base and inference are separated • 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 cons: • Propositional logic has limited expressive power unlike natural language • e.g. cannot say "pits cause breezes in adjacent squares“ (except by writing one sentence for each square) Question : How can we write one sentence only that can be applied on a group of objects?

  3. From propositional logic (PL) to First order logic (FOL) • Examples of things we can say: • All men are mortal: • ∀x Man(x) ⇒ Mortal(x) • Everybody loves somebody • ∀x ∃y Loves(x, y) • The meaning of the word “above” • ∀ x ∀ y above(x,y) ⇔(on(x,y) ∨ ∃ z (on(x,z) ∧ above(z,y))

  4. 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, … • Relations: • Unary(properties) red, round, prime, • N-ary: brother of, bigger than, part of, … • Functions:Sqrt, Plus, … • Can express the following: Squaresneighboring the Wumpus are smelly Squaresneighboring a pit are breezy

  5. Syntax of First Order Logic • User defines these primitives: • Constant symbols (i.e., the "individuals" in the world) e.g., Mary, 3, apple • Predicate/relation symbols (mapping from individuals to truth values) e.g., greater(5,3), green(apple), color(apple, Green) • Function symbols (mapping individuals to individuals) e.g., fatherOf(Mary) = John, colorOf(Sky) = Blue

  6. Syntax of First Order Logic • FOL supplies these primitives: • Variable symbols. x, y, … • Connectives. Same as in PL: ⇔,∧,∨, ⇒ • Equality = • Quantifiers: Universal (∀) : “for all”: and Existential (∃) : “thereexists” • A legitimate expression of FOL (also called first order predicate calculus) is called a well-formed formula (wff) or, simply, a sentence.

  7. Syntax of First Order Logic: Constant Symbols • Each constant symbol names exactly one object in a universe of discourse, but: • not all objects have symbol names; • some objects have several symbol names. • Usually denoted with upper-case first letter. • e.g. Wumpus, Ali.

  8. Syntax of First Order Logic: Relation (Predicate) Symbols • A predicate symbol is used to represent a relation in a universe of discourse. • The sentence: Relation(Term1, Term2,…) • is either TRUE or FALSE depending on whether Relation holds of Term1, Term2,… • To write “Malek wrote Muata” in a universe of discourse of names and written works: • Wrote(Malek, Muata)  This sentence is true in the intended interpretation. • Another example: - A proposition in predicate logic: Taking(IT422, Sarah)

  9. Syntax of First Order Logic: Function symbols • Functions talk about the binary relation of pairs of objects. • For example, the Father relation might represent all pairs of persons in father-daughter or father-son relationships: • Father(Ali)  Refers to the father of Ali • Father(x)  Refers to the father of variable x

  10. Syntax of First Order Logic: Variables • Used to represent objects or properties of objects without explicitly naming the object. • Usually lower case. • For example: • x • father • square

  11. Syntax of First Order Logic: Quantifiers • Quantifiers: Universal (∀) and Existential (∃) • Allow us to express properties of collections of objects instead of enumerating objects by name • Universal:“for all”: • ∀ <variables> <sentence> • ∀x At(x,KSU) ⇒ Smart(x) • Existential: “there exists” • ∃ <variables> <sentence> • ∃x At(x,PNU) ∧ Smart(x)

  12. Syntax of First Order Logic: Quantifiers • ⇒ is the main connective with (∀) • ∀x At(x,KSU) ⇒ Smart(x) • “everyone that is at KSU is smart” • ∧ is the main connective with (∃) • ∃x At(x,PNU) ∧ Smart(x) • “there are students at PNU that are smart”

  13. Syntax of First Order Logic: properties of quantifiers • ∀ 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) • ∃ x Likes(x,Broccoli) ≡ ¬ ∀ x ¬Likes(x,Broccoli)

  14. Syntax of First Order Logic: Atomic sentence • Atomic sentence = • predicate (term1,...,termn). • term1 = term2 • Term = • function (term1,...,termn). • constant. • variable • Example terms: • Brother(Ali , Mohamed) • Greater(Length(x), Length(y))

  15. Syntax of First Order Logic: Complex sentence • Complex sentences are made from atomic sentences using connectives and by applying quantifiers. • Examples: • Sibling(Ali,Mohamed) ⇒ Sibling(Mohamed,Ali) • greater(1,2) ∨ less-or-equal(1,2) • ∀ x,ySibling(x,y) ⇒ Sibling(y,x)

  16. Syntax of First Order Logic Sentence→ Atomic Sentence |(Sentence connective Sentence) | Quantifier variable,… Sentence | ¬ Sentence Atomic Sentence → Predicate (Term,…) |Term=Term Term → Function(Term,…) | Constant |variable Connective →⇔ | ∧ | ∨ |  Quantifier →∀ | ∃ Constant→ A |X1… Variable→ a | x | s | … Predicate→ Before |hascolor| …. Function→ Mother | Leftleg |…

  17. The language of logic • In first order logic, we use functions and predicates • The language of logic is based on set theory: • Sets • Relations • Functions

  18. a d b c e The language of logic • SETS: • The set of objects defines a “Universe of Discourse.” [Objects are represented by Constant Symbols.] Interpretation: A  a B  b C  c D  d E  e For example, in this blocks world, the universe of discourse is {a,b,c,d,e}.

  19. a d b c e The language of logic • RELATIONS: • A binary relation is a set of ordered pairs • Example: Consider set of blocks {a,b,c,d,e} The “on” relation: on = {<a,b>, <b,c>, <d,e>}. The predicateOn(A,B) can be interpreted as: <a,b>  on. On(A,B) is TRUE, but On(A,C) and On(C,D) are FALSE in this interpretation.

  20. The language of logic • FUNCTIONS: • A function is a binary relation such that no two distinct members have the same first element. • In other words, if F is a function • <x,y>  F and <x,z>  F  y=z • If <x,y>  F : • x is an argument of F ; • y is the value of F at x ; • y is the image of x under F. • F(x) designates the object y such that y=F(X).

  21. a d b c e The language of logic • FUNCTIONS: • hat = {<c,b>, <b,a>,<e,d>} • hat (c) = b • hat(b) = a • hat(d) is not defined. • Hat(E) can be interpreted as d • UsingFOL • On(A,B) • On(B,C) • On(D,E) • On(A, Hat(C))

  22. RECALL • Knowledge base is a set of sentences. Each sentence is expressed in a language called a knowledge representation language. • A sentence represents some assertion about the world. • Entailment α╞ β if and only if in every model in which α is true, β is also true • Inference is the process of deriving new sentences from old ones KB α • Sound inference algorithms derive only sentences that are entailed. • Complete inference algorithms derive all sentences that are entailed. • Model checking Enumerates all possible models to check that α is true in all models in which KB is true. • Inference rules (e.g. modus ponens, resolution rule)are patterns of sound inference that can be used to find proofs • Proof a sequence of applications of inference rules. • Resolution is a sound and complete method of inference • Forward chaining and backward chaining are natural reasoning algorithms for knowledge bases in Horn form. • Horn clause is a disjunction of literals of which at most one is positive. i

  23. Inference in First Order Logic Purpose of inference: KB ╞ α ? Inference in FOL can be performed by: • Reducing FOL to PL and then apply PL inference • Use inference rules of FOL • Unification • Generalized Modus Ponens • Resolution

  24. Inference in First Order Logic From FOL to PL • First order inference can be done by converting the knowledge base to PL and using propositional inference. • Two questions ? • How to convert universal quantifiers (∀)? • Replace variable by ground term. • How to convert existential quantifiers (∃)? • Skolemization.

  25. Inference in First Order Logic Substitution • Given a sentence αand binding list , the result of applying the substitution  to α is denoted by Subst(, α). Example:  = {x/Ali, y/Fatima} = Likes(x,y) Subst({x/Ali, y/Fatima}, Likes(x,y)) = Likes(Ali, Fatima)

  26. Inference in First Order Logic Universal instantiation (UI) • Every instantiation of a universally quantified sentence is entailed by it: ∀ v α Subst({v/g}, α) • for any variable v and ground term g e.g., ∀ x King(x) ∧ Greedy(x) Evil(x)yields: King(John) ∧ Greedy(John) Evil(John) King(Richard) ∧ Greedy(Richard) Evil(Richard) King(Father(John)) ∧ Greedy(Father(John))Evil(Father(John)) • UI can be applied several times to add new sentences

  27. Inference in First Order Logic Existential instantiation (EI) • For any sentence α, variable v, and constant symbol k that does not appear elsewhere in the knowledge base: ∃v α Subst({v/k}, α) • e.g., ∃x Crown(x) ∧OnHead(x,John) yields: Crown(C1) ∧OnHead(C1,John) provided C1 is a new constant symbol, called a Skolem constant • EI can be applied once to replace the existential sentence

  28. Inference in First Order Logic Reduction to propositional inference • Suppose the KB contains just the following: • ∀ x King(x) ∧ Greedy(x)Evil(x) • King(John) • Greedy(John) • Brother(Richard,John) • Instantiating the universal sentence in all possible ways, we have: • King(John) ∧ Greedy(John)Evil(John) • King(Richard) ∧ Greedy(Richard) Evil(Richard)  irrelevant substitution • King(John) • Greedy(John) • Brother(Richard,John) • The new KB is propositionalized

  29. Inference in First Order Logic Reduction to PL • A ground sentence is entailed by a new KB iff entailed by the original KB. • Every FOL KB can be propositionalized so as to preserve entailment • IDEA: propositionalize KB and query, apply resolution, return result • PROBLEM: with function symbols, there are infinitely many ground terms, e.g., Father(Father(Father(John)))

  30. Inference in First Order Logic • Instead of translating the knowledge base to PL, we can make the inference rules work in FOL. • For example, given: • ∀ x King(x) ∧ Greedy(x)  Evil(x) • King(John) • Greedy(John) • Can we prove Evil(John)? • The inference that John is evil works like this: • find some x such that x is a king and x is greedy, • and then infer that x is evil. • Generally: • It is intuitively clear that we can substitute {x/John} and obtain that Evil(John)

  31. Inference in First Order Logic • What if we have: • ∀ x King(x) ∧ Greedy(x)  Evil(x) • King(John) • ∀ y Greedy(y) • It is intuitively clear that we can substitute {x/John,y/John} and obtain that Evil(John)

  32. Inference in First Order Logic Unification • We can make the inference if we can find a substitution such that King(x) and Greedy(x) match King(John) and Greedy(y){x/John,y/John} works • Unify(α ,β) = θ if Subst(θ, α) = Subst(θ, β)

  33. Inference in First Order Logic 1) Generalized Modus Ponens (GMP) • Suppose that Subst( θ, pi’) = Subst( θ, pi) for all i then: p1', p2', … , pn', ( p1 ∧ p2 ∧ … ∧ pn q ) Subst(θ, q) • 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) • All variables assumed universally quantified.

  34. Inference in First Order Logic 2) Resolution • Full first-order version: l1 ∨ ··· ∨ lk, m1 ∨ ··· ∨ mn Subst( θ, l1 ∨ ··· ∨ li-1 ∨ li+1 ∨ ··· ∨ lk ∨ m1 ∨ ··· ∨ mj-1 ∨ mj+1 ∨ ··· ∨ mn) where θ = Unify( li, ¬mj) ¬Rich(x) ∨ Unhappy(x) , Rich(Ken) Unhappy(Ken) with θ = {x/Ken} • Apply resolution steps to CNF(KB ∧ ¬α); complete for FOL

  35. Inference in First Order Logic Forward chaining When a new fact P is added to the KB: For each rule such that P unifies with a premise,if the other premises are knownthen add the conclusion to the KB and continue chaining. • Forward chaining is data-driven,e.g., inferring conclusions from incoming percepts.

  36. Inference in First Order Logic Forward chaining example • Rules • Buffalo(x)  Pig(y)  Faster(x, y) • Pig(y)  Slug(z)  Faster(y, z) • Faster(x, y)  Faster(y, z)  Faster(x, z) • Facts • Buffalo(Bob) • Pig(Pat) • Slug(Steve) • New facts • Faster(Bob, Pat) • Faster(Pat, Steve) • Faster (Bob, Steve) Faster(Bob,Steve) {x/Bob, y/Pat} {y/Pat, z/Steve} Faster(Pat,Steve) Faster (Bob,Pat) {y/Pat} {x/Bob} {z/Steve} Buffalo(Bob) Pig (Pat) Slug(Steve)

  37. Inference in First Order Logic Backward chaining Backward chaining starts with a hypothesis (query) and work backwards, according to the rules in the knowledge base until reaching confirmed findings or facts. Example • Pig(y) ∧ Slug(z) ⇒ Faster (y, z) • Slimy(z) ∧ Creeps(z) ⇒Slug(z) • Pig(Pat) • Slimy(Steve) • Creeps(Steve)

  38. Other knowledge representation schemes Semantic Networks • A semantic network consists of entities and relations between the entities. • Generally it is represented as a graph. • Example: • A bird is a kind of animal • Flying is the normal moving method of birds • Birds are usually active at the day-light • An albatross is a bird • Albert is an albatross, and so is Ross

  39. Other knowledge representation schemes Semantic Networks • Example: animal Active-at Moving-method Bird fly daylight Is a albatross colour Is a Is a Black and white Ross Albert

  40. Other knowledge representation schemes Frames • A frame is a data structure whose components are called slots. • Slots have names and accommodate information of various kinds. • Example: Frame: Bird A_kind_of: animal Moving_method: fly Active_at: daylight

  41. Summary • FOL extends PL by adding new concepts such as sets, relations and functions and new primitives such as variables, equality and quantifiers. • There exist several alternatives to perform inference in FOL. • Logic is not the only one alternative to represent knowledge. • Inference algorithms depend on the way knowledge is represented. • Development of expert systems relies heavily on knowledge representation and reasoning.

More Related