Download presentation
Presentation is loading. Please wait.
Published byCoral Long Modified over 9 years ago
1
CS 416 Artificial Intelligence Lecture 9 Logical Agents Chapter 7 Lecture 9 Logical Agents Chapter 7
2
Chess Article Garry Kasparov reflects on computerized chess IBM should have released the contents of Deep Blue to chess community to advance research of computation as it relates to chessIBM should have released the contents of Deep Blue to chess community to advance research of computation as it relates to chess Kudos to Deep Junior for putting information in public domain so state of the art can advanceKudos to Deep Junior for putting information in public domain so state of the art can advance Deep Blue made one good move that surprised Kasparov (though he thinks a person was in the loop)Deep Blue made one good move that surprised Kasparov (though he thinks a person was in the loop) Deep Junior made a fantastic sacrifice that reflects a new accomplishment for computerized chessDeep Junior made a fantastic sacrifice that reflects a new accomplishment for computerized chesshttp://www.opinionjournal.com/extra/?id=110003081 Garry Kasparov reflects on computerized chess IBM should have released the contents of Deep Blue to chess community to advance research of computation as it relates to chessIBM should have released the contents of Deep Blue to chess community to advance research of computation as it relates to chess Kudos to Deep Junior for putting information in public domain so state of the art can advanceKudos to Deep Junior for putting information in public domain so state of the art can advance Deep Blue made one good move that surprised Kasparov (though he thinks a person was in the loop)Deep Blue made one good move that surprised Kasparov (though he thinks a person was in the loop) Deep Junior made a fantastic sacrifice that reflects a new accomplishment for computerized chessDeep Junior made a fantastic sacrifice that reflects a new accomplishment for computerized chesshttp://www.opinionjournal.com/extra/?id=110003081
3
Where are we? We’ve studied classes of search problems Find the best sequence of actionsFind the best sequence of actions –Uninformed search (BFS, Iterative Deepening) –Informed search (A*) Find the best value of something (possibly a sequence)Find the best value of something (possibly a sequence) –Simulated annealing, genetic algorithms, hill climbing Finding the best action in an adversarial settingFinding the best action in an adversarial setting We’ve studied classes of search problems Find the best sequence of actionsFind the best sequence of actions –Uninformed search (BFS, Iterative Deepening) –Informed search (A*) Find the best value of something (possibly a sequence)Find the best value of something (possibly a sequence) –Simulated annealing, genetic algorithms, hill climbing Finding the best action in an adversarial settingFinding the best action in an adversarial setting
4
Logical Agents What are we talking about, “logical?” Aren’t search-based chess programs logicalAren’t search-based chess programs logical –Yes, but knowledge is used in a very specific way Win the game Not useful for extracting strategies or understanding other aspects of chess We want to develop more general-purpose knowledge systems that support a variety of logical analysesWe want to develop more general-purpose knowledge systems that support a variety of logical analyses What are we talking about, “logical?” Aren’t search-based chess programs logicalAren’t search-based chess programs logical –Yes, but knowledge is used in a very specific way Win the game Not useful for extracting strategies or understanding other aspects of chess We want to develop more general-purpose knowledge systems that support a variety of logical analysesWe want to develop more general-purpose knowledge systems that support a variety of logical analyses
5
Why study knowledge-based agents Partially observable environments combine available information (percepts) with general knowledge to select actionscombine available information (percepts) with general knowledge to select actions Natural Language Language is too complex and ambiguous. Problem-solving agents are impeded by high branching factor.Language is too complex and ambiguous. Problem-solving agents are impeded by high branching factor.Flexibility Knowledge can be reused for novel tasks. New knowledge can be added to improve future performance.Knowledge can be reused for novel tasks. New knowledge can be added to improve future performance. Partially observable environments combine available information (percepts) with general knowledge to select actionscombine available information (percepts) with general knowledge to select actions Natural Language Language is too complex and ambiguous. Problem-solving agents are impeded by high branching factor.Language is too complex and ambiguous. Problem-solving agents are impeded by high branching factor.Flexibility Knowledge can be reused for novel tasks. New knowledge can be added to improve future performance.Knowledge can be reused for novel tasks. New knowledge can be added to improve future performance.
6
Components of knowledge-based agent Knowledge Base Store informationStore information –knowledge representation language Add information (Tell)Add information (Tell) Retrieve information (Ask)Retrieve information (Ask) Perform inferencePerform inference –derive new sentences (knowledge) from existing sentences Knowledge Base Store informationStore information –knowledge representation language Add information (Tell)Add information (Tell) Retrieve information (Ask)Retrieve information (Ask) Perform inferencePerform inference –derive new sentences (knowledge) from existing sentences
7
The wumpus world A scary world, indeed A maze in a caveA maze in a cave A wumpus who will eat youA wumpus who will eat you One arrow that can kill the wumpusOne arrow that can kill the wumpus Pits that can entrap you (but not the wumpus for it is too large to fall in)Pits that can entrap you (but not the wumpus for it is too large to fall in) A heap of gold somewhereA heap of gold somewhere A scary world, indeed A maze in a caveA maze in a cave A wumpus who will eat youA wumpus who will eat you One arrow that can kill the wumpusOne arrow that can kill the wumpus Pits that can entrap you (but not the wumpus for it is too large to fall in)Pits that can entrap you (but not the wumpus for it is too large to fall in) A heap of gold somewhereA heap of gold somewhere
8
But you have sensing and action Sensing (each is either on or off – a single bit) wumpus emits a stench in adjacent squareswumpus emits a stench in adjacent squares pits cause a breeze in adjacent squarespits cause a breeze in adjacent squares gold causes glitter you see when in the squaregold causes glitter you see when in the square walking into wall causes a bumpwalking into wall causes a bump death of wumpus can be heard everywhere in worlddeath of wumpus can be heard everywhere in world Sensing (each is either on or off – a single bit) wumpus emits a stench in adjacent squareswumpus emits a stench in adjacent squares pits cause a breeze in adjacent squarespits cause a breeze in adjacent squares gold causes glitter you see when in the squaregold causes glitter you see when in the square walking into wall causes a bumpwalking into wall causes a bump death of wumpus can be heard everywhere in worlddeath of wumpus can be heard everywhere in world
9
But you have sensing and action Action You can turn left or right 90 degreesYou can turn left or right 90 degrees You can move forwardYou can move forward You can shoot an arrow in your facing directionYou can shoot an arrow in your facing directionAction You can turn left or right 90 degreesYou can turn left or right 90 degrees You can move forwardYou can move forward You can shoot an arrow in your facing directionYou can shoot an arrow in your facing direction
10
An example
12
Our agent played well Used inference to relate two different percepts observed from different locationsUsed inference to relate two different percepts observed from different locations Agent is guaranteed to draw correct conclusions if percepts are correctAgent is guaranteed to draw correct conclusions if percepts are correct Used inference to relate two different percepts observed from different locationsUsed inference to relate two different percepts observed from different locations Agent is guaranteed to draw correct conclusions if percepts are correctAgent is guaranteed to draw correct conclusions if percepts are correct
13
Knowledge Representation Must be syntactically and semantically correct Syntax the formal specification of how information is storedthe formal specification of how information is stored –a + 2 = c (typical mathematical syntax) –a2y += (not legal syntax for infix (regular math) notation) Semantics the meaning of the informationthe meaning of the information –a + 2 = c (c is a number whose value is 2 more than a) –a + 2 = c (the symbol that comes two after ‘a’ in the alphabet is ‘c’) Must be syntactically and semantically correct Syntax the formal specification of how information is storedthe formal specification of how information is stored –a + 2 = c (typical mathematical syntax) –a2y += (not legal syntax for infix (regular math) notation) Semantics the meaning of the informationthe meaning of the information –a + 2 = c (c is a number whose value is 2 more than a) –a + 2 = c (the symbol that comes two after ‘a’ in the alphabet is ‘c’)
14
Logical Reasoning Entailment one sentence follows logically from anotherone sentence follows logically from another – –the sentence entails the sentence entails ( ) if and only if for every model in which is true, is also true entails ( ) if and only if for every model in which is true, is also true Model: a description of the world where every relevant sentence has been assigned truth or falsehood Entailment one sentence follows logically from anotherone sentence follows logically from another – –the sentence entails the sentence entails ( ) if and only if for every model in which is true, is also true entails ( ) if and only if for every model in which is true, is also true Model: a description of the world where every relevant sentence has been assigned truth or falsehood
15
An example After one step in wumpus world Knowledge base (KB) isKnowledge base (KB) is –A set of all game states that are possible given: rules of game percepts How does the KB represent the game?How does the KB represent the game? After one step in wumpus world Knowledge base (KB) isKnowledge base (KB) is –A set of all game states that are possible given: rules of game percepts How does the KB represent the game?How does the KB represent the game?
16
Building the KB Consider a KB intended to represent the presence of pits in a Wumpus world where [1,1] is clear and [2,1] has a breeze There are three cells with two conditions eachThere are three cells with two conditions each 2 3 = Eight possible models2 3 = Eight possible models According to percepts and rules, KB is well definedAccording to percepts and rules, KB is well defined Consider a KB intended to represent the presence of pits in a Wumpus world where [1,1] is clear and [2,1] has a breeze There are three cells with two conditions eachThere are three cells with two conditions each 2 3 = Eight possible models2 3 = Eight possible models According to percepts and rules, KB is well definedAccording to percepts and rules, KB is well defined
17
Model Checking The agent wishes to check all models of the game in which a pit is in the three candidate spots Enumerate all models where three candidate spots may have pitsEnumerate all models where three candidate spots may have pits 3 pits, two conditions each3 pits, two conditions each 2 3 = Eight models2 3 = Eight models The agent wishes to check all models of the game in which a pit is in the three candidate spots Enumerate all models where three candidate spots may have pitsEnumerate all models where three candidate spots may have pits 3 pits, two conditions each3 pits, two conditions each 2 3 = Eight models2 3 = Eight models
18
Checking entailment Can “ 1 :There is no pit in [1, 2]” be true? Enumerate all states where 1 is trueEnumerate all states where 1 is true For all models where KB is true, 1 is true alsoFor all models where KB is true, 1 is true also The KB entails 1The KB entails 1 Can “ 1 :There is no pit in [1, 2]” be true? Enumerate all states where 1 is trueEnumerate all states where 1 is true For all models where KB is true, 1 is true alsoFor all models where KB is true, 1 is true also The KB entails 1The KB entails 1
19
Checking entailment Can “ 2 : There is no pit in [2, 2]” be true? Enumerate all states where 2 is trueEnumerate all states where 2 is true For all models where KB is true, 2 is not always true alsoFor all models where KB is true, 2 is not always true also KB does not entail 2KB does not entail 2 Can “ 2 : There is no pit in [2, 2]” be true? Enumerate all states where 2 is trueEnumerate all states where 2 is true For all models where KB is true, 2 is not always true alsoFor all models where KB is true, 2 is not always true also KB does not entail 2KB does not entail 2
20
Logical inference Entailment permitted logic we inferred new knowledge from entailmentswe inferred new knowledge from entailments Inference algorithms The method of logical inference we demonstrated is called model checking because we enumerated all possibilities to find the inferenceThe method of logical inference we demonstrated is called model checking because we enumerated all possibilities to find the inference Entailment permitted logic we inferred new knowledge from entailmentswe inferred new knowledge from entailments Inference algorithms The method of logical inference we demonstrated is called model checking because we enumerated all possibilities to find the inferenceThe method of logical inference we demonstrated is called model checking because we enumerated all possibilities to find the inference
21
Inference algorithms There are many inference algorithms If an inference algorithm, i, can derive from KB, we writeIf an inference algorithm, i, can derive from KB, we write There are many inference algorithms If an inference algorithm, i, can derive from KB, we writeIf an inference algorithm, i, can derive from KB, we write
22
Inference Algorithms Sound Algorithm derives only entailed sentencesAlgorithm derives only entailed sentences An unsound algorithm derives falsehoodsAn unsound algorithm derives falsehoodsComplete inference algorithm can derive any sentence that is entailedinference algorithm can derive any sentence that is entailed –Means inference algorithm cannot become caught in infinite loop? Sound Algorithm derives only entailed sentencesAlgorithm derives only entailed sentences An unsound algorithm derives falsehoodsAn unsound algorithm derives falsehoodsComplete inference algorithm can derive any sentence that is entailedinference algorithm can derive any sentence that is entailed –Means inference algorithm cannot become caught in infinite loop?
23
Propositional (Boolean) Logic Syntax of allowable sentences atomic sentencesatomic sentences –indivisible syntactic elements –Use uppercase letters to represent a proposition that can be true or false –True and False are predefined propositions where True means always true and False means always false Syntax of allowable sentences atomic sentencesatomic sentences –indivisible syntactic elements –Use uppercase letters to represent a proposition that can be true or false –True and False are predefined propositions where True means always true and False means always false
24
Atomic sentences Syntax of atomic sentences indivisible syntactic elementsindivisible syntactic elements Use uppercase letters to represent a proposition that can be true or falseUse uppercase letters to represent a proposition that can be true or false True and False are predefined propositions where True means always true and False means always falseTrue and False are predefined propositions where True means always true and False means always false Syntax of atomic sentences indivisible syntactic elementsindivisible syntactic elements Use uppercase letters to represent a proposition that can be true or falseUse uppercase letters to represent a proposition that can be true or false True and False are predefined propositions where True means always true and False means always falseTrue and False are predefined propositions where True means always true and False means always false
25
Complex sentences Formed from atomic sentences using connectives ~ (or = not): the negation~ (or = not): the negation ^ (and): the conjunction^ (and): the conjunction V (or): the disjunctionV (or): the disjunction => (or = implies): the implication=> (or = implies): the implication (if and only if): the biconditional (if and only if): the biconditional Formed from atomic sentences using connectives ~ (or = not): the negation~ (or = not): the negation ^ (and): the conjunction^ (and): the conjunction V (or): the disjunctionV (or): the disjunction => (or = implies): the implication=> (or = implies): the implication (if and only if): the biconditional (if and only if): the biconditional
26
Backus-Naur Form (BNF)
27
Propositional (Boolean) Logic Semantics given a particular model (situation), what are the rules that determine the truth of a sentence?given a particular model (situation), what are the rules that determine the truth of a sentence? use a truth table to compute the value of any sentence with respect to a model by recursive evaluationuse a truth table to compute the value of any sentence with respect to a model by recursive evaluationSemantics given a particular model (situation), what are the rules that determine the truth of a sentence?given a particular model (situation), what are the rules that determine the truth of a sentence? use a truth table to compute the value of any sentence with respect to a model by recursive evaluationuse a truth table to compute the value of any sentence with respect to a model by recursive evaluation
28
Truth table
29
Example from wumpus A square is breezy only if a neighboring square has a pit B 1,1 (P 1,2 V P 2,1 )B 1,1 (P 1,2 V P 2,1 ) A square is breezy if a neighboring square has a pit (P 1,2 V P 2,1 ) => B 1,1 (P 1,2 V P 2,1 ) => B 1,1 Former is more powerful and true to Wumpus rules A square is breezy only if a neighboring square has a pit B 1,1 (P 1,2 V P 2,1 )B 1,1 (P 1,2 V P 2,1 ) A square is breezy if a neighboring square has a pit (P 1,2 V P 2,1 ) => B 1,1 (P 1,2 V P 2,1 ) => B 1,1 Former is more powerful and true to Wumpus rules
30
A wumpus knowledge base Initial conditionsInitial conditions –R 1 : ~P 1,1 no pit in [1,1] Rules of Breezes (for a few example squares)Rules of Breezes (for a few example squares) –R 2 : B 1,1 (P 1,2 V P 2,1 ) –R 3 : B 2,1 (P 1,1 V P 2,1 V P 3,1 ) PerceptsPercepts –R 4 : ~B 1,1 –R 5 : B 2,1 We know: R 1 ^ R 2 ^ R 3 ^ R 4 ^ R 5 Initial conditionsInitial conditions –R 1 : ~P 1,1 no pit in [1,1] Rules of Breezes (for a few example squares)Rules of Breezes (for a few example squares) –R 2 : B 1,1 (P 1,2 V P 2,1 ) –R 3 : B 2,1 (P 1,1 V P 2,1 V P 3,1 ) PerceptsPercepts –R 4 : ~B 1,1 –R 5 : B 2,1 We know: R 1 ^ R 2 ^ R 3 ^ R 4 ^ R 5
31
Inference Does KB entail (KB -> ?) Is there a pit in [1,2]: P 1,2 ?Is there a pit in [1,2]: P 1,2 ? Consider only what we needConsider only what we need –B 1,1 B 2,1 P 1,1 P 1,2 P 2,1 P 2,2 P 3,1 –2 7 permutations of models to check For each model, see if KB is trueFor each model, see if KB is true For all KB = True, see if is trueFor all KB = True, see if is true Does KB entail (KB -> ?) Is there a pit in [1,2]: P 1,2 ?Is there a pit in [1,2]: P 1,2 ? Consider only what we needConsider only what we need –B 1,1 B 2,1 P 1,1 P 1,2 P 2,1 P 2,2 P 3,1 –2 7 permutations of models to check For each model, see if KB is trueFor each model, see if KB is true For all KB = True, see if is trueFor all KB = True, see if is true Model Checking
32
Inference Truth table
33
Concepts related to entailment logical equivalence Two sentences a and b are logically equivalent if they are true in the same set of models… a bTwo sentences a and b are logically equivalent if they are true in the same set of models… a b validity (or tautology) a sentence that is valid in all modelsa sentence that is valid in all models –P V ~P –deduction theorem: a entails b if and only if a implies b satisfiability a sentence that is true in some modela sentence that is true in some model a entails b (a ^ ~b) is unsatisfiablea entails b (a ^ ~b) is unsatisfiable logical equivalence Two sentences a and b are logically equivalent if they are true in the same set of models… a bTwo sentences a and b are logically equivalent if they are true in the same set of models… a b validity (or tautology) a sentence that is valid in all modelsa sentence that is valid in all models –P V ~P –deduction theorem: a entails b if and only if a implies b satisfiability a sentence that is true in some modela sentence that is true in some model a entails b (a ^ ~b) is unsatisfiablea entails b (a ^ ~b) is unsatisfiable
34
Logical Equivalences Know these equivalences
35
Reasoning w/ propositional logic Inference Rules Modus Ponens:Modus Ponens: –Whenever sentences of form => and are given the sentence can be inferred R 1 : Green => Martian R 2 : Green Inferred: Martian Inference Rules Modus Ponens:Modus Ponens: –Whenever sentences of form => and are given the sentence can be inferred R 1 : Green => Martian R 2 : Green Inferred: Martian
36
Reasoning w/ propositional logic Inference Rules And-EliminationAnd-Elimination –Any of conjuncts can be inferred R 1 : Martian ^ Green Inferred: Martian Inferrred: Green Use truth tables if you want to confirm inference rules Inference Rules And-EliminationAnd-Elimination –Any of conjuncts can be inferred R 1 : Martian ^ Green Inferred: Martian Inferrred: Green Use truth tables if you want to confirm inference rules
37
Example of a proof ~P ~B B P?
38
Example of a proof ~P ~B B ~P P?
39
Constructing a proof Proving is like searching Find sequence of logical inference rules that lead to desired resultFind sequence of logical inference rules that lead to desired result Note the explosion of propositionsNote the explosion of propositions –Good proof methods ignore the countless irrelevant propositions Proving is like searching Find sequence of logical inference rules that lead to desired resultFind sequence of logical inference rules that lead to desired result Note the explosion of propositionsNote the explosion of propositions –Good proof methods ignore the countless irrelevant propositions
40
Monotonicity of knowledge base Knowledge base can only get larger Adding new sentences to knowledge base can only make it get largerAdding new sentences to knowledge base can only make it get larger –If (KB entails ) ((KB ^ ) entails ) This is important when constructing proofsThis is important when constructing proofs –A logical conclusion drawn at one point cannot be invalidated by a subsequent entailment Knowledge base can only get larger Adding new sentences to knowledge base can only make it get largerAdding new sentences to knowledge base can only make it get larger –If (KB entails ) ((KB ^ ) entails ) This is important when constructing proofsThis is important when constructing proofs –A logical conclusion drawn at one point cannot be invalidated by a subsequent entailment
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.