Knowledge and reasoning – second part

Slides:



Advertisements
Similar presentations
1 Knowledge and reasoning – second part Knowledge representation Logic and representation Propositional (Boolean) logic Normal forms Inference in propositional.
Advertisements

Russell and Norvig Chapter 7
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
Logic.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
CS 561, Sessions Knowledge and reasoning – second part Knowledge representation Logic and representation Propositional (Boolean) logic Normal forms.
1 DCP 1172 Introduction to Artificial Intelligence Lecture notes for Chap. 7 & 10 [AIMA] Chang-Sheng Chen.
CS 460, Sessions Knowledge and reasoning – second part Knowledge representation Logic and representation Propositional (Boolean) logic Normal forms.
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. 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
Logic Agents and Propositional Logic CS 271: Fall 2007 Instructor: Padhraic Smyth.
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 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): 
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,
CHAPTERS 7, 8 Oliver Schulte Logical Inference: Through Proof to Truth.
Logical Agents Logic Propositional Logic Summary
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.
Propositional Logic: Methods of Proof (Part II) This lecture topic: Propositional Logic (two lectures) Chapter (previous lecture, Part I) Chapter.
Logic Agents and Propositional Logic 부산대학교 전자전기컴퓨터공학과 인공지능연구실 김민호
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,
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 Chapter 7. 2 A simple knowledge-based agent The agent must be able to: –Represent states, actions, etc. –Incorporate new percepts –Update.
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,
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.
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)
1 UNIT-3 KNOWLEDGE REPRESENTATION. 2 Agents that reason logically(Logical agents) A Knowledge based Agent The Wumpus world environment Representation,
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Review: What is a logic? A formal language –Syntax – what expressions are legal –Semantics – what legal expressions mean –Proof system – a way of manipulating.
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.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
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.
EA C461 Artificial Intelligence
Knowledge and reasoning – second part
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.
Artificial Intelligence
Artificial Intelligence: Agents and Propositional Logic.
Knowledge and reasoning – second part
Methods of Proof Chapter 7, second half.
Propositional Logic: Methods of Proof (Part II)
Problems in AI Problem Formulation Uninformed Search Heuristic Search
Presentation transcript:

Knowledge and reasoning – second part Knowledge representation Logic and representation Propositional (Boolean) logic Normal forms Inference in propositional logic Wumpus world example SE 420

Knowledge-Based Agent Agent that uses prior or acquired knowledge to achieve its goals Can make more efficient decisions Can make informed decisions Knowledge Base (KB): contains a set of representations of facts about the Agent’s environment Each representation is called a sentence Use some knowledge representation language, to TELL it what to know e.g., (temperature 72F) ASK agent to query what to do Agent can use inference to deduce new facts from TELLed facts Knowledge Base Inference engine Domain independent algorithms Domain specific content TELL ASK SE 420

Generic knowledge-based agent TELL KB what was perceived Uses a KRL to insert new sentences, representations of facts, into KB ASK KB what to do. Uses logical reasoning to examine actions and select best. SE 420

Wumpus world example SE 420

Wumpus world characterization Deterministic? Accessible? Static? Discrete? Episodic? SE 420

Wumpus world characterization Deterministic? Yes – outcome exactly specified. Accessible? No – only local perception. Static? Yes – Wumpus and pits do not move. Discrete? Yes Episodic? (Yes) – because static. SE 420

Exploring a Wumpus world A= Agent B= Breeze S= Smell P= Pit W= Wumpus OK = Safe V = Visited G = Glitter SE 420

Exploring a Wumpus world A= Agent B= Breeze S= Smell P= Pit W= Wumpus OK = Safe V = Visited G = Glitter SE 420

Exploring a Wumpus world A= Agent B= Breeze S= Smell P= Pit W= Wumpus OK = Safe V = Visited G = Glitter SE 420

Exploring a Wumpus world A= Agent B= Breeze S= Smell P= Pit W= Wumpus OK = Safe V = Visited G = Glitter SE 420

Exploring a Wumpus world A= Agent B= Breeze S= Smell P= Pit W= Wumpus OK = Safe V = Visited G = Glitter SE 420

Exploring a Wumpus world A= Agent B= Breeze S= Smell P= Pit W= Wumpus OK = Safe V = Visited G = Glitter SE 420

Exploring a Wumpus world A= Agent B= Breeze S= Smell P= Pit W= Wumpus OK = Safe V = Visited G = Glitter SE 420

Exploring a Wumpus world A= Agent B= Breeze S= Smell P= Pit W= Wumpus OK = Safe V = Visited G = Glitter SE 420

Other tight spots SE 420

Another example solution No perception  1,2 and 2,1 OK Move to 2,1 B in 2,1  2,2 or 3,1 P? 1,1 V  no P in 1,1 Move to 1,2 (only option) SE 420

Example solution S and No S when in 2,1  1,3 or 1,2 has W 1,2 OK  1,3 W No B in 1,2  2,2 OK & 3,1 P SE 420

Logic in general SE 420

Types of logic SE 420

Physical Symbol System World The Semantic Wall Physical Symbol System World +BLOCKA+ +BLOCKB+ +BLOCKC+ P1:(IS_ON +BLOCKA+ +BLOCKB+) P2:((IS_RED +BLOCKA+) Syntax: says what is allowed on the LHS Semantics: says how what is on the LHS relates to what is on the RHS Inference: says how you can manipulate (formally, i.e., with no reference to the RHS) the symbols. [remember PSSH] Want to be able to trust the results: want whatever the inference procedure does to “respect” what’s true or what follows in the world. So this is where we’re headed; good to keep in mind as we go through all the definitions now to follow. There is a method in this madness... algebra example (put on board): but don’t use “entails” instead convey the idea > n m: is this true or false? don’t know if n=3, m=5, and > has its usual meaning, then (>n m) is false (> n m) and (> m p) entail (n p) SE 420

Truth depends on Interpretation Representation 1 World A B ON(A,B) T ON(A,B) F ON(A,B) F A ON(A,B) T B block pictures (on A B) and on(B C) entails (on A C) (again don’t say “entails) for this as well as for number example jus t did, need transitivity relationships spend time on why it matters: if build a KB want to be able to verify its answers introduce notion of “refer” “mean” idea of mapping into world; for this slide handwave about meaning of “on(a,b)” SE 420

Entailment is different than inference SE 420

Logic as a representation of the World Facts World Fact follows Refers to (Semantics) Representation: Sentences Sentence entails SE 420

Models SE 420

Inference SE 420

Basic symbols Expressions only evaluate to either “true” or “false.” P “P is true” ¬P “P is false” negation P V Q “either P is true or Q is true or both” disjunction P ^ Q “both P and Q are true” conjunction P => Q “if P is true, the Q is true” implication P  Q “P and Q are either both true or both false” equivalence SE 420

Propositional logic: syntax SE 420

Propositional logic: semantics

Truth tables Truth value: whether a statement is true or false. Truth table: complete list of truth values for a statement given all possible values of the individual atomic expressions. Example: P Q P V Q T T T T F T F T T F F F SE 420

Truth tables for basic connectives P Q ¬P ¬Q P V Q P ^ Q P=>Q PQ T T F F T T T T T F F T T F F F F T T F T F T F F F T T F F T T SE 420

Propositional logic: basic manipulation rules ¬(¬A) = A Double negation ¬(A ^ B) = (¬A) V (¬B) Negated “and” ¬(A V B) = (¬A) ^ (¬B) Negated “or” A ^ (B V C) = (A ^ B) V (A ^ C) Distributivity of ^ on V A => B = (¬A) V B by definition ¬(A => B) = A ^ (¬B) using negated or A  B = (A => B) ^ (B => A) by definition ¬(A  B) = (A ^ (¬B))V(B ^ (¬A)) using negated and & or … SE 420

Propositional inference: enumeration method SE 420

Enumeration: Solution SE 420

Propositional inference: normal forms “product of sums of simple variables or negated simple variables” “sum of products of simple variables or negated simple variables” SE 420

Deriving expressions from functions Given a boolean function in truth table form, find a propositional logic expression for it that uses only V, ^ and ¬. Idea: We can easily do it by disjoining the “T” rows of the truth table. Example: XOR function P Q RESULT T T F T F T P ^ (¬Q) F T T (¬P) ^ Q F F F RESULT = (P ^ (¬Q)) V ((¬P) ^ Q) SE 420

A more formal approach To construct a logical expression in disjunctive normal form from a truth table: Build a “minterm” for each row of the table, where: - For each variable whose value is T in that row, include the variable in the minterm - For each variable whose value is F in that row, include the negation of the variable in the minterm - Link variables in minterm by conjunctions The expression consists of the disjunction of all minterms. SE 420

Example: adder with carry Takes 3 variables in: x, y and ci (carry-in); yields 2 results: sum (s) and carry-out (co). To get you used to other notations, here we assume T = 1, F = 0, V = OR, ^ = AND, ¬ = NOT. co is: s is: SE 420

Tautologies Logical expressions that are always true. Can be simplified out. Examples: T T V A A V (¬A) ¬(A ^ (¬A)) A  A ((P V Q)  P) V (¬P ^ Q) (P  Q) => (P => Q) SE 420

Validity and satisfiability Theorem SE 420

Proof methods SE 420

Inference Rules SE 420

Inference Rules SE 420

li  …  li-1  li+1  …  lk  m1  …  mj-1  mj+1 ...  mn Resolution Conjunctive Normal Form (CNF) conjunction of disjunctions of literals clauses E.g., (A  B)  (B  C  D) Resolution inference rule (for CNF): li …  lk, m1  …  mn li  …  li-1  li+1  …  lk  m1  …  mj-1  mj+1 ...  mn where li and mj are complementary literals. E.g., P1,3  P2,2, P2,2 P1,3 Resolution is sound and complete for propositional logic

Conversion to CNF B1,1  (P1,2  P2,1) 1) Eliminate , replacing α  β with (α  β)(β  α). (B1,1  (P1,2  P2,1))  ((P1,2  P2,1)  B1,1) 2) Eliminate , replacing α  β with α β. (B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1) Move  inwards using de Morgan's rules and double-negation: (B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1) 4) Apply distributivity law ( over ) and flatten: (B1,1  P1,2  P2,1)  (P1,2  B1,1)  (P2,1  B1,1)

Resolution algorithm Proof by contradiction, i.e., show KBα unsatisfiable

Resolution example KB = (B1,1  (P1,2 P2,1))  B1,1 α = P1,2

Forward and backward chaining Horn Form (restricted) KB = conjunction of Horn clauses Horn clause = proposition symbol; or (conjunction of symbols)  symbol E.g., C  (B  A)  (C  D  B) Modus Ponens (for Horn Form): complete for Horn KBs α1, … ,αn α1  …  αn  β β Can be used with forward chaining or backward chaining. These algorithms are very natural and run in linear time

Idea: fire any rule whose premises are satisfied in the KB, Forward chaining Idea: fire any rule whose premises are satisfied in the KB, add its conclusion to the KB, until query is found

Forward chaining algorithm Forward chaining is sound and complete for Horn KB

Forward chaining example

Forward chaining example

Forward chaining example

Forward chaining example

Forward chaining example

Forward chaining example

Forward chaining example

Forward chaining example

FC derives every atomic sentence that is entailed by KB Proof of completeness FC derives every atomic sentence that is entailed by KB FC reaches a fixed point where no new atomic sentences are derived Consider the final state as a model m, assigning true/false to symbols Every clause in the original KB is true in m a1  …  ak  b Hence m is a model of KB If KB╞ q, q is true in every model of KB, including m

to prove q by BC, Backward chaining check if q is known already, or prove by BC all premises of some rule concluding q Avoid loops: check if new subgoal is already on the goal stack Avoid repeated work: check if new subgoal has already been proved true, or has already failed

Backward chaining example

Backward chaining example

Backward chaining example

Backward chaining example

Backward chaining example

Backward chaining example

Backward chaining example

Backward chaining example

Backward chaining example

Backward chaining example

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 PhD program? Complexity of BC can be much less than linear in size of KB

Efficient propositional inference Two families of efficient algorithms for propositional inference: Complete backtracking search algorithms DPLL algorithm (Davis, Putnam, Logemann, Loveland) Incomplete local search algorithms WalkSAT algorithm

The DPLL algorithm Determine if an propositional logic sentence (in CNF) is satisfiable. Improvements over truth table enumeration: Early termination A clause is true if any literal is true. A sentence is false if any clause is false. Pure symbol heuristic Pure symbol: always appears with the same "sign" in all clauses. e.g., In the three clauses (A  B), (B  C), (C  A), A and B are pure, C is impure. Make a pure symbol literal true. Unit clause heuristic Unit clause: only one literal in the clause The only literal in a unit clause must be true.

The DPLL algorithm

The WalkSAT algorithm Incomplete, local search algorithm Evaluation function: The min-conflict heuristic of minimizing the number of unsatisfied clauses Balance between greediness and randomness

The WalkSAT algorithm

Inference-based agents in the wumpus world A wumpus-world agent using propositional logic: P1,1 W1,1 Bx,y  (Px,y+1  Px,y-1  Px+1,y  Px-1,y) Sx,y  (Wx,y+1  Wx,y-1  Wx+1,y  Wx-1,y) W1,1  W1,2  …  W4,4 W1,1  W1,2 W1,1  W1,3 …  64 distinct proposition symbols, 155 sentences

Facts: Percepts inject (TELL) facts into the KB Wumpus world: example Facts: Percepts inject (TELL) facts into the KB [stench at 1,1 and 2,1]  S1,1 ; S2,1 Rules: if square has no stench then neither the square or adjacent square contain the wumpus R1: !S1,1 !W1,1  !W1,2  !W2,1 R2: !S2,1 !W1,1 !W2,1  !W2,2  !W3,1 … Inference: KB contains !S1,1 then using Modus Ponens we infer !W1,1  !W1,2  !W2,1 Using And-Elimination we get: !W1,1 !W1,2 !W2,1 SE 420

Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has to be represented for each situation: e.g., “don’t go forward if the wumpus is in front of you” takes 64 rules 2. It cannot keep track of changes: If one needs to track changes, e.g., where the agent has been before then we need a timed-version of each rule. To track 100 steps we’ll then need 6400 rules for the previous example. Its hard to write and maintain such a huge rule-base Inference becomes intractable SE 420

Summary SE 420