COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Similar documents
COMP219: Artificial Intelligence. Lecture 19: Logic for KR

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

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

Formal Verification Methods 1: Propositional Logic

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

Propositional Reasoning

Foundations of Artificial Intelligence

Logic and Inferences

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

Introduction to Artificial Intelligence. Logical Agents

Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011

CS156: The Calculus of Computation

Inference in Propositional Logic

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Lecture 2 Propositional Logic & SAT

Kecerdasan Buatan M. Ali Fauzi

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

Warm-Up Problem. Is the following true or false? 1/35

Part 1: Propositional Logic

Propositional Logic: Methods of Proof (Part II)

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

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

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

Propositional logic. Programming and Modal Logic

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

Foundations of Artificial Intelligence

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Logic: Propositional Logic (Part I)

Propositional Logic: Models and Proofs

CS 380: ARTIFICIAL INTELLIGENCE

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

Lecture Notes on SAT Solvers & DPLL

Proof Methods for Propositional Logic

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

CSE507. Introduction. Computer-Aided Reasoning for Software. Emina Torlak courses.cs.washington.edu/courses/cse507/17wi/

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Tutorial 1: Modern SMT Solvers and Verification

Propositional Logic: Methods of Proof (Part II)

Foundations of Artificial Intelligence

CS156: The Calculus of Computation Zohar Manna Autumn 2008

Propositional Logic Part 1

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

Intelligent Agents. Pınar Yolum Utrecht University

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Propositional Resolution

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

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

Propositional and First Order Reasoning

Lecture 9: The Splitting Method for SAT

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Language of Propositional Logic

SAT Solvers: Theory and Practice

Class Assignment Strategies

Deductive Systems. Lecture - 3

Artificial Intelligence

CS:4420 Artificial Intelligence

An Introduction to SAT Solving

3 Propositional Logic

Propositional logic II.

Comp487/587 - Boolean Formulas

Logical Agents. Chapter 7

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

Inference Methods In Propositional Logic

Supplementary exercises in propositional logic

Chapter 4: Classical Propositional Semantics

Advanced Topics in LP and FP

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

Conjunctive Normal Form and SAT

CS 730/730W/830: Intro AI

Logical agents. Chapter 7. Chapter 7 1

Decision Procedures for Satisfiability and Validity in Propositional Logic

Lecture 9: Search 8. Victor R. Lesser. CMPSCI 683 Fall 2010

Propositional logic. Programming and Modal Logic

LOGIC PROPOSITIONAL REASONING

Satisfiability Modulo Theories

Inference Methods In Propositional Logic

Clause/Term Resolution and Learning in the Evaluation of Quantified Boolean Formulas

Introduction to Arti Intelligence

Logical agents. Chapter 7. Chapter 7 1

CS 771 Artificial Intelligence. Propositional Logic

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 3: Practical SAT Solving

6. Logical Inference

Propositional Calculus

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

Artificial Intelligence Chapter 7: Logical Agents

Propositional Logic: Methods of Proof (Part II)

Propositional Resolution Introduction

Tautologies, Contradictions, and Contingencies

Artificial Intelligence

TDT4136 Logic and Reasoning Systems

Conjunctive Normal Form and SAT

Description Logics. Deduction in Propositional Logic. franconi. Enrico Franconi

CS 4700: Foundations of Artificial Intelligence

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

Propositional and Predicate Logic. jean/gbooks/logic.html

An instance of SAT is defined as (X, S)

Logical Agents. Santa Clara University

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

Conjunctive Normal Form and SAT

Transcription:

COMP219: Artificial Intelligence Lecture 20: Propositional Reasoning 1

Overview Last time Logic for KR in general; Propositional Logic; Natural Deduction Today Entailment, satisfiability and validity Normal forms Negation normal form Conjunctive normal form Satisfiability as a search problem DPLL algorithm Learning outcomes covered today: Distinguish the characteristics, and advantages and disadvantages, of the major knowledge representation paradigms that have been used in AI, such as production rules, semantic networks, propositional logic and firstorder logic; Solve simple knowledge-based problems using the AI representations studied; 2

Propositional Logic for KR Given a knowledge base KB and a property α, check if KB α Model checking (e.g., use truth tables) Theorem proving / inference: Prove α from KB Natural deduction (last week) Reduce to problems of validity or unsatisfiability Davis-Putnam algorithm 3

Validity and Satisfiability A formula is said to be valid (or a tautology) iff it is true under every interpretation. A formula is said to be satisfiable (or consistent) iff it is true under at least one interpretation. A formula is said to be unsatisfiable (or inconsistent or contradictory) iff it is not made true under any interpretation. φ is a valid φ is unsatisfiable. 4

Validity, Satisfiability and Entailment Implications for Knowledge Representation... Deduction Theorem: KB α if and only if (KB α) is valid Or... Reductio ad absurdum: KB α if and only if (KB α) is unsatisfiable 5

Satisfiability Checking Given a knowledge base KB and a property α, check if (KB α) is satisfiable If not satisfiable, α is implied by KB Otherwise, an interpretation of propositions would give us a countermodel shows how (KB α) can be made true Compare Prolog...?- goal(x). KB goal(x) Prolog attempts to satisfy KB goal(x)=kb ( goal(x)) not satisfiable: KB goal(x) satisfiable: countermodels to goal(x), which are models of the goal. 6

Countermodel (I) To check if (hot smoky fire) (alarm_beeps smoky) (fire switch_on_sprinklers)? (alarm_beeps we form switch_on_sprinklers) (hot smoky fire) (alarm_beeps smoky) (fire switch_on_sprinklers) (alarm_beeps switch_on_sprinklers) 7

Countermodel (II) But (hot smoky fire) (alarm_beeps smoky) (fire switch_on_sprinklers) (alarm_beeps switch_on_sprinklers) is true under the interpretation I: I(hot) = F I(smoky) = T I(fire) = F I(alarm_beeps) = T I(switch_on_sprinklers) = F 8

Example: Truth Tables and Satisfiability Using a truth table show whether (p q) (q p) is a tautology, consistent or inconsistent. p q (p q) (q p) (p q) (q p) T T T T T T F F T T F T T F T F F T T T 9

Efficiency So we are back to model checking... A truth table contains 2 n rows, construction requires 2 n steps... Can we do better than that? Not in general: theory says that this is a very hard problem (Satisfiability checking is NP-complete) In practice, not so bad, if we can use heuristics to identify lines we don t need to check But we have to transform (KB α) into a normal form 10

Equivalent Sentences Two sentences A and B are equivalent, written A B iff A and B have the same truth values for every interpretation. Show (p q) ( p q) Draw up a truth table for (p q) and ( p q) and check their truth values are the same. p q (p q) ( p) ( p q) T T T F T T F F F F F T T T T F F T T T 11

Equivalent Sentences Two sentences A and B are equivalent, written A B iff A and B have the same truth values for every interpretation. Show (p q) ( p q) Draw up a truth table for (p q) and ( p q) and check their truth is values not a 'logical are the operator' same. (as ) but similar to entailment... p q (p q) ( p) ( p q) In fact: two Tsentences T are equivalent T F T α β T if and F only if F F F F α β Tand β α T T T F F T T T 12

Equivalent Transformations (I) Where A, B and C are propositions or propositional formulae and T and F are true and false respectively Idempotent laws A A A A A A Associative laws (A B) C A (B C) (A B) C A (B C) Commutative laws A B B A A B B A Distributive laws A (B C) (A B) (A C) A (B C) (A B) (A C) 13

Equivalent Transformations (II) Identity laws A T A F A F A T A A F T Complement laws A A F A A T ( A) A T F F T de Morgan s laws (A B) A B (A B) A B laws for and A B A B A B (A B) (B A) We can use these laws to simplify expressions and to prove equivalences. 14

Examples Simplify the following expression: ( P Q) ( P Q) given ( P Q) de Morgan s laws (P Q) Complement laws Prove the following equivalence: ( (P Q) P) F ( (P Q) P) given (( P Q) P) de Morgan s laws (( Q P) P) Commutative laws ( Q ( P P)) Associative laws ( Q T) Complement laws T Complement laws F Complement laws 15

Negation Normal Form It is often useful to transform formulae into normal forms. These are logically equivalent formulae but have syntactically different forms that may be more suitable for reasoning with. There are several normal forms: Negation Normal Form, Clausal Form, Disjunctive Normal Form and Conjunctive Normal Form. We are most interested in Conjunctive Normal Form (CNF). but first: a formula is in negation normal form if negations appear only in front of propositions and the only operators are, and. First remove the and operators. Then apply de Morgan s laws and remove double negations (complement laws), until in the correct form., can still be nested 16

Conjunctive Normal Form A formula is in Conjunctive Normal Form if it is of the form A 1 A 2... A k where each A i is a disjunction of propositions or their negations. Example (p q) r ( p r s) is in CNF. (p q) r ( p r s) is not in CNF. (p q) r (p ( r s)) is not in CNF. 17

Conjunctive Normal Form To translate into CNF, first translate into NNF. Then apply distribution laws or commutativity laws until in the correct form. Any well-formed formula of propositional logic can be rewritten, using the previous equivalences, as an equivalent formula of CNF. 18

Example Translate ( (p q) r) p into CNF. We first translate into NNF and obtain ( (p q) r) p ((p q) r) p Then transform into CNF ((p q) r) p ((p q) p) ( r p) (p q p) ( r p) 19

Exercise Convert the following into Conjunctive Normal Form, using the appropriate equivalence laws: p (q r) 20

Exercise Convert the following into Conjunctive Normal Form, using the appropriate equivalence laws: p (q r) (p (q r)) ((q r) p) law for ( p q r) ( (q r) p) law for ( p q r) (( q r) p) de Morgan s law ( p q r) ( q p) ( r p) distributive law 21

Satisfiability as a Search Problem Given a formula in CNF, can we find an assignment of truth values to propositions that satisfies it? States are partial assignments - some propositions get values, some are possibly unassigned. Actions are deciding whether a (yet unassigned) proposition is true or false. Initial state: empty partial assignment. Goal state: an assignment making the formula true. 22

Algorithm as Satisfiability for CNF A complete backtracking algorithm Davis-Putnam paper (1960) The version presented (DPLL) is described in a paper by Davis, Logemann, and Loveland (1962). Naive Approach: every proposition is either true or false in any interpretation. 23

Search Space Consider ( p r) (p q) (r q) p p q q q q r r r r r r r r F F F T T F F F Every path in the tree represents a (partial) assignment 24

Partial Assignment Another idea: Simplify formula with a (previously guessed) partial assignment ( p r) (p q) (r q) { if we tried p = True we can now simplify:} ( True r) (True q) (r q) (False r) True (r q) r (r q) {can only be true if r = False} False (False q) q { can only be true if q = True (so q = False) } True Given a good order for partial assignments this can be very helpful. DPLL provides heuristics for choosing partial assignments. Only in the worst case we will need to try everything. 25

Likewise ( p r) (p q) (r q) { let us now consider p = False } ( False r) (False q) (r q) (True r) q (r q) True q (r q) q (r q) { can only be true if q = True } True (r True) (r False) {r can only be true if r = True} True 26

Reduced Search Space Consider ( p r) (p q) (r q) p p q, r q, r T T Only 5 nodes! 27

Algorithm Structure Search through possible assignments of propositions Simplify formulae with partial assignments Unit clause propagation Pure literal elimination

Unit Clause A clause with just one literal is called a unit clause e.g. q ( r q) (r s) Literal s value can be uniquely assigned q must be set to True Unit clause propagation: Check if a formula in CNF has a unit clause, C. Set the value of the literal in C such that C is True Notice that some other clauses may become unit e.g. q ( r q) (r s) reduces to r (r s) r must be set to False r (r s) reduces to s 29

Pure Literal A pure literal is a literal that always appears with the same sign in all clauses. e.g. (p q) ( q r) ( q r) Making a pure literal True makes some clauses True, but no clause False e.g. (p q) ( q r) ( q r) reduces to ( q r) ( q r) ( q r) ( q r) reduces to True Pure literal elimination: Check if a formula in CNF has a pure literal, l Set the value of l to True 30

DPPL(φ) Given a propositional formula φ, DPLL(φ) does the following: If φ is True then return True; If φ is False then return False; Pick a symbol p in φ If DPLL(Simplify(φ, p)) is True then return True; If DPLL(Simplify(φ, p)) is True then return True; Return False; 31

Simplify(φ,L) Given a propositional formula φ and a literal l, simplify(φ,l) does the following: Delete every clause that contains l from φ; Delete l from all clauses in φ Apply exhaustively unit clause propagation and pure literal elimination; Fail (return False) if positive and negative unit clauses for the same literal. 32

Applications There are now several efficient SAT solvers based on DPLL available on the web. They are used in a number of applications. Hardware and software verification IBM, Intel,... Planning Scheduling... 33

Summary We have considered issues concerning efficiency in propositional reasoning This has covered equivalent transformations and normal forms Negation normal form Conjunctive normal form We have considered how satisfiability can be viewed as a search problem Looked at an algorithm for satisfiability in CNF Next time Proof method resolution for propositional logic 34