1 / 107

Logical Agents

Logical Agents. Knowledge bases. Knowledge base = set of sentences in a form a l language Decl a r ati v e approach to building an a gent (or other system): T ELL it what it needs to know Then it can A S K itself what to d o — answers should fo l low from the KB

megan-kirk
Download Presentation

Logical 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. Logical Agents

  2. Knowledge bases • Knowledgebase= setofsentencesina formallanguage • Declarativeapproach to buildingan agent (or other system): TELLitwhat itneedsto know • Then itcan ASKitselfwhat to do—answersshouldfollowfrom theKB • Agents canbeviewedat theknowledgelevel i.e.,what they know,regardless ofhowimplemented • Or at theimplementationlevel i.e., data structures inKBand algorithmsthatmanipulate them

  3. Knowledge-Based Agent • Agent thatuses priororacquired • knowledge to achieve itsgoals • Canmake moreefficientdecisions • Canmake informed decisions • KnowledgeBase (KB): contains a setof representationsof factsabout the Agent’s environment • Each representation iscalleda • sentence • Usesome knowledgerepresentation language,to TELLitwhat to know e.g., (temperature 72F) • ASKagent to querywhatto do • Agent can use inferenceto deducenew facts fromTELLedfacts Domain independentalgorithms ASK Inferenceengine KnowledgeBase TELL Domainspecificcontent

  4. A simple knowledge-based agent • Theagent mustbe able to: • Represent states,actions,etc. • Incorporatenewpercepts • Updateinternalrepresentationsoftheworld • Deducehiddenproperties oftheworld • Deduceappropriate actions

  5. Wumpus World Example • Performance measure • ◦ gold+1000, death-1000 • -1perstep, -10 forusingthe arrow • Environment • Squaresadjacentto wumpusare smelly • Squaresadjacenttopitare breezy • Glitteriff goldisinthe samesquare • Shootingkills wumpusifyou are facing it • Shootingusesup the only arrow • Grabbingpicks upgoldif insame square • Releasingdropsthe goldinsame square • Actuators • Leftturn,Rightturn,Forward, Grab, Release,Shoot • Sensors • Breeze,Glitter,Smell

  6. Wumpus world characterization • Observable? • Deterministic? • Episodic? • Static? • Discrete? • Single-agent?

  7. Wumpus world 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 • Single-agent?Yes—Wumpus is a feature

  8. Exploring a wumpus world

  9. Exploring a wumpus world A=Agent B= Breeze S= Smell P= Pit W= Wumpus OK= Safe V = Visited G= Glitter CS561-Lecture09-10-Macskassy-Fall 2010

  10. Exploring a wumpus world A=Agent B= Breeze S= Smell P= Pit W= Wumpus OK= Safe V = Visited G= Glitter CS561-Lecture09-10-Macskassy-Fall 2010 10

  11. Exploring a wumpus world A=Agent B= Breeze S= Smell P= Pit W= Wumpus OK= Safe V = Visited G= Glitter CS561-Lecture09-10-Macskassy-Fall 2010

  12. Exploring a wumpus world A=Agent B= Breeze S= Smell P= Pit W= Wumpus OK= Safe V = Visited G= Glitter CS561-Lecture09-10-Macskassy-Fall 2010

  13. Exploring a wumpus world A=Agent B= Breeze S= Smell P= Pit W= Wumpus OK= Safe V = Visited G= Glitter CS561-Lecture09-10-Macskassy-Fall 2010

  14. Exploring a wumpus world A=Agent B= Breeze S= Smell P= Pit W= Wumpus OK= Safe V = Visited G= Glitter CS561-Lecture09-10-Macskassy-Fall 2010

  15. Exploring a wumpus world A=Agent B= Breeze S= Smell P= Pit W= Wumpus OK= Safe V = Visited G= Glitter CS561-Lecture09-10-Macskassy-Fall 2010

  16. Exploring a wumpus world A=Agent B= Breeze S= Smell P= Pit W= Wumpus OK= Safe V = Visited G= Glitter CS561-Lecture09-10-Macskassy-Fall 2010

  17. Other tight spots Breeze in(1,2) and (2,1) no safeactions Assuming pitsuniformly distributed, (2,2) has pitw/ prob 0.86,vs. 0.31 Smellin(1,1) cannotmove Can use a strategy of coercion: shootstraightahead wumpuswas theredeadsafe wumpuswasn't theresafe CS561-Lecture09-10-Macskassy-Fall 2010

  18. Example Solution S in 1,21,3or2,2has W No S in 2,12,2OK 2,2OK1,3W NoB in 1,2&B in2,13,1P CS561-Lecture09-10-Macskassy-Fall 2010

  19. Another example solution No perception1,2and2,1 OK Moveto2,1 Bin 2,12,2or3,1P? 1,1V no P in1,2 Moveto1,2(only option) CS561-Lecture09-10-Macskassy-Fall 2010

  20. Logic in general • Logicsare formal languagesfor representinginformation suchthat conclusions canbedrawn • Syntaxdefinesthe sentencesinthe language • Semanticsdefinethe“meaning” ofsentences; • i.e., define truthof a sentenceinaworld • E.g., thelanguageof arithmetic • x+ 2≥ yisasentence; x2+y> isnot a sentence • x+2≥yistrue iffthenumberx+2isno lessthan thenumber y • x+2≥yistrue inaworld where x=7; y=1 • x+ 2 ≥ yis falseina worldwherex=0;y=6

  21. Types of logic • Logics arecharacterized by what they commit to as “primitives” • Ontological commitment: what exists—facts?objects?time?beliefs? • Epistemologicalcommitment: whatstatesof knowledge?

  22. The Semantic Wall PhysicalSymbol System World +BLOCKA+ +BLOCKB+ +BLOCKC+ P1:(IS_ON+BLOCKA+ +BLOCKB+) P2:((IS_RED+BLOCKA+)

  23. Truth depends on Interpretation Representation1 World A B ON(A,B)T ON(B,A)F ON(A,B) F A ON(B,A) T B

  24. Entailment • Entailmentmeansthatonethingfollowsfromanother: • KB╞α • KnowledgebaseKBentailssentenceα • ifandonlyif(iff) • αistrue inall worldswhere KBis true • E.g.,theKBcontaining“the Giantswon”and“the Reds won” entails“Either theGiantswonortheReds won” • E.g.,x+y=4entails4=x +y • Entailmentisarelationshipbetween sentences(i.e.,syntax) thatis basedonsemantics • Note:brainsprocesssyntax(ofsome sort) • Entailment isdifferentthaninference!

  25. Logic as a representation of the World entails Representation: Sentences Sentence Refersto (Semantics) follows Fact World Facts

  26. Models • Logicianstypicallythinkinterms ofmodels,whichare formally structured worlds withrespectto whichtruth canbeevaluated • We saymisa modelof a sentenceαifαistrue inm • M(α)isthesetof allmodelsofα • ThenKB╞αifand only ifM(KB)µM(α) • E.g. KB= Giants wonand Reds won • α = Giantswon

  27. Entailment in the wumpusworld • Situationafterdetectingnothingin[1,1], movingright, breezein[2,1] • Considerpossiblemodelsfor ?s assuming only pits • 3 Boolean choices8possiblemodels

  28. Wumpus models

  29. Wumpus Models KB=wumpus-worldrules +observations

  30. Wumpus Models KB=wumpus-worldrules +observations α1 = “[1,2] issafe",KB╞α 1,proved by modelchecking

  31. Wumpus Models KB=wumpus-worldrules +observations α2 = “[2,2] issafe",KB╞\α 2

  32. Inference • KBα=sentenceαcanbederivedfrom KB byprocedurei • Consequencesof KBare a haystack;αisaneedle. • Entailment=needleinhaystack;inference =finding it • Soundness:iissound if • wheneverKBα,itis alsotrue thatKB╞α • Completeness:iiscompleteif • wheneverKB╞α,itisalsotrue thatKBα • Preview:wewilldefinea logic (first-orderlogic)whichis expressive enough to say almost anything ofinterest, and for which there existsa soundand completeinferenceprocedure. • That is,the procedurewillansweranyquestionwhoseanswer follows from what isknownbytheKB.

  33. Basic symbols • Expressionsonlyevaluate to either“true”or “false.” • PQ “P and Q are either bothtrue orboth false”equivalence

  34. Propositional logic: Syntax • Propositionallogicisthesimplestlogic—illustratesbasicideasThepropositionsymbolsP1,P2 etcaresentences • IfSisasentence,¬Sisasentence(negation) • IfS1 andS2 aresentences,S1∧S2 isasentence(conjunction) • IfS1 andS2 aresentences,S1∨S2 isasentence(disjunction) • IfS1 andS2 aresentences,S1 ⇒ S2 isasentence(implication) • IfS1 andS2 aresentences,S1 ⇔ S2 isasentence(biconditional)

  35. Precedence • Use parentheses • A  B  C is not allowed

  36. Propositional logic: Semantics

  37. Truth tables for connectives

  38. Wumpus world sentences • LetPi;j be true if thereisa pitin[i;j]. • LetBi;j betrue ifthereisa breeze in[i;j]. • P1;1B1;1B2;1 • “Pitscause breezes in adjacentsquares”

  39. Wumpus world sentences • LetPi;j be true if thereisa pitin[i;j]. • LetBi;j betrue ifthereisa breeze in[i;j]. • P1;1B1;1B2;1 • “Pitscause breezes in adjacentsquares” • B1;1 (P1,2 VP2;1) • B2;1 (P1,1 VP2;2 VP311) • “A squareis breezy if andonly if thereis anadjacent pit”

  40. Truth tables for inference Enumeraterows(differentassignmentsto symbols), ifKBistrue inrow, check thatαistoo

  41. Propositional inference: enumeration method Let α=AVBandKB= (AVC)^(BV¬C) Is itthecase thatKB╞α? Check allpossiblemodels—αmust betrue whereverKBistrue

  42. Enumeration: Solution Let α=AVBandKB= (AVC)^(BV¬C) Is itthecase thatKB╞α? Check allpossiblemodels—αmust betrue whereverKBistrue

  43. Inference by enumeration • Depth-firstenumerationofallmodelsissound and complete • O(2n)for nsymbols;problemisco-NP-complete

  44. Propositional inference: normal forms “productofsumsof simple variablesor negated simplevariables” “sumof productsof simple variablesor negatedsimplevariables”

  45. Logical equivalence

  46. Validity and satisfiability • A sentenceis validifit istrue inallmodels, • e.g., True,AV¬ A, AA,(A^(AB)) B • Validityisconnected toinference viatheDeductionTheorem: • KB╞αifandonlyif(KBα) isvalid • A sentenceis satisfiableifit istrue insomemodel e.g., AVB,C • A sentenceis unsatisfiableifitistrue innomodelse.g., A^ ¬ A • Satisfiabilityisconnectedto inferenceviathe following: • KB╞αif and only if (KB^: ¬ α)isunsatisfiable • i.e., prove αbyreductioadabsurdum

  47. Example

  48. Satisfiability • Related to constraint satisfaction • Given a sentence S, try to find an interpretation I where S is true • Analogous to finding an assignment of values to variables such that the constraint hold • Example problem: scheduling nurses in a hospital • Propositional variables represent for example that Nurse1 is working on Tuesday at 2 • Constraints on the schedule are represented using logical expressions over the variables • Brute force method: enumerate all interpretations and check

  49. Example problem • Imagine that we knew that: • If today is sunny, then Amir will be happy (S H) • If Amir is happy, then the lecture will be good (H  G) • Today is Sunny (S) • Should we conclude that today the lecture will be good

  50. Checking Interpretations • Start by figuring out what set of interpretations make our original sentences true. • Then, if G is true in all those interpretations, it must be OK to conclude it from the sentences we started out with (our knowledge base). • In a universe with only three variables, there are 8 possible interpretations in total.

More Related