chapter 7 logical agents
play

Chapter 7 Logical Agents CS4811 - Artificial Intelligence Nilufer - PowerPoint PPT Presentation

Chapter 7 Logical Agents CS4811 - Artificial Intelligence Nilufer Onder Department of Computer Science Michigan Technological University Outline Knowledge-based agents Wumpus world Logic in general: models and entailment Propositional Logic


  1. Chapter 7 Logical Agents CS4811 - Artificial Intelligence Nilufer Onder Department of Computer Science Michigan Technological University

  2. Outline Knowledge-based agents Wumpus world Logic in general: models and entailment Propositional Logic Equivalence, validity, satisfiability Inference rules and theorem proving Forward chaining Backward chaining Resolution

  3. A knowledge-based agent The knowledge base ◮ contains domain-specific information Agent ◮ is a set of sentences in a formal sensors TELL language what is the world like now e.g., propositional logic, knowledge first order logic base Environment The inference engine what inferences can be made ◮ contains domain-independent inference algorithms engine ◮ is a set of inference algorithms ASK actuators e.g., model checking, forward checking, resolution refutation

  4. The Wumpus world Environment ◮ interconnected caves B r e PIT 4 e z e Stench ◮ searching for gold B r e e z e PIT B r e e 3 Stench z e ◮ squares adjacent to Wumpus are Gold smelly B r e e 2 z e Stench ◮ squares adjacent to pits are breezy ◮ pits are bottomless B r e e B r e e z e PIT z e 1 START will trap the agent but not the 1 2 3 4 Wumpus ◮ glitter is seen if square has gold Actuators and percepts: ◮ shooting kills wumpus if you are ◮ Actions: left turn, right facing it turn, forward, grab, ◮ shooting uses up the only arrow release, shoot ◮ grabbing picks up gold ◮ Sensors: breeze, glitter, smell ◮ releasing drops the gold

  5. Exploring the Wumpus world P? P? OK OK, B OK, B P? OK, B P? A A OK OK OK OK OK OK OK OK, S A A P? P? OK P? OK P P P OK, B P? OK OK, B P? OK OK OK, B P? OK OK,BGS A A OK OK, S OK OK, S OK OK, S A W W W

  6. Logic in general ◮ Logics are formal languages for representing information such that conclusions can be drawn ◮ Syntax defines the sentences in the language ◮ Semantics define the “meaning” of sentences, i.e., define truth of a sentence in a world ◮ E.g., the language of arithmetic ◮ x + 2 ≥ y is a sentence; x 2 + y > is not a sentence ◮ 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

  7. Logic in general (Wumpus world example) ◮ Logics are formal languages for representing information such that conclusions can be drawn ◮ Syntax defines the sentences in the language ◮ Semantics define the “meaning” of sentences, i.e., define truth of a sentence in a world ◮ E.g., a language for the Wumpus world ◮ P i , j is a proposition It’s true if there is a pit in [i,j] ◮ B i , j a proposition It’s true if there is a breeze in [i,j] ◮ The following are sentences that represent “Pits cause breezes in adjacent squares” or “A square is breezy if and only if there is an adjacent pit” B 1 , 1 ⇔ ( P 1 , 2 ∨ P 2 , 1 ) B 2 , 1 ⇔ ( P 1 , 1 ∨ P 2 , 2 ∨ P 3 , 1 )

  8. Entailment ◮ Entailment means one thing follows from another: KB | = α ◮ Knowledge base KB entails sentence α if and only if α is true in all worlds where KB is true ◮ For example: x + y = 4 entails 4 = x + y ◮ In the Wumpus world, “no breeze in [1,1]” entails no pit in [1,2] and no pit in [2,1] ◮ Entailment is a relationship between sentences (i.e., syntax) that is based on semantics

  9. Models ◮ Logicians typically think in terms of models , which are formally structured worlds with respect to which truth can be evaluated ◮ We say m is a model of a sentence α if alpha is true in m ◮ M ( α ) is the set of all models of α , i.e., all the worlds in which α is true ◮ Then KB | = α if and only if M ( KB ) ⊆ M ( α ) ◮ For example, in every world where there is no breeze in [1,1], there is no pit in [1,2] and [2,1]

  10. Entailment in the Wumpus world ◮ Consider the situation after detecting nothing in [1,1], moving right to [2,1], and detecting a breeze in [2,1] ◮ Write all the possible models for the cells with questions marks ? ? (only for pits) ◮ There are 3 cells with Boolean B ? choices (pit or no pit) so A A there are 8 possible models

  11. Wumpus models 2 2 B B 1 1 1 2 3 1 2 3 2 2 2 B B B 1 1 1 1 2 3 1 2 3 1 2 3 2 2 2 B B B 1 1 1 1 2 3 1 2 3 1 2 3

  12. Knowledge base KB 2 2 B B 1 1 1 2 3 1 2 3 2 2 2 B B B 1 1 1 1 2 3 1 2 3 1 2 3 2 2 2 B B B 1 1 1 1 2 3 1 2 3 1 2 3 KB = wumpus-world rules + observations

  13. Model checking α 1 KB 2 2 B B 1 1 α 1 1 2 3 1 2 3 2 2 2 B B B 1 1 1 1 2 3 1 2 3 1 2 3 2 2 2 B B B 1 1 1 1 2 3 1 2 3 1 2 3 KB = wumpus-world rules + observations α 1 = “[1,2] is safe” KB | = α 1 , proved by model checking

  14. Model checking α 2 α 2 2 2 B B 1 1 1 2 3 1 2 3 2 2 2 B B B 1 1 1 1 2 3 1 2 3 1 2 3 2 2 2 B B B 1 1 1 1 2 3 1 2 3 1 2 3 KB KB = wumpus-world rules + observations α 2 = “[2,2] is safe” KB ✓ ✓ | = α 2 , the knowledge base does not entail α 2

  15. Inference ◮ KB ⊢ i α means sentence α can be derived from KB by procedure i ◮ Consequences of KB are a haystack; α is a needle Entailment is a needle in haystack; inference is finding it ◮ 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 α ◮ 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 i.e., the procedure will answer any question whose answer follows from what is known by the KB

  16. Propositional logic: Syntax Propositional logic is the simplest logic–illustrates basic ideas The proposition symbols such as P 1 , P 2 are sentences If S is a sentence, ¬ S is a sentence ( negation ) If S 1 and S 2 are sentences, S 1 ∧ S 2 is a sentence ( conjunction ) If S 1 and S 2 are sentences, S 1 ∨ S 2 is a sentence ( disjunction ) If S 1 and S 2 are sentences, S 1 → S 2 is a sentence ( implication ) If S 1 and S 2 are sentences, S 1 → S 2 is a sentence ( biconditional )

  17. The forward chaining algorithm Idea: Fire any rule whose premises are satisfied in the KB, add its conclusion to the KB, until the query is found

  18. Forward chaining example Q P P ⇒ Q L ∧ M ⇒ P B ∧ L ⇒ M A ∧ P ⇒ L M A ∧ B ⇒ L L A B A B

  19. Initially Q 1 Agenda: A , B P Inferred: ∅ premise conclusion count 2 P Q 1 M L ∧ M 2 P L B ∧ L M 2 2 A ∧ P 2 L 2 2 A ∧ B L 2 A B

  20. Take A Q 1 Agenda: B P Inferred: A premise conclusion count 2 1 P Q M L ∧ M P 2 L B ∧ L M 2 2 A ∧ P L 1 1 1 A ∧ B L 1 A B

  21. Take B Q 1 Agenda: L P Inferred: A , B premise conclusion count 2 1 P Q M L ∧ M P 2 L B ∧ L M 1 1 A ∧ P 1 L 1 0 A ∧ B L 0 A B

  22. Take L Q 1 Agenda: M P Inferred: A , B , L premise conclusion count 1 1 P Q M L ∧ M P 1 L B ∧ L M 0 0 A ∧ P 1 L 1 0 A ∧ B L 0 A B

  23. Take M Q 1 Agenda: P P Inferred: A , B , L , M premise conclusion count 0 1 P Q M L ∧ M P 0 L B ∧ L M 0 0 A ∧ P 1 L 1 0 A ∧ B L 0 A B

  24. Take P Q 0 Agenda: Q P Inferred: A , B , L , M , P premise conclusion count 0 P Q 0 M L ∧ M 0 P L B ∧ L M 0 0 A ∧ P L 0 A ∧ B 0 0 0 L A B

  25. L will not be inferred the second time Q 0 Agenda: Q P Inferred: A , B , L , M , P premise conclusion count 0 P Q 0 M L ∧ M 0 P L B ∧ L M 0 0 A ∧ P L 0 A ∧ B 0 0 0 L A B

  26. Take Q Q 0 Agenda: ∅ P Inferred: A , B , L , M , P , Q premise conclusion count 0 0 P Q M L ∧ M P 0 L B ∧ L 0 M 0 A ∧ P L 0 A ∧ B 0 0 0 L A B

  27. Party time! Scenario 1 ◮ If Chris goes to a party, Pat also does ◮ If Pat goes to party, Pat can’t study ◮ If Pat can’t study, Pat fails ◮ Chris went to a party Can we prove Pat will fail using forward chaining?

  28. Party time! Scenario 2 ◮ If Chris goes to a party, Pat also does ◮ If Chris doesn’t go to the party, Pat will ◮ If Pat goes to party, Pat can’t study ◮ If Pat can’t study, Pat fails Can we prove Pat will fail using forward chaining?

  29. Summary ◮ Logical agents apply inference to a knowledge base to derive new information and make decisions ◮ Basic concepts of logic: ◮ syntax: formal structure of sentences ◮ semantics: truth of sentences with respect to models ◮ entailment: necessary truth of one sentence given another ◮ inference: deriving sentences from other sentences ◮ soundess: derivations produce only entailed sentences ◮ completeness: derivations can produce all entailed sentences ◮ optimal decisions depend on information state, not real state ◮ Forward and backward chaining are linear-time, complete for Horn clauses ◮ Resolution is complete for propositional logic ◮ Propositional logic lacks expressive power

  30. Sources for the slides ◮ AIMA textbook (3 rd edition) ◮ AIMA slides (http://aima.cs.berkeley.edu/)

Recommend


More recommend