Artificial Intelligence

Slides:



Advertisements
Similar presentations
Simplifications of Context-Free Grammars
Advertisements

Variations of the Turing Machine
Applications Computational LogicLecture 11 Michael Genesereth Spring 2004.
1 Knowledge Representation Introduction KR and Logic.
1 Knowledge and reasoning – second part Knowledge representation Logic and representation Propositional (Boolean) logic Normal forms Inference in propositional.
Artificial Intelligence: Natural Language and Prolog
First-Order Logic Chapter 8.
Inference in First-Order Logic
1
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
1 Hyades Command Routing Message flow and data translation.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
Programming Language Concepts
Knowledge Representation using First-Order Logic CS 271: Fall 2007 Instructor: Padhraic Smyth.
Some Prolog Prolog is a logic programming language
Inference in first-order logic
First-Order Logic.
Turing Machines.
PP Test Review Sections 6-1 to 6-6
Bellwork Do the following problem on a ½ sheet of paper and turn in.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
1 Declarative Programming Motivation Warm Fuzzies What is Logic?... Logic Programming? Mechanics of Prolog Terms, Substitution, Unification, Horn Clauses,
Russell and Norvig Chapter 7
1 Let’s Recapitulate. 2 Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Essential Cell Biology
PSSA Preparation.
Inference Rules Universal Instantiation Existential Generalization
First-Order Logic: Better choice for Wumpus World Propositional logic represents facts First-order logic gives us Objects Relations: how objects relate.
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.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
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.
Agents That Reason Logically Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 7 Spring 2004.
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Logic.
3/30/00 Agents that Reason Logically by Chris Horn Jiansui Yang Xiaojing Wu.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 9 Jim Martin.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Knowledge Representation & Reasoning (Part 1) Propositional Logic chapter 6 Dr Souham Meshoul CAP492.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Knowledge in intelligent systems So far, we’ve used relatively specialized, naïve agents. How can we build agents that incorporate knowledge and a memory?
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 8 Jim Martin.
First-Order Logic: Better choice for Wumpus World Propositional logic represents facts First-order logic gives us Objects Relations: how objects relate.
Knoweldge Representation & Reasoning
Knowledge Representation & Reasoning (Part 1) Propositional Logic chapter 5 Dr Souham Meshoul CAP492.
Logical Agents Chapter 7 Feb 26, Knowledge and Reasoning Knowledge of action outcome enables problem solving –a reflex agent can only find way from.
Logical Agents Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 7 Spring 2005.
Agents that Reason Logically Logical agents have knowledge base, from which they draw conclusions TELL: provide new facts to agent ASK: decide on appropriate.
Inference is a process of building a proof of a sentence, or put it differently inference is an implementation of the entailment relation between sentences.
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
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Class Project Due at end of finals week Essentially anything you want, so long as its AI related and I approve Any programming language you want In pairs.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
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.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
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 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start  Breeze.
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.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
1 UNIT-3 KNOWLEDGE REPRESENTATION. 2 Agents that reason logically(Logical agents) A Knowledge based Agent The Wumpus world environment Representation,
First-Order Logic Chapter 8. Problem of Propositional Logic  Propositional logic has very limited expressive power –E.g., cannot say "pits cause breezes.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Knowledge and reasoning – second part
EA C461 – Artificial Intelligence Logical Agent
Artificial Intelligence
Knowledge and reasoning – second part
Presentation transcript:

Artificial Intelligence First-Order Logic Inference in First-Order Logic

First-Order Logic: Better choice for Wumpus World Propositional logic represents facts First-order logic gives us Objects Relations: how objects relate to each other Properties: features of an object Functions: output an object, given others

Syntax and Semantics Propositional logic has the following: Constant symbols: book, A, cs327 Predicate symbols: specify that a given relation holds Example: Teacher(CS327sec1, Barb) Teacher(CS327sec2, Barb) “Teacher” is a predicate symbol For a given set of constant symbols, relation may or may not hold

Syntax and Semantics Function Symbols Variables FatherOf(Luke) = DarthVader Variables Refer to other symbols x, y, a, b, etc. In Prolog, capitalization is reverse: Variables are uppercase Symbols are lower case Prolog example ([user], ;)

Syntax and Semantics Atomic Sentences Complex Sentences Equality Father(Luke,DarthVader) Siblings(SonOf(DarthVader), DaughterOf(DarthVader)) Complex Sentences and, or, not, implies, equivalence Equality

Universal Quantification “For all, for every”: Examples: Usually use with Common mistake to use

Existential Quantification “There exists”: Typically use with Common mistake to use True if there is no one at Carleton!

Properties of quantifiers Can express each quantifier with the other

Some examples Definition of sibling in terms of parent:

First-Order Logic in Wumpus World Suppose an agent perceives a stench, breeze, no glitter at time t = 5: Percept([Stench,Breeze,None],5) [Stench,Breeze,None] is a list Then want to query for an appropriate action. Find an a (ask the KB):

Simplifying the percept and deciding actions Simple Reflex Agent Agent Keeping Track of the World

Using logic to deduce properties Define properties of locations: Diagnostic rule: infer cause from effect Causal rule: infer effect from cause Neither is sufficient: causal rule doesn’t say if squares far from pits can be breezy. Leads to definition:

Keeping track of the world is important Without keeping track of state... Cannot head back home Repeat same actions when end up back in same place Unable to avoid infinite loops Do you leave, or keep searching for gold? Want to manage time as well Holding(Gold,Now) as opposed to just Holding(Gold)

Situation Calculus Adds time aspects to first-order logic Result function connects actions to results

Describing actions Pick up the gold! Stated with an effect axiom When you pick up the gold, still have the arrow! Nonchanges: Stated with a frame axiom

Cleaner representation: successor-state axiom For each predicate (not action): P is true afterwards means An action made P true, OR P true already and no action made P false Holding the gold: (if there was such a thing as a release action – ignore that for our example)

Difficulties with first-order logic Frame problem Need for an elegant way to handle non-change Solved by successor-state axioms Qualification problem Under what circumstances is a given action guaranteed to work? e.g. slippery gold Ramification problem What are secondary consequences of your actions? e.g. also pick up dust on gold, wear and tear on gloves, etc. Would be better to infer these consequences, this is hard

Keeping track of location Direction (0, 90, 180, 270) Define function for how orientation affects x,y location

Location cont... Define location ahead: Define what actions do (assuming you know where wall is):

Primitive goal based ideas Once you have the gold, your goal is to get back home How to work out actions to achieve the goal? Inference: Lots more axioms. Explodes. Search: Best-first (or other) search. Need to convert KB to operators Planning: Special purpose reasoning systems

Some Prolog Prolog is a logic programming language Used for implementing logical representations and for drawing inference We will do: Some examples of Prolog for motivation Generalized Modus Ponens, Unification, Resolution Wumpus World in Prolog

Inference in First-Order Logic Need to add new logic rules above those in Propositional Logic Universal Elimination Existential Elimination (Person1 does not exist elsewhere in KB) Existential Introduction

Example of inference rules “It is illegal for students to copy music.” “Joe is a student.” “Every student copies music.” Is Joe a criminal? Knowledge Base:

Example cont... Universal Elimination Existential Elimination Modus Ponens

How could we build an inference engine? Software system to try all inferences to test for Criminal(Joe) A very common behavior is to do: And-Introduction Universal Elimination Modus Ponens

Example of this set of inferences 4 & 5 Generalized Modus Ponens does this in one shot

Substitution A substitution s in a sentence binds variables to particular values Examples:

Unification A substitution s unifies sentences p and q if ps = qs. p q Knows(John,x) Knows(John,Jane) Knows(y,Phil) Knows(y,Mother(y))

Unification p q s Knows(John,x) Knows(John,Jane) {x/Jane} Knows(y,Phil) {x/Phil,y/John} Knows(y,Mother(y)) {y/John, x/Mother(John)} Use unification in drawing inferences: unify premises of rule with known facts, then apply to conclusion If we know q, and Knows(John,x)  Likes(John,x) Conclude Likes(John, Jane) Likes(John, Phil) Likes(John, Mother(John))

Generalized Modus Ponens Two mechanisms for applying binding to Generalized Modus Ponens Forward chaining Backward chaining

Forward chaining Start with the data (facts) and draw conclusions 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 add the conclusion to the KB and continue chaining

Forward Chaining Example

Backward Chaining Start with the query, and try to find facts to support it When a query q is asked: If a matching fact q’ is known, return unifier For each rule whose consequent q’ matches q attempt to prove each premise of the rule by backward chaining Prolog does backward chaining

Backward Chaining Example

Completeness in first-order logic A procedure is complete if and only if every sentence a entailed by KB can be derived using that procedure Forward and backward chaining are complete for Horn clause KBs, but not in general

Example

Resolution Resolution is a complete inference procedure for first order logic Any sentence a entailed by KB can be derived with resolution Catch: proof procedure can run for an unspecified amount of time At any given moment, if proof is not done, don’t know if infinitely looping or about to give an answer Cannot always prove that a sentence a is not entailed by KB First-order logic is semidecidable

Resolution

Resolution Inference Rule

Resolution Inference Rule In order to use resolution, all sentences must be in conjunctive normal form bunch of sub-sentences connected by “and”

Converting to Conjunctive Normal Form (briefly)

Example: Using Resolution to solve problem

Sample Resolution Proof

What about Prolog? Only Horn clause sentences semicolon (“or”) ok if equivalent to Horn clause Negation as failure: not P is considered proved if system fails to prove P Backward chaining with depth-first search Order of search is first to last, left to right Built in predicates for arithmetic X is Y*Z+3 Depth-first search could result in infinite looping

Theorem Provers Theorem provers are different from logic programming languages Handle all first-order logic, not just Horn clauses Can write logic in any order, no control issue

Sample theorem prover: Otter Define facts (set of support) Define usable axioms (basic background) Define rules (rewrites or demodulators) Heuristic function to control search Sample heuristic: small and simple statements are better OTTER works by doing best first search http://www-unix.mcs.anl.gov/AR/sobb/ Boolean algebras