1 First Order Logic. 2 Knowledge Representation & Reasoning  Introduction Propositional logic is declarative Propositional logic is compositional: meaning.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

First-Order Logic Chapter 8.
First-Order Logic.
Inference Rules Universal Instantiation Existential Generalization
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
Inference in FOL All rules of inference for propositional logic apply to first-order logic We just need to reduce FOL sentences to PL sentences by instantiating.
First-Order Logic Inference
Logic. Propositional Logic Logic as a Knowledge Representation Language A Logic is a formal language, with precisely defined syntax and semantics, which.
First-Order Logic Chapter 8.
1 Problem Solving CS 331 Dr M M Awais Representational Methods Formal Methods Propositional Logic Predicate Logic.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
Predicate Calculus.
CE An introduction to Artificial Intelligence CE Chapter 8: First Order Logic Ramin Halavati In which we notice that.
Propositional Logic Agenda: Other forms of inference in propositional logic Basics of First Order Logic (FOL) Vision Final Homework now posted on web site.
1 Inference in First-Order Logic. 2 Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward chaining.
FIRST ORDER LOGIC Levent Tolga EREN.
Knowledge representation methods جلسه سوم. KR is AI bottleneck The most important ingredient in any expert system is knowledge. The power of expert systems.
Inference in First-Order Logic CS 271: Fall 2007 Instructor: Padhraic Smyth.
Inference in first-order logic I CIS 391 – Introduction to Artificial Intelligence AIMA Chapter (through p. 278) Chapter 9.5 (through p. 300)
1 Inference in first-order logic Chapter 9. 2 Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Propositional Calculus Composed of symbols –P – some true statement P might represent something like “It is Monday” or “the car is red” And sentences –a.
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 3 Logic Representations (Part 3)
Limitation of propositional logic  Propositional logic has very limited expressive power –(unlike natural language) –E.g., cannot say "pits cause breezes.
First-Order Logic Chapter 8. Outline Why FOL? Syntax and semantics of FOL Using FOL Wumpus world in FOL Knowledge engineering in FOL.
Inference in first- order logic. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward chaining.
Inference in First-Order Logic 부산대학교 전자전기컴퓨터공학과 인공지능연구실 김민호
1 Unification ( 統一 ) Forward Chaining ( 前向き仮説推理 ) Backward Chaining ( 後ろ向き仮説推理 ) Unification ( 統一 ) Forward Chaining ( 前向き仮説推理 ) Backward Chaining ( 後ろ向き仮説推理.
1 Knowledge Representation & Reasoning First Order Logic chapter 6 Dr Souham Meshoul CAP492.
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 24, 2012.
1 Inference in First-Order Logic CS 271: Fall 2009.
1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.
An Introduction to Artificial Intelligence – CE Chapter 9 - Inference in first-order logic Ramin Halavati In which we define.
Artificial Intelligence First-Order Logic (FOL). Outline of this Chapter The need for FOL? What is a FOL? Syntax and semantics of FOL Using FOL.
1 First Order Logic CS 171/271 (Chapters 8 and 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.
For Wednesday Read chapter 9, sections 1-3 Homework: –Chapter 7, exercises 8 and 9.
For Friday Read chapter 8 Homework: –Chapter 7, exercises 2 and 10 Program 1, Milestone 2 due.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 11 Jim Martin.
Inference in first-order logic
First-Order Logic Chapter 8 (not 8.1). Outline Why FOL? Why FOL? Syntax and semantics of FOL Syntax and semantics of FOL Using FOL Using FOL Wumpus world.
Inference in First Order Logic. Outline Reducing first order inference to propositional inference Unification Generalized Modus Ponens Forward and backward.
First-Order Logic. Outline Why FOL? Syntax and semantics of FOL Using FOL Knowledge engineering in FOL.
First-Order Logic Reading: C. 8 and C. 9 Pente specifications handed back at end of class.
First-Order Logic Semantics Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read: FOL.
1 First Order Logic CS 171/271 (Chapter 8) Some text and images in these slides were drawn from Russel & Norvig’s published material.
First-Order Logic Chapter 8. Problem of Propositional Logic  Propositional logic has very limited expressive power –E.g., cannot say "pits cause breezes.
Lecture 041 Predicate Calculus Learning outcomes Students are able to: 1. Evaluate predicate 2. Translate predicate into human language and vice versa.
Inference in First-Order Logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
First-Order Logic Chapter 8.
Knowledge Representation using First-Order Logic
Inference in first-order logic
Inference in First-Order Logic
First-Order Logic Chapter 8.
First Order Logic.
Inference in First-Order Logic
Inference in first-order logic part 1
Artificial intelli-gence 1:Inference in first-order logic
Artificial intelligence: Inference in first-order logic
Artificial Intelligence Inference in First Order Logic
First-Order Logic Chapter 8.
Inference in first-order logic
Inference in first-order logic part 1
Inference in First Order Logic (1)
First-Order Logic Chapter 8.
First-Order Logic Inference
Presentation transcript:

1 First Order Logic

2 Knowledge Representation & Reasoning  Introduction Propositional logic is declarative 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 limited expressive power unlike natural language e.g., cannot say "pits cause breezes in adjacent squares“ (except by writing one sentence for each square)

3 Knowledge Representation & Reasoning  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 Knowledge Representation & Reasoning  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: red, round, prime, brother of, bigger than, part of, … Functions: Sqrt, Plus, … Can express the following: –Squares neighboring the Wumpus are smelly; –Squares neighboring a pit are breezy.

5 Knowledge Representation & Reasoning  Syntax Order Logic User defines these primitives: 1.Constant symbols (i.e., the "individuals" in the world) e.g., Mary, 3 2.Function symbols (mapping individuals to individuals) e.g., father-of(Mary) = John, colorof(Sky) = Blue 3.Predicate/relation symbols (mapping from individuals to truth values) e.g., greater(5,3), green(apple), color(apple, Green)

6 Knowledge Representation & Reasoning  Syntax Order Logic FOL supplies these primitives: 1.Variable symbols. e.g., x,y 2.Connectives. Same as in PL: ⇔,∧,∨, ⇒ 3.Equality = 4.Quantifiers: Universal ( ∀ ) and Existential ( ∃ ) A legitimate expression of predicate calculus is called a well-formed formula (wff) or, simply, a sentence.

7 Knowledge Representation & Reasoning  Syntax Order Logic Quantifiers: Universal ( ∀ ) and Existential ( ∃ ) Allow us to express properties of collections of objects instead of enumerating objects by name Universal: “for all”: ∀ Existential: “there exists” ∃

8 Knowledge Representation & Reasoning  Syntax Order Logic: Constant Symbols A symbol, e.g. Wumpus, Ali. 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.

9 Knowledge Representation & Reasoning  Syntax Order Logic: Variables Used to represent objects or properties of objects without explicitly naming the object. Usually lower case. For example: –x –father –square.

10 Knowledge Representation & Reasoning  Syntax 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: Instructor (CAP492, Souham)

11 Knowledge Representation & Reasoning  Syntax 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

12 Knowledge Representation & Reasoning  Syntax 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)

13 Knowledge Representation & Reasoning  Syntax Order Logic: Atomic sentence Atomic sentence = predicate (term1,...,termn) or term1 = term2 Term = function (term1,...,termn) or constant or variable Example terms: Brother(Ali, Mohamed) Greater(Length(x), Length(y))

14 Knowledge Representation & Reasoning  Syntax 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,y Sibling(x,y) ⇒ Sibling(y,x)

15 Knowledge Representation & Reasoning  While constant symbols, variables and connectives are like propositional logic, “What are functions and predicates?” The language of logic is based on set theory: –Sets; –Relations; –Functions.

16 Knowledge Representation & Reasoning SETS: The set of objects defines a “Universe of Discourse.” [Objects are represented by Constant Symbols.] a b c d e 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}.

17 Knowledge Representation & Reasoning RELATIONS: Def: A binary relation is a set of ordered pairs Example: Consider set of blocks {a,b,c,d,e} a b c d e The “on” relation: on = {,, }. The predicate On(A,B) can be interpreted as:  on. On(A,B) is TRUE, but On(A,C) and On(C,D) are FALSE in this interpretation.

18 Knowledge Representation & Reasoning 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  F and  F  y=z If  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).

19 Knowledge Representation & Reasoning FUNCTIONS: a b c d e hat = {,, } hat (c) = b hat(b) = a hat(d) is not defined. Hat(E) can be interpreted as d Using FOL On(A,B) On(B,C) On(D,E) On(A,Hat(C))

20 Knowledge Representation & Reasoning 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 |X 1 … Variable → a | x | s | … Predicate → Before | hascolor | …. Function → Mother | Leftleg |…

21 Knowledge Representation & Reasoning Inference in First Order Logic Inference in FOL can be performed by: Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Resolution Forward chaining Backward chaining

22 Knowledge Representation & Reasoning 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.

23 Knowledge Representation & Reasoning 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/Sam, y/Pam}, Likes(x,y)) = Likes(Ali, fatima)

24 Knowledge Representation & Reasoning 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))

25 Knowledge Representation & Reasoning 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

26 Knowledge Representation & Reasoning 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) The new KB is propositionalized

27 Knowledge Representation & Reasoning Inference in First Order Logic Reduction to PL CLAIM: A ground sentence is entailed by a new KB iff entailed by the original KB. CLAIM: 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)))

28 Knowledge Representation & Reasoning 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) ∀ y Greedy(y) It is intuitively clear that we can substitute {x/John,y/John} and obtain that Evil(John)

29 Knowledge Representation & Reasoning Inference in First Order Logic 2.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(θ, β) α β Subst Knows(John,x) Knows(John,Jane) {x/Jane} Knows(John,x) Knows(y,OJ) {x/OJ,y/John} Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)}} Knows(John,x) Knows(x,OJ) {fail}

30 Knowledge Representation & Reasoning Inference in First Order Logic 3.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.

31 Knowledge Representation & Reasoning Inference in First Order Logic 3.Resolution Full first-order version: l 1 ∨ ··· ∨ l k, m 1 ∨ ··· ∨ m n Subst( θ, l 1 ∨ ··· ∨ l i-1 ∨ l i+1 ∨ ··· ∨ l k ∨ m 1 ∨ ··· ∨ m j-1 ∨ m j+1 ∨ ··· ∨ m n ) where θ = Unify( l i, ¬m j ) ¬ Rich(x) ∨ Unhappy(x), Rich(Ken) Unhappy(Ken) with θ = {x/Ken} Apply resolution steps to CNF(KB ∧ ¬α); complete for FOL

32 Knowledge Representation & Reasoning Inference in First Order Logic 4. 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 known then add the conclusion to the KB and continue chaining. Forward chaining is data-driven, e.g., inferring properties and categories from percepts.

33 Knowledge Representation & Reasoning Inference in First Order Logic 4. Forward chaining example. Rules 1.Buffalo(x)  Pig(y)  Faster(x, y) 2.Pig(y)  Slug(z)  Faster(y, z) 3.Faster(x, y)  Faster(y, z)  Faster(x, z) Facts 1.Buffalo(Bob) 2.Pig(Pat) 3.Slug(Steve) New facts 4.Faster(Bob,Pat) 5.Faster(Pat, Steve) 6.Faster (Bob, Steve) Buffalo(Bob)Pig (Pat) { y/Pat } {x/Bob} Faster (Bob,Pat) Slug(Steve) Faster(Pat,Steve) Faster(Bob,Steve) { z/Steve } {x/Bob, y/Pat}{y/Pat, z/Steve}

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

35 Knowledge Representation & Reasoning  Other knowledge representation schemes 1.Semantic Networks A semantic network consists of entities and relations between the entities. Generally it is represented as a graph. A bird is a kind of animal Flying is the normal moving method of birds An albatross is a bird Albert is an albatross, and so is Ross

36 Knowledge Representation & Reasoning  Other knowledge representation schemes 1.Semantic Networks Bird daylight fly animal albatross Black and white Albert Ross colour isa Moving-method Active-at

37 Knowledge Representation & Reasoning  Other knowledge representation schemes 2. Frames A frame is a data structure whose components are called slots. Slots have names and accomodate information of various kinds. Example: Frame: Bird A_kind_of: animal Moving_method: fly Active_at:daylight

38 Knowledge Representation & Reasoning  Expert Systems (ES) Definition: an ES is a program that behaves like an expert for some problem domain. Should be capable of explaining its decisions and the underlying reasoning. Often, it is expected to be able to deal with uncertain and incomplete information. Application domains: Medical diagnosis (MYCIN), locating equipment failures,…

39 Knowledge Representation & Reasoning  Expert Systems (ES) Functions and structure: Expert systems are designed to lve problems that require expert knowledge in a particular domain → possessing knowledge in some form. ES are known as knowledge based systems. Expert systems have to have a friendly user interaction capability that will make the system’s reasoning transparent to the user.

40 Knowledge Representation & Reasoning  Expert Systems (ES) Functions and structure: The structure of an ES includes three main modules: 1.A knowledge base 2.An inference engine 3.A user interface Knowledge base Inference engine User interface user Shell

41 Knowledge Representation & Reasoning  Expert Systems (ES) Functions and structure: 1.The knowledge base comprises the knowledge that is specific to the domain of application: simple facts, rules, constraints and possibly also methods, heuristics and ideas for solving problems. 2.Inference engine: designed to use actively the knowledge in the base deriving new knoweldge to help decision making. 3.User interface: caters for smooth communication between the user and the system.

42 Knowledge Representation & Reasoning 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 sevaral 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 knoweldge representation and reasoning.