Logic and Inferences

Similar documents
22c:145 Artificial Intelligence

CS:4420 Artificial Intelligence

Proof Methods for Propositional Logic

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Inference in Propositional Logic

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

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

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

Artificial Intelligence. Propositional logic

Intelligent Agents. Pınar Yolum Utrecht University

Knowledge based Agents

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

Deductive Systems. Lecture - 3

Logic: Propositional Logic (Part I)

Logical Agents. Outline

2. The Logic of Compound Statements Summary. Aaron Tan August 2017

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

CS 380: ARTIFICIAL INTELLIGENCE

Logical Agents. Chapter 7

Deliberative Agents Knowledge Representation I. Deliberative Agents

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/30)

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

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Language of Propositional Logic

Artificial Intelligence

Propositional logic II.

Part 1: Propositional Logic

CS156: The Calculus of Computation

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

Introduction Logic Inference. Discrete Mathematics Andrei Bulatov

Artificial Intelligence

Artificial Intelligence Chapter 7: Logical Agents

Logical agents. Chapter 7. Chapter 7 1

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Introduction to Artificial Intelligence. Logical Agents

Propositional Logic: Models and Proofs

Logical Agents. Chapter 7

TDT4136 Logic and Reasoning Systems

Kecerdasan Buatan M. Ali Fauzi

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Class Assignment Strategies

Logical Agent & Propositional Logic

Propositional Reasoning

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

Logical agents. Chapter 7. Chapter 7 1

Advanced Topics in LP and FP

Propositional Logic: Methods of Proof (Part II)

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

Propositional Logic: Part II - Syntax & Proofs 0-0

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Logical Agent & Propositional Logic

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel

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

Inference Methods In Propositional Logic

Propositional Logic: Methods of Proof (Part II)

CS 2740 Knowledge Representation. Lecture 4. Propositional logic. CS 2740 Knowledge Representation. Administration

CS 188: Artificial Intelligence Spring 2007

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

Foundations of Artificial Intelligence

6. Logical Inference

Lecture 6: Knowledge 1

The Logic of Compound Statements cont.

Propositional Logic: Review

Propositional Logic. Methods & Tools for Software Engineering (MTSE) Fall Prof. Arie Gurfinkel

The Importance of Being Formal. Martin Henz. February 5, Propositional Logic

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

Comp487/587 - Boolean Formulas

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

Inference Methods In Propositional Logic

Logical Agents (I) Instructor: Tsung-Che Chiang

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

Propositional Resolution Introduction

A brief introduction to Logic. (slides from

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

Part 1: Propositional Logic

Formal Verification Methods 1: Propositional Logic

Propositional logic (revision) & semantic entailment. p. 1/34

Propositional Logic: Methods of Proof (Part II)

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

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

Classical Propositional Logic

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Artificial Intelligence Knowledge Representation I

Inf2D 13: Resolution-Based Inference

Propositional Resolution

Tautologies, Contradictions, and Contingencies

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

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

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

15414/614 Optional Lecture 1: Propositional Logic

Decision Procedures for Satisfiability and Validity in Propositional Logic

CS156: The Calculus of Computation Zohar Manna Autumn 2008

Propositional Resolution Part 1. Short Review Professor Anita Wasilewska CSE 352 Artificial Intelligence

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

Supplementary exercises in propositional logic

Propositional Logic Language

Propositional logic. Programming and Modal Logic

Propositional Logic Resolution (6A) Young W. Lim 12/12/16

Natural Deduction. Formal Methods in Verification of Computer Systems Jeremy Johnson

Transcription:

Artificial Intelligence Logic and Inferences Readings: Chapter 7 of Russell & Norvig. Artificial Intelligence p.1/34

Components of Propositional Logic Logic constants: True (1), and False (0) Propositional variables: X = {p 1,q 2,...}, a set of Boolean variables Logical connectives: F = {,,,,,...} Logical sentences: L(X, F), expressions built from X and F Logical interpretations: a mapping θ from X to {0, 1} Logical evaluations: a process of applying a mapping θ to sentences in L(X, F) (to obtain a value in {0, 1}) Artificial Intelligence p.2/34

Propositional Variables Also called Boolean variables, 0-1 variables. Every statement can be represented by a propositional variable: p 1 = It is sunny today p 2 = Tom went to school yesterday p 3 = f(x) = 0 has two solutions p 4 = point A is on line BC p 5 = place a queen at position (1, 2) on a 8 by 8 chessboard... Artificial Intelligence p.3/34

Properties of Logical Connectives and are commutative ϕ 1 ϕ 2 ϕ 2 ϕ 1 ϕ 1 ϕ 2 ϕ 2 ϕ 1 and are associative ϕ 1 (ϕ 2 ϕ 3 ) (ϕ 1 ϕ 2 ) ϕ 3 ϕ 1 (ϕ 2 ϕ 3 ) (ϕ 1 ϕ 2 ) ϕ 3 and are mutually distributive ϕ 1 (ϕ 2 ϕ 3 ) (ϕ 1 ϕ 2 ) (ϕ 1 ϕ 3 ) ϕ 1 (ϕ 2 ϕ 3 ) (ϕ 1 ϕ 2 ) (ϕ 1 ϕ 3 ) and are related by (DeMorgan s Laws) (ϕ 1 ϕ 2 ) ϕ 1 ϕ 2 (ϕ 1 ϕ 2 ) ϕ 1 ϕ 2 Artificial Intelligence p.4/34

Properties of Logical Connectives,, and are actually redundant: ϕ 1 ϕ 2 ( ϕ 1 ϕ 2 ) ϕ 1 ϕ 2 ϕ 1 ϕ 2 ϕ 1 ϕ 2 (ϕ 1 ϕ 2 ) (ϕ 2 ϕ 1 ) We keep them all mainly for convenience. Exercise Use the truth tables to prove all the logical equivalences seen so far. Artificial Intelligence p.5/34

Negation Normal Form (NNF) A propositional sentence is said to be in Negation Normal Form if it contains no connectives other than,,, and if (α) appears in the sentence, then α must be a propositional variable. p, p q, p (q r) are NNF. p q, (p q) are not NNF. Every propositional sentence can be transformed into an equivalent NNF. ϕ 1 ϕ 2 (ϕ 1 ϕ 2 ) (ϕ 2 ϕ 1 ) ϕ 1 ϕ 2 ϕ 1 ϕ 2 (ϕ 1 ϕ 2 ) ϕ 1 ϕ 2 (ϕ ϕ ) ϕ ϕ Artificial Intelligence p.6/34

Conjunctive Normal Form (CNF) A propositional sentence φ is said to be in Conjunctive Normal Form if φ is True, False, or a conjunction of α i s: α 1 α 2 α n, where each α is a clause (a disjunction of β j s): α = (β 1 β 2 β m ), where each β is called a literal, which is either a variable or the negation of a variable: β = p or β = (p). p, p q, p (q r) are CNF. p (q r) are not CNF. Every CNF is an NNF but the opposite does not hold. Artificial Intelligence p.7/34

Existence of CNF Every propositional sentence can be transformed into an equivalent CNF. That is, from NNF, using (ϕ 1 ϕ 2 ) ϕ 3 (ϕ 1 ϕ 3 ) (ϕ 2 ϕ 3 ) Artificial Intelligence p.8/34

Example: The 8-Queen Problem Variables: q i,j, 1 i, j 8. q ij is true iff a queen is placed in the square at row i and column j. Clauses: Every row has a queen: For each 1 i 8, q i,1 q i,2 q i,3 q i,4 q i,5 q i,6 q i,7 q i,8 Two queens from the same row cannot see each other: q i,1 q i,2,... Two queens from the same column cannot see each other: q 1,j q 2,j,... Two queens on the same diagonal cannot see each other: Artificial Intelligence p.9/34

Interpretations and Models A (partial) interpretation is a mapping from variables to {0, 1}. An complete interpretation is if it maps every variables to {0, 1}. An interpretation θ can be extended to be a mapping from propositional sentences to {0, 1} if it obeys the following rules: θ( p) = 1 if and only if θ(p) = 0; if θ(p) = 1 or θ(q) = 1 then θ(p q) = 1; if θ(p) = 1 and θ(q) = 1 then θ(p q) = 1;... Computing this interpretation is called evaluation. For any propositional sentence Φ, if there exists an interpreation θ such that θ(φ) = 1, then θ is a model of Φ and Φ is said to be satisfiable. If every complete interpretation is a model for Φ, then Φ is said to be valid. Artificial Intelligence p.10/34

Validity vs. Satisfiability A sentence is satisfiable if it is true in some interpretation, valid if it is true in every possible interpretation. Reasoning Tools for Propositional Logic: A tool to prove a sentence is valid needs only to return yes or no. A tool to prove a sentence is satisfiable often returns an interpretation under which the sentence is true. A sentence φ is valid if and only if φ is unsatisfiable. Artificial Intelligence p.11/34

Inference Systems In practice, an inference system I for PL is a procedure that given a set Γ = {α 1,...,α m } of sentences and a sentence ϕ, may reply yes, no, or run forever. If I replies yes on input (Γ,ϕ), we say that Γ derives ϕ in I, Or, I derives ϕ from Γ, or, ϕ is deduced (derived) from Γ in I. and write Γ I ϕ Intuitively, I should be such that it replies yes on input (Γ,ϕ) only if ϕ is in fact deduced from Γ by I. Artificial Intelligence p.12/34

All These Fancy Symbols! A B C is a sentence (an expression built from variables and logical connectives) where is a logical connective. A B = C is a mathematical abbreviation standing for the statement: every interpretation that makes A B true, makes C also true. We say that the sentence A B entails C. A B I C is a mathematical abbreviation standing for the statement: I returns yes on input (A B,C) [C is deduced from A B in I]. Artificial Intelligence p.13/34

All These Fancy Symbols! In other words, is a formal symbol of the logic, which is used by the inference system. = is a shorthand for the entailment of formal sentences that we use to talk about the meaning of formal sentences. I is a shorthand for the inference procedure that we use to talk about the output of the inference system I. The formal symbol and the shorthands =, I are related. Artificial Intelligence p.14/34

All These Fancy Symbols! The sentence ϕ 1 ϕ 2 is valid (always true) if and only if ϕ 1 = ϕ 2. Example: A (A B) is valid and A = (A B) A B A B A (A B) 1. False False False True 2. False True True True 3. True False True True 4. True True True True Artificial Intelligence p.15/34

Soundness and Completeness An inference system I is sound if it derives only sentences that logically follow from a given set of sentences: if Γ I ϕ then Γ = ϕ. An inference system I is complete if it derives all sentences that logically follow from a given set of sentences: or equivalently, if Γ = ϕ then Γ I ϕ. if Γ I ϕ then Γ = ϕ. Artificial Intelligence p.16/34

Inference in Propositional Logic There are two (equivalent) types of inference systems of Propositional Logic: one based on truth tables (T T ) one based on derivation rules (R) Truth Tables The inference system T T is specified as follows: {α 1,...,α m } T T ϕ iff all the values in the truth table of (α 1 α m ) ϕ are True. Artificial Intelligence p.17/34

Inference by Truth Tables The truth-tables-based inference system is sound: α 1,...,α m TT ϕ implies truth table of (α 1 α m ) ϕ all true implies implies implies It is also complete (exercise: prove it). (α 1 α m ) ϕ is valid (α 1 α m ) = ϕ α 1,...,α m = ϕ Its time complexity is O(2 n ) where n is the number of propositional variables in α 1,...,α m, ϕ. We cannot hope to do better because a related, simpler problem (determining the satisfiability of a sentence) is NP-complete. However, the really hard cases of propositional inference when we need O(2 n ) time are somewhat rare. Artificial Intelligence p.18/34

Rule-Based Inference System An inference system in Propositional Logic can also be specified as a set R of inference (or derivation) rules. Each rule is actually a pattern premises/conclusion. A rule applies to Γ and derives ϕ if some of the sentences in Γ match with the premises of the rule and ϕ matches with the conclusion. A rule is sound it the set of its premises entails its conclusion. Artificial Intelligence p.19/34

Rule-Based Inference System Inference Rules And-Introduction α β α β And-Elimination α β α Or-Introduction α α β α β β α β α Artificial Intelligence p.20/34

Rule-Based Inference System Inference Rules (cont ) Implication-Elimination (aka Modus Ponens) α β β α Unit Resolution α β β Resolution α β α α γ β γ or, equivalently, α β, β γ α γ Artificial Intelligence p.21/34

Rule-Based Inference Systems Inference Rules (cont d.) Double-Negation-Elimination α α False-Introduction α α False False-Elimination False β Artificial Intelligence p.22/34

Inference by Proof We say there is a proof of ϕ from Γ in R if we can derive ϕ by applying the rules of R repeatedly to Γ and its derived sentences. Example: a proof of P from {(P H) H} 1. (P H) H by assumption 2. P H by -elimination applied to (1) 3. H by -elimination applied to (1) 4. P by unit resolution applied to (2),(3) Artificial Intelligence p.23/34

Inference by Proof We can represent a proof more visually as a proof tree: Example: (P H) H P H P (P H) H H Artificial Intelligence p.24/34

Rule-Based Inference System More formally, there is a proof of ϕ from Γ in R if 1. ϕ Γ or, 2. there is a rule in R that applies to Γ and produces ϕ or, 3. there is a proof of each ϕ 1,...,ϕ m from Γ in R and a rule that applies to {ϕ 1,...,ϕ m } and produces ϕ. Then, the inference system R is specified as follows: Γ R ϕ iff there is a proof of ϕ from Γ in R Artificial Intelligence p.25/34

Soundness of Rule-Based Inferences R is sound if all of its rules are sound. Example: the Resolution rule α β, α γ β γ α β γ β α β β γ α γ 1. False False False True False True False 2. False False True True False True True 3. False True False False True False False 4. False True True False True True True 5. True False False True True True True 6. True False True True True True True 7. True True False False True False True 8. True True True False True True True All the interpretations that make both α β and β γ true (ie, 4,5,6,8) make α γ also true. Artificial Intelligence p.26/34

The Rules of R α β α β α α β α β α α β α α β β α β α α β β α β β γ β α α γ α α α False α False β Artificial Intelligence p.27/34

One Rule Suffices! Assumptions: β β α β β is a special case of when α False α is False. α β β α β β γ is a special case of α α γ when γ is False. To prove that Γ ϕ is valid, Convert Γ (ϕ) into a set of clauses. Repeatedly apply the Resolution Rule on the clauses. If False is derived out, then (Γ ϕ) is valid. Artificial Intelligence p.28/34

Resolution Proof Example: A proof of P from {(P H) H} Convert {(P H) H} P into a set of clauses (CNF): {(1) (P H), (2) H, (3) P } Apply the Resolution Rule: 1. (1) (P H) and (2) H produces (4) P 2. (3) P and (4) P produces False Since False is produced, so ((P H) H) P is valid. Artificial Intelligence p.29/34

Proof by Contradiction Γ ϕ R False implies implies implies implies (Γ ϕ) False is valid. (Γ ϕ) False is valid. Γ ϕ is valid. Γ ϕ is valid. Artificial Intelligence p.30/34

An Example Theorem: If (p q) r and p r, then q. Obtain clauses from the premises and the negation of the conclusion. From (p q) r, we obtain: (1) p q r, (2) p q r, (3) p q r, (4) p q r. From p r we obtain: (5) p r, (6) p r From q, we obtain: (7) q. Apply Resolution to the clauses: From (7), (1): (8) p r From (10), (6): (11) p From (7), (4): (9) p r From (10), (9): (12) p From (5), (8): (10) r From (11), (12): (13) Artificial Intelligence p.31/34

How to get CNF from (p q) r (p q) r ((p q) r) (r (p q)) (p q) r (p q) r ( p q) r (( p q) (q p)) r ((p q) ( q p)) r (p q r) ( q p r) r (p q) r (p q) r ((p q) (q p)) r (( p q) ( q p)) ( p q r) ( q p r) Artificial Intelligence p.32/34

Some Resolution Strategies Unit resolution: Unit resolution only. Input resolution: One of the two clauses must be an input clause. Set of support: One of the two clauses must be from a designed set called set of support. New resolvent are added into the set of support. Linear resolution The latest resolvent must be used in the current resolution. Note: The first 3 strategies above are incomplete. The Unit resolution strategy is equivalent to the Input resolution strategy: a proof in one strategy can be converted into a proof in the other strategy. Artificial Intelligence p.33/34

Proof System for Satisfiability The Davis-Putnam-Logemann-Loveland (DPLL) method takes a set of input clauses and converts them into an equivalent set of unit clauses if the set is satisfiable. Inference Rules: S {α β, β} S {α, β} S {α β,β} S {β} S S {α} or S { α} : Unit Resolution : Unit Subsumption : Case Splitting Artificial Intelligence p.34/34