1 / 79

logic agents

Notes adapted from lecture notes for CMSC 421 by B.J. Dorr. logic agents. “Thinking Rationally”. Computational models of human “thought” processes Computational models of human behavior Computational systems that “think” rationally Computational systems that behave rationally.

penha
Download Presentation

logic 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. Notes adapted from lecture notes for CMSC 421 by B.J. Dorr logic agents

  2. “Thinking Rationally” • Computational models of human “thought” processes • Computational models of human behavior • Computational systems that “think” rationally • Computational systems that behave rationally

  3. Logical Agents • Reflex agents find their way from Arad to Bucharest by dumb luck • Chess program calculates legal moves of its king, but doesn’t know that no piece can be on 2 different squares at the same time • Logic (Knowledge-Based) agents combine general knowledge with current percepts to infer hidden aspects of current state prior to selecting actions • Crucial in partially observable environments

  4. Outline • Knowledge-based agents • Wumpus world • Logic in general • Propositional and first-order logic • Inference, validity, equivalence and satifiability • Reasoning patterns • Resolution • Forward/backward chaining

  5. Knowledge Base Knowledge Base: set of sentences represented in a knowledge representation language and represents assertions about the world. Inference rule: when one ASKs questions of the KB, the answer should follow from what has been TELLed to the KB previously. tell ask

  6. Generic KB-Based Agent

  7. Generic KB-Based Agent • Takes percent as input and returns an action • agent maintains a knowledge base KB • Each time agent program is called it does • TELLs knowledge base what It perceives • ASKs knowledge base what action it should perform • Agent records its choice with TELL an executes action

  8. Abilities KB agent • Agent must be able to: • Represent states and actions, • Incorporate new percepts • Update internal representation of the world • Deduce hidden properties of the world • Deduce appropriate actions

  9. Desription level • The KB agent is similar to agents with internal state • Agents can be described at different levels • Knowledge level • What they know, regardless of the actual implementation. (Declarative description) • Implementation level • Data structures in KB and algorithms that manipulate them e.g propositional logic and resolution.

  10. A Typical Wumpus World Wumpus

  11. A Typical Wumpus World • Cave consisting of rooms connected by passageways • Agent has only one arrow • Some of rooms contain bottomless pit that will trap anyone who wanders into these rooms – except for wumpus

  12. Wumpus World PEAS Description

  13. Wumpus World Characterization • Observable? • Deterministic? • Episodic? • Static? • Discrete? • Single-agent?

  14. Wumpus World Characterization • Observable? No, only local perception • Deterministic? • Episodic? • Static? • Discrete? • Single-agent?

  15. Wumpus World Characterization • Observable? No, only local perception • Deterministic? Yes, outcome exactly specified • Episodic? • Static? • Discrete? • Single-agent?

  16. Wumpus World Characterization • Observable? No, only local perception • Deterministic? Yes, outcome exactly specified • Episodic? No, sequential at the level of actions • Static? • Discrete? • Single-agent?

  17. Wumpus World Characterization • Observable? No, only local perception • Deterministic? Yes, outcome exactly specified • Episodic? No, sequential at the level of actions • Static? Yes, Wumpus and pits do not move • Discrete? • Single-agent?

  18. Wumpus World Characterization • Observable? No, only local perception • Deterministic? Yes, outcome exactly specified • Episodic? No, sequential at the level of actions • Static? Yes, Wumpus and pits do not move • Discrete? Yes • Single-agent?

  19. Wumpus World Characterization • Observable? No, only local perception • Deterministic? Yes, outcome exactly specified • Episodic? No, sequential at the level of actions • Static? Yes, Wumpus and pits do not move • Discrete? Yes • Single-agent? Yes, Wumpus is essentially a natural feature.

  20. Exploring the Wumpus World [1,1] The KB initially contains the rules of the environment. The first percept is [none, none,none,none,none], move to safe cell e.g. 2,1 [none, none,none,none,none] – no stench, no breeze, no glitter, no wall in front, no scream [2,1] breeze which indicates that there is a pit in [2,2] or [3,1], return to [1,1] to try next safe cell

  21. Exploring the Wumpus World [1,2] Stench in cell which means that wumpus is in [1,3] or [2,2] YET … not in [1,1] YET … not in [2,2] or stench would have been detected in [2,1] THUS … wumpus is in [1,3] THUS [2,2] is safe because of lack of breeze in [1,2] THUS pit in [1,3] move to next safe cell [2,2]

  22. Exploring the Wumpus World [2,2] move to [2,3] [2,3] detect glitter , smell, breeze THUS pick up gold THUS pit in [3,3] or [2,4]

  23. What is a logic? • A formal language • Syntax – what expressions are legal (well-formed) • Semantics – what legal expressions mean • in logic the truth of each sentence with respect to each possible world. • E.g the language of arithmetic • X+2 >= y is a sentence, x2+y is not a sentence • X+2 >= y is true in a world where x=7 and y =1 • X+2 >= y is false in a world where x=0 and y =6

  24. Entailment • One thing follows from another KB | =  • KB entails sentence  if and only if is true in worlds where KB is true. • E.g. x+y=4 entails 4=x+y • Entailment is a relationship between sentences that is based on semantics.

  25. Models • Logicians typically think in terms of models, which are formally structured worlds with respect to which truth can be evaluated. • m is a model of a sentence  if  is true in m • M() is the set of all models of 

  26. Wumpus world model

  27. Wumpus world model

  28. Wumpus world model

  29. Wumpus world model

  30. Wumpus world model

  31. Wumpus world model

  32. Logical inference • The notion of entailment can be used for logic inference. • Model checking (see wumpus example): enumerate all possible models and check whether is true. • If an inference algorithm i can derive  from KB • KB |-i • Sentence  is derived from KB by i or i derives  from KB • Soundness: i is sound if whenever KB |-i, it is also true that KB |=  • Completeness : i is complete if whenever KB |=  it is also true that KB|-i 

  33. Schematic perspective If KB is true in the real world, then any sentence  derived From KB by a sound inference procedure is also true in the real world.

  34. Logical inference • Preview: we will define a logic (first-order logic) which is expressive enough to say almost anything of interest, and for which there exists a sound and complete inference procedure. • That is, the procedure will answer any question whose answer follows from what is known by the KB.

  35. Propositional logic: Syntax • Propositional logic is the simplest logic - illustrates basic ideas • The proposition symbols P1, P2 etc are sentences • If S is a sentence, S is a sentence (negation) • If S1 and S2 are sentences, S1  S2 is a sentence (conjunction) • If S1 and S2 are sentences, S1  S2 is a sentence (disjunction) • If S1 and S2 are sentences, S1  S2 is a sentence (implication) • If S1 and S2 are sentences, S1  S2 is a sentence (biconditional)

  36. Truth tables for connectives P Q P PQ PQ PQ PQ false false true false false true true false true true false true true false true false false false true false false true true false true true true true

  37. Propositional logic: Semantics • Each model species true/false for each proposition symbol • E.g. P1,2 P2,2 P3,1 true true false • (With these symbols, 8 possible models, can be enumerated automatically.) • Rules for evaluating truth with respect to a model m: •  S is true iff S is false • S1  S2 is true iff S1 is true and S2 is true • S1  S2 is true iff S1 is true or S2 is true • S1  S2 is true iff S1 is false or S2 is true • i.e., is false iff S1 is true and S2 is false • S1  S2 is true iff  S2 is true and S2  S1 is true • Simple recursive process evaluates an arbitrary sentence, e.g., •  P1,2  (P2,2  P3,1) = true  (false  true)=true  true=true

  38. Wumpus world sentences • Let Pi,j be true if there is a pit in [i, j]. • Let Bi,j be true if there is a breeze in [i, j].  P1,1  B1,1 B2,1 • “Pits cause breezes in adjacent squares" B1,1 (P1,2 P2,1) B2,1 (P1,1 P2,2 P3,1) “A square is breezy if and only if there is an adjacent pit"

  39. Truth tables for inference

  40. Logical equivalence

  41. Validity and satisability

  42. Inference Rules Modus ponens ,   And elimination   Logical equivalences on pg 40 apply Eg biconditional elimination yields 2 inference rules  and ()  () ()  () 

  43. Inference Rules • All inferences may not apply in the opposite direction

  44. Inference Rules • Wumpus world KB There is no pit in [1,1] etc R1:  P1,1 R2: B1,1 (P1,2 P2,1) R3: B2,1 (P1,1 P2,2 P3,1) R4:  B1,1 R5: B2,1

  45. Inference Rules • Show there is no pit in [1,2] • biconditional elimination to R2 R6: (B1,1(P1,2 P2,1))  ((P1,2 P2,1 )  B1,1) And elimination to R6 R7: ((P1,2 P2,1 )  B1,1) logical equivalence for contrapositives R8: (B1,1 (P1,2 P2,1)) Apply modus ponens with R8 with precept R4 R9: (P1,2 P2,1)) De Morgan R10: P1,2 P2,1) Neither [1,2] nor [2,1] contains a pit

  46. Searching for Proofs • Finding proofs is exactly like finding solutions to search problems. • Can search forward (forward chaining) to derive goal or search backward (backward chaining) from the goal. • Searching for proofs is not more efficient than enumerating models, but in many practical cases, it’s more efficient because we can ignore irrelevant propositions

  47. Resolution • So far – soundness of inference algorithm • soundness – truth preserving – inference algorithm derives only entailed sentences • Unsound – makes things up as it goes along • Completeness of inference algorithms? • Completeness – algorithm can derive any sentence that is entailed

  48. Resolution • Wumpus world • agent returns from [2,1] to [1,1], then goes to [1,2] – stench, but no breeze • Add facts to knowledge base • R11: B1,2 • R12: B1,2 (P1,1 P2,2 P1,3) • Same process that led to R10 – we can derive • R13: P2,2 • R14: P1,3

  49. Resolution • Biconditional elimination to R3, … • R15: P1,1  P2,2  P3,1 • Resolution • P2,2 in R13 resolves with P2,2 in R15 to give R16: P1,1 P3,1 In other words, if there Is a pit in one of [1,1],[2,2],[3,1], and it is not in [2,2] then it is in [1,1] or [3,1] • Similarly, P1,1 in R1 resolves with P1,1 in R16 to give R17: P3,1 In other words, if there Is a pit of [1,1] or [3,1], and it is not in [1,1] then it is in [3,1]

  50. Resolution • We used the unit resolution inference rule above li and m are complimentary literals (one is the negative of the other) • A Full Resolution Rule is a generalization of this rule

More Related