1 / 35

Logical Agents

Logical Agents. CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material. Logic and Knowledge Bases. Logic: means of representation and reasoning Knowledge Base (KB): set of sentences (expressed in some language)

lee-griffin
Download Presentation

Logical Agents

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn fromRussel & Norvig’s published material

  2. Logic and Knowledge Bases • Logic: means of representation and reasoning • Knowledge Base (KB): set of sentences (expressed in some language) • Inference: deriving new sentences from sentences in the KB

  3. Knowledge-BasedAgent Function TELL: adds a sentence to the KBASK: queries the KB

  4. Example: Wumpus World • 4 by 4 grid of rooms • A room may contain: Agent, Wumpus, Pit, Gold • Agent can perceive pit or wumpus from neighboring squares • Agent starts in lower left corner, can move to neighboring squares, or shoot an arrow N,E,W, or S

  5. Wumpus WorldPEAS Description • Performance measure: • gold +1000 • death –1000 • -1 per step • -10 for using up arrow • Environment: • 4 by 4 grid of rooms • one room contains the agent (initially at [1,1] facing right) • one room (not [1,1]) contains the wumpus (and it stays there) • one room contains the gold • the other rooms may contain a pit

  6. PEAS Description, continued • Actuators: Left turn, Right turn, Forward, Grab, Shoot • Shooting kills wumpus if you are facing it • Shooting uses up the only arrow • Grabbing picks up gold if in same square • Agent dies when it enters a room containing pit/live wumpus • Sensors: Stench, Breeze, Glitter, Bump, Scream • Squares adjacent to wumpus are smelly • Squares adjacent to a pit are breezy • Glitter perceived in square containing gold • Bump perceived when agent hits a wall • Scream perceived everywhere when wumpus is hit

  7. Wumpus World and Knowledge • State of knowledge • What is known about the rooms at time t • Associate one or more values to each room, when known: A, B, G, OK, P, S, V, W(use ? to indicate possibility) • Contrast against what are actually in the rooms • A move and resulting percept allow agent to update the state of knowledge • Next move would depend on what is known

  8. Example: Initial Stateand First Move [None,None,None,None,None] [None,Breeze,None,None,None]

  9. Sample Action Sequence: forward, turn around, forward,turn right, forward, turn right, forward, turn left, forward

  10. Later Moves Actions: forward, turn around, forward, turn right,forward, turn right, forward, turn left, forward

  11. Inference • Agent can infer that there is a wumpus in [1,3] • Stench in [1,2] means wumpus is in [1,1], [1,3], or [2,2] • Wumpus not in [1,1] by the rules of the game • Wumpus not in [2,2] because [2,1] had no stench • Agent can also infer that there is a pit in [3,1] (how?)

  12. Logic • Representation • Syntax: how well-formed sentences are specified • Semantics: “meaning” of the sentences; truth with respect to each possible world (model) • Reasoning • Entailment: sentence following from another sentence ( a ╞ b )

  13. Models and Entailment • Logicians typically think in terms of models, with respect to which truth can be evaluated • model: a possible world • We say mis a model of a sentence α if α is true in m • M(α) is the set of all models of α • Then KB ╞ α iff M(KB)  M(α) • E.g.KB = I am smart and you are prettyα = I am smart

  14. Models and Entailmentin the Wumpus World Situation after detecting nothing in [1,1], moving right, breeze in [2,1] Consider possible models for KB assuming only pits 3 Boolean choices 8 possible models

  15. Wumpus Models

  16. Wumpus Models KB = wumpus-world rules + observations

  17. Wumpus Models α1 = "[1,2] is safe", KB ╞ α1 proved by model checking

  18. Wumpus Models α2 = "[2,2] is safe", KB ╞ α2

  19. Inference Algorithm • An inference algorithm i is a procedure that derives sentences from a knowledge base: KB ├i s • i is sound if it derives only entailed sentences • i is complete if it can derive anysentence that is entailed

  20. Propositional Logic (PL) • PL: logic that consists of proposition symbols and connectives • Each symbol is either true or false • Syntax: describes how the symbols and connectives form sentences • Semantics: describes rules for determining the truth of a sentence wrt to a model

  21. Syntax • A sentence in Propositional Logic is either Atomic or Complex • Atomic Sentence • Symbol: e.g., P, Q, R, … • True • False • Complex Sentence • Let S and T be sentences (atomic or complex) • The following are also sentences:S, S  T, S  T, S  T, S  T

  22. Connectives • S: negation • if P is a symbol, P and P are called literals • S  T: conjunction • S and T are called conjuncts • S  T: disjunction • S and T are called disjuncts • S  T: implication • S is called the premise, T is called the conclusion • S  T: biconditional

  23. Back to the Wumpus World • Start with a vocabulary of proposition symbols, for example: • Pi,j: there is a pit in room [i,j] • Bi,j: there is a breeze in room [i,j] • Sample sentences (could be true or false) • P1,2 • B2,2P2,3 • P4,3 B3,3  B4,2  B4,4 • P3,4 B1,3 • Note issue of precedence with connectives

  24. Semantics • Truth of symbols are specified in the model • Truth of complex sentences can be determined using truth tables

  25. Knowledge Base forthe Wumpus World • Rules constitute the initial KB and can be expressed in PL; for example: • P1,1 • P4,4 B3,4  B4,3 • As the agent progresses, it can perceive other facts and incorporate it in its KB; for example: • B1,1 if it doesn’t perceive a breeze in room [1,1] • B2,1 if it perceives a breeze in room [2,1] • Can view the KB as a conjunction of all sentences asserted as true so far

  26. Inference in theWumpus World • We want to decide on the existence of pits in the rooms; i.e. does KB╞ Pi,j ? • Suppose we have already perceivedB1,1 andB2,1 • KB contains the rules and these facts • What can we say about: • P1,1, P1,2, P2,1, P2,2, P3,1 ?

  27. Truth Table Depicting128 Possible Models

  28. Inference Examples • KB is true when the rules hold—only for three rows in the table • The three rows are models of KB • Consider the value of P1,2 for these 3 rows • P1,2 is false in all rows(the rows are models of α1 = P1,2) • Thus, there is no pit in room [1,2] • Consider the value of P2,2 for these 3 rows • P1,2 false in one row, true for 2 rows • Thus, there may be a pit in room [2,2]

  29. P1,2

  30. P2,2

  31. Inference by Enumeration • We want an algorithm that determines whether KB entails some sentence α • Strategy: • Enumerate all possible models (true-false combinations of symbols in KB) • Consider only those models of KB (models where KB is true) • Return true if α is true for all such models

  32. Inference by Enumeration

  33. Analysis • Inference by Enumeration is sound and complete • By definition of sound and complete  • Runs in exponential time - O(2n) • Requires linear space - O(n)

  34. To be continued… What’s next? • Other Logical Inference Algorithms: can’t really do better than exponential, but there are algorithms that do reasonably better in practice • First-order Logic (FOL):deals with a world of objects, functions, and relations, rather than just facts (PL)

More Related