1 Intro to AI Logical Agents. 2 Intro to AI Outline Logic Efficient satisfiability testing by backtracking search Efficient satisfiability testing by.

Slides:



Advertisements
Similar presentations
Russell and Norvig Chapter 7
Advertisements

Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Agents That Reason Logically Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 7 Spring 2004.
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
Logic.
Artificial Intelligence Knowledge-based Agents Russell and Norvig, Ch. 6, 7.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Logic in general Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language.
1 Problem Solving CS 331 Dr M M Awais Representational Methods Formal Methods Propositional Logic Predicate Logic.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Knowledge Representation & Reasoning (Part 1) Propositional Logic chapter 6 Dr Souham Meshoul CAP492.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Logical Agents Chapter 7.
Methods of Proof Chapter 7, second half.
INTRODUÇÃO AOS SISTEMAS INTELIGENTES Prof. Dr. Celso A.A. Kaestner PPGEE-CP / UTFPR Agosto de 2011.
Knoweldge Representation & Reasoning
Knowledge Representation & Reasoning (Part 1) Propositional Logic chapter 5 Dr Souham Meshoul CAP492.
Logical Agents Chapter 7 Feb 26, Knowledge and Reasoning Knowledge of action outcome enables problem solving –a reflex agent can only find way from.
Logical Agents Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 7 Spring 2008.
Rutgers CS440, Fall 2003 Propositional Logic Reading: Ch. 7, AIMA 2 nd Ed. (skip )
Logical Agents Chapter 7 (based on slides from Stuart Russell and Hwee Tou Ng)
Logical Agents. Knowledge bases Knowledge base = set of sentences in a formal language Declarative approach to building an agent (or other system): 
Logical Agents (NUS) Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 19, 2012.
Propositional Logic: Logical Agents (Part I) This lecture topic: Propositional Logic (two lectures) Chapter (this lecture, Part I) Chapter 7.5.
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
1 Problems in AI Problem Formulation Uninformed Search Heuristic Search Adversarial Search (Multi-agents) Knowledge RepresentationKnowledge Representation.
1 CMSC 471 Fall 2002 Class #10/12–Wednesday, October 2 / Wednesday, October 9.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
S P Vimal, Department of CSIS, BITS, Pilani
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 17, 2012.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
1 Logical Agents Chapter 7. 2 A simple knowledge-based agent The agent must be able to: –Represent states, actions, etc. –Incorporate new percepts –Update.
Knowledge Representation Lecture # 17, 18 & 19. Motivation (1) Up to now, we concentrated on search methods in worlds that can be relatively easily represented.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start  Breeze.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Dr. Shazzad Hosain Department of EECS North South Universtiy Lecture 04 – Part B Propositional Logic.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Computing & Information Sciences Kansas State University Wednesday, 13 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 10 of 42 Wednesday, 13 September.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Logical Agents Russell & Norvig Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean)
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7 Part I. 2 Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Artificial Intelligence Logical Agents Chapter 7.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents. Inference : Example 1 How many variables? 3 variables A,B,C How many models? 2 3 = 8 models.
LOGICAL AGENTS CHAPTER 7 AIMA 3. OUTLINE  Knowledge-based agents  Wumpus world  Logic in general - models and entailment  Propositional (Boolean)
CS666 AI P. T. Chung Logic Logical Agents Chapter 7.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Propositional Logic: Logical Agents (Part I)
EA C461 – Artificial Intelligence Logical Agent
Logical Agents Chapter 7.
Logical Agents Chapter 7 Selected and slightly modified slides from
Logical Agents Reading: Russell’s Chapter 7
Logical Agents Chapter 7.
Artificial Intelligence
Knowledge and reasoning – second part
Logical Agents Chapter 7.
Knowledge Representation I (Propositional Logic)
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
Problems in AI Problem Formulation Uninformed Search Heuristic Search
Logical Agents Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

1 Intro to AI Logical Agents

2 Intro to AI Outline Logic Efficient satisfiability testing by backtracking search Efficient satisfiability testing by local search Applications

3 Intro to AI 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

4 Intro to AI Knowledge bases Knowledge base = set of sentences in a formal language Declarative approach to building an agent (or other system) : –TELL it what it needs to know Then is can ASK itself what to do - answers should follow from the KB Agents can be viewed at the knowledge level –i.e., what they know, regardless of how implemented Or at the implementation level –I.e., data structures in KB and algorithms that manipulate them

5 Intro to AI Wumpus World PEAS description Performance measure –gold +1000, death –1 per step, -10 for using the arrow Environment –Squares adjacent to wumpus are smelly –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 Sensors Breeze, Glitter, Smell Actuators Left turn, Right turn, Forward, Grab, Release, Shoot

6 Intro to AI Exploring a wumpus world

7 Intro to AI Exploring a wumpus world

8 Intro to AI Exploring a wumpus world

9 Intro to AI Exploring a wumpus world

10 Intro to AI Exploring a wumpus world

11 Intro to AI Exploring a wumpus world

12 Intro to AI Exploring a wumpus world

13 Intro to AI Exploring a wumpus world

14 Intro to AI 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; x2 + 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

15 Intro to AI Entailment Entailment means that one thing follows from another –KB ⊨ α Knowledge base KB entails sentence α if and only if α is true in all worlds where KB is true E.g., the KB containing “the Giants won” and “the Reds won” entails “Either the Giants won or the Reds won” E.g., x + y = 4 entails 4 = x + y Entailment is a relationship between sentences (i.e., syntax) that is based on semantics Note : brains process syntax (of some sort)

16 Intro to AI 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 α is true in m M ( α ) is the set of all models of α Then KB ⊨ α if and only if M(KB) ⊆ M(α) E.g. KB = Giants won and Reds won α = Giants won

17 Intro to AI 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

18 Intro to AI Wumpus models

19 Intro to AI Wumpus models KB = wumpus-world rules + observations

20 Intro to AI Wumpus models KB = wumpus-world rules + observations α 1 = “[1,2] is safe”, KB ⊨ α 1 proved by model checking

21 Intro to AI Wumpus models KB = wumpus-world rules + observations α 2 = “[2,2] is safe”, KB ⊭ α 2

22 Intro to AI Inference by enumeration Depth first enumeration of all models is sound and complete O(2 n ) for n symbols; problem is co-NP-complete Don’t sweat the details: later we will see a much more efficient way of searching through model space!

23 Intro to AI Inference KB ⊢ i α = sentence α can be derived from KB by procedure i Consequences of KB are a haystack; α is a needle. Entailment = needle in haystack; inference = 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 α

24 Intro to AI The object of knowledge representation is to express knowledge in a computer-tractable form, so that agents can perform well A knowledge representation language is defined by: – its syntax, which defines all possible sequences of symbols that constitute sentences of the language. –its semantics, which determines the facts in the world to which the sentences refer.  Each sentence makes a claim about the world.  An agent is said to believe a sentence about the world. Representation, reasoning, and logic

25 Intro to AI The connection between sentences and facts Semantics maps sentences in logic to facts in the world. The property of one fact following from another is mirrored by the property of one sentence being entailed by another.

26 Intro to AI Soundness and completeness A sound inference method derives only entailed sentences Analogous to the property of completeness in search, a complete inference method can derive any sentence that is entailed

27 Intro to AI Propositional logic : Syntax Propositional logic is the simplest logic – illustrates basic ideas The proposition symbols P 1, P 2 etc are atomic sentences If S is sentence, ¬ S is a sentence (negation)  literal: atomic sentence or its 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)

28 Intro to AI Examples of PL sentences A simple language useful for showing key ideas and definitions User defines a set of propositional symbols, like P and Q. User defines the semantics of each propositional symbol: –P means “It is hot” –Q means “It is humid” –R means “It is raining” ( P  Q )  R : “If it is hot and humid, then it is raining” Q  P : “If it is humid, then it is hot” Q : “It is humid.”

29 Intro to AI A BNF grammar of sentences in propositional logic S := ; := | ; := "TRUE" | "FALSE" | "P" | "Q" | "S" ; := "(" ")" | | "NOT" ; := "AND" | "OR" | "IMPLIES" | "EQUIVALENT" ;

30 Intro to AI Some terms The meaning or semantics of a sentence determines its interpretation. Given the truth values of all symbols in a sentence, it can be “evaluated” to determine its truth value (True or False). A model for a KB is a “possible world” (assignment of truth values to propositional symbols) in which each sentence in the KB is True.

31 Intro to AI More terms A valid sentence or tautology is a sentence that is True under all interpretations, no matter what the world is actually like or what the semantics is. Example: “It’s raining or it’s not raining.” An inconsistent sentence or contradiction is a sentence that is False under all interpretations. The world is never like what it describes, as in “It’s raining and it’s not raining.” P entails Q, written P |= Q, means that whenever P is True, so is Q. In other words, all models of P are also models of Q.

32 Intro to AI Propositional logic : Semantics Each model specifies true/false for each proposition symbol E.g. P 1,2 P 2,2 P 3,1 true true false (With these symbols, 8 possible models, can be enumerated automatically.) Rules for evaluating truth with respect to a model m: ¬ S is true iff S is false S 1 ∧ S 2 is true iff S 1 is true and S 2 is true S 1 ∨ S 2 is true iff S 1 is true or S 2 is true S 1  S 2 is true iff S 1 is false or S 2 is true i.e., is false iff S 1 is true and S 2 is false S 1  S 2 is true iff S 1  S 2 is true and S 2  S 1 is true Simple recursive process evaluates an arbitrary sentence, e.g., ¬ P 1,2 ∧ (P 2,2 ∨ P 3,1 ) = true ∧ (false ∨ true) = true ∧ true = true

33 Intro to AI Truth tables for connectives PQ ¬P¬PP∧QP∧QP∨QP∨Q P  QP  Q false true false true false true false true false true false true false true

34 Intro to AI Models of complex sentences P ∨ Q P ∧ Q P  Q P  Q

35 Intro to AI Inference rules Logical inference is used to create new sentences that logically follow from a given set of predicate calculus sentences (KB). An inference rule is sound if every sentence X produced by an inference rule operating on a KB logically follows from the KB. (That is, the inference rule does not create any contradictions) An inference rule is complete if it is able to produce every expression that logically follows from (is entailed by) the KB. (Note the analogy to complete search algorithms.)

36 Intro to AI Proof methods Proof method divide into(roughly) two kinds: Application of inference rules –Legitimate (sound) generation of new sentences from old –Proof = a sequence of inference rule applications  Can use inference rules as operators in a standard search alg. –Typically require translation of sentences into a normal form Model checking –truth table enumeration (always exponential in n) –improved backtracking, e.g., Davis-Putnam-Logemann-Loveland –heuristic search in model space( sound but incomplete)  e.g., min-conflicts-like hill-climbing algorithms

37 Intro to AI Sound rules of inference Here are some examples of sound rules of inference –A rule is sound if its conclusion is true whenever the premise is true Each can be shown to be sound using a truth table RULEPREMISECONCLUSION Modus Ponens A, A  BB And Introduction A, BA  B And Elimination A  BA Double Negation  AA Unit Resolution A  B,  BA Resolution A  B,  B  CA  C

38 Intro to AI Soundness of modus ponens ABA → BOK? True  False  True  False True 

39 Intro to AI Resolution is a valid inference rule producing a new clause implied by two clauses containing complementary literals –A literal is an atomic symbol or its negation, i.e., P, ~ P Amazingly, this is the only interference rule you need to build a sound and complete theorem prover –Based on proof by contradiction and usually called resolution refutation The resolution rule was discovered by Alan Robinson (CS, U. of Syracuse) in the mid 60s Resolution

40 Intro to AI Resolution A KB is actually a set of sentences all of which are true, i.e., a conjunction of sentences. To use resolution, put KB into conjunctive normal form (CNF), where each sentence written as a disjunction of (one or more) literals Example KB: [ P  Q, Q  R  S ] KB in CNF: [~ P  Q, ~ Q  R, ~ Q  S ] Resolve KB(1) and KB(2) producing: ~ P  R (i.e., P  R ) Resolve KB(1) and KB(3) producing: ~ P  S (i.e., P  S ) New KB: [~ P  Q, ~ Q  ~ R  ~ S, ~ P  R, ~ P  S ] Tautologies (A  B)↔(~A  B) (A  (B  C)) ↔(A  B)  (A  C)

41 Intro to AI Resolution Conjunctive Normal Form (CNF – universal) –conjunction of disjunctions of literals clauses –E.g., (A ∨ ¬ B) ∧ (B ∨ ¬ C ∨ ¬ D) Resolution inference rule (for CNF) : complete for propositional logic where l i and m j are complementary literals. E.g., Resolution is sound and complete for propositional logic

42 Intro to AI Conversion to CNF B 1,1  (P 1,2 ∨ P 2,1 ) 1.Eliminate , replacing α  β with (α  β) ∧ (β  α). (B 1,1  (P 1,2 ∨ P 2,1 )) ∧ ((P 1,2 ∨ P 2,1 )  B 1,1 ) 2.Eliminate , replacing α  β with ¬ α ∨ β. ( ¬ B 1,1 ∨ P 1,2 ∨ P 2,1 ) ∧ ( ¬ (P 1,2 ∨ P 2,1 ) ∨ B 1,1 ) 3.Move ¬ inwards using de Morgan’s rules and double-negation: ( ¬ B 1,1 ∨ P 1,2 ∨ P 2,1 ) ∧ (( ¬ P 1,2 ∧ ¬ P 2,1 ) ∨ B 1,1 ) 4.Apply distributivity law( ∨ over ∧ ) and flatten: ( ¬ B 1,1 ∨ P 1,2 ∨ P 2,1 ) ∧ ( ¬ P 1,2 ∨ B 1,1 ) ∧ ( ¬ P 2,1 ∨ B 1,1 )

43 Intro to AI Soundness of the resolution inference rule From the rightmost three columns of this truth table, we can see that (α  β)  (β  γ) ↔ (α  γ) is valid (i.e., always true regardless of the truth values assigned to α, β and γ)

44 Intro to AI Proving things A proof is a sequence of sentences, where each sentence is either a premise or a sentence derived from earlier sentences in the proof by one of the rules of inference. The last sentence is the theorem (also called goal or query) that we want to prove. Example for the “weather problem” given above. 1 Hu Premise “It is humid” 2 Hu  Ho Premise “If it is humid, it is hot” 3 Ho Modus Ponens(1,2) “It is hot” 4 ( Ho  Hu )  R Premise “If it’s hot & humid, it’s raining” 5 Ho  Hu And Introduction(1,3) “It is hot and humid” 6 R Modus Ponens(4,5) “It is raining”

45 Intro to AI THE CURIOUS INCIDENT OF THE DOG IN THE NIGHT A racehorse was stolen from a stable, and a bookmaker Fitzroy Simpson was accused. Sherlock Holmes found the true thief by reasoning from the following premises: 1. The horse was stolen by Fitzroy or by the trainer, John Straker. 2. The thief entered the stable the night of the theft. 3. The dog barks if a stranger enters the stable. 4. Fitzroy was a stranger. 5. The dog did not bark. Create a resolution refutation proof, using the propositions: thief_fitzroy thief_john entered_fitzroy entered_john stranger_fitzroy stranger_john barks

46 Intro to AI Some atomic propositions: S12 = There is a stench in cell (1,2) B34 = There is a breeze in cell (3,4) W22 = Wumpus is in cell (2,2) V11 = We’ve visited cell (1,1) OK11 = Cell (1,1) is safe. … Some rules: (R1)  S11   W11   W12   W21 (R2)  S21   W11   W21   W22   W31 (R3)  S12   W11   W12   W22   W13 (R4) S12  W13  W12  W22  W11 … Hunt the Wumpus domain

47 Intro to AI We can prove that the Wumpus is in (1,3) using the four rules given. See R&N section 7.5 After the third move

48 Intro to AI Apply MP with  S11 and (R1):  W11   W12   W21 Apply And-Elimination to this, yielding 3 sentences:  W11,  W12,  W21 Apply MP to  S21 and (R2), then apply And-elimination:  W11,  W22,  W21,  W31 Apply MP to S12 and (R4) to obtain: W13  W12  W22  W11 Apply Unit resolution on ( W13  W12  W22  W11 ) and  W11 : W13  W12  W22 Apply Unit Resolution with ( W13  W12  W22 ) and  W22 : W13  W12 Apply UR with ( W13  W12 ) and  W12 : W13 Proving W13

49 Intro to AI Lack of variables prevents stating more general rules –We need a set of similar rules for each cell Change of the KB over time is difficult to represent –Standard technique is to index facts with the time when they’re true –This means we have a separate KB for every time point Propositional Wumpus hunter problems

50 Intro to AI Validity and satisfiability A sentence is valid if it is true in all models, –e.g., True, A ∨¬ A, A  A, (A ∧ (A  B))  B Validity is connected to inference via the Deduction Theorem: –KB ⊨ α if and only if ( KB  α ) is valid A sentence is satisfiable if it is true in some model –e.g., A ∨ B, C A sentence is unsatisfiable if it is true in no models –e.g., A ∧¬ A Satisfiability is connected to inference via the following: –KB ⊨ α if and only if (KB ∧ ¬ α) is unsatisfiable i.e., prove α by reductio ad adsurdum

51 Intro to AI Formal Computational Complexity SAT = Prototypical NP-complete problem: –Given a Boolean formula, is there an assignment of truth values to the Boolean variables that makes it true? –As hard as any problem where an answer can be verified in polynomial time –Still NP-complete if formulas are restricted to Conjunctive Normal Form: literals (a v b v ~c) & (~a v c) & (~b v c) clauses