logical agents
play

Logical Agents CE417: Introduction to Artificial Intelligence - PowerPoint PPT Presentation

Logical Agents CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2017 Soleymani Artificial Intelligence: A Modern Approach , 3 rd Edition, Chapter 7 Knowledge-based agents Knowledge-based agents


  1. Logical Agents CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2017 Soleymani “ Artificial Intelligence: A Modern Approach ” , 3 rd Edition, Chapter 7

  2. Knowledge-based agents  Knowledge-based agents  Reasoning operates on internal representation of knowledge  Logic as a general class of representation  Propositional logic  First-order logic 2

  3. A generic knowledge-based agent function KB_AGENT(𝑞𝑓𝑠𝑑𝑓𝑞𝑢) returns an 𝑏𝑑𝑢𝑗𝑝𝑜 persistent : 𝐿𝐶 , a knowledge base 𝑢, 𝑏 counter for time, initially 0 TELL(𝐿𝐶, MAKE_PERCEPT_SENTENCE(𝑞𝑓𝑠𝑑𝑓𝑞𝑢, 𝑢)) 𝑏𝑑𝑢𝑗𝑝𝑜 ← ASK(𝐿𝐶, MAKE_ACTION_QUERY(𝑢)) TELL(𝐿𝐶, MAKE_ACTION_SENTENCE(𝑏𝑑𝑢𝑗𝑝𝑜, 𝑢)) 𝑢 ← 𝑢 + 1 • Makes a sentence asserting that the agent return 𝑏𝑑𝑢𝑗𝑝𝑜 perceived the given percept at the given time. • Makes a sentence that asks what action should be done at the current time.  The agent must be able to: • Makes a sentence asserting that the chosen  Represent states, actions, percepts, … . action was executed.  Incorporate new percepts  Update internal representations of the world  Deduce hidden properties of the world  Deduce appropriate actions 3

  4. Knowledge Base (KB)  KB = a set of sentences expressed in a knowledge representation language  TELL : adds new sentences to the knowledge base  ASK : asks a question of KB  the answer follows from previously TELL ed sentences to the KB  Inference: derives new sentences from old ones  Basis of TELL and ASK operations 4

  5. Wumpus world  Wumpus  Pitts  Gold Wumpus  Agent 5

  6. Wumpus world PEAS description  Performance measure  +1000 for garbing gold  -1000 for death  -1 for each action  -10 for using up the arrow  Game ends when the agent dies or climbs out of the cave  Environment  4×4 grid  Agent starts in [1,1] while facing to the right  Gold and wumpus are located randomly in the squares except to [1,1]  Each square other than [1,1] can be a pit with probability 0.2 6

  7. Wumpus world PEAS description  Sensors: Stench, Breeze, Glitter, Bump, Scream  In the squares adjacent to wumpus, agent perceives a Stench  It the squares adjacent to a pit, agent perceives a Breeze  In the gold square, agent perceives a Glitter  When walking into a wall, agent perceives a Bump  When Wumpus is killed, agent perceives a Scream  Actuators: Forward, TurnLeft, TurnRight, Shoot, Grab, Climb  Forward,TurnLeft,TurnRight: moving and rotating face actions.  Moving to a square containing a pit or a live wumpus causes death.  If an agent tries to move forward and bumps into a wall then it does not move.  Shoot: to fire an arrow in a straight line in the facing direction of the agent  Shooting kills wumpus if the agent is facing it (o.w. the arrow hits a wall) The first shoot action has any effect (the agent has only one arrow)   Grab: to pick up the gold if it is in the same square as the agent .  Climb: climb out of the cave but only from [1,1] 7

  8. Wumpus world characterization  Fully Observable? No – many aspects are not directly perceivable  Episodic? No – sequential at the level of actions  Static? Yes  Discrete?Yes  Single-agent?Yes 8

  9. Wumpus world example A: agent OK: safe square 9

  10. Wumpus world example A: agent A: agent OK: safe square OK: safe square B: Breeze 10

  11. Wumpus world example A: agent OK: safe square B: Breeze P: Pit 11

  12. Wumpus world example A: agent OK: safe square B: Breeze P: Pit S: Stench 12

  13. Wumpus world example A: agent OK: safe square B: Breeze P: Pit S: Stench 13

  14. Wumpus world example A: agent OK: safe square B: Breeze P: Pit S: Stench 14

  15. Wumpus world example A: agent OK: safe square B: Breeze P: Pit S: Stench 15

  16. Wumpus world example A: agent OK: safe square B: Breeze P: Pit S: Stench 16

  17. Logic & Language  Logic includes formal languages for representing information such that conclusions can be drawn  Syntax defines the well-formed sentences in a language  Semantics define the "meaning" of sentences  i.e., define truth of a sentence with respect to each possible world  We will introduce Propositional Logic in this lecture  It talks about facts  Propositions can be true, false, or unknown 17

  18. Propositional logic: Syntax  Propositional logic is the simplest logic  To illustrate basic ideas about logic & reasoning  The proposition symbols 𝑄 , 𝑅 , … are sentences.  If 𝑄 is a sentence,  𝑄 is a sentence (negation)  If 𝑄 and 𝑅 are sentences, 𝑄  𝑅 is a sentence (conjunction)  If 𝑄 and 𝑅 are sentences, 𝑄  𝑅 is a sentence (disjunction)  If 𝑄 and 𝑅 are sentences, 𝑄  𝑅 is a sentence (implication)  If 𝑄 and 𝑅 are sentences, 𝑄  𝑅 is a sentence (biconditional) 18

  19. Propositional logic (Grammar) 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 → 𝐵𝑢𝑝𝑛𝑗𝑑𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 | 𝐷𝑝𝑛𝑞𝑚𝑓𝑦𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 𝐵𝑢𝑝𝑛𝑗𝑑𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 → 𝑈𝑠𝑣𝑓 𝐺𝑏𝑚𝑡𝑓 𝑄 𝑅 𝑆 | … 𝐷𝑝𝑛𝑞𝑚𝑓𝑦𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 → (𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓) | ¬𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 | 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 ∧ 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 | 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 ∨ 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 | 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 ⟹ 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 | 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 ⇔ 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 𝑄𝑠𝑓𝑑𝑓𝑒𝑓𝑜𝑑𝑓: ¬ , ∧ , ∨ , ⟹ , ⇔ 19

  20. Truth tables for connectives 20

  21. Propositional logic: Semantics  Each model specifies true/false of each proposition symbol  e .g., Propistion symbols: 𝑄 1,2 , 𝑄 2,2 , 𝑄 3,1  8 possible models  𝑛 1 = {𝑄 1,2 = 𝑔𝑏𝑚𝑡𝑓, 𝑄 2,2 = 𝑔𝑏𝑚𝑡𝑓, 𝑄 3,1 = 𝑢𝑠𝑣𝑓}  Semantics of a complex sentence in any model m :  𝑄 is true iff 𝑄 is false in 𝑛 .  𝑄  𝑅 is true iff 𝑄 is true and 𝑅 is true in 𝑛 .  𝑄 ∨ 𝑅 is true iff 𝑄 is true or 𝑅 is true in 𝑛 .  𝑄 ⟹ 𝑅 is true unless 𝑄 is true and 𝑅 is false in 𝑛 .  𝑄 ⟺ 𝑅 is true iff 𝑄 and 𝑅 are both true or both false in 𝑛 .  21

  22. Wumpus world sentences  𝑄 𝑗,𝑘 is true if there is a pit in [𝑗, 𝑘] . 𝑗,𝑘 is true if there is a wumpus in [𝑗, 𝑘] , dead or alive.  𝑋  𝐶 𝑗,𝑘 is true if the agent perceives a breeze in [𝑗, 𝑘] .  𝑇 𝑗,𝑘 is true if the agent perceives a stench in [𝑗, 𝑘] .  General rules (only related ones to the current agent position)  𝑆 1 :  𝑄 (no pit in [1,1]) 1,1 (Pits cause breezes in adjacent squares)  𝑆 2 : 𝐶 1,1 ⇔ 𝑄 1,2 ∨ 𝑄 2,1 (Pits cause breezes in adjacent squares)  𝑆 3 : 𝐶 2,1 ⇔ 𝑄 1,1 ∨ 𝑄 2,2 ∨ 𝑄 3,1  Perception  𝑆 4 :  𝐶 1,1  𝑆 5 : 𝐶 2,1 22

  23. Models  Models are mathematical abstraction of possible worlds  For each logical sentence, we can consider a set that specifies all possible worlds in which 𝛽 is true  𝑁(𝛽) : set of all models of the sentence 𝛽 (all satisfying 𝛽 )  𝑛 ∈ 𝑁(𝛽) if 𝛽 is true in model 𝑛  E.g., For 𝛽 : 𝑦 + 𝑧 = 4 , all possible assignments of values to 𝑦 , 𝑧 are models. 𝑁(𝛽) contains a subset of models satisfying 𝑦 + 𝑧 = 4. 23

  24. Wumpus models  Agents starts at [1,1] with no active sensor, then moves to [2,1] and senses Breeze in it  Possible models for pits in [1,2], [2,2], [3,1]: 24

  25. Logical reasoning: entailment  𝛽 ⊨ 𝛾 (entailment): 𝛽 entails 𝛾  𝛽 ⇒ 𝛾 is a tautology or valid  A sentence is valid or tautology if it is T𝑠𝑣𝑓 in all models ( e.g., 𝑄  𝑄 , (𝑄  (𝑄  𝑅))  𝑅 )  𝛾 logically follows from 𝛽 or 𝛽 is stronger than 𝛾  𝛽 ⊨ 𝛾 iff 𝑁 𝛽  𝑁 𝛾  𝛽 entails 𝛾 iff 𝛾 is true in all worlds where 𝛽 is true 25

  26. Entailment iff  𝐿𝐶 ⊨ 𝛽 𝑁(𝐿𝐶) ⊆ 𝑁(𝛽)  Example:  KB = “ A is red ” & “ B is blue ”  α = “ A is red ” 26

  27. Entailment in the wumpus world (before perception): rules of the  𝐿𝐶 wumpus world  Perception: After detecting nothing in [1,1], moving right, a breeze in [1,2] 27

  28. Wumpus models  Possible models for pits in [1,2], [2,2], [3,1] Consider possible models for only pits in neighboring squares 2 3 = 8 possible models 28

  29. Wumpus models  𝐿𝐶 = wumpus-world rules + perceptions 29

  30. Wumpus models  𝐿𝐶 = wumpus-world rules + perceptions  𝛽 1 = "[1,2] is safe"  𝑁(𝐿𝐶) ⊆ 𝑁(𝛽 1 ) ⇒ 𝐿𝐶 ⊨ 𝛽 1 30

  31. Wumpus models  KB = wumpus-world rules + perceptions 31

  32. Wumpus models  𝐿𝐶 = wumpus-world rules + perceptions  𝛽 2 = " [2,2] is safe", 𝐿𝐶 ⊭ 𝛽 2 32

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