First Order Predicate Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.

Slides:



Advertisements
Similar presentations
Knowledge Representation using First-Order Logic
Advertisements

Artificial Intelligence
First-Order Logic Chapter 8.
Some Prolog Prolog is a logic programming language
March 2, 2006AI: Chapter 8: First-Order Logic1 Artificial Intelligence Chapter 8: First-Order Logic Michael Scherger Department of Computer Science Kent.
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.
Artificial Intelligence
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 CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Logic.
(FO) Inference Methods CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Knowledge Representation Methods
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Logic. Propositional Logic Logic as a Knowledge Representation Language A Logic is a formal language, with precisely defined syntax and semantics, which.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2004.
Inference in First-Order Logic
Knowledge Representation using First-Order Logic (Part III) This lecture: R&N Chapters 8, 9 Next lecture: Chapter 13; Chapter (Please read lecture.
Predicate Calculus.
Agents that Reason Logically Logical agents have knowledge base, from which they draw conclusions TELL: provide new facts to agent ASK: decide on appropriate.
First-Order Logic Knowledge Representation Reading: Chapter 8, , FOL Syntax and Semantics read: FOL Knowledge Engineering read:
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
Logical Inference 2 rule based reasoning
Pattern-directed inference systems
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
1 Last time: Logic and Reasoning Knowledge Base (KB): contains a set of sentences expressed using a knowledge representation language TELL: operator to.
March 14, 2006AI: Chapter 9: Inference in First- Order Logic 1 Artificial Intelligence Chapter 9: Inference in First- Order Logic Michael Scherger Department.
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 FOL Compared to predicate logic, more abstract reasoning and specific conclusions.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Logic Programming Languages Session 13 Course : T Programming Language Concept Year : February 2011.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 24, 2012.
CPSC 386 Artificial Intelligence Ellen Walker Hiram College
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.
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.
Propositional Logic Predicate 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.
Review: What is a logic? A formal language –Syntax – what expressions are legal –Semantics – what legal expressions mean –Proof system – a way of manipulating.
1 CS 2710, ISSP 2610 Chapter 8, Part 1 First Order Predicate Calculus FOPC.
First-Order Logic Knowledge Representation
Introduction to Logic for Artificial Intelligence Lecture 2
Logical Inference 2 Rule-based reasoning
Knowledge Representation using First-Order Logic
Presented By S.Yamuna AP/CSE
First-Order Logic Chapter 8.
Artificial Intelligence First Order Logic
Logical Inference 2 Rule-based reasoning
First-Order Logic Knowledge Representation
First-Order Logic Knowledge Representation
First-Order Logic Knowledge Representation
First-Order Logic Chapter 8.
Introduction to Artificial Intelligence
Knowledge Representation using First-Order Logic (Part III)
First-Order Logic Knowledge Representation
First-Order Logic Chapter 8.
Presentation transcript:

First Order Predicate Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College

First Order Logic (ch. 8) Has a greater expressive power than propositional logic –We no longer need a separate rule for each square to say which other squares are breezy/pits Allows for facts, objects, and relations –In programming terms, allows classes, functions and variables

Components of First Order Logic Term –Constant, e.g. Red –Function of constant, e.g. Color(Block1) Atomic Sentence –Predicate relating objects (no variable) Brother (John, Richard) Married (Mother(John), Father(John)) Complex Sentences –Atomic sentences + logical connectives Brother (John, Richard)  Brother (John, Father(John))

More Components… Quantifiers –Each quantifier defines a variable for the duration of the following expression, and indicates the truth of the expression… Universal quantifier “for all”  –The expression is true for every possible value of the variable Existential quantifer “there exists”  –The expression is true for at least one value of the variable

Quantification examples Everyone like chocolate –  x, likes(x, chocolate) Someone likes chocolate –  x, likes(x, chocolate) All children like chocolate –  x, child(x)  likes(x, chocolate) Everyone likes chocolate unless they are allergic to it –  x, likes(x, chocolate)  allergic(x, chocolate) –  x,  allergic (x, chocolate)  likes(x, chocolate)

Quantification and Negation Not everyone like chocolate  (  x, likes(x, chocolate))  x,  likes(x, chocolate) No one likes chocolate  (  x, likes(x, chocolate))  x,  likes(x, chocolate)

Nesting Variables Everyone likes some kind of food  y  x, food(x)  likes(y, x) There is a kind of food that everyone likes  x  y, food(x)  likes(y, x) Someone likes all kinds of food  y  x, food(x)  likes(y, x) Every food has someone who likes it  x  y, food(x)  likes(y, x)

Quantification with Classes To say “everyone likes chocolate”, the following is too broad! –  x, likes(x, chocolate) –Example: likes (chocolate, chocolate) We mean: Every one (who is a person) likes chocolate –  x, person(x)  likes(x, chocolate) Essentially, the left side of the rule declares the class of the variable x Constraints like this are often called “domain constraints”

Equality We allow the usual infix = operator –Father(John) = Henry –  x, sibling(x, y)   (x=y) Generally, we also allow mathematical operations when needed, e.g. –  x,y, NatNum(x)  NatNum(y)  x = (y+1)  x > y

Try some! Every successful person has a mentor. Every successful person is a mentor. Every mentor is a successful person. No person is successful without a mentor. There are no successful people who are mentors.

Using FOL to Model the World Tell the system assertions –Facts : Tell (KB, person (John) ) –Rules: Tell (KB,  x, person(x)  likes(x, chocolate)) Ask questions –Ask (KB, person(John)) –Ask (KB, likes(John, chocolate)) –Ask (KB, likes(x, chocolate))

Types of Answers Fact is in the KB –Yes. Fact is not in the KB –Yes (if it can be proven from the KB) –No (otherwise) Fact contains variables –List of bindings for which the fact can be proven, e.g. ((x John) (x Ellen) … )

Example Domains (pp ) Kinship domain –What is a second cousin once removed, anyway? Numbers, sets, and lists –This one is a classic. You should understand these, even if you don’t memorize them. The Wumpus World –Note how much simpler the description is in FOL! “Whatever your domain, if the axioms correctly and completely describe how the world works, any complete logical inference procedure will infer the strongest possible description of the world, given the available percepts” (AIMA, p. 260)

Knowledge Engineering Translating real-world knowledge to a usable form 1. Identify the task (PEAS description) 2. Assemble the relevant knowledge (knowledge acquisition) 3. Decide on the vocabulary: predicates, functions, constants (ontology) 4. Encode general knowledge 5. Encode a specific problem instance 6. Query and debug …

Types of Rules Diagnostic Rules lead from observed effects to hidden causes (like medical diagnosis) Causal Rules lead from (hidden) causes to observed effects (like simulation systems) Systems should reason either one way or the other, but not mix rules of both types (to avoid circular reasoning!)

Necessary algorithms (Ch. 9) We already know enough to implement TELL (although maybe not efficiently) But how do we implement ASK? Recall 3 cases –Direct matching –Finding a proof (inference) –Finding a set of bindings (unification)

Inference with Quantifiers Universal Instantiation: –Given  x, person(x)  likes(x, chocolate) –Infer person(john)  likes(john, chocolate) Existential Instantiation: –Given  x, likes(x, chocolate) –Infer  likes(S1, chocolate) –S1 is a “Skolem Constant” that is not found anywhere else in the KB and refers to (one of) the indviduals that likes chocolate.

Reduction to Propositional Inference Use instantiation rules to create relevant (!) propositional facts in the KB, then use propositional reasoning Problems: –May generate infinite sentences when it cannot prove –Will generate many irrelevant sentences along the way!

Generalized Modus Ponens This is a general inference rule for FOL that does not require instantiation Given: – p1’, p2’ … pn’ (p1  … pn)  q –Subst(theta, pi’) = subst(theta, pi) for all i Conclude: –Subst(theta, q)

Simple Example of GMP Rule: king(x)  rich(x) –p1 = king(x), q = rich(x) Fact: king(John) –p1’ = king(John) Theta is x = John –Subst(x=John, king(x)) = king(John) –Subst(x=John, rich(x)) = rich(John) We can conclude rich(John).

GMP in “CS terms” Given a rule containing variables If there is a consistent set of bindings for all of the variables of the left side of the rule (before the arrow) Then you can derive the result of substituting all of the same variable bindings into the right side of the rule

GMP Example  x, parent(x,y)  parent(y,z)  grandparent(x,z) Parent(james, john), parent(james, richard), parent(harry, james), parent(charles,hal) We can derive: –Grandparent(harry, john), bindings: ((x harry) (y james) (z john)) –Grandparent(harry, richard), bindings: ((x harry) (y james) (z richard))

Unification Process of finding all legal substitutions Given 2 expressions Find a set of unifiers (variable bindings) that causes the expressions to “match” This is a beautifully recursive algorithm.

Base Cases for Unification If two expressions are identical, the result is (NIL) (succeed with empty unifier set) If two expressions are different constants, the result is NIL (fail) If one expression is a variable and is not contained in the other, the result is ((variable other-exp))

Recursive Case If both expressions are lists, –Combine the results of unifying the CAR with unifying the CDR –(append (unify (car list1) (car list2)) (unify (cdr list1) (cdr list2))

A few more details… Don’t reuse variable names –Before actually unifying, give each rule a separate set of variables. –The lisp function gentemp creates uniquely numbered variables Keep track of bindings –If a variable is already bound to something, it must retain the same value throughout the computation. –This requires substituting each successful binding in the remainder of the expression.

Storage and retrieval Most systems don’t use variables on predicates Therefore, hash statements by predicate for quick retrieval (predicate indexing) Subsumption lattice for efficiency (see p. 279)

Forward Chaining Given a new fact, generate all consequences Assumes all rules are of the form –C1 and c2 and c3 and…. --> result Each rule & binding generates a new fact This new fact will “trigger” other rules Keep going until the desired fact is generated (Semi-decidable as is FOL in general)

Efficient Forward Chaining Order conjuncts appropriately –E.g. most constrained variable Don’t generate redundant facts; each new fact should depend on at least one newly generated fact. –Production systems –RETE matching –CLIPS

Backward Chaining Consider the item to be proven a goal Find a rule whose head is the goal (and bindings) Apply bindings to the body, and prove these (subgoals) in turn If you prove all the subgoals, increasing the binding set as you go, you will prove the item. Logic Programming (SWI Prolog)