Logical Agents ECE457 Applied Artificial Intelligence Spring 2007 Lecture #6.

Slides:



Advertisements
Similar presentations
Russell and Norvig Chapter 7
Advertisements

Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Logic Use mathematical deduction to derive new knowledge.
Agents That Reason Logically Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 7 Spring 2004.
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Logic.
3/30/00 Agents that Reason Logically by Chris Horn Jiansui Yang Xiaojing Wu.
Artificial Intelligence Knowledge-based Agents Russell and Norvig, Ch. 6, 7.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Logic in general Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language.
Knowledge Representation & Reasoning.  Introduction How can we formalize our knowledge about the world so that:  We can reason about it?  We can do.
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.
Cooperating Intelligent Systems Logical agents Chapter 7, AIMA This presentation owes some to V. Rutgers and D. OSU.
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?
Logical Agents Chapter 7.
Methods of Proof Chapter 7, second half.
Cooperating Intelligent Systems Logical agents Chapter 7, AIMA This presentation owes some to V. Rutgers and D. OSU.
Knoweldge Representation & Reasoning
Artificial Intelligence
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.
Rutgers CS440, Fall 2003 Propositional Logic Reading: Ch. 7, AIMA 2 nd Ed. (skip )
Logical Agents Chapter 7 (based on slides from Stuart Russell and Hwee Tou Ng)
Logical Agents. Knowledge bases Knowledge base = set of sentences in a formal language Declarative approach to building an agent (or other system): 
February 20, 2006AI: Chapter 7: Logical Agents1 Artificial Intelligence Chapter 7: Logical Agents Michael Scherger Department of Computer Science Kent.
‘In which we introduce a logic that is sufficent for building knowledge- based agents!’
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,
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
1 Problems in AI Problem Formulation Uninformed Search Heuristic Search Adversarial Search (Multi-agents) Knowledge RepresentationKnowledge Representation.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
S P Vimal, Department of CSIS, BITS, Pilani
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 Agents Chapter 7. 2 A simple knowledge-based agent The agent must be able to: –Represent states, actions, etc. –Incorporate new percepts –Update.
Knowledge Representation Lecture # 17, 18 & 19. Motivation (1) Up to now, we concentrated on search methods in worlds that can be relatively easily represented.
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.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Dr. Shazzad Hosain Department of EECS North South Universtiy Lecture 04 – Part B Propositional Logic.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Logical Agents Russell & Norvig Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean)
1 UNIT-3 KNOWLEDGE REPRESENTATION. 2 Agents that reason logically(Logical agents) A Knowledge based Agent The Wumpus world environment Representation,
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents ECE457 Applied Artificial Intelligence Spring 2008 Lecture #6.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7 Part I. 2 Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents. Inference : Example 1 How many variables? 3 variables A,B,C How many models? 2 3 = 8 models.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
ECE457 Applied Artificial Intelligence Fall 2007 Lecture #6
EA C461 Artificial Intelligence
EA C461 – Artificial Intelligence Logical Agent
Logical Agents Chapter 7 Selected and slightly modified slides from
Logical Agents Reading: Russell’s Chapter 7
Logical Agents Chapter 7.
Artificial Intelligence
CS 416 Artificial Intelligence
Logical Agents Chapter 7.
Methods of Proof Chapter 7, second half.
Logical Agents Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

Logical Agents ECE457 Applied Artificial Intelligence Spring 2007 Lecture #6

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 2 Outline Logical reasoning Propositional Logic Wumpus World Inference Russell & Norvig, chapter 7

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 3 Logical Reasoning Recall: Game-playing with imperfect information Partially-observable environment Need to infer about hidden information Two new challenges How to represent the information we have (knowledge representation) How to use the information we have to infer new information and make decisions (knowledge reasoning)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 4 Knowledge Representation Represent facts about the environment Many ways: ontologies, mathematical functions, … Statements that are either true or false Language To write the statements Syntax: symbols (words) and rules to combine them (grammar) Semantics: meaning of the statements Expressiveness vs. efficiency Knowledge base (KB) Contains all the statements Agent can TELL it new statements (update) Agent can ASK it for information (query)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 5 Knowledge Representation Example: Language of arithmetic Syntax describes well-formed formulas (WFF) X + Y > 7 (WFF) X Y + (not a WFF) Semantics describes meanings of formulas “X + Y > 7” is true if and only if the value of X and the value of Y summed together is greater than 7

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 6 Knowledge Reasoning Inference Discovering new facts and drawing conclusions based on existing information During ASK or TELL “All humans are mortal” “Socrates is human” Entailment A sentence  is inferred from sentences   is true given that the  are true  entails    

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 7 Propositional Logic Sometimes called “Boolean Logic” Sentences are true (T) or false (F) Words of the syntax include propositional symbols… P, Q, R, … P = “I’m hungry”, Q = “I have money”, R = “I’m going to a restaurant” … and logical connectives ¬negationNOT  conjunctionAND  disjunctionOR  implicationIF-THEN  biconditionalIF AND ONLY IF

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 8 Propositional Logic Atomic sentences Propositional symbols True or false Complex sentences Groups of propositional symbols joined with connectives, and parenthesis if needed (P  Q)  R Well-formed formulas following grammar rules of the syntax

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 9 Propositional Logic Complex sentences evaluate to true or false Using truth tables Semantics PQR P  Q(P  Q)  R TTTTT FTTFT TFTFT FFTFT TTFTF FTFFT TFFFT FFFFT

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 10 Propositional Logic Semantics PQ¬P¬P P  QP  QP  QP  Q TTFTTTT FTTFTTF TFFFTFF FFTFFTT Truth tables for all connectives Given each possible truth value of each propositional symbol, we can get the possible truth values of the expression

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 11 Propositional Logic Example Propositional symbols: A = “The car has gas” B = “I can go to the store” C = “I have money” D = “I can buy food” E = “The sun is shining” F = “I have an umbrella” G = “I can go on a picnic” If the car has gas, then I can go to the store A  B I can buy food if I can go to the store and I have money (B  C)  D If I can buy food and either the sun is not shining or I have an umbrella, I can go on a picnic D  (¬E  F)  G

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 12 DEFG¬E ¬E  FD  (¬E  F)D  (¬E  F)  G TTTTFTTT FTTTFTFT TFTTTTTT FFTTTTFT TTFTFFFT FTFTFFFT TFFTTTTT FFFTTTFT TTTFFTTF FTTFFTFT TFTFTTTF FFTFTTFT TTFFFFFT FTFFFFFT TFFFTTTF FFFFTTFT

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 13 Wumpus World 2D cave divided in rooms Gold Glitters Agent has to pick it up Pits Agent falls in and dies Agent feels breeze near pit Wumpus Agent gets eaten and dies if Wumpus alive Agent can kill Wumpus with arrow Agent smells stench near Wumpus (alive or dead)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 14 Wumpus World Initial state: (1,1) Goal: Get the gold and get back to (1,1) Actions: Turn 90°, move forward, shoot arrow, pick up gold Cost: for getting gold, for dying, -1 per action, -10 for shooting the arrow

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 15 Exploring the Wumpus World OK Pit? Wumpus? OK

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 16 Wumpus World Logic Propositional symbols P i,j = “there is a pit at (i,j)” B i,j = “there is a breeze at (i,j)” S i,j = “there is a stench at (i,j)” W i,j = “there is a Wumpus at (i,j)” K i,j = “(i,j) is ok” Rules P i,j  (B i+1,j  B i-1,j  B i,j+1  B i,j-1 ) W i,j  (S i+1,j  S i-1,j  S i,j+1  S i,j-1 ) B i,j  (P i+1,j  P i-1,j  P i,j+1  P i,j-1 ) S i,j  (W i+1,j  W i-1,j  W i,j+1  W i,j-1 ) K i,j  (¬W i,j  ¬P i,j ) Have to be written out for every (i,j)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 17 Wumpus World KB K 1,1 2.¬B 1,1 3.¬S 1,1 a. B 1,1  (P 2,1  P 1,2 ) b. S 1,1  (W 2,1  W 1,2 ) c. K 2,1  (¬W 2,1  ¬P 2,1 ) d. K 1,2  (¬W 1,2  ¬P 1,2 )

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 18 Wumpus World Inference B 1,1 P 1,2 P 2,1 ¬B 1,1 P 1,2  P 2,1 B 1,1  (P 1,2  P 2,1 ) TTTFTT TFTFTT TTFFTT TFFFFF FTTTTF FFTTTF FTFTTF FFFTFT 1. K 1,1 3. ¬S 1,1 2. ¬B 1,1 1. K 1,1 3. ¬S 1,1 5. ¬P 2,1 2. ¬B 1,1 4. ¬P 1,2

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page K 1,1 3. ¬S 1,1 5. ¬P 2,1 7. ¬W 2,1 2. ¬B 1,1 4. ¬P 1,2 6. ¬W 1,2 Wumpus World Inference S 1,1 W 1,2 W 2,1 ¬S 1,1 W 1,2  W 2,1 S 1,1  (W 1,2  W 2,1 ) TTTFTT TFTFTT TTFFTT TFFFFF FTTTTF FFTTTF FTFTTF FFFTFT

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page K 1,1 3. ¬S 1,1 5. ¬P 2,1 7. ¬W 2,1 2. ¬B 1,1 4. ¬P 1,2 6. ¬W 1,2 1. K 1,1 3. ¬S 1,1 5. ¬P 2,1 7. ¬W 2,1 9. K 2,1 2. ¬B 1,1 4. ¬P 1,2 6. ¬W 1,2 8. K 1,2 Wumpus World Inference P 1,2 W 1,2 K 1,2 ¬P 1,2 ¬W 1,2 ¬W 1,2  ¬P 1,2 K 1,2  (¬W 1,2  ¬P 1,2 ) TTTFFFF FTTTFFF TFTFTFF FFTTTTT TTFFFFT FTFTFFT TFFFTFT FFFTTTF

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page B 2,1 11.P 3,1 12.¬S 2,1 13.¬W 2,2 14.¬W 3,1 15.¬B 1,2 16.¬P 1,3 17.¬P 2,2 18.S 1,2 19.W 1,3 20.K 2,2 Wumpus World KB 1.K 1,1 2.¬B 1,1 3.¬S 1,1 4.¬P 1,2 5.¬P 2,1 6.¬W 1,2 7.¬W 2,1 8.K 1,2 9.K 2, OK Pit? Wumpus? OK 10.B 2,1 11.P 2,2  P 3,1 12.¬S 2,1 13.¬W 2,2 14.¬W 3,1 15.¬B 1,2 16.¬P 1,3 17.¬P 2,2 18.S 1,2 19.W 1,3  W 2,2

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 22 Inference with Truth Tables Sound Only infers true conclusions from true premises Complete Finds all facts entailed by KB Time complexity = O(2 n ) Checks all truth values of all symbols Space complexity = O(n)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 23 Inference with Rules Speed up inference by using inference rules Use along with logical equivalences No need to enumerate and evaluate every truth value

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 24 Rules and Equivalences Logical equivalences (α  β)  (β  α) (α  β)  (β  α) ((α  β)  γ)  (α  (β  γ)) ((α  β)  γ)  (α  (β  γ)) ¬(¬α)  α (α  β)  (¬β  ¬α) (α  β)  (¬α  β) (α  β)  ((α  β)  (β  α)) ¬(α  β)  (¬α  ¬β) ¬(α  β)  (¬α  ¬β) (α  (β  γ))  ((α  β)  (α  γ)) (α  (β  γ))  ((α  β)  (α  γ)) Inference rules (α  β), α β (α  β) α α, β (α  β) (α  β), ¬β α ) (α  β), (¬β  γ) (α  γ)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 25 Wumpus World & Inference Rules KB: ¬B 1,1 1.B 1,1  (P 2,1  P 1,2 )  Biconditional elimination 2.(B 1,1  (P 2,1  P 1,2 ))  ((P 2,1  P 1,2 )  B 1,1 )  And elimination 3.(P 2,1  P 1,2 )  B 1,1  Contraposition 4.¬B 1,1  ¬(P 2,1  P 1,2 )  Modus Ponens 5.¬(P 2,1  P 1,2 )  De Morgan’s Rule 6.¬P 2,1  ¬P 1,2

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 26 Resolution Inference with rules is sound, but only complete if we have all the rules Resolution rule is both sound and complete ) (α  β), (¬β  γ) (α  γ) But it only works on disjunctions! Conjunctive normal form (CNF) 1. Eliminate biconditionals: (α  β)  ((α  β)  (β  α)) 2. Eliminate implications: (α  β)  (¬α  β) 3. Move/Eliminate negations: ¬(¬α)  α, ¬(α  β)  (¬α  ¬β), ¬(α  β)  (¬α  ¬β) 4. Distribute  over  : (α  (β  γ))  ((α  β)  (α  γ))

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 27 CNF Example 1.B 1,1  (P 2,1  P 1,2 )  Eliminate biconditionals 2.(B 1,1  (P 2,1  P 1,2 ))  ((P 2,1  P 1,2 )  B 1,1 )  Eliminate implications 3.(¬B 1,1  P 2,1  P 1,2 )  (¬(P 2,1  P 1,2 )  B 1,1 )  Move/Eliminate negations 4.(¬B 1,1  P 2,1  P 1,2 )  ((¬P 2,1  ¬P 1,2 )  B 1,1 )  Distribute  over  5.(¬B 1,1  P 2,1  P 1,2 )  (¬P 2,1  B 1,1 )  (¬P 1,2  B 1,1 )

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 28 Resolution Algorithm Given a KB Need to answer a query α KB  α ? Proof by contradiction Show that (KB  ¬α) is unsatisfiable i.e. leads to a contradiction If (KB  ¬α), then (KB  α) must be true

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 29 Resolution Algorithm Convert (KB  ¬α) into CNF For every pair of clauses that contain complementary symbols Apply resolution to generate a new clause Add new clause to sentence End when Resolution gives the empty clause (KB  α) No new clauses can be added (fail)

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 30 Wumpus World & Resolution (¬B 1,1  P 1,2  P 2,1 )  (¬P 1,2  B 1,1 )  (¬P 2,1  B 1,1 ) CNF form of B 1,1  (P 2,1  P 1,2 ) ¬B 1,1 Query: ¬P 1,2 (¬B 1,1  P 1,2  P 2,1 )  (¬P 1,2  B 1,1 )  (¬P 2,1  B 1,1 )  ¬ B 1,1  P 1,2 (¬B 1,1  P 1,2  P 2,1 )  (¬P 1,2  B 1,1 )  ¬P 2,1  P 1,2 (¬B 1,1  P 1,2  P 2,1 )  (¬P 1,2  B 1,1 )  Empty clause! KB  ¬P 1,2

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 31 Resolution Algorithm Sound Complete Not efficient

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 32 Horn Clauses Resolution algorithm can be further improved by using Horn clauses Disjunction clause with at most one positive symbol ¬α  ¬β  γ Can be rewritten as implication (α  β)  γ Inference in linear time! Using Modus Ponens Forward or backward chaining

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 33 Forward Chaining Data-driven reasoning Start with known symbols Infer new symbols and add to KB Use new symbols to infer more new symbols Repeat until query proven or no new symbols can be inferred Work forward from known data, towards proving goal 1. KB: α, β, δ, ε 2. (α  β)  γ 3. ( δ  ε )  λ 4. ( λ  γ)  q

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 34 Backward Chaining Goal-driven reasoning Start with query, try to infer it If there are unknown symbols in the premise of the query, infer them first If there are unknown symbols in the premise of these symbols, infer those first Repeat until query proven or its premise cannot be inferred Work backwards from goal, to prove needed information 1. KB: α, β, δ, ε 2. ( λ  γ)  q 3. ( δ  ε )  λ 4. (α  β)  γ

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 35 Forward vs. Backward Forward chaining Proves everything Goes to work as soon as new information is available Expands the KB a lot Improves understanding of the world Typically used for proving a world model Backward chaining Proves only what is needed for the goal Does nothing until a query is asked Expands the KB as little as needed More efficient Typically used for proofs by contradiction

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 36 Assumptions Utility-based agent Environment Fully observable / Partially observable (approximation) Deterministic / Strategic / Stochastic Sequential Static / Semi-dynamic Discrete / Continuous Single agent / Multi-agent

ECE457 Applied Artificial Intelligence R. Khoury (2007)Page 37 Assumptions Updated Learning agent Environment Fully observable / Partially observable Deterministic / Strategic / Stochastic Sequential Static / Semi-dynamic Discrete / Continuous Single agent / Multi-agent