440 likes | 792 Views
Chapter 7 Logic Agents Outline Knowledge-based agents Wumpus world Logic in general – models and entailment Propositional (Boolean) Logic Equivalence, validity, satisfiability Inference rules and theorem proving forward chaining backward chaining resolution Knowledge bases
E N D
Outline • Knowledge-based agents • Wumpus world • Logic in general – models and entailment • Propositional (Boolean) Logic • Equivalence, validity, satisfiability • Inference rules and theorem proving • forward chaining • backward chaining • resolution Introduction to Artificial Intelligence - APSU
Knowledge bases • Knowledge base (KB) • a set of sentences in a formal language • Declarative approach to building an agent • TELL it what it needs to know (add new sentences to the KB) • ASK what it knows (query KB) and the answer should follow from what has been told • involve inference – deriving new sentences from old • Agents can be viewed at the knowledge level • what they know, regardless of how implemented or at the implementation level • data structures in KB • algorithms that manipulate them Introduction to Artificial Intelligence - APSU
Define game as a search problem • The agent must be able to: • represent states, actions, etc. • incorporate new percepts • update internal representations of the world • deduce hidden properties of the world • deduce appropriate actions Introduction to Artificial Intelligence - APSU
Wumpus world PEAS description • Performance measure • gold +1000, death -1000 • -1 per step, -10 for using the arrow • Environment • Squares adjacent to wumpus are stench • Squares adjacent to pit are breezy • Glitter iff gold is in the same square • Shooting kills wumpus if you are facing it • Shooting uses up the only arrow • Grabbing picks up gold if in same square • Releasing drops the gold in same square • Wumpus emits a woeful scream when it is killed • Agent dies if entering a square with a pit or wumpus • Actuators • Left turn, Right turn, Forward, Grab, Release, Shoot • Sensors • Stench, Breeze, Glitter, Bump, Woeful scream Introduction to Artificial Intelligence - APSU
Properties of wumpus world • 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 essentially a natural feature Introduction to Artificial Intelligence - APSU
Exploring a wumpus world Introduction to Artificial Intelligence - APSU
Exploring a wumpus world (cont’d) Introduction to Artificial Intelligence - APSU
Logic in general • Logics are formal languages for representing information such that conclusions can be drawn • Syntax defines the (well-formed) sentences in the language • Semantics defines the “meaning” of sentences, i.e., defines truth of a sentence in each possible world • Every sentence must be either true or false in each possible world • Examples: the language of arithmetic Introduction to Artificial Intelligence - APSU
Model and Entailment • Logicians call each possible world Model • We say m is a model of a sentence aifa is true in m. • Entailment refers a sentence follows logically from another sentence • a |= b represents the sentence aentails the sentence b • a |= b if and only if, in every model in whichais true, b is also true • e.g. x + y = 4 entails 4 = x + y • M(a) is the set of all models of a M(b) is the set of all models of b • Knowledge base KB entails sentence a • KB |= a iff a is true in all models where KB is true • M(KB) is the set of all models of KB M(a) is the set of all models of a Introduction to Artificial Intelligence - APSU
Entailment in the wumpus world • Situation after detecting nothing in [1, 1], moving right, breeze in [2, 1] • Consider possible models for ?s assuming only pits • 3 Boolean choices 8 possible models Introduction to Artificial Intelligence - APSU
Wumpus models Introduction to Artificial Intelligence - APSU
Wumpus models (cont’d) • KB = wumpus-world rules + observations Introduction to Artificial Intelligence - APSU
Wumpus models (cont’d) • a1 = “There is no pit in [1, 2].” KB |= a1 proved by model checking • enumerates all possible models to check that a1 is true in all models in which KB is true Introduction to Artificial Intelligence - APSU
Wumpus models (cont’d) • a2 = “There is no pit in [2, 2].” KB a2 Introduction to Artificial Intelligence - APSU
Inference • Inference is to derive conclusions from KB i.e., an inference algorithm derives only entailed sentences i.e., an inference algorithm can derive any sentence that is entailed Introduction to Artificial Intelligence - APSU
Propositional logic: Syntax Introduction to Artificial Intelligence - APSU
Propositional logic: Semantics • The semantics defines the rules for determining the truth of a sentence w.r.t. a particular model • Each model specifies true/false for each propositional symbol • 8 possible models can be enumerated automatically with these symbols • Rules for evaluating truth w.r.t. a model m: Note means “If P is true, then I am claiming that Q is true. Otherwise I am making no claim.” • simple recursive process evaluates an arbitrary sentence, e.g., Introduction to Artificial Intelligence - APSU
Wumpus world sentences Wumpus world rules R1: R2: R3: The sentences from the breeze percepts for the first two squares visited R4: R5: Introduction to Artificial Intelligence - APSU
Truth tables for inference KB: Note KB is true in three models Does KB entails the following sentences? Introduction to Artificial Intelligence - APSU
Inference by enumeration Introduction to Artificial Intelligence - APSU
Logical equivalence Introduction to Artificial Intelligence - APSU
Validity and satisfiability Introduction to Artificial Intelligence - APSU
Proof methods Introduction to Artificial Intelligence - APSU
Inference Rules • Modus Ponens • And-Elimination • All of the logical equivalences • Example on P212 • Monotonicity: the set of entailed sentences can only increase as information is added to the knowledge base • inference rules can be applied whenever suitable premises are found in the knowledge base – the conclusion of rule must follow regardless of what else is in the knowledge base. Introduction to Artificial Intelligence - APSU
Resolution Introduction to Artificial Intelligence - APSU
Conversion to CNF Introduction to Artificial Intelligence - APSU
Resolution algorithm Introduction to Artificial Intelligence - APSU
Resolution example Introduction to Artificial Intelligence - APSU
Forward and backward chaining A disjunction of literals of which at most one is positive. written as an implication Introduction to Artificial Intelligence - APSU
Forward chaining • Idea: Fire any rule whose premises are satisfied in the KB, add its conclusion to the KB, until query is found Data-driven reasoning Introduction to Artificial Intelligence - APSU
Forward chaining algorithm Introduction to Artificial Intelligence - APSU
Forward chaining example Introduction to Artificial Intelligence - APSU
Forward chaining example Introduction to Artificial Intelligence - APSU
Forward chaining example Introduction to Artificial Intelligence - APSU
Backward chaining • Idea: Work backwards from the query q: to prove q by BC, 1) check if q is known already, or 2) prove by BC all premises of some rule concluding q 3) until reaches a set of known facts Goal-driven reasoning Introduction to Artificial Intelligence - APSU
Backward chaining example Introduction to Artificial Intelligence - APSU
Backward chaining example Introduction to Artificial Intelligence - APSU
Backward chaining example Introduction to Artificial Intelligence - APSU
Backward chaining example Introduction to Artificial Intelligence - APSU
Forward vs. backward chaining • FC is data-driven: automatic, unconscious processing, e.g., object recognition, routine decisions May do lots of work that is irrelevant to the goal • BC is goal-driven: appropriate for problem-solving, e.g., Where are my keys? How do I get into a graduate program Complexity of BC can be much less than linear in size of KB Introduction to Artificial Intelligence - APSU
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 wrt models • entailment: necessary truth of one sentence given another • inference: deriving sentences from other sentences • soundness: derivations produce only entailed sentences • completeness: derivations can produce all entailed sentences • Wumpus world requires the ability to represent partial and negated information, reason by cases, etc. • Forward, backwardchaining are linear-time, complete for Horn clauses • Resolution is complete for propositional logic • Propositional logic lacks expressive power Introduction to Artificial Intelligence - APSU