Logical Agents Chapter 7 Part I. 2 Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic.

Slides:



Advertisements
Similar presentations
Russell and Norvig Chapter 7
Advertisements

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.
INTRODUÇÃO AOS SISTEMAS INTELIGENTES Prof. Dr. Celso A.A. Kaestner PPGEE-CP / UTFPR Agosto de 2011.
Logical Agents Chapter 7 Feb 26, Knowledge and Reasoning Knowledge of action outcome enables problem solving –a reflex agent can only find way from.
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 Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7.
Logical Agents. Knowledge bases Knowledge base = set of sentences in a formal language Declarative approach to building an agent (or other system): 
Artificial Intelligence Lecture No. 9 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
February 20, 2006AI: Chapter 7: Logical Agents1 Artificial Intelligence Chapter 7: Logical Agents Michael Scherger Department of Computer Science Kent.
Logical Agents (NUS) Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Propositional Logic: Logical Agents (Part I) This lecture topic: Propositional Logic (two lectures) Chapter (this lecture, Part I) Chapter 7.5.
‘In which we introduce a logic that is sufficent for building knowledge- based agents!’
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.
Class Project Due at end of finals week Essentially anything you want, so long as its AI related and I approve Any programming language you want In pairs.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
S P Vimal, Department of CSIS, BITS, Pilani
Logical Agents 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 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 Logical Inference Algorithms CS 171/271 (Chapter 7, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material.
1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start  Breeze.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
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.
1 Logical Agents Chapter 7. 2 Logical Agents What are we talking about, “logical?” –Aren’t search-based chess programs logical Yes, but knowledge is used.
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,
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
1 Knowledge Representation Logic and Inference Propositional Logic Vumpus World Knowledge Representation Logic and Inference Propositional Logic Vumpus.
1 Intro to AI Logical Agents. 2 Intro to AI Outline Logic Efficient satisfiability testing by backtracking search Efficient satisfiability testing by.
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.
EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS
Logical Agents Chapter 7 Selected and slightly modified slides from
Logical Agents Reading: Russell’s Chapter 7
Logical Agents Chapter 7.
Artificial Intelligence
Artificial Intelligence: Logic agents
Logical Agents Chapter 7.
Knowledge Representation I (Propositional Logic)
Problems in AI Problem Formulation Uninformed Search Heuristic Search
Logical Agents Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

Logical Agents Chapter 7 Part I

2 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

3 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 it 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

4 A simple knowledge-based agent 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 function KB-Agent(percept) returns an action static:KB, a knowledge base t, a counter, initially 0, indicating time Tell(KB, Make-Percept-Sentence(percept, t)) action←Ask(KB, Make-Action-Query(t)) Tell(KB, Make-Action-Sentence(action, t)) t←t + 1 return action

5 Wumpus World PEAS description Performance measure –gold +1000, death –-1 per step, -10 for using the arrow Environment –4X4 grid of rooms –Start from (1,1), facing to the right –Locations of gold and wumpus are chosen randomly –Squares other than the start square can be a pit with probability 0.2

6 Wumpus World PEAS description Sensors –Perceive a stench if adjacent to wumpus –Perceive a breeze if adjacent to a pit –Perceive a glitter iff in the same square where the gold is –Perceive a bump if walk into a wall –Perceive a scream when wumpus is killed Actuators –Turn Left; turn right; forward –Shoot kills wumpus if you are facing it, using up the only arrow –Grab picks up gold if in same square –Release drops the gold in same square  Die if enter a square with a live wumpus or a pit

7 Wumpus world characterization Fully 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

8 Exploring a wumpus world

9

10 Exploring a wumpus world

11 Exploring a wumpus world

12 Exploring a wumpus world

13 Exploring a wumpus world

14 Exploring a wumpus world

15 Exploring a wumpus world

16 Some tight spots Breeze in (1,2) and (2,1)  not safe Assume not many pits –Either pits in (3,1) and (1,3) –Or a pit in (2,2) –P(pit(3,1), pit(1,3)) : P(pit(2,2)) = 1:4  guess a pit in (2,2) Stench in (1,1)  not safe Shoot ahead! –Perceive a scream  wumpus was there  safe –No scream  wumpus was not there  safe

17 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

18 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

19 Logicians typically think in terms of models, which are formally structured worlds with respect to which truth can be evaluated Model: a truth assignment to all symbols We say m is a model of a sentence  if  is true in m M(  ) is the set of all models of  Then KB ⊨  iff M(KB)  M(  ) –E.g.KB = Giants won and Reds won  = Giants won  Models

20 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

21 Wumpus models

22 Wumpus models KB = wumpus-world rules + observations

23 Wumpus models  1 = "[1,2] is safe", KB ⊨  1, proved by model checking

24 Wumpus models  2 = "[2,2] is safe", KB ⊭  2

25 Inference KB ⊢ i  : sentence  can be derived from KB by procedure i 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  Preview: we will define a logic (first-order logic) which is expressive enough to say almost anything of interest, and for which there exists a sound and complete inference procedure.

26 Propositional logic: Syntax Propositional logic is the simplest logic – illustrates basic ideas The proposition symbols P 1, P 2 etc are sentences –If S is a sentence,  S is a sentence (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)

27 Propositional logic: Semantics Each model specifies true/false for each proposition symbol E.g. P 1,2 P 2,2 P 3,1 false true false (With these symbols, 8 possible models, can be enumerated automatically.) Rules for evaluating truth with respect to a model m:  Sis 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 iffS 1 is false orS 2 is true i.e., is false iffS 1 is true andS 2 is false S 1  S 2 is true iff S 1  S 2 is true and S 2  S 1 is true

28 Truth tables for connectives

29 Wumpus world sentences Let P i,j be true if there is a pit in [i, j]. Let B i,j be true if there is a breeze in [i, j].  P 1,1  B 1,1 B 2,1 "Pits cause breezes in adjacent squares" B 1,1  (P 1,2  P 2,1 ) B 2,1  (P 1,1  P 2,2  P 3,1 )

30 Truth tables for inference Enumerate all truth assignments. If KB is true, check that  is, too.

31 Inference by enumeration Depth-first enumeration of all models is sound and complete For n symbols, time complexity is O(2 n ), space complexity is O(n) function TT-Entails?(KB,  ) returns true or false inputs:KB, the knowledge base, a sentence in propositional logic , the query, a sentence in propositional logic symbols ← a list of the proposition symbols in KB and  return TT-Check-All(KB, , symbols, [ ]) function TT-Check-All(KB, , symbols, model) returns true or false if Empty?(symbols) then if PL-True?(KB, model) then return PL-True?( , model) else return true else do P ← First(symbols); rest ← Rest(symbols) returnTT-Check-All(KB, , rest, Extend(P, true, model)) and TT-Check-All(KB, , rest, Extend(P, false, model))

32 Logical equivalence Two sentences are logically equivalent iff true in same models:  ≡  iff  ⊨  and  ⊨ 

33 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 If A is valid, then  A is unsatisfiable.

34 Proof methods Proof methods 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 algorithm Typically require transformation of sentences into a normal form –Model checking truth table enumeration (always exponential in n) improved backtracking, e.g., Davis-Putnam-Logemann- Loveland (DPLL) heuristic search in model space (sound but incomplete) e.g., min-conflicts-like hill-climbing algorithms

35 Inference Rules Modus Ponens   ,   And-Elimination  1   2  …   n  i And-Introduction  1,  2, …,  n  1   2  …   n

36 Inference Rules Or-Introduction  i  1   2  …   i  …   n Double-Negation Elimination   Resolution

37 Resolution Conjunctive Normal Form (CNF) conjunction of disjunctions of literals E.g., (A   B)  (B   C   D) Resolution inference rule (for a clause in a CNF): l i  …  l k, m 1  …  m n l i  …  l i-1  l i+1  …  l k  m 1  …  m j-1  m j+1 ...  m n where l i =  m j. E.g., P 1,3  P 2,2,  P 2,2 P 1,3 Resolution is sound and complete for propositional logic

38 Resolution Soundness of resolution inference rule: (recall that l i =  m j )  ( l i  …  l i-1  l i+1  …  l k )  l i  m j  ( m 1  …  m j-1  m j+1 ...  m n )  ( l i  …  l i-1  l i+1  …  l k )  ( m 1  …  m j-1  m j+1 ...  m n )

39 Conversion to CNF E.g. 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 )