logical agents
play

Logical agents Chapter 7 (Some slides adapted from Stuart Russell, - PowerPoint PPT Presentation

Logical agents Chapter 7 (Some slides adapted from Stuart Russell, Dan Klein, and many others. Thanks guys!) 1 Outline Knowledge-based agents Wumpus world Logic in generalmodels and entailment Propositional (Boolean) logic


  1. Logical agents Chapter 7 (Some slides adapted from Stuart Russell, Dan Klein, and many others. Thanks guys!) 1

  2. Outline • Knowledge-based agents • Wumpus world • Logic in general—models and entailment • Propositional (Boolean) logic • Equivalence, validity, satisfiability • Inference rules and theorem proving – forward chaining – backward chaining – resolution 2

  3. Knowledge-based Agents • Previously: Solved problems by search – Basically brute force. Clever...but is it “intelligent”? – “Knowledge” about how world works hidden...embodied in successor fn. • Knowledge-based agents: – Have internal representations of the world...and reason about them. – Based on formal symbolic logics: propositional, first-order predicate, etc. • Advantages: – Can combine and recombine base knowledge for many purposes – Can accept new tasks anytime, explicitly states as goals • Q: Could Boggle do any task except...well...boggle search boards? – Can achieve competence quickly • Being told new facts about the world • Learning new knowledge by deduction + percepts – Can adapt to changes in environment by updating knowledge 3

  4. Knowledge Bases • Knowledge base is basis for all KB-agent reasoning and action – Consists of: set of sentences in a formal language domain − independent algorithms Inference engine Knowledge base domain − specific content • Declarative approach to building an agent (or other system): • Idea: – Tell it what it needs to know – Then it can Ask itself what to do (autonomous agent) or you Ask it goal. – answers should follow from the KB • KB-Agents can be viewed at the knowledge level – i.e., what they know, regardless of how implemented • Or at the implementation level – i.e., data structures in KB and algorithms that manipulate them

  5. A simple knowledge-based agent function KB-Agent( percept ) returns an action static : KB , a knowledge base t , a counter, initially 0, indicating time Tell( KB , Make-Percept-Sentence( percept , t )) action ← Ask( KB , Make-Action-Query( t )) Tell( KB , Make- Action-Sentence( action , t )) t ← t + 1 return action • KB-agent function centered around on: – Tell: Adding new information to the KB – Ask: Posing a query (goal) to be resolved using the KB and universal algorithms • The agent must be able to: – Represent states, actions, etc. – Incorporate new percepts – Update internal representations of the world – Deduce hidden properties of the world • Things it has not been told explicitly...but arise from evolving facts – Deduce appropriate actions (given tacit or explicit goal)

  6. Wumpus World: A classic example • Simple game of logical deduction – Dark cave with deadly pits and voracious wumpus monster Breeze Stench PIT 4 – Goal: Find hidden pile of gold, avoid dying, return safely Breeze Breeze PEAS Description: PIT 3 Stench Gold • Performance measure: Breeze Stench • gold +1000, death -1000 2 • -1 per step, -10 for using the arrow Breeze • Environment: Breeze 1 PIT • Squares adjacent to wumpus are smelly START • Squares adjacent to pit are breezy 1 2 3 4 • Glitter iff gold is in the same square • Shooting kills wumpus if you are facing it. Shooting uses up the only arrow • Grabbing picks up gold if in same square • Releasing drops the gold in same square • Actuators: • Left turn, Right turn, Forward, Grab, Release, Shoot • Sensors: • Breeze, Glitter, Smell 6

  7. Wumpus World: problem characterization • Observable?? – No—only local perception • Deterministic?? – Yes—outcomes exactly specified • Episodic?? – No—sequential at the level of actions • Static?? – Yes—Wumpus and Pits do not move • Discrete?? – Yes. Actions are discrete and limited. States are definite and finite. • Single-agent?? – Yes—Wumpus is essentially a natural feature

  8. Exploring a wumpus world 4 3 OK 2 OK OK A 1 1 2 3 4 • Start in [1,1]. Cave entry/exit. Guaranteed safe. 8 • Note: No smells, no breezes à adjacent squares ok.

  9. Exploring a wumpus world B OK A OK OK A • Move to [2,1]. Sensor detects breeze (B) 9

  10. Exploring a wumpus world P? B OK P? A OK OK A • Deduce possible pits in adjacent squares. 10

  11. Exploring a wumpus world P? B OK P? A S OK OK A A • BeSer go explore a safer place...maybe gather more info... 11 • Detect smell (S) in [1,2]... But no breeze!

  12. Exploring a wumpus world P? P B OK P? OK A S OK OK W A A • Can deduce W in [1,3] (can’t be in [2,2] because was no smell in [2,1]! ) • Can definitely place the Pit in [3,1] 12

  13. Exploring a wumpus world P? P B OK P? OK A A S OK OK W A A 13

  14. Exploring a wumpus world P? OK P B OK P? OK OK A A S OK OK W A A • Now that [2,2] determined OK, can go there. 14 • Nothing sensed à deducZons about adjacent

  15. Exploring a wumpus world P? OK P B OK P? BGS OK OK A A A S OK OK W A A • And then on to [2,3]. Detect GliSer! Grab Gold! 15 • Then head back out to exit.

  16. Tight spots: Can’t always reason safely • Breeze in (1,2) and (2,1) P? ⇒ no safe actions! • Make educated guess: B OK P? P? Assuming pits uniformly distributed, (2,2) has pit A w/ prob 0.86, vs. 0.31 OK B OK P? A A • Smell in (1,1) ⇒ cannot move! • Can use a strategy of coercion: S Act: shoot straight ahead A • Wumpus was there à dead • Wumpus not there à safe 16

  17. Introduction to Logic Let’s start with some basics: definitions • Logics are formal languages for representing information – such that conclusions can be drawn • Syntax defines the format of legal sentences in the language • Semantics define the “meaning” of sentences – i.e., define truth of a sentence with respect to a particular world (state) Example: The language of arithmetic Syntax: x + 2 ≥ y is a legal sentence; x 2 + y > is not • • Semantics: – x + 2 ≥ y is true iff the number x + 2 is no less than the number y – x + 2 ≥ y is true in a world where x = 7, y = 1 – x + 2 ≥ y is false in a world where x = 0, y = 6

  18. Logical Entailment • Entailment means that one thing follows from another: – KB |= α – Knowledge base KB entails sentence α if and only if α is true in all worlds where KB is true • Example: the KB containing “the Giants won” and “the Reds won” entails α =“Either the Giants won or the Reds won” • à α is true in all worlds in which KB is true. • Example: x + y = 4 entails 4 = x + y • Entailment our first element of reasoning! – is a relationship between sentences (i.e., syntax) – Idea that one sentence (logical fact) follows logically from another sentence 18

  19. Models • What about “ in a world where x is true”? A “world”? What’s that? • Model = a possible “world”. – Formally structured expression of world state with respect to which truth can be evaluated – Basically a collection of logical sentences describing a world or state – We say m is a model of a sentence α if α is true in m – Notation: M ( α ) is the set of all models of α x x x x x x x x x M( α ) x x x x x x x x • Example: x x x x x x x x x x x x – KB = Giants won and Reds won xx x xx x x x x x x – α = Giants won M(KB) x x x x x x x – Then KB | = α if and only if M ( KB ) ⊆ M ( α ) • KB entails α iff, in every model where α is true, KB is also true. • Note that KB is the stronger statement here: the “tighter” set of possible models. 19

  20. Example: Entailment in the wumpus world Situation after detecting nothing in [1,1], moving right, breeze in [1,2] Consider possible models for ?s assuming only pits: ? ? • Each square could contain a pit...or not à 3 Boolean choices à 8 possible models B ? A A Note: The full model set for this world is large! à contains all possible combinaZons of possible contents for every square on board. We are just looking at the subset dealing with the squares at the fronZer of our exploraZon. Efficient! 20

  21. Wumpus models • KB = wumpus world rules + observations (percepts) – Percepts = breeze([1,2]) , nothing([1,1]) • Solid red line = all of the models in which KB is true = M(KB) – The state of the world represented by KB is consistent with the model 21

  22. Wumpus models α1 • KB = wumpus-world rules + percepts • Assertion α 1 = “[2,1] is safe” – Dotted line is M( α 1) = Set of all models in which α 1 holds true. • Then we can say that KB |= α 1 – In every model in which KB is true, α 1 is also true. è Proof by model checking – Thus: α 1 is consistent with KB à “ α 1 is derivable from KB via model checking” 22

  23. Wumpus models PIT 2 2 Breeze α2 1 Breeze PIT 1 1 2 3 KB 1 2 3 PIT 2 2 PIT 2 Breeze PIT 1 Breeze 1 Breeze 1 1 2 3 1 2 3 1 2 3 2 PIT PIT PIT 2 Breeze 1 Breeze PIT 1 PIT PIT 2 1 2 3 1 2 3 Breeze 1 PIT 1 2 3 Now let’s consider another case: • KB = wumpus-world rules + observations again, same as before • α 2 = “[2,2] is safe” • Model checking shows that KB does not entail α 2 • Can not conclude there is no pit in [2,2] – But also doesn’t prove that there is one. Logical facts are simply inconclusive. 23

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend