SAT and DPLL. Introduction. Preliminaries. Normal forms DPLL. Complexity. Espen H. Lian. DPLL Implementation. Bibliography.

Similar documents
SAT and DPLL. Espen H. Lian. May 4, Ifi, UiO. Espen H. Lian (Ifi, UiO) SAT and DPLL May 4, / 59

Practical SAT Solving

Lecture 2: The Simple Story of 2-SAT

Another Variant of 3sat. 3sat. 3sat Is NP-Complete. The Proof (concluded)

Levin Reduction and Parsimonious Reductions

Another Variant of 3sat

Computing Unsatisfiable k-sat Instances with Few Occurrences per Variable

You Have an NP-Complete Problem (for Your Thesis)

arxiv: v1 [math.lo] 24 Feb 2014

monotone circuit value

The Traveling Salesman Problem. Time Complexity under Nondeterminism. A Nondeterministic Algorithm for tsp (d)

Computing Unsatisfiable k-sat Instances with Few Occurrences per Variable

TABLEAU-BASED DECISION PROCEDURES FOR HYBRID LOGIC


Finding Equilibria in Games of No Chance

Binary Decision Diagrams

Notes on Natural Logic

Binary Decision Diagrams

Cook s Theorem: the First NP-Complete Problem

Yao s Minimax Principle

0.1 Equivalence between Natural Deduction and Axiomatic Systems

Search Space and Average Proof Length of Resolution. H. Kleine Buning T. Lettmann. Universitat { GH { Paderborn. Postfach 16 21

5 Deduction in First-Order Logic

Tableau Theorem Prover for Intuitionistic Propositional Logic

An Adaptive Characterization of Signed Systems for Paraconsistent Reasoning

Lecture 5: Iterative Combinatorial Auctions

2 Deduction in Sentential Logic

A Knowledge-Theoretic Approach to Distributed Problem Solving

Bidding Languages. Chapter Introduction. Noam Nisan

Solving MAXSAT by Solving a Sequence of Simpler SAT Instances

ExpTime Tableau Decision Procedures for Regular Grammar Logics with Converse

Generalising the weak compactness of ω

CTL Model Checking. Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula. Approach Model checking!

Tableau Theorem Prover for Intuitionistic Propositional Logic

Complexity of Iterated Dominance and a New Definition of Eliminability

TR : Knowledge-Based Rational Decisions

Threshold logic proof systems

Semantics with Applications 2b. Structural Operational Semantics

Fundamentals of Logic

Unary PCF is Decidable

Equivalence Nucleolus for Partition Function Games

Handout 4: Deterministic Systems and the Shortest Path Problem

Bidding Languages. Noam Nissan. October 18, Shahram Esmaeilsabzali. Presenter:

4: SINGLE-PERIOD MARKET MODELS

On the Optimality of a Family of Binary Trees Techical Report TR

Laurence Boxer and Ismet KARACA

CATEGORICAL SKEW LATTICES

Laurence Boxer and Ismet KARACA

Essays on Some Combinatorial Optimization Problems with Interval Data

Mathematical Logic Final Exam 14th June PROPOSITIONAL LOGIC

GUESSING MODELS IMPLY THE SINGULAR CARDINAL HYPOTHESIS arxiv: v1 [math.lo] 25 Mar 2019

Brief Notes on the Category Theoretic Semantics of Simply Typed Lambda Calculus

THE NUMBER OF UNARY CLONES CONTAINING THE PERMUTATIONS ON AN INFINITE SET

Maximum Contiguous Subsequences

Algorithmic Game Theory and Applications. Lecture 11: Games of Perfect Information

,,, be any other strategy for selling items. It yields no more revenue than, based on the

A Translation of Intersection and Union Types

Online Algorithms SS 2013

Decidability and Recursive Languages

Single Price Mechanisms for Revenue Maximization in Unlimited Supply Combinatorial Auctions

arxiv: v2 [math.lo] 13 Feb 2014

An effective perfect-set theorem

Lecture 23: April 10

Cut-free sequent calculi for algebras with adjoint modalities

3.2 No-arbitrage theory and risk neutral probability measure

Single Price Mechanisms for Revenue Maximization in Unlimited Supply Combinatorial Auctions

Best-Reply Sets. Jonathan Weinstein Washington University in St. Louis. This version: May 2015

A Syntactic Realization Theorem for Justification Logics

American Option Pricing Formula for Uncertain Financial Market

Tableau-based Decision Procedures for Hybrid Logic

A No-Arbitrage Theorem for Uncertain Stock Model

A Decidable Logic for Time Intervals: Propositional Neighborhood Logic

In Discrete Time a Local Martingale is a Martingale under an Equivalent Probability Measure

On the h-vector of a Lattice Path Matroid

MATH 5510 Mathematical Models of Financial Derivatives. Topic 1 Risk neutral pricing principles under single-period securities models

Automated Reasoning in Modal and Description Logics via SAT Encoding: the Case Study of K m /ALC-Satisfiability

A Logic-based Approach to Decision Making. Magdalena Ivanovska and Martin Giese

Single-Parameter Mechanisms

Interpolation. 1 What is interpolation? 2 Why are we interested in this?

Separable Preferences Ted Bergstrom, UCSB

Lecture 14: Basic Fixpoint Theorems (cont.)

Sublinear Time Algorithms Oct 19, Lecture 1

ISBN ISSN

Interpolation of κ-compactness and PCF

Sy D. Friedman. August 28, 2001

The Stackelberg Minimum Spanning Tree Game

3 Arbitrage pricing theory in discrete time.

CSE 21 Winter 2016 Homework 6 Due: Wednesday, May 11, 2016 at 11:59pm. Instructions

On the Optimality of a Family of Binary Trees

Microeconomics of Banking: Lecture 5

Optimal Satisficing Tree Searches

Lecture l(x) 1. (1) x X

8. Propositional Logic Natural deduction - negation. Solved problems

Lecture 10: The knapsack problem

COMBINATORICS OF REDUCTIONS BETWEEN EQUIVALENCE RELATIONS

6: MULTI-PERIOD MARKET MODELS

The Role of Human Creativity in Mechanized Verification. J Strother Moore Department of Computer Science University of Texas at Austin

Approximate Revenue Maximization with Multiple Items

arxiv: v1 [math.co] 31 Mar 2009

On Existence of Equilibria. Bayesian Allocation-Mechanisms

Transcription:

SAT and Espen H. Lian Ifi, UiO Implementation May 4, 2010 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 1 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 2 / 59 Introduction Introduction SAT is the problem of determining if a propositional formula (on conjunctive normal form) is satisfiable. The (Davis-Putnam-Logemann-Loveland) procedure from 1962 [2] is an algorithm solving SAT. is a refinement of the DP (Davis-Putnam) procedure from 1960 [3]. We present (a version of) as a calculus. is interesting because it works well in practice, ie. the best SAT solvers are based on. Preliminaries A literal is a propositional variable or its negation. Our connectives are,, and. and are the truth constants. We will use the following notation. propositional variables: P, Q, R, S (possibly subscripted) literals: x, y, z (possibly subscripted) general formulae: X, Y, Z The complement of a literal is defined as follows. P = P, and P = P. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 3 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 4 / 59

NNF A formula is on negation normal form (NNF) if negations occur only in front of propositional variables and implications does not occur at all. Any formula can be put on NNF using the following rewrite rules. X X X Y X Y (X Y ) X Y (X Y ) X Y Some additional rewrite rules are needed for formula containing and. We will assume that a formula X on NNF does not contain or unless X = or X =. CNF and DNF A formula is on conjunctive normal form (CNF) if it is a conjunction of disjunctions of literals. Example 1 ( P Q) (P Q R) (Q S) (P R) A formula on NNF can be put on CNF using the following rewrite rules. (X Y ) Z (X Z) (Y Z) Z (X Y ) (Z X ) (Z Y ) A formula is on disjunctive normal form (DNF) if it is a disjunction of conjunctions of literals. DNF is like CNF, only with and exchanged. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 5 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 6 / 59 Example The following formula expresses P Q or R S but not both, (ie. exclusive or). ((P Q) (R S)) ( (P Q) (R S)) NNF: ((P Q) (R S)) (( P Q) ( R S)) Size increase Rewriting a formula from DNF to CNF (or vice versa) may cause an exponential increase in size. (P 1 P 2 ) (P 3 P 4 ) (P 5 P 6 ) CNF: (P R) (P S) (Q R) (Q S) ( P Q R S) The NNF to CNF part is performed as follows. (P Q) (R S) (P (R S)) (Q (R S)) (P R) (P S) (Q (R S)) (P R) (P S) (Q R) (Q S) On CNF: (P 1 P 3 P 5 ) (P 1 P 3 P 6 ) (P 1 P 4 P 5 ) (P 1 P 4 P 6 ) (P 2 P 3 P 5 ) (P 2 P 3 P 6 ) (P 2 P 4 P 5 ) (P 2 P 4 P 6 ) Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 7 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 / 59

For the sake of notational simplicity, instead of using formula on CNF, we will use clause sets. A clause is a disjunction of literals. A unit clause is a singleton clause. A clause set is a finite set of clauses (interpreted conjunctively). We will represent non-empty clauses by the set of its literals using a Prolog-like notation. An empty clause is the empty disjunction. x 1 x n is represented by the set [x 1... x n ], for n > 0 (n is the length). We will sometimes write [] for. Example Some clauses: 1. [P Q R] 2. [P P] 3. [], the empty clause Some clause sets: 1. {[P Q R]} 2. {[P P], [], [P Q R]} 3., the empty clause set 4. {[]}, the clause set containing exactly the empty clause Observe that [] (see next foil). Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 9 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 10 / 59 Valuation Let Γ be a clause set and C a clause. As clauses are disjunctions, it follows that they are valuated as follows. v(c) = 1 iff v(x) = 1 for some x C. We will interpret clause sets conjunctively, ie. Observe that v(γ) = 1 iff v(c) = 1 for every C Γ. if C is empty, then v(c) = 0, while if Γ is empty, then v(γ) = 1. Thus we may use clause sets to represent formula on CNF. Example: v({[p Q R], [ P R]}) = v((p Q R) ( P R)) Subsumption Let C 1 and C 2 be clauses. If C 1 C 2, we say that C 1 subsumes C 2. Lemma 2 (Subsumption) If C 1 subsumes C 2, and v(c 1 ) = 1, then v(c 2 ) = 1. If v(c 1 ) = 1, then v(x) = 1 for some x C 1. If C 1 C 2, then x C 2. Thus v(c 2 ) = 1. Example: = P (P Q) as [P] subsumes [P Q]. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 11 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 12 / 59

Subsumption Define Γ x = {C [x] C Γ}, ie. x is added to every clause. Example 1. {[P Q], [ Q], [ P Q]} x = {[P Q x], [ Q x], [ P Q x]}. 2. {[P Q], [ Q], [ P Q]} P = {[P Q], [P Q], [P P Q]}. 3. { } x = {[]} x = {[x]}. 4. x =. Corollary 3 (of the Subsumption Lemma) If v(γ) = 1, then v(γ x ) = 1. Every clause in Γ subsumes one in Γ x. Subsumption A similar lemma for clause sets, only the other way as clause sets are interpreted conjunctively and clauses disjunctively. Lemma 4 Let Γ and be clause sets. If Γ and v(γ) = 1, then v( ) = 1. If v(γ) = 1, then v(c) = 1 for every C Γ. If Γ, then v(c) = 1 for every C. Thus v( ) = 1. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 13 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 14 / 59 Some lemmata Let Γ and be clause sets and C a clause. Γ, means Γ. Γ, C means Γ {C}. We say that x occurs in Γ if x C for some C Γ. Lemma 5 Let Γ be a non-empty clause set without any occurence of x or x. If Γ is satisfiable, there is some valuation v such that v(γ, [x]) = 1. Some lemmata Lemma 6 If v(x) = 1, then 1. v(γ x ) = 1. 2. v(γ x ) = v(γ). 1. If v(x) = 1, then v(c [x]) = 1 for any clause C,...... in particular every one in Γ. Thus v(γ x ) = 1. 2. Left as exercise. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 15 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 16 / 59

The core of The preceding lemma comes close to the core of. If we make x true, we can 1. remove every clause containing x, and 2. remove x from every clause containing it. Example 7 Let Γ = {[P Q], [ P Q], [Q R]}. If v(p) = 1, then we can 1. remove [P Q], and 2. remove P from [ P Q]. In other words, v(γ) = v({[ Q], [Q R]}). Implementation Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 17 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 1 / 59 Preliminaries The rules Preliminaries The rules Let Γ, Λ and be clause sets without any occurence of x or x such that Γ and Λ are non-empty. The calculus operates not on general formulae but on a clause set Γ. We start by removing from Γ any clause C such that {x, x} C for some x. This obviously does not affect satisfiability. If {x, x} C, then v(c) = 1, thus v(γ) = v(γ \ {C}). Definition An axiom is any clause set where the empty clause occurs, ie. of the form,. Why are the axioms unsatisfiable? In terms of sequent calculus, that Γ is satisfiable may be expressed as Γ or Γ. can be viewed as a left-calculus, ie. the right hand side of the sequent is empty. Thus in sequent calculus terms,, means,, which is valid. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 19 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 20 / 59

The rules The rules Monotone literal fixing If it s the case that some x occurs in some clauses and x does not, we say that x is monotone, and we make x true, because this makes the clauses x occurs in true and does not affect the other clauses. Γ x, Mon This rule is sometimes called the Affirmative-Negative Rule. Example: Q is monotone. [P Q R], [ P R], [P R] [P Q R], [ P R], [P R] Mon Unit subsumption If it s the case that the unit clause [x] occurs, x occur in some other clauses, and x occurs in yet others, [x] subsumes the others where x occurs. [x], Λ x, Sub [x], Γ x, Λ x, Example: [Q] subsumes [ P Q]. [Q], [ P Q], [ P Q], [R] [Q], [ P Q], [ P Q], [R] Sub Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 21 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 22 / 59 The rules The rules Unit resolution If it s the case that the unit clause [x] occurs, x does not occur anywhere else but x does, make x true. Example: Λ, Res [x], Λ x, [Q], [P Q], [ P Q], [R] [Q], [P Q], [ P Q], [R] Res Split If it s the case that some x occurs in some clauses, and x occurs in others, we can make two branches: one where x is true and one where x is false. Example: Split on P. Γ, Λ, Split Γ x, Λ x, [P Q], [ P Q] [P Q],[ P Q] [P Q], [ P Q] Split Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 23 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 24 / 59

Examples Examples Example 1 The following formula is valid. Example 2 (P (Q R)) ((P Q) (P R)) Its negation is equivalent to the following clause set. {[P], [ R], [ P Q], [ P Q R]} It is unsatisfiable, hence it should be provable. We show unsatisfiability using only Res. [P], [ R], [ P Q], [ P Q R] [P], [ R], [ P Q], [ P Q R] [P], [ R], [ P Q], [ P Q R] [P], [ R], [ P Q], [ P Q R] Res Res Res {[ P Q], [P Q R], [Q S], [P R]} is satisfiable: Mon [ R] Mon Res [P R], [P R] [ P], [P R] Split [ P Q], [P Q R], [P R] Mon [ P Q], [P Q R], [Q S], [P R] Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 25 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 26 / 59 Derived rules Derived rules Derivable rules Res is, in fact superfluous, and can be derived from Split:, Λ, Split [x], Λ x, If we allow Γ and Λ to be empty, the following rule is called Unit propagation (on x). Λ, [x], Γ x, Λ x, It can be derived from the other rules. Prop Unit propagation We can derive Prop as follows. If Γ and Λ are non-empty: If Λ =, then Λ x = : If Γ =, then Γ x = : Λ, Res [x], Λ x, Sub [x], Γ x, Λ x, [x], Γ x, Mon Λ, Res [x], Λ x, Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 27 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 2 / 59

Termination Termination Termination Termination Lemma 9 A maximal derivation ends in an axiom or. Assume the opposite: that there is a maximal derivation whose leaf node Γ is neither an axiom nor. Thus there is some x occurring in Γ. If x does not occur in Γ, Mon is applicable. If x does occur in Γ, Split (or in some cases Sub) is applicable. Theorem 10 (Termination) Any proof attempt terminates. Sub and Mon both reduce the number of clauses. Split reduces the number of distinct variables. Both are finite, thus we have termination. In either case we get a contradiction, as the derivation is not maximal. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 29 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 30 / 59 Lemma 11 (Mon) Γ x, is satisfiable iff is satisfiable. Only if: Follows directly from Lemma 4. If: Assume that is satisfiable. By Lemma 5, there is a v such that v( ) = v(x) = 1. By Lemma 6(1), v(γ x ) = 1. Thus v(γ x, ) = 1. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 31 / 59 Lemma 12 (Sub) [x], Γ x, Λ x, is satisfiable iff [x], Λ x, is satisfiable. Only if: Follows directly from Lemma 4. If: Follows from Lemma 6(1). Lemma 13 (Split) Γ x, Λ x, is satisfiable iff Γ, or Λ, are satisfiable. Left as exercise. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 32 / 59

Theorem 14 (Soundness) If there exists a proof of Γ, then Γ is unsatisfiable. We show this contrapositively: if Γ is satisfiable, then Γ is not provable. Assume that Γ is satisfiable. Rules preserve satisfiability upwards. Thus any derivation π has at least one satisfiable leaf node Λ. As axioms are unsatisfiable, Λ is not an axiom, thus π is not a proof. Theorem 15 (Completeness) If Γ is unsatisfiable, there exists a proof of Γ. We show this contrapositively: if there exists no proof of Γ, then Γ is satisfiable. Assume that there exists no proof of Γ. Then any maximal derivation has at least one open leaf node. Termination lets us assume that a derivation is maximal, hence with an open leaf node, which is satisfiable. Rules preserve satisfiability downwards. Thus Γ is satisfiable. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 33 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 34 / 59 NP-completeness NP-completeness Implementation The first problem to be proven NP-complete was SAT. Theorem 16 (Cook s Theorem) SAT is NP-complete. Non-trivial. See [1] or []. We know from the previous lecture (in 200 at least) that propositional satisfiablity is NP-complete. NP-hardness: follows directly from Cook s Theorem. NP-membership: a non-deterministic machine can guess a satisfying valuation and verify it in polynomial time. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 35 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 36 / 59

Size Reduction to CNF Size A problem (instance) is an instance of SAT, ie. a clause set. If the number of clauses is n, there occurs m distinct propositional variables, and every clause is of length c, the problem size is represented by the triple n m c. Example. The following problem has size 2 4 3. {[P Q R], [Q R S]} Reduction to CNF As mentioned, reducing a propositional formula to CNF can cause exponential increase in size. A formula of the form (x 1 y 1 ) (x n y n ) reduced to CNF has size that is 2 n clauses of length n. Example 17 If n = 3, we get a 6 3 problem: 2 n 2n n, (x 1 x 2 x 3 ) (x 1 x 2 y 3 ) (x 1 x 3 y 2 ) (x 1 y 2 y 3 ) (x 2 x 3 y 1 ) (x 2 y 1 y 3 ) (x 3 y 1 y 2 ) (y 1 y 2 y 3 ) But the reason for using in the first place is effectivity! Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 37 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 3 / 59 Equivalence Equisatisfiability Equivalence Two formulae X and Y are equivalent if v(x ) = v(y ) for every valuation v. Equivalence can be expressed in our logical language. Let (X Y ) denote (X Y ) (Y X ). So far we have reduced a formula to an equivalent one on CNF: X Y, where X and Y are equivalent, and Y is on CNF. This, in fact, is not strictly necessary. Equisatisfiability For our purposes, it suffices that X and Y are equisatisfiable: X is satisfiable iff Y is satisfiable. Until now, the procedure for generating input to has been X NNF Y CNF Z Clause Γ, where X, Y, Z and Γ are equivalent, and Z may be exponentially larger than Y. Our next approach is as follows. X NNF Y Tseitin Γ, where Y and Γ are not equivalent, and Γ is no more than polynomially larger than X. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 39 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 40 / 59

Problem given an arbitrary formula on NNF, find an equisatisfiable formula on CNF (or the corresponding clause set). Solution Represent each subformulae (except for literals) with a propositional variable, recursively. Example 1 Usually attributed to Tseitin [9]. ((P Q) R) has two non-literal subformulae, one of which is itself. P 1 {}}{ ((P Q) R) }{{} P 2 For each new variable P k, we generate a formula expressing that P k is equivalent to the formula it represents: (P1 (P 2 R)) (P 2 (P Q)) In addition we want the variable expressing the entire formula, in our case P 1 to be true. Let ϕ denote the following conjunction. P 1 (P 1 (P 2 R)) (P 2 (P Q)) Then ϕ is equisatisfiable to ((P Q) R). Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 41 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 42 / 59 In fact = ϕ ((P Q) R). If v(ϕ) = 1, then v makes the three conjuncts true: 1. v(p 1 ) = 1 2. v(p 1 (P 2 R)) = 1 Thus v(p 1) = v(p 2 R) = 1. Thus v(p 2) = 1 or v(r) = 1. 3. v(p 2 (P Q)) = 1 Thus v(p 2) = v(p Q). If v(p 2) = 1, then v(p Q) = 1. Hence v((p Q) R) = 1. In order to convert ϕ to CNF, we use the following functions. x y P = {[ P x], [ P y], [P x y]} x y P = {[P x], [P y], [ P x y]} x y P = {[P x], [P y], [ P x y]} Lemma 19 (Clause representation) X P is equivalent to (P X ). E.g., {[P x], [P y], [ P x y]} is equivalent to P (x y). Observe that = ((P Q) R) ϕ. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 43 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 44 / 59

Recall that ϕ is the formula P 1 (P 1 (P 2 R)) (P 2 (P Q)). Using the lemma, ϕ is equivalent to the clause set {{[P 1 ]} P 2 R P 1 P Q P 2 }, which again equals {[P 1 ], [P 1 P 2 ], [P 1 R], [ P 1 P 2 R], [ P 2 P], [ P 2 Q], [P 2 P Q]}. Is this any better than the original CNF translation? We will use the number of binary connectives (n) as a measure of the size of our original formula on NNF. We let m denote the number of distinct propositional variables. Then the size of the equisatisfiable clause set generated is (3n + 1) (m + n) 3. Hence we obtain an instance of 3SAT with a linear (in n) number of clauses, with n new variables. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 45 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 46 / 59 Implementation Pseudocode algorithm Implementation Pseudocode algorithm can be implemented as follows, where (Γ) = true iff Γ is satisfiable. proc LookAhead(Γ) while Γ contains unit clause [x] perform unit propagation on x Implementation proc (Γ) LookAhead(Γ) if Γ = return true if Γ return false x := ChooseLiteral(Γ) return (Γ, [x]) or (Γ, [x]) Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 47 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 4 / 59

Implementation Jeroslow Wang heuristic Implementation Jeroslow Wang heuristic Jeroslow Wang heuristic The only non-deterministic part is which literal is chosen. Picking the optimal literal is in general NP-hard and conp-hard [7]. Thus it is harder than deciding satisfiability of the formula! But there exists heuristics. Let Γ(x) denote the subset of Γ where x occurs. Pick the x that maximizes w(γ(x)), where w is the weight function w(γ) = k 1 n(γ, k) 2 k, and n(γ, k) is the number of clauses in Γ of length k. Pick an x that occurs in many short clauses. Example 2 Let Γ = {[ P Q], [P Q R], [Q S], [P R]}. What is (Γ)? Γ contains no unit clause. We calculate w(γ(x)) for each x occurring in Γ. x P P Q Q R R S S w(γ(x)) 2 3 Q has the highest weight in Γ. (Γ) is true if (Γ, [Q]) or (Γ, [ Q]) are. 1 4 2 1 0 2 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 49 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 50 / 59 Implementation Jeroslow Wang heuristic Implementation Jeroslow Wang heuristic Example 2 Example 2 (Γ) is true if Unit propagation is performed on Γ, [ Q]: Let Γ = {[P R], [P R]}. [P R], [P R] Γ, [Q] Prop x P P R R w(γ (x)) 0 4 P has the highest weight in Γ. 2 4 1 4 1 4 (Γ, [P]) or (Γ, [ P]) or (Γ, [ Q]) are. Unit propagation is performed on Γ, [P]: Prop [ R] Prop Γ, [P] (Γ, [P]) returns true, thus (Γ) returns true, which means Γ is satisfiable. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 51 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 52 / 59

Implementation MiniSAT Implementation MiniSAT MiniSAT MiniSAT MiniSAT won the following categories at SAT Competition 2005: Industrial SAT+UNSAT Industrial UNSAT Industrial SAT Crafted UNSAT It didn t do that well at SAT Competition 2007 though. We can try it on an 335 1015 3 problem. villasayas: MiniSat_v1.14>./minisat../DIMACS/par16-5.cnf ==================================[MINISAT]=================================== Conflicts ORIGINAL LEARNT Progress Clauses Literals Limit Clauses Literals Lit/Cl ============================================================================== 0 221 6602 739 0 0 nan 0.000 % 102 221 6602 12 102 953 9.3 3.227 % 252 221 6602 94 252 3313 13.1 3.227 % 477 221 6602 93 477 5729 12.0 3.227 % 14 221 6602 101 14 9112 11.2 3.227 % 1321 221 6602 1190 1321 1354 10.3 3.227 % 201 221 6602 1309 1292 10791.4 3.227 % 3220 2220 6602 1440 1576 12234 7. 3.227 % ============================================================================== restarts : conflicts : 4670 (11121 /sec) decisions : 4911 (11695 /sec) propagations : 10756 (256191 /sec) conflict literals : 3966 (36.40 % deleted) Memory used : 2.97 MB CPU time : 0.419936 s SATISFIABLE villasayas: MiniSat_v1.14> Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 53 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 54 / 59 I Implementation S. A. Cook. The complexity of theorem-proving procedures. In STOC 71: Proceedings of the third annual ACM symposium on Theory of computing, pages 151 15, New York, NY, USA, 1971. ACM. M. Davis, G. Logemann, and D. Loveland. A machine program for theorem-proving. Commun. ACM, 5(7):394 397, 1962. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 55 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 56 / 59

II M. Davis and H. Putnam. A Computing Procedure for Quantification Theory. J. ACM, 7(3):201 215, 1960. N. Eén and N. Sörensson. An Extensible SAT-solver. In E. Giunchiglia and A. Tacchella, editors, SAT, volume 2919 of Lecture Notes in Computer Science, pages 502 51. Springer, 2003. M. Fitting. First-Order Logic and Automated Theorem Proving. Springer-Verlag New York, Inc., Secaucus, NJ, USA, 2. edition, 1996. III R. G. Jeroslow and J. Wang. Solving Propositional Satisfiability Problems. Annals of Mathematics and Artificial Intelligence, 1(1):167 17, 1990. P. Liberatore. On the complexity of choosing the branching literal in. Artificial Intelligence, 116(1-2):315 326, 2000. C. H. Papadimitriou. Computational. Addison Wesley, Reading, Massachusetts, 1994. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 57 / 59 Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 5 / 59 IV G. S. Tseitin. On the of Derivation in Propositional Calculus. In J. Siekmann and G. Wrightson, editors, Automation of Reasoning 2: Classical Papers on Computational Logic 1967-1970, pages 466 43. Springer, Berlin, Heidelberg, 193. Espen H. Lian (Ifi, UiO) SAT and May 4, 2010 59 / 59