Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material."— Presentation transcript:

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

2 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 3 Knowledge-Based Agent Function TELL: adds a sentence to the KB ASK: queries the KB

4 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 5 Wumpus World PEAS 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 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 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 8 Example: Initial State and First Move [None,None,None,None,None][None,Breeze,None,None,None]

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

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

11 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 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 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 m is 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 14 Models and Entailment in 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 15 Wumpus Models

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

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

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

19 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 any sentence that is entailed

20 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 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 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 23 Back to the Wumpus World Start with a vocabulary of proposition symbols, for example: P i,j : there is a pit in room [i,j] B i,j : there is a breeze in room [i,j] Sample sentences (could be true or false) P 1,2 B 2,2   P 2,3 P 4,3  B 3,3  B 4,2  B 4,4  P 3,4   B 1,3 Note issue of precedence with connectives

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

25 25 Knowledge Base for the Wumpus World Rules constitute the initial KB and can be expressed in PL; for example:  P 1,1 P 4,4  B 3,4  B 4,3 As the agent progresses, it can perceive other facts and incorporate it in its KB; for example:  B 1,1 if it doesn’t perceive a breeze in room [1,1] B 2,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 26 Inference in the Wumpus World We want to decide on the existence of pits in the rooms; i.e. does KB ╞ P i,j ? Suppose we have already perceived  B 1,1 and B 2,1 KB contains the rules and these facts What can we say about: P 1,1, P 1,2, P 2,1, P 2,2, P 3,1 ?

27 27 Truth Table Depicting 128 Possible Models

28 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 P 1,2 for these 3 rows P 1,2 is false in all rows (the rows are models of α 1 =  P 1,2 ) Thus, there is no pit in room [1,2] Consider the value of P 2,2 for these 3 rows P 1,2 false in one row, true for 2 rows Thus, there may be a pit in room [2,2]

29 29 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

30 30 Inference by Enumeration

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

32 32 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)


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

Similar presentations


Ads by Google