Propositional logic. Programming and Modal Logic

Similar documents
Propositional logic. Programming and Modal Logic

Symbolic Analysis. Xiangyu Zhang

Natural Deduction for Propositional Logic

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Propositional Logic: Deductive Proof & Natural Deduction Part 1

Normal Forms of Propositional Logic

15414/614 Optional Lecture 1: Propositional Logic

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

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

Intelligent Agents. Pınar Yolum Utrecht University

Propositional Reasoning

Logical Agents. Chapter 7

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

Part 1: Propositional Logic

Introduction to Artificial Intelligence. Logical Agents

CS156: The Calculus of Computation

Learning Goals of CS245 Logic and Computation

LOGIC PROPOSITIONAL REASONING

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

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

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

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

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

Logical agents. Chapter 7. Chapter 7 1

Lecture 2 Propositional Logic & SAT

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

Proof Methods for Propositional Logic

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

Advanced Topics in LP and FP

Propositional Logic: Methods of Proof (Part II)

Inference in Propositional Logic

Propositional and First Order Reasoning

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

Propositional Logic: Models and Proofs

Propositional Logic: Evaluating the Formulas

Propositional Logic: Methods of Proof (Part II)

Kecerdasan Buatan M. Ali Fauzi

Class Assignment Strategies

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

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

Logic and Inferences

Classical Propositional Logic

CS 380: ARTIFICIAL INTELLIGENCE

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

Logic: Propositional Logic (Part I)

Lecture Notes on SAT Solvers & DPLL

Warm-Up Problem. Write a Resolution Proof for. Res 1/32

Decision Procedures for Satisfiability and Validity in Propositional Logic

Deductive Systems. Lecture - 3

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

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

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

Overview. I Review of natural deduction. I Soundness and completeness. I Semantics of propositional formulas. I Soundness proof. I Completeness proof.

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

Propositional and Predicate Logic - II

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

Artificial Intelligence

Language of Propositional Logic

Artificial Intelligence Chapter 7: Logical Agents

An Introduction to SAT Solving

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

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

CS156: The Calculus of Computation Zohar Manna Autumn 2008

Part 1: Propositional Logic

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

CS:4420 Artificial Intelligence

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

Comp487/587 - Boolean Formulas

03 Propositional Logic II

Propositional Logic Language

Artificial Intelligence

Propositional logic II.

02 Propositional Logic

Logic. proof and truth syntacs and semantics. Peter Antal

Knowledge based Agents

Deliberative Agents Knowledge Representation I. Deliberative Agents

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

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

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

Lecture 1: Logical Foundations

3 Propositional Logic

Logical Agents. Outline

CS 512, Spring 2017, Handout 10 Propositional Logic: Conjunctive Normal Forms, Disjunctive Normal Forms, Horn Formulas, and other special forms

Logical agents. Chapter 7. Chapter 7 1

Tecniche di Verifica. Introduction to Propositional Logic

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

A brief introduction to Logic. (slides from

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

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

TDT4136 Logic and Reasoning Systems

SAT Solvers: Theory and Practice

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

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Logical Agents. Santa Clara University

CS720 Class Notes. Steve Revilak

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

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

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

Transcription:

Propositional logic Programming and Modal Logic 2006-2007 4

Contents Syntax of propositional logic Semantics of propositional logic Semantic entailment Natural deduction proof system Soundness and completeness Validity Conjunctive normal forms Satisfiability Horn formulas Programming and Modal Logic 2006-2007 5

Syntax of propositional logic F ::= (P ) ( F ) (F F ) (F F ) (F F ) P ::= p q r... propositional atoms: p, q, r,... for describing declarative sentences such as: All students have to follow the course Programming and Modal Logic 1037 is a prime number connectives: Connective Symbol Alternative symbols negation disjunction conjunction & implication,, Sometimes also bi-implication (,, ) is considered as a connective. Programming and Modal Logic 2006-2007 6

Syntax of propositional logic inding priorities ( ) for reducing the number of brackets. Also outermost brackets are often omitted. Programming and Modal Logic 2006-2007 7

Semantics of propositional logic The meaning of a formula depends on: The meaning of the propositional atoms (that occur in that formula) The meaning of the connectives (that occur in that formula) Programming and Modal Logic 2006-2007 8

Semantics of propositional logic The meaning of a formula depends on: The meaning of the propositional atoms (that occur in that formula) a declarative sentence is either true or false captured as an assignment of truth values ( = {T, F}) to the propositional atoms: a valuation v : P The meaning of the connectives (that occur in that formula) the meaning of an n-ary connective is captured by a function f : n usually such functions are specified by means of a truth table. A A A A A T T F T T T T F F F T F F T T F T T F F T F F T Programming and Modal Logic 2006-2007 9

Exercise Find the meaning of the formula (p q) (q r) (p r) by constructing a truth table from the subformulas. Programming and Modal Logic 2006-2007 10

Exercise Find the meaning of the formula (p q) (q r) (p r) by constructing a truth table from the subformulas. (p q) (p q) (q r) p q r p q q r p r (q r) (p r) T T T T T T T T T T F T F F F T T F T F T F T T T F F F T F F T F T T T T T T T F T F T F F T T F F T T T T T T F F F T T T T T Programming and Modal Logic 2006-2007 11

Exercise Find the meaning of the formula (p q) (q r) (p r) by constructing a truth table from the subformulas. (p q) (p q) (q r) p q r p q q r p r (q r) (p r) T T T T T T T T T T F T F F F T T F T F T F T T T F F F T F F T F T T T T T T T F T F T F F T T F F T T T T T T F F F T T T T T Formally (this is not in the book) [ ] : F ((P ) ) [p ](v) = v(p) [φ ψ ](v) = f ( [φ ](v), [ψ ](v)) [ φ ](v) = f ( [φ ](v)) [φ ψ ](v) = f ( [φ ](v), [ψ ](v)) [φ ψ ](v) = f ( [φ ](v), [ψ ](v)) Programming and Modal Logic 2006-2007 12

Questions Our interest lies with the following questions: Semantic entailment Many logical arguments are of the form: from the assumptions φ 1,, φ n, we know ψ. This is formalised by the semantic entailment relation =. Formally, φ 1,, φ n = ψ iff for all valuations v such that [φ i ](v) = T for all 1 i n we have [ψ ](v) = T. Validity: A formula φ is valid if = φ holds. Satisfiability: A formula φ is satisfiable if there exists a valuation v such that [φ](v) = T. Programming and Modal Logic 2006-2007 13

Semantic entailment How to establish semantic entailment φ 1,, φ n = ψ? Option 1: Construct a truth table. If the formulas contain m different propositional atoms, the truth table contains 2 m lines! Option 2: Give a proof. Suppose that (p q) (q r). Suppose that p. Then, as p q follows from (p q) (q r), we have q. Finally, as q r follows from (p q) (q r), we have r. Thus the formula holds. Programming and Modal Logic 2006-2007 14

Semantic entailment Proof rules for inferring a conclusion ψ from a list of premises φ 1,, φ n : φ 1,, φ n ψ (sequent) What is a proof of a sequent φ 1,, φ n ψ according to the book (informal definition)? Proof rules may be instantiated, i.e. consistent replacement of variables by formulas Constructing the proof is filling the gap between the premises and the conclusion by applying a suitable sequence of proof rules. Programming and Modal Logic 2006-2007 15

Natural deduction Proof rules for conjunction: introduction φ ψ φ ψ i elimination φ ψ φ ψ φ e 1 ψ e 2 Programming and Modal Logic 2006-2007 16

Exercise Exercise 1.2.1: Prove (p q) r, s t q s. Programming and Modal Logic 2006-2007 17

Exercise Exercise 1.2.1: Prove (p q) r, s t q s. Linear representation: 1 (p q) r premise 2 s t premise 3 p q e 1 1 4 q e 2 3 5 s e 1 2 6 q s i 4, 5 Programming and Modal Logic 2006-2007 18

Exercise Exercise 1.2.1: Prove (p q) r, s t q s. Linear representation: 1 (p q) r premise 2 s t premise 3 p q e 1 1 4 q e 2 3 5 s e 1 2 6 q s i 4, 5 Tree representation: (p q) r p q q e 1 e 2 q s s t s e 1 i Programming and Modal Logic 2006-2007 19

Natural deduction Proof rules for disjunction: introduction φ ψ φ ψ i 1 φ ψ i 2 elimination φ ψ φ. χ χ ψ. χ e Programming and Modal Logic 2006-2007 20

Exercise Exercise 1.4.2.(q). Prove (p q) (p r) p (q r) Programming and Modal Logic 2006-2007 21

Exercise Exercise 1.4.2.(q). Prove (p q) (p r) p (q r) 1 (p q) (p r) premise 2 3 4 5 6 7 8 9 10 11 p q p q q r p (q r) p r p r q r p (q r) assumption e 1 2 e 2 2 i 1 4 i 3,5 assumption e 1 7 e 2 7 i 2 9 i 8,10 12 p (q r) e 1,2-6,7-11 Programming and Modal Logic 2006-2007 22

Natural deduction Proof rules for implication: introduction φ. ψ φ ψ i elimination φ φ ψ ψ e Programming and Modal Logic 2006-2007 23

Exercise 1. Prove p q, q r p r. 2. Prove (p (q r)) (q (p r)). Programming and Modal Logic 2006-2007 24

Exercise Prove p q, q r p r Linear representation: 1 p q premise 2 q r premise 3 4 5 p q r assumption e 1,3 e 2,4 6 p r i 3-5 Tree representation (assumption management more difficult): p q q p e r p r q r e i Programming and Modal Logic 2006-2007 25

Natural deduction Proof rules for negation: introduction φ. φ i elimination φ φ e Example: p ( p q) Programming and Modal Logic 2006-2007 26

Natural deduction Proof rules for falsum: introduction: there are no proof rules for the introduction of elimination e φ Proof rules for double negation: elimination φ e φ Programming and Modal Logic 2006-2007 27

Natural deduction Derived rules (derivation in book): Modus Tollens introduction φ ψ ψ MT φ φ φ i Reduction Ad Absurdum / Proof by contradiction φ. φ RAA Law of the Excluded Middle / Tertium Non Datur φ φ LEM Programming and Modal Logic 2006-2007 29

Natural deduction Soundness of natural deduction if φ 1,, φ n ψ, then φ 1,, φ n = ψ Completeness of natural deduction if φ 1,, φ n = ψ, then φ 1,, φ n ψ Programming and Modal Logic 2006-2007 32

Deciding validity and satisfiability of propositional formulas Validity: A formula φ is valid if for any valuations v, [φ](v) = T. Satisfiability: A formula φ is satisfiable if there exists a valuation v such that [φ](v) = T. Programming and Modal Logic 2006-2007 33

Deciding validity and satisfiability of propositional formulas Validity: A formula φ is valid if for any valuations v, [φ](v) = T. Satisfiability: A formula φ is satisfiable if there exists a valuation v such that [φ](v) = T. Examples p q p (q p) p p valid? satisfiable? valid? satisfiable? valid? satisfiable? Programming and Modal Logic 2006-2007 34

Deciding validity and satisfiability of propositional formulas Validity: A formula φ is valid if for any valuations v, [φ](v) = T. Satisfiability: A formula φ is satisfiable if there exists a valuation v such that [φ](v) = T. Examples p q p (q p) p p satisfiable valid unsatisfiable Given a propositional formula φ, how to check whether it is valid? satisfiable? Programming and Modal Logic 2006-2007 35

Deciding validity What are the means to decide whether or not a given formula φ is valid? Use techniques for semantic entailment (e.g., natural deduction). Use a calculus for semantical equivalence to prove that φ. Transform φ into some normal form that is semantically equivalent and then apply dedicated techniques (syntactic). φ and ψ are semantically equivalent (not. φ ψ) iff φ = ψ and ψ = φ. A decision procedure for validity can be used for semantic entailment. Lemma (1.41): φ 1,, φ n = ψ iff = φ 1 (φ 2 (φ n ψ)) Programming and Modal Logic 2006-2007 36

Deciding Validity If I am wealthy, then I am happy. I am happy. Therefore, I am wealthy. If John drinks beer, he is at least 18 years old. John does not di drink kbeer. Therefore, John is not yet 18 years old. If girls areblonde, they arepopular with boys. Ugly girls are unpopular with boys. Intellectual girls are ugly. Therefore, blonde girls are not intellectual. If I study, then I will not fail basket weaving 101. If I do not play cards to often, then I will study. I failed basket weaving 101. Therefore, I played cards too often.

Deciding validity Conjunctive Normal Forms A literal is either an atom p or the negation of an atom p. A formule φ is in conjunctive normal form (CNF) if it is a conjunction of a number of disjunctions of literals only. L ::= P P C ::= L C C CNF ::= C CNF CNF literal clause CNF Examples p and p are in CNF; p is not in CNF; p p and (p r) ( r s) q are in CNF; (p q) q is not in CNF. Programming and Modal Logic 2006-2007 37

Deciding validity Usefulness of CNF Deciding validity of formulas in CNF is easy! C 1 C 2 C n (CNF) Each clause has to be valid. L 1 L 2 L m (C) Lemma (1.43): = L 1 L m iff there are i and j (1 i, j m) such that L i and L j are syntactically equal. Any formula be transformed into an equivalent formula in CNF! Programming and Modal Logic 2006-2007 38

Deciding validity Transformation into CNF 1. Remove all occurrences of. Done by the algorithm IF Input: formula Output: formula without 2. Obtain a negation normal form (only atoms are negated!). N ::= P P (N N) (N N) P ::= p q r Done by the algorithm NNF 3. Apply distribution laws Done by the algorithm CNF Input: formula without Output: formula in NNF Input: formula in NNF Output: formula in CNF Therefore, CNF(NNF(IF(φ))) is in CNF and semantically equivalent with φ. Programming and Modal Logic 2006-2007 39

Deciding validity Transformation into CNF. The algorithm IF Idea: Apply the following replacement until it can not be applied anymore: φ ψ replace by φ ψ Inductive definition of IF: IF(p) = p IF( φ) = IF(φ) IF(φ 1 φ 2 ) = IF(φ 1 ) IF(φ 2 ) IF(φ 1 φ 2 ) = IF(φ 1 ) IF(φ 2 ) IF(φ 1 φ 2 ) = IF(φ 1 ) IF(φ 2 ) Properties of IF: IF is well-defined (terminates for any input) IF(φ) φ (the output of IF and the input of IF are semantically equivalent) IF(φ) is an implication-free formula for any formula φ Programming and Modal Logic 2006-2007 40

Deciding validity Transformation into CNF. The algorithm NNF Idea: apply the following replacements until none can be applied anymore: φ replace by φ (φ ψ) replace by φ ψ (φ ψ) replace by φ ψ Inductive definition of NNF: Properties of NNF: NNF(p) = p NNF( p) = p NNF( φ) = NNF(φ) NNF( (φ 1 φ 2 )) = NNF( φ 1 φ 2 ) NNF( (φ 1 φ 2 )) = NNF( φ 1 φ 2 ) NNF(φ 1 φ 2 ) = NNF(φ 1 ) NNF(φ 2 ) NNF(φ 1 φ 2 ) = NNF(φ 1 ) NNF(φ 2 ) NNF is well-defined (terminates for any input) NNF(φ) φ (the output of NNF and the input of NNF are semantically equivalent) NNF(φ) is a NNF for any implication-free formula φ Programming and Modal Logic 2006-2007 41

Deciding validity Transformation into CNF. The algorithm CNF Idea: apply until no longer possible: (φ 1 φ 2 ) ψ replace by (φ 1 ψ) (φ 2 ψ) φ (ψ 1 ψ 2 ) replace by (φ ψ 1 ) (φ ψ 2 ) Inductive definition of CNF: CNF(p) = p CNF( p) = p CNF(φ 1 φ 2 ) = CNF(φ 1 ) CNF(φ 2 ) CNF(φ 1 φ 2 ) = D(CNF(φ 1 ), CNF(φ 2 )) Properties of CNF (and D): with D(φ 1, φ 2 ) = D(φ 11, φ 2 ) D(φ 12, φ 2 ) φ 1 = φ 11 φ 12 D(φ 1, φ 21 ) D(φ 1, φ 22 ) φ 2 = φ 21 φ 22 φ 1 φ 2 otherwise CNF and D are well-defined D(φ, ψ) φ ψ and CNF(φ) φ CNF(φ) is in CNF for any formula φ in NNF and D(φ, ψ) is in CNF for any formulas φ and ψ in CNF Programming and Modal Logic 2006-2007 42

Example Find a CNF for p q r. p q r (p q) r (p q) r ( p q) r ( p q) r ( p q) r ( p r) (q r) Programming and Modal Logic 2006-2007 43

Example Validity of ((p q) r) s. CNF:?? Programming and Modal Logic 2006-2007 44

SAT Solver Finding satisfying valuations to a proposition Finding satisfying valuations to a propositional formula.

Forcing laws { negation : T F F T xxx : TKS F xxx : FKS T

D< " " " D< D< D< Forcing laws { conjunction ^ T T T T F F F T F F F F T ^ = : = : = : : = = : T T T ^ : Zb = : = : : = = : = T T Other laws possible, but : and ^ are adequate F ^ = : = : = : : = = : F F ^ T < : < : < : : < < : T +3 F F ^ : Zb < : < : : < < : < T F F ^ : : : : : +3T F

Using the SAT solver 1. Convert to : and ^. T (p) = p T (:) = :T () T ( ^ ) = T () ^ T ( ) T ( _ ) = :(:T () ^ :T ( )) T (! ) = :(T () ^ :T ( )) Linear growth in formula size (no distributivity). 2. Translate the formula to a DAG, sharing common subterms. 3. Set the root to T and apply the forcing rules. Satisable if all nodes are consistently annotated.

Example: satisability Formula: p ^ :(q _ :p) p ^ ::(:q ^ ::p) 1T ^ S SSSSSSSSS 5T : : 2T : 3F ^ 4T : 5T 2T p o ooo o ooo o ooo q 6T o o : 6F Satisable?

Example: satisability Formula: p ^ :(q _ :p) p ^ ::(:q ^ ::p) 1T ^ S SSSSSSSSS 5T : : 2T : 3F ^ 4T : 5T 2T p o ooo o ooo o ooo q 6T o o : 6T Satisable?

Example: satisability Formula: p ^ :(q _ :p) p ^ ::(:q ^ ::p) 1T ^ S SSSSSSSSS 5T : : 2T : 3F ^ 4T : 5T 2T p o ooo o ooo o ooo q 6T o o : 6T Satisable?

Example: satisability Formula: p ^ :(q _ :p) p ^ ::(:q ^ ::p) 1T ^ S SSSSSSSSS 5T : : 2T : 3F ^ 4T : 5T 2T p o ooo o ooo o ooo q 6T o o : 6T Satisable?

Example: satisability Formula: p ^ :(q _ :p) p ^ ::(:q ^ ::p) 1T ^ S SSSSSSSSS 5T : : 2T : 3F ^ 4T : 5T 2T p o ooo o ooo o ooo q 6T o o : 6T Satisable?

Example: satisability Formula: p ^ :(q _ :p) p ^ ::(:q ^ ::p) 1T ^ S SSSSSSSSS 5T : : 2T : 3F ^ 4T : 5T 2T p o ooo o ooo o ooo q 6F o o : 6F Satisable?

Example: satisability Formula: p ^ :(q _ :p) p ^ ::(:q ^ ::p) 1T ^ S SSSSSSSSS 5T : : 2T : 3F ^ 4T : 5T 2T p o ooo o ooo o ooo q 6F o o : 6F Satisable?

Example: validity Formula: (p _ (p ^ q))! p Valid if :((p _ (p ^ q))! p) is not satisable Translated formula: :(:p ^ :(p ^ q)) ^ :p ^J J1T J J J : 2T ^3F q 2T : qqqq : 4F 3F p p ppp p ppp p ^ 5T q Contradiction.

Example: validity Formula: (p _ (p ^ q))! p Valid if :((p _ (p ^ q))! p) is not satisable Translated formula: :(:p ^ :(p ^ q)) ^ :p ^J J1T J J J : 2T ^3F q 2T : qqqq : 4F 3F p p ppp p ppp p ^ 5T q Contradiction.

Example: validity Formula: (p _ (p ^ q))! p Valid if :((p _ (p ^ q))! p) is not satisable Translated formula: :(:p ^ :(p ^ q)) ^ :p ^J J1T J J J : 2T ^3F q 2T : qqqq : 4F 3F p p ppp p ppp p ^ 5T q Contradiction.

Example: validity Formula: (p _ (p ^ q))! p Valid if :((p _ (p ^ q))! p) is not satisable Translated formula: :(:p ^ :(p ^ q)) ^ :p ^J J1T J J J : 2T ^3F q 2T : qqqq : 4F 3F p p ppp p ppp p ^ 5T q Contradiction.

Example: validity Formula: (p _ (p ^ q))! p Valid if :((p _ (p ^ q))! p) is not satisable Translated formula: :(:p ^ :(p ^ q)) ^ :p ^J J1T J J J : 2T ^3F q 2T : qqqq : 4F 3F p p ppp p ppp p ^ 5T q Contradiction.

Example: validity Formula: (p _ (p ^ q))! p Valid if :((p _ (p ^ q))! p) is not satisable Translated formula: :(:p ^ :(p ^ q)) ^ :p ^J J1T J J J : 2T ^3F q 2T : qqqq : 4F 3F p p ppp p ppp p ^ 5T q Contradiction.

Example: validity Formula: (p _ (p ^ q))! p Valid if :((p _ (p ^ q))! p) is not satisable Translated formula: :(:p ^ :(p ^ q)) ^ :p ^J J1T J J J : 2T ^3F q 2T : qqqq : 4F 3F p p ppp p ppp p ^ 5T q Contradiction.

Example: satisability Formula: (p _ (p ^ q))! p :(:(:p ^ :(p ^ q)) ^ :p) Now what? : 1T ^J2F J J : ^ q : qqqq : ^ p J J p ppp p ppp p q

Example: satisability Formula: (p _ (p ^ q))! p :(:(:p ^ :(p ^ q)) ^ :p) Now what? : 1T ^J2F J J : ^ q : qqqq : ^ p J J p ppp p ppp p q

Example: satisability Formula: (p _ (p ^ q))! p :(:(:p ^ :(p ^ q)) ^ :p) Now what? 1T 2F : ^J J J J J : ^ q : qqqq : ^ p p ppp p ppp p q

Example: satisability Formula: (p _ (p ^ q))! p :(:(:p ^ :(p ^ q)) ^ :p) Now what? 1T 2F : ^J J J J J : ^ q : qqqq : ^ p p ppp p ppp p q

Limitation of the SAT solver algorithm Fails for all formulas of the form :( 1 ^ 2 ). : T ^ F 1? 2? Some are valid, and thus satisable: > p! p :(p ^ :p) Some are not valid, and thus not satisable:? :> :(> ^ >) :(p! p ^ p! p) :(:(p ^ :p) ^ :(p ^ :p))

Limitation of the SAT solver algorithm Fails for all formulas of the form :( 1 ^ 2 ). : T ^ F 1? 2? Some are valid, and thus satisable: > p! p :(p ^ :p) Some are not valid, and thus not satisable:? :> :(> ^ >) :(p! p ^ p! p) :(:(p ^ :p) ^ :(p ^ :p))

Limitation of the SAT solver algorithm Fails for all formulas of the form :( 1 ^ 2 ). : T ^ F 1? 2? Some are valid, and thus satisable: > p! p :(p ^ :p) Some are not valid, and thus not satisable:? :> :(> ^ >) :(p! p ^ p! p) :(:(p ^ :p) ^ :(p ^ :p))

Limitation of the SAT solver algorithm Fails for all formulas of the form :( 1 ^ 2 ). : T ^ F 1? 2? Some are valid, and thus satisable: > p! p :(p ^ :p) Some are not valid, and thus not satisable:? :> :(> ^ >) :(p! p ^ p! p) :(:(p ^ :p) ^ :(p ^ :p))

Limitation of the SAT solver algorithm Fails for all formulas of the form :( 1 ^ 2 ). : T ^ F 1? 2? Some are valid, and thus satisable: > p! p :(p ^ :p) Some are not valid, and thus not satisable:? :> :(> ^ >) :(p! p ^ p! p) :(:(p ^ :p) ^ :(p ^ :p))

Limitation of the SAT solver algorithm Fails for all formulas of the form :( 1 ^ 2 ). : T ^ F 1? 2? Some are valid, and thus satisable: > p! p :(p ^ :p) Some are not valid, and thus not satisable:? :> :(>^>) :(p! p ^ p! p) :(:(p ^ :p) ^ :(p ^ :p))

Limitation of the SAT solver algorithm Fails for all formulas of the form :( 1 ^ 2 ). : T ^ F 1? 2? Some are valid, and thus satisable: > p! p :(p ^ :p) Some are not valid, and thus not satisable:? :> :(>^>) :(p! p^p! p) :(:(p ^ :p) ^ :(p ^ :p))

Limitation of the SAT solver algorithm Fails for all formulas of the form :( 1 ^ 2 ). : T ^ F 1? 2? Some are valid, and thus satisable: > p! p :(p ^ :p) Some are not valid, and thus not satisable:? :> :(>^>) :(p! p^p! p) :(:(p^:p)^:(p^:p))

Extending the algorithm Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T : ^ 1T llllll W WWWWWWWWW l W: 2T 3F ^ ^ 3F 8F q l l R R R R l 6T 7T r 6T 4T: llll R R R 4F 5F: 5F^ 5T 6T ^ 8F q 6T 7T r 6T 7T: 7T r 6T 8F q 6T Idea: pick a node and try both possibilities

Extending the algorithm Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T : ^ 1T llllll W WWWWWWWWW l W: 2T 3F ^ ^ 3F 8F q l l R R R R l 6T 7T r 6T 4T: llll R R R 4F 5F: 5F^ 5T 6T ^ 8F q 6T 7T r 6T 7T: 7T r 6T 8F q 6T Idea: pick a node and try both possibilities

Extending the algorithm Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T : ^ 1T llllll W WWWWWWWWW l W: 2T 3F ^ ^ 3F 8F q l l R R R R l 6T 7T r 6T 4T: llll R R R 4F 5F: 5F^ 5T 6T ^ 8F q 6T 7T r 6T 7T: 7T r 6T 8F q 6T Idea: pick a node and try both possibilities

Extending the algorithm Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T : ^ 1T llllll W WWWWWWWWW l W: 2T 3F ^ ^ 3F 8F q l l R R R R l 6T 7T r 6T 4T: llll R R R 4F 5F: 5F^ 5T 6T ^ 8F q 6T 7T r 6T 7T: 7T r 6T 8F q 6T Idea: pick a node and try both possibilities

Extending the algorithm Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T : ^ 1T llllll W WWWWWWWWW l W: 2T 3F ^ ^ 3F 8F q l l R R R R l 6T 7T r 6T 4T: llll R R R 4F 5F: 5F^ 5T 6T ^ 8F q 6T 7T r 6T 7T: 7T r 6T 8F q 6T Idea: pick a node and try both possibilities

Extending the algorithm Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T : ^ 1T llllll W WWWWWWWWW l W: 2T 3F ^ ^ 3F 8F q l l R R R R l 6T 7T r 6T 4T: llll R R R 4F 5F: 5F^ 5T 6T ^ 8F q 6T 7T r 6T 7T: 7T r 6T 8F q 6T r is true in both casesidea: pick a node and try both possibilities

Using the value of r Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T q : ^ 3F ^ 1T llllll W WWWWWWWWW l W: 2T ^ 3F l l R R R R l llll R R R 5F r 4T : 7T : 8F ^ 6F 5F q r 4T 6T: 5F q ^ 7T r 4T Idea: pick a node and try both possibilities

Using the value of r Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T q : ^ 3F ^ 1T llllll W WWWWWWWWW l W: 2T ^ 3F l l R R R R l llll R R R 5F r 4T : 7T : 8F ^ 6F 5F q r 4T 6T: 5F q ^ 7T r 4T Idea: pick a node and try both possibilities

Using the value of r Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T q : ^ 3F ^ 1T llllll W WWWWWWWWW l W: 2T ^ 3F l l R R R R l llll R R R 5F r 4T : 7T : 8F ^ 6F 5F q r 4T 6T: 5F q ^ 7T r 4T Idea: pick a node and try both possibilities

Using the value of r Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T q : ^ 3F ^ 1T llllll W WWWWWWWWW l W: 2T ^ 3F l l R R R R l llll R R R 5F r 4T : 7T : 8F ^ 6F 5F q r 4T 6T: 5F q ^ 7T r 4T Idea: pick a node and try both possibilities

Using the value of r Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T q : ^ 3F ^ 1T llllll W WWWWWWWWW l W: 2T ^ 3F l l R R R R l llll R R R 5F r 4T : 7T : 8F ^ 6F 5F q r 4T 6T: 5F q ^ 7T r 4T Satisable.Idea: pick a node and try both possibilities

Extended algorithm Algorithm: 1. Pick an unmarked node and add temporary T and F marks. 2. Use the forcing rules to propagate both marks. 3. If both marks lead to a contradiction, report a contradiction. 4. If both marks lead to some node having the same value, permanently assign the node that value. 5. Erase the remaining temporary marks and continue. Complexity O(n 3 ): 1. Testing each unmarked node: O(n) 2. Testing a given unmarked node: O(n) 3. Repeating the whole thing when a new node is marked: O(n) Why isn't it exponential?

An optimization Formula: :(q ^ r) ^ :(:(q ^ r) ^ :(:q ^ r)) 2T : ^ 1T llllll W WWWWWWWWW l W: 2T 3F ^ ^ 3F 8F q l l R R R R l 6T 7T r 6T 4T: llll R R R 4F 5F: 5F^ 5T 6T ^ 8F q 6T 7T r 6T 7T: 7T r 6T 8F q 6T We could stop here: red values give a complete and consistent valuation.

Another optimization 2T : ^ 1T llllll W WWWWWWWWW l W: 2T 3F ^ ^ 3F 8F q l l R R R R l 6T 7T r 6T 4T: llll R R R 4F 5F: 5F^ 5T 6T ^ 8F q 6T 7T r 6T 7T: 7T r 6T 8F q 6T I Contradiction in the leftmost subtree. I No need to analyze q, etc. I Permanently mark \4T4F" as T.

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) Perform backtracking search over values of variables Try to satisfy each clause M. Davis, G. Logemann, and D. Loveland. A machine program for theorem-proving. Communications of the ACM, 5:394 397, 1962 Slides from Aarti Gupta 19

asic DLL Search Performs backtracking search over variable assignments asic definitions Under a given partial assignment (PA) to variables A variable may be assigned (true/false literal) unassigned. A clause may be satisfied ( 1 true literal) unsatisfied (all false literals) unit (one unassigned literal, rest false) unresolved (otherwise) 20

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) a 21

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) 0 a Decision 22

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 a 0 Decision 23

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 b 0 a 0 Decision 24

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) Unit 0 c 0 b 0 d=1 a Implication Graph a=0 c=0 (a + c + d) d=1 d is implied CP: oolean Constraint Propagation repeatedly applies Unit Clause Rule lit clause[lit ] clause[ ] 25

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) Unit 0 c 0 0 a b d=1,d=0 a=0 (a + c + d) d=1 Implication Graph c=0 (a + c + d ) d=0 26

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) 0 c 0 0 a b d=1,d=0 Conflict! Implication Graph a=0 c=0 (a + c + d) (a + c + d ) d=1 d=0 Conflict! 27

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) 0 c 0 b 0 a acktrack 28

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 b 0 0 1 Forced Decision a 29

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) 0 c 0 0 a b d=1,d=0 1 Forced Decision Implication Graph a=0 c=1 (a + c + d) (a + c + d ) d=1 d=0 Conflict! 30

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 0 1 b 0 a acktrack 31

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 0 1 b 0 a acktrack 32

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 0 1 b 0 a 1 Forced Decision 33

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) 0 c 0 1 b 0 1 0 c a d=1,d=0 Decision Implication Graph a=0 c=0 (a + c + d) (a + c + d ) d=1 d=0 Conflict! 34

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 0 1 b 0 1 0 c a acktrack 35

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) 0 c 0 1 b 0 1 a c 0 1 d=1,d=0 Forced Decision Implication Graph a=0 c=1 (a + c + d) (a + c + d ) d=1 d=0 Conflict! 36

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 0 1 b 0 1 a c 0 1 acktrack 37

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 0 1 b 0 1 a c 0 1 1 Forced Decision 38

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 0 1 b 0 1 a c 0 1 1 b 1 c=1 Decision Implication Graph a=1 b=1 (a + b + c) c=1 39

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 0 1 b 0 1 a c 0 1 1 b 1 c=1,d=1 Implication Graph a=1 b=1 (a + b + c) (b + c + d) c=1 d=1 40

asic DLL Search (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) c 0 0 1 b 0 1 a c 0 1 1 b 1 c=1,d=1 SAT Implication Graph a=1 b=1 (a + b + c) (b + c + d) c=1 d=1 Unit-clause rule with backtrack search 41

DPLL SAT Solver unit clause rule DPLL(F) G CP(F) decision heuristics if G = then return true if G = then return false p choose(vars(g)) return DPLL(G{p }) = SAT or DPLL(G{p }) backtracking search 42