Logical Inference. Artificial Intelligence. Topic 12. Reading: Russell and Norvig, Chapter 7, Section 5

Similar documents
CS 380: ARTIFICIAL INTELLIGENCE

CS 380: ARTIFICIAL INTELLIGENCE PREDICATE LOGICS. Santiago Ontañón

Logical agents. Chapter 7. Chapter 7 1

7. Logical Agents. COMP9414/ 9814/ 3411: Artificial Intelligence. Outline. Knowledge base. Models and Planning. Russell & Norvig, Chapter 7.

Intelligent Agents. Pınar Yolum Utrecht University

CS:4420 Artificial Intelligence

Logical agents. Chapter 7. Chapter 7 1

TDT4136 Logic and Reasoning Systems

Artificial Intelligence

Logical Agents. Chapter 7

Artificial Intelligence

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Proof Methods for Propositional Logic

Revised by Hankui Zhuo, March 21, Logical agents. Chapter 7. Chapter 7 1

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Propositional Logic: Methods of Proof (Part II)

The Wumpus Game. Stench Gold. Start. Cao Hoang Tru CSE Faculty - HCMUT

Logical Agents. Outline

Last update: March 4, Logical agents. CMSC 421: Chapter 7. CMSC 421: Chapter 7 1

Propositional Logic: Methods of Proof (Part II)

Logical Agents: Propositional Logic. Chapter 7

Propositional Logic: Methods of Proof. Chapter 7, Part II

Propositional inference, propositional agents

Inference Methods In Propositional Logic

Lecture 6: Knowledge 1

Artificial Intelligence Chapter 7: Logical Agents

Inference Methods In Propositional Logic

CS 771 Artificial Intelligence. Propositional Logic

Deliberative Agents Knowledge Representation I. Deliberative Agents

Title: Logical Agents AIMA: Chapter 7 (Sections 7.4 and 7.5)

A simple knowledge-based agent. Logical agents. Outline. Wumpus World PEAS description. Wumpus world characterization. Knowledge bases.

Introduction to Artificial Intelligence. Logical Agents

Logical Agents. Outline

Class Assignment Strategies

Logical Agents. Chapter 7

Propositional Logic: Methods of Proof (Part II)

Lecture 7: Logical Agents and Propositional Logic

Logical Agent & Propositional Logic

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

Logical Agent & Propositional Logic

Chương 3 Tri th ức và lập luận

Logical Agents (I) Instructor: Tsung-Che Chiang

Logic. Introduction to Artificial Intelligence CS/ECE 348 Lecture 11 September 27, 2001

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

Kecerdasan Buatan M. Ali Fauzi

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Price: $25 (incl. T-Shirt, morning tea and lunch) Visit:

Outline. Logic. Knowledge bases. Wumpus world characteriza/on. Wumpus World PEAS descrip/on. A simple knowledge- based agent

Logic and Inferences

Adversarial Search & Logic and Reasoning

Inference in Propositional Logic

Artificial Intelligence. Propositional logic

Logical Agents. Course material: Artificial Intelligence: A Modern Approach, 3 rd Edition, Chapter 7

Inf2D 06: Logical Agents: Knowledge Bases and the Wumpus World

Advanced Topics in LP and FP

CS 7180: Behavioral Modeling and Decision- making in AI

CSC242: Intro to AI. Lecture 11. Tuesday, February 26, 13

Logical Agents. Soleymani. Artificial Intelligence: A Modern Approach, 3 rd Edition, Chapter 7

Logic. proof and truth syntacs and semantics. Peter Antal

7 LOGICAL AGENTS. OHJ-2556 Artificial Intelligence, Spring OHJ-2556 Artificial Intelligence, Spring

COMP3702/7702 Artificial Intelligence Week 5: Search in Continuous Space with an Application in Motion Planning " Hanna Kurniawati"

CS 188: Artificial Intelligence Spring 2007

Agenda. Artificial Intelligence. Reasoning in the Wumpus World. The Wumpus World

Propositional Logic: Logical Agents (Part I)

Propositional logic II.

Logical Agents. Santa Clara University

CS 2710 Foundations of AI Lecture 12. Propositional logic. Logical inference problem

INF5390 Kunstig intelligens. Logical Agents. Roar Fjellheim

Logical Agents. Soleymani. Artificial Intelligence: A Modern Approach, 3 rd Edition, Chapter 7

Description Logics. Foundations of Propositional Logic. franconi. Enrico Franconi

Logic: Propositional Logic (Part I)

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Logical Agents. Knowledge based agents. Knowledge based agents. Knowledge based agents. The Wumpus World. Knowledge Bases 10/20/14

CSCI 5582 Artificial Intelligence. Today 9/28. Knowledge Representation. Lecture 9

Logic in AI Chapter 7. Mausam (Based on slides of Dan Weld, Stuart Russell, Subbarao Kambhampati, Dieter Fox, Henry Kautz )

Foundations of Artificial Intelligence

Knowledge based Agents

22c:145 Artificial Intelligence

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

AI Programming CS S-09 Knowledge Representation

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Deductive Systems. Lecture - 3

Overview. Knowledge-Based Agents. Introduction. COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Introduction to Intelligent Systems

Introduction to Intelligent Systems

Logic in AI Chapter 7. Mausam (Based on slides of Dan Weld, Stuart Russell, Dieter Fox, Henry Kautz )

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Lecture 7: Logic and Planning

Propositional Logic: Logical Agents (Part I)

Logical Inference 2 rule based reasoning

Part 1: Propositional Logic

Language of Propositional Logic

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Propositional Logic: Review

Inf2D 13: Resolution-Based Inference

Propositional Resolution

Propositional Reasoning

Transcription:

rtificial Intelligence Topic 12 Logical Inference Reading: Russell and Norvig, Chapter 7, Section 5 c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 41

Outline Inference systems Soundness and Completeness Proof methods normal forms forward chaining backward chaining resolution c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 42

From Entailment to Inference We have answered what it means to say α follows from from a knowledge base KB: KB = α We have seen that this can be determined semantically by model checking or by truth table enumeration 2 n models or rows for n symbols Is there a better way? can we do it from syntax alone? can we automate it? can we even turn it into a programming language? c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 43

Inference Systems Inference system - set of rules for deriving new sentences from existing ones K Proof System, Derivation System, Theorem-Proving System rules operate directly on syntax Example: P 1 = Socrates is a man P 2 = Socrates is mortal P 1 P 2 (If Socrates is a man, then Socrates is mortal) ssume KB = {P 1, P 1 P 2 }. We know KB = P 2. (check) What about inference rules? c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 44

Inference Systems Modus Ponens α α β β pattern matching from sentences that match α and α β, generate a new sentence that matches β More examples... nd Elimination α β α Or Introduction α? c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 45

Inference Systems Modus Tolens β α β α n inference system may contain one or more inference rules. Notation: KB α = sentence α can be derived from KB using the rules of the inference system c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 46

Soundness and Completeness In fact we could make up any inference rule we like. How about: nd Introduction α α β? Why wouldn t we want this rule in our inference system? c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 47

Soundness and Completeness We only want rules that correspond to logical consequences. Formally... Soundness: an inference system is sound if whenever KB α, it is also true that KB = α That is, it only allows you to generate logical consequences. Completeness: an inference system is complete if whenever KB = α, it is also true that KB α That is, it allows you to generate all logical consequences. (Which do you think is worse, sound but not complete, or complete but not sound?) Ideally we would like to use an inference system that is both sound and complete. c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 48

Review of Progress Recall our logical agent: Inference engine domain independent algorithms Knowledge base domain specific content Knowledge base = set of sentences in a formal language Tell it what it needs to know (KB KB {α}) sk answers should follow from the KB? (KB α) sound and complete inference system means that if α follows from KB then there is a sequence of rule applications that allow you to generate α starting with KB but it doesn t tell you how to get there! c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 49

Proof Methods Consequences of KB are a haystack; α is a needle. Entailment = needle in haystack; inference = finding it c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 50

Proof Methods pplication 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 Examples forward and backward chaining (Horn form) resolution (conjunctive normal form) c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 51

Horn Form Horn Form (restricted) KB = conjunction of Horn clauses Horn clause = proposition symbol or (conjunction of symbols symbol) E.g., C (B ) (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. c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 52

Forward chaining Idea: systematically iterate through knowledge base, fire any rule whose premises are satisfied in the KB, add its conclusion to the KB, until query is found Q P Q L M P B L M P L B L B L P M B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 53

Forward chaining example Q 1 L 2 P M 2 2 2 B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 54

Forward chaining example Q 1 L 2 P M 2 1 1 B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 55

Forward chaining example Q 1 L 2 P M 1 1 0 B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 56

Forward chaining example Q 1 L 1 P M 0 1 0 B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 57

Forward chaining example Q 1 L 0 P M 0 1 0 B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 58

Forward chaining example Q 0 L 0 P M 0 0 0 B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 59

Forward chaining example Q 0 L 0 P M 0 0 0 B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 60

Forward chaining example Q 0 L 0 P M 0 0 0 B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 61

Backward chaining Idea: work backwards from the query q: to prove q by BC, check if q is known already, or prove by BC all premises of some rule concluding q void loops: check if new subgoal is already on the goal stack void repeated work: check if new subgoal 1) has already been proved true, or 2) has already failed c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 62

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 63

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 64

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 65

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 66

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 67

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 68

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 69

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 70

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 71

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 72

Backward chaining example Q P M L B c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 73

Forward vs. backward chaining FC is data-driven, cf. 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 c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 74

Resolution Conjunctive Normal Form (CNF universal) conjunction of disjunctions of literals }{{} clauses E.g., ( B) (B C D) Resolution inference rule (for CNF): complete for propositional logic l 1 l k, m 1 m n l 1 l i 1 l i+1 l k m 1 m j 1 m j+1 m n where l i and m j are complementary literals. E.g., P 1,3 P 2,2, P 2,2 P 1,3 P P? B OK P? OK Resolution is sound and complete for propositional logic OK S OK W c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 75

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. pply 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 ) c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 76

Resolution algorithm Proof by contradiction Based on the fact that KB = α iff KB { α} is unsatisfiable (prove!) Unsatisfiability in CNF is indicated by the empty clause We repeatedly apply the resolution rule to α and its consequences until we derive the empty clause. Exercise: What is the complexity of the conversion to CNF? What is the complexity of the resolution algorithm? c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 77

Resolution example KB = (B 1,1 (P 1,2 P 2,1 )) B 1,1 α = P 1,2 P 2,1 B 1,1 B 1,1 P 1,2 P 2,1 P 1,2 B 1,1 B 1,1 P 1,2 B 1,1 P 1,2 B 1,1 P 1,2 P 2,1 P 1,2 B 1,1 P 2,1 B 1,1 P1,2 P 2,1 P 2,1 P 2,1 P 1,2 Resolution combined with first-order logic is the key mechanism used in logic programming (eg PROLOG). c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 78

Efficient Reasoning lgorithms The satisfiability problem for propositional logic in both infeasible (NPcomplete) and very useful (TSP, CSP, planning, etc). So if an agent is required to perform propositional reasoning, what kind of efficient mechanisms are available? We will look at two possible algorithms: The Davis-Putnam algorithm is a recursive DFS for satisfying models of a formula, aided by some heuristics; and WLKST is a randomized algorithm that performs a local search for a satisfying model. c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 79

The DPLL lgorithm (1962) DPLL is a variation fo the Davis-Putnam algorithm. It takes the input as a senetnce in CNF, and iterates through potential models using the following heuristics: Early Termination The algorithm recognizes if a clause is true (one of its literals is true) or if a sentence of false (one of its clauses is false) and therefore does not need to search redundant branches of the search tree. Pure Symbols pure symbol is a symbol that has the same sign in all (active) clauses. These symbls can be ignored. Unit Clause unit clause is a clause with just one (active) literal. unit clause dictates the value of that literal in all the other clauses. c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 80

function DPLL-Satisfiable?(s) returns true or false inputs: s, a sentence in propositional logic clauses the set of clauses in the CNF representation of s symbols a list of the proposition symbols in s return DPLL(clauses, symbols, [ ]) function DPLL(clauses, symbols, model) returns true or false if every clause in clauses is true in model then return true if some clause in clauses is false in model then return false P, value Find-Pure-Symbol(symbols, clauses, model) if P is non-null then return DPLL(clauses, symbols P, [P = value model]) P, value Find-Unit-Clause(clauses, model) if P is non-null then return DPLL(clauses, symbols P, [P = value model]) P First(symbols); rest Rest(symbols) return DPLL(clauses, rest, [P = true model]) or DPLL(clauses, rest, [P = false model]) c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 81

The WLKST algorithm The WLKST algorithm simply performs a random walk over all models hoping to find a model that satisfies a sentence in CNF. For each step of the walk it flips the value of a symbol (proposition) and tests if the sentence becomes true. The algorithm nondeterministically chooses either a randomly selected proposition to flip, or chooses the proposition that maximizes the number of satisfied clauses. c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 82

The WLKST algorithm function WalkST(clauses, p, max-flips) returns a satisfying model or failure inputs: clauses, a set of clauses in propositional logic p, the probability of choosing to do a random walk move, typically around 0.5 max-flips, number of flips allowed before giving up model a random assignment of true/false to the symbols in clauses for i = 1 to max-flips do if model satisfies clauses then return model clause a randomly selected clause from clauses that is false in model with probability p flip the value in model of a randomly selected symbol from clause else flip whichever symbol in clause maximizes the number of satisfied clauses return failure c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 83

More Logics lthough propositional logic is computationally attractive, it lacks expressive power in practice. eg. How would you say ll men are mortal or ll squares adjacent to a pit have a breeze? There are many other logics that extend propositional logic, eg: first-order logic introduces objects, functions, relations, variables, quantifiers (for all, there exists) higher order logics allow the logic to refer to its own constructs temporal logics introduce specific structures to represent time steps modal logics introduce possibility and necessity probabilistic logics introduce the probability a statement is true fuzzy logics introduce a degree of membership to a class c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 84

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 soundess: derivations produce only entailed sentences completeness: derivations can produce all entailed sentences Forward, backward chaining are linear-time, complete for Horn clauses Resolution is complete for propositional logic Resolution is the basis of the Prolog programming language Uses first-order logic more expressive power c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical Inference Slide 85