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.

Slides:



Advertisements
Similar presentations
First-Order Logic Chapter 8.
Advertisements

First-Order Logic.
Inference Rules Universal Instantiation Existential Generalization
Standard Logical Equivalences
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.
For Friday No reading Homework: –Chapter 9, exercise 4 (This is VERY short – do it while you’re running your tests) Make sure you keep variables and constants.
Logic.
1 Resolution in First Order Logic CS 171/271 (Chapter 9, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
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
1 FOL Resolution based Inferencing Resolution based rules studied earlier can lead to inferences, rules such as modus ponen, unit resolution etc… Other.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2004.
Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Knoweldge Representation & Reasoning
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Fall 2004.
Predicate Calculus.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2005.
1 Inference in First-Order Logic. 2 Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward chaining.
Cooperating Intelligent Systems Inference in first-order logic Chapter 9, AIMA.
CHAPTER 9 Oliver Schulte Inference in First-Order Logic.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
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.
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Logical Agents Logic Propositional Logic Summary
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.
Computing & Information Sciences Kansas State University Friday, 29 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 16 of 42 Friday, 29 September.
First Order Predicate Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Inference in First-Order Logic 부산대학교 전자전기컴퓨터공학과 인공지능연구실 김민호
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
1 Logical Inference Algorithms CS 171/271 (Chapter 7, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material.
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.
5/18/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 13, 5/18/2005 University of Washington, Department of Electrical Engineering Spring.
An Introduction to Artificial Intelligence – CE Chapter 9 - Inference in first-order logic Ramin Halavati In which we define.
1/19 Inference in first-order logic Chapter 9- Part2 Modified by Vali Derhami.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
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.
Dr. Shazzad Hosain Department of EECS North South Universtiy Lecture 04 – Part B Propositional Logic.
1 First Order Logic CS 171/271 (Chapter 8) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Inference in First-Order Logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Inference in first-order logic
Inference in 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
Inference in first-order logic
Inference in first-order logic part 1
Inference in First Order Logic (1)
First-Order Logic Inference
First-Order Logic Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

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

2 Propositional Logic Limitations Stating similar facts is cumbersome Can’t make generalizations The world (in propositional logic) contains facts, not objects Natural language deals with objects (nouns) and relations (verbs), hence is more expressive Ontological commitment of PL is limited

3 First Order Logic World consists of Objects Relations Functions Sentences are made up of Symbols: for constant objects, predicates, and functions Connectives: as in PL Quantifiers and variables:  x,  y

4 FOL Syntax Sentence Atomic Sentence ( Sentence Connective Sentence )  Sentence Quantifier Variable Sentence Atomic Sentence Predicate-Symbol( Term, … ) Term = Term

5 FOL Syntax Term (refers to an object) Function-Symbol( Term, … ) Constant-Symbol Variable Connective: , , , , Quantifier: ,  Variable: x, y, z, …

6 Example

7 Symbols Constants: John, Richard, C, L1, L2 Predicates: Person={John, Richard} King={Richard} Crown={C} Brother={(John,Richard),(Richard,John)} OnHead={(C,Richard)} Functions: LeftLeg={(Richard->L1),(John->L2)} (strictly speaking, the function should be total)

8 Models and Interpretations A model in FOL consists of the objects (domain elements) and relations (including functions) See example diagram “conceptual” view of world An interpretation associates the symbols to the objects, relations, and functions in the model Number of interpretations for a given set of symbols is combinatorially explosive

9 Semantics Truth of a sentence in FOL: Determined with respect to a model and an interpretation Analogous notions for entailment, validity, and satisfiability Model enumeration is impractical in FOL

10 Sample Sentences Person(John)  Person(Richard) OnHead(C, John) LeftLeg(John) = L1  LeftLeg(Richard) = L1 Richard, and LeftLeg(John) are examples of terms (a term is an expression that refers to an object) Atomic Sentences: constructed by equating terms (=) or by a predicate (with terms as arguments) Complex Sentences: sentences with connectives

11 Quantifiers Universal Quantification  x P is true in a model m iff P is true with x being each possible object in the model A conjunction of instantiations Existential Quantification  x P is true in a model m iff P is true with x being some object in the model A disjunction of instantiations

12 Sample Sentences Using Quantifiers  x King(x)  Person(x)  x Crown(x)  OnHead(x,John) “John has a crown on his head”  x  y Brother(x,y)  Brother(y,x)  x  y Brother(x,Richard)  Brother(y,Richard)   (x=y) “Richard has at least 2 brothers”

13 Properties of Quantifiers Nested Quantifiers  x  y P equivalent to  y  x P  y  x P equivalent to  y  x P Does not apply if quantifiers are different De Morgan’s law for quantifiers  x  P   x P  x P   x  P  x  P   x P  x P   x  P

14 More About Quantifiers Be careful when: Using quantifiers ( ,  ) in combination with ,  The domain consists of multiple kinds of objects In the quantified sentence (such as  x P or  x P), P would typically contain terms that are variables Not just ground terms (terms that have no variables)  x P as a query: binding list more important than truth of the sentence

15 Axioms and Theorems Axioms are sentences that represent first principles Plain facts Definitions Theorems are sentences entailed by axioms

16 Some Useful Domains Natural Numbers Built from 0, successor function S, and Peano axioms Sets , , , , and element insertion Lists Nil, Cons, Append, First, Rest, Find, …

17 FOL and the Wumpus World We can represent the Wumpus World in a more compact fashion Less sentences needed to represent rules We can include time and percept objects in the world A percept is represented as a list of constant symbols Predicates with time arguments capture the dynamic nature of the agent moving in this world

18 Knowledge Engineering Identify the task Assemble the relevant knowledge Decide on a vocabulary Encode general knowledge of the domain Encode the specific problem instance Pose queries to the inference procedure Debug the knowledge base

19 Inference Algorithms in FOL Reduction to Propositional Inference (Propositionalization) Lifting and Unification Resolution

20 Propositionalization Strategy: convert KB to propositional logic and then use PL inference Ground atomic sentences become propositional symbols What about the quantifiers?

21 Example KB in FOL:  x King(x)  Greedy(x)  Evil(x) King(John) Greedy(John) Brother(Richard,John) The last 3 sentences can be symbols in PL Apply Universal Instantiation to the first sentence

22 Universal Instantiation UI says that from a universally quantified sentence, we can infer any sentence obtained by substituting a ground term for the variable Back to Example From:  x King(x)  Greedy(x)  Evil(x) To: King(John)  Greedy(John)  Evil(John) King(Richard)  Greedy(Richard)  Evil(Richard) …

23 Issue with UI Ground terms: all symbols that refer to objects as well as function applications (recall that function applications return objects) For example, suppose Father is a function: Father(John) and Father(Richard) are also objects/ground terms But so are Father(Father(John)) and Father(Father(Father(John))) Infinitely many ground terms/instantiations

24 Existential Instantiation Whenever there is a sentence,  x P, introduce a new object symbol called the skolem constant and then add the unquantified sentence P, substituting the variable with that constant Example: From:  x Crown(x)  OnHead(x, John) To: Crown(C new )  OnHead(C new, John)

25 Substitution UI and EI apply substitutions A substitution is represented by a variable v and a ground term g; {v/g} Can have sets of these pairs if there are more variables involved Let  be a sentence (possibly containing v) SUBST( {v/g},  ) stands for the sentence that applies the substitution to 

26 UI and EI Defined UI:  v α ___ for any ground term g SUBST({v/g}, α) EI:  v α ___ for some constant symbol k not SUBST({v/k}, α) yet in the knowledge base

27 Back to Propositionalization Given a KB in FOL, convert KB to PL by 1. applying UI and EI to quantified sentences 2. converting atomic sentences to symbols If there are no functions (Datalog KB), UI application does not result in infinitely many sentences Regular PL Inference can now be carried out without problems What if there are functions?

28 Dealing with Infinitely Many Ground Terms Can set a depth-limit for ground terms Depth specifies levels of function nesting allowed Carry out reduction and inference process for depth 1, then 2, then 3, … Stop when entailment can be concluded This works if there is such a proof, but goes into an endless loop if there is not The strategy is complete The entailment problem in this sense is semidecidable

29 Inefficiencies in Propositionalization An inordinate number of irrelevant sentences may be generated, resulting from UI This motivates generating only those sentences that are important in entailment

30 Example Suppose KB contains:  x King(x)  Greedy(x)  Evil(x)  y Greedy(y) King(John) Suppose we want to conclude Evil(John) Because of the existence of objects other than John (such as Richard) and the existence of functions, UI will generate many sentences

31 Example, continued It is sufficient to generate: King(John)  Greedy(John)  Evil(John) Greedy(John) Which is just: SUBST( {x/John}, King(x)  Greedy(x)  Evil(x) ) SUBST( {y/John}, Greedy(y) ) Applying the substitution matches the Premises: King(x)  Greedy(x) With other sentences in the KB: Greedy(y), King(John)

32 Lifted Modus Ponens Lifting: Raising propositional inference rules to first order logic Example: Generalized Modus Ponens If there is a substitution θ, such that SUBST(θ, p i ) = SUBST(θ, p i ’) for all i, then p 1 ', p 2 ', …, p n ’, ( p 1  p 2  …  p n  q) _______________________________________________________________________________ SUBST(θ,q) In our example,  = {x/John, y/John}

33 Unification Process that makes logical expressions identical Goal: match the premises of implications so that conclusions can be derived UNIFY algorithm takes two sentences and returns a unifier (substitution) if it exists

34 Unification Algorithm

35 Unification Algorithm

36 About UNIFY UNIFY returns a Most General Unifier (MGU) There are efficiency issues with OCCUR-CHECK function May need to standardize apart: rename variables to avoid name clashes Unification is a key component of all first-order algorithms

37 Algorithms that use unification Forward and backward chaining algorithms Will not be discussed Resolution-based theorem proving systems

38 PL Resolution Revisited Recall PL Resolution algorithm: Convert (KB   ) to CNF Repeatedly get pairs of clauses and eliminate complementary literals If an empty clause results, KB ╞  Resolution applies to FOL, but we need to refine definitions of: CNF (for quantified sentences) Resolution inference rule / complimentary literals

39 CNF Conversion in FOL 1. Eliminate biconditionals and implications 2. Move  inwards (De Morgan’s) For quantifiers:  x P   x  P,  x P   x  P 3. Standardize variables Eliminate possible name clashes 4. Skolemize (Apply EI to existential sentences) Introduce Skolem constants or functions 5. Drop universal quantifiers 6. Distribute  over 

40 Example Everyone who loves all animals is loved by someone:  x [  y Animal(y)  Loves(x,y)]  [  y Loves(y,x)] 1. Eliminate biconditionals and implications  x [  y  Animal(y)  Loves(x,y)]  [  y Loves(y,x)] 2. Move  inwards:  x [  y  (  Animal(y)  Loves(x,y))]  [  y Loves(y,x)]  x [  y  Animal(y)   Loves(x,y)]  [  y Loves(y,x)]  x [  y Animal(y)   Loves(x,y)]  [  y Loves(y,x)] 3. Standardize variables: each quantifier should use a different one  x [  y Animal(y)   Loves(x,y)]  [  z Loves(z,x)]

41 Example, continued 4. Skolemize: a more general form of existential instantiation. Each existential variable is replaced by a Skolem function of the enclosing universally quantified variables:  x [Animal(F(x))   Loves(x,F(x))]  Loves(G(x),x) 5. Drop universal quantifiers: [Animal(F(x))   Loves(x,F(x))]  Loves(G(x),x) 6. Distribute  over  : [Animal(F(x))  Loves(G(x),x)]  [  Loves(x,F(x))  Loves(G(x),x)]

42 Resolution Lifted version of resolution inference rule: l 1  ···  l k, m 1  ···  m n (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 ) = θ. The two clauses are assumed to be standardized apart so that they share no variables For example,  Rich(x)  Unhappy(x), Rich(Ken) Unhappy(Ken) with θ = {x/Ken}

43

44 Making Resolution More Efficient Can favor particular clauses in the KB Unit preference (unit clauses) Sets of support Input resolution (e.g. “single spine”) Subsumption Reduces size of KB by eliminating redundant sentences