<<

Satisfiability

Victor W. Marek

Computer Science

University of Kentucky

Spring Semester 2005

Satisfiability – p.1/97 Satisfiability story

ie×

Á Satisfiability - invented in the of XX century by philosophers and mathematicians (Wittgenstein, Tarski)

ie×

Á Shannon (late ) applications to what was then known as electrical engineering

ie× ie×

Á Fundamental developments: and – both mathematics of it, and fundamental algorithms

ie×

Á - progress in computing speed and solving moderately large problems

Á Emergence of “killer applications” in Computer Engineering, Bounded Model Checking

Satisfiability – p.2/97 Current situation

Á SAT solvers as a class of software

Á Solving large cases generated by industrial applications

Á Vibrant area of research both in Computer Science and in Computer Engineering

¯ Various CS meetings (SAT, AAAI, CP)

¯ Various CE meetings (CAV, FMCAD, DATE)

¯ CE meetings Stressing applications

Satisfiability – p.3/97 This Course

Á Providing mathematical and computer science foundations of SAT

¯ General mathematical foundations

¯ Two- and Three- valued

¯ Complete sets of functors

¯ Normal forms (including ite)

¯ Compactness of propositional

¯ rule, of resolution, semantical resolution

¯ Fundamental algorithms for SAT

¯ Craig Lemma

Satisfiability – p.4/97 And if there is enough of time and will...

Á Easy cases of SAT

¯ Horn

¯ 2SAT

¯ Linear formulas

Á And if there is time (but notes will be provided anyway)

¯ Expressing runs of polynomial-time NDTM as SAT, NP completeness

¯ “Mix and match”

¯ Learning in SAT, partial closure under resolution

¯ Bounded Model Checking

Satisfiability – p.5/97 Various remarks

Á Expected involvement of Dr. Truszczynski

Á An extensive set of notes (> 200 pages), covering most of topics will be provided f.o.c. to registered students (in installments)

Á No claim to absolute correctness made

Á Syllabus: http://www.cs.uky.edu/ marek/htmldid.dir/686.html

Á Homeworks every other week

Á Midterm

Á Individually-negotiated project a ¯ Write your own SAT solver

¯ Modify Chaff

¯ Use SAT solver for some reasonable task

Á Questions?

aHic Rhodes, Hic Salta

Satisfiability – p.6/97 Basic concepts

Á Sets and operations on sets

Á Relations

Á Partial orderings (posets)

Á Elements’ classification

Á Lattices

Á Boolean Algebras

Á Chains in posets, Zorn Lemma

Á Well-orderings, ordinals, induction

Á Inductive proofs

Á Inductive definability

Satisfiability – p.7/97 Fixpoint

Á Complete Lattices

Á Monotone operators (functions) in lattices

Á (Knaster-Tarski Fixpoint Theorem) If is a complete lattice and ! is

monotone operator in then possesses a fixpoint. In fact fixpoints of form a

complete lattice under the ordering of , and thus there is a least and largest

fixpoint of

Á Continuous monotone functions

Á The least fixpoint (but not the largest fixpoint) of a continuous operator reached

in or less steps

Á Generalizations of fixpoint theorem

Satisfiability – p.8/97 of propositional logic

Á Variables of some (problem-dependent) set Var

Á For each set Var a separate propositional logic

Á

Inductive definition of the set of formulas Î aÖ

Á Thinking about formulas as binary trees, the rank of formula

Satisfiability – p.9/97

Á Valuations of variables

Á Partial valuations of variables

Á Two-valued logic and valuations

Á Type Bool

Á Tables for operations in Bool

Á Valuations acting on formulas

Á Valuations uniquely extend from variables to formulas

Á Characterizing valuations as complete sets of literals

Á Characterizing valuations as sets of variables

Á

Two-valued function ¾

Á Satisfaction relation j

Á Consistent theories

Satisfiability – p.10/97 Localization and joint-

Á Interactions between sets of variables

Á Restrictions of valuations

Á  ¾ Ä

Localization theorem: If ½ ¾ and Î aÖ , is a valuation of ¾ ,

½

¼ ¼

j j j

is the restriction of to ½ then

Á Complete sets of formulas

Á Lemma: Complete sets of formulas determine valuations and conversely, valuations determine completes sets of formulas

Á

(Robinson joint-consistency) Let ½ , ¾ are two sets of formulas in ½ , ¾

\

resp. Let us assume that ½ ¾ and that both ½ , ¾ are complete

[

for and coincide. Then ½ ¾ is consistent

Satisfiability – p.11/97 Partial valuations, 3-valued logic

Á Need for partial valuations?

Á Partial valuation as complete valuations but in f g

Á Post ordering and Kleene ordering in the set f g

Á Product ordering

Á f g 

Post ordering and Kleene ordering in the multiple-copies product of ,



and

Á Getting Kleene and Post orderings of partial valuations

Á Valuations as maximal partial valuations

Satisfiability – p.12/97 Tables for Kleene 3-valued logic

Á

Three-valued ¿

Á

¾ and ¿ coincide if is a (two-valued) valuation

Á  

If then for every formula , ¿ ¿

Á Autarkies

Á Fundamental effect of this result in SAT

Á Restriction result for 3-valued valuations

Satisfiability – p.13/97 Tautologies and Satisfiability

Á A - formula true under all valuation of its variables

Á Satisfiable formulas

Á A formula is satisfiable if and only if : is not a tautology

Á Consequences of this fact: satisfiability checkers as tautology checkers

Á Common tautologies

Á How many are there tautologies?

Satisfiability – p.14/97 Substitutions to formulas

Á

!

½

½

Á Valuations acting on substitutions

Á Substitution Lemma ¾ : Let f g be a formula in propositional

½ Ñ

h i

variables ½ and let ½ be a sequence of propositional

formulas. Let be a valuation of all variables occurring in ½ . Finally,

¼ ¼

let be a valuation of variables ½ defined by ,

  . Then

!!

½

¼

½

Satisfiability – p.15/97 Substitutions to formulas, cont’d

Á

Let be a tautology, with variables of among ½ . Then for every

!

½

h i

choice of formulas ½ , the formula is a tautology.

½

Á There are infinitely many tautologies

Satisfiability – p.16/97 Lindenbaum Algebra

Á Relation  :  if for all valuations (of all variables occurring in , )

Á  is an equivalence relation

Á  iff the formula  is a tautology

Á We can form the cosets 

Á Operations in 

Á Independence from the choice of representatives

Á Lindenbaum Algebra

Á Lindenbaum Algebra is a

Satisfiability – p.17/97 Permutations of atoms and literals

Á Permutations of atoms

Á Permutations of literals, consistent permutations of literals

Á Shifts

Á Consistent permutations form a group

Á Decomposing consistent permutations of literals into shifts and permutation of variables

Á There is ¡ of consistent permutations of literals over a set of size

Á Consistent permutations of literals (and thus permutations of variables) preserve completeness of sets of literals

Á Every consistent and complete set of literals can be mapped onto any other consistent and complete set of literals by a suitably chosen consistent permutation of literals

Satisfiability – p.18/97 Permutations and formulas

Á Permutations act on formulas

Á (Permutation Theorem) If is a formula, is a valuation and a consistent

permutation of literals then j if and only if j

Á Set-representation of valuations and permutation

Satisfiability – p.19/97 Semantical consequence

Á Operation Cn, entailment of the (sets of) formulas

f 8 j µ j g

Á is an operator in the complete Boolean algebra of sets of formulas

Á For all sets , 

Á is monotone and idempotent

Á is continuous (but we have no means to prove it, yet)

Á ; consists of tautologies and nothing else

Satisfiability – p.20/97

Á Implication functor and consequence operation

Á The following are equivalent

¯

µ ¾

¯

¾ [ f g

Satisfiability – p.21/97 Operations Mod and Th

Á From sets of formulas to valuations: f j g

Á From sets of valuations to formulas f for all ¾ , j g

Á Connection: Let be a valuation and a set of valuations. Then

¾ if and only if for every finite set of variables there is a

¾ j j

valuation such that .

Á Let be a finite set of propositional variables. Let be a collections of

valuations of set and be a valuation of . Then j if and

only if ¾ .

Á

Á

Satisfiability – p.22/97 Functors and formulas

Á An -ary functor is a -ary function in

Ò

¾

Á There are n-ary functors

Á Table - of finite number of variables

Á Altogether there is infinitely many tables

C

Á Given a set C of for functors we can form - the set of formulas

based on C (obvious syntactic restrictions)

Satisfiability – p.23/97 Completeness of sets of functors

Á Valuations as before, functions on into Bool

Á Assigning tables to well-formed formulas (i.e. trees, but no longer binary trees)

Á

table associated with

C

Á C ¾

is complete if every table is equal to for some

Satisfiability – p.24/97 Completeness of sets of functors, cont’d

Á C C C C  C C

If ½ are two sets of functors, is complete and ½ then ½ is also complete.

Á The set f: ^ _g is a complete set of functors.

Á Thus f: ^ _ µ g is a complete set of functors.

Á C C C

Let ½ and ¾ be two sets of functors. Let us assume that ¾ is a complete set of

C

½

¾ C ¾

functors, and that for every functor ¾ there is a formula such

C

that the table is identical with the table . Then ½ is also a complete set of functors.

Á C C C

Let ½ and ¾ be two sets of functors. Let us assume that ¾ is a complete set of

C

½

¾ C ¾

functors, and that for every functor ¾ there is a formula such

 C

that the formula ½ ½ is a tautology. Then ½ is a complete set of functors.

Satisfiability – p.25/97 Completeness of sets of functors, cont’d

Á f: ^g is a complete set of functors

Á f: _g is a complete set of functors

Á fµg is a complete set of functors.

Á But in this last case we allowed use of ?

Á f g is complete, but use of constants needed

Á Beautiful property of ite:

Let be a and let be a variable. Then for all variables

and formulas and the equivalence

     



is a tautology.

Satisfiability – p.26/97 More on completeness

Á The set f^ _g is not a complete set of functors, even in the weak sense.

Á The set fg is not complete

Satisfiability – p.27/97 Normal Forms, starting with

Á Negation normal form, pushing negation downwards

Á rewrite rule

Á De Morgan laws as rewrite rules

Á Canonical negation normal form

Satisfiability – p.28/97 Occurrences of variables

Á Inductive definition of positive and negative occurrences

Á A variable may occur both positively and negatively in a formula

Á Canonical negative normal form preserves both positive and negative occurrences of variables

Satisfiability – p.29/97 Alternative way of getting the occurrences result

Á Treating formulas as trees

Á Counting on the unique path from the leaf to the root

Á Positive occurrrence if this number is even, odd occurrence o/w

Á Rewrite rules, when interpreted as operations on trees preserve even and odd number of occurrences on paths

Á In number of occurrences or

Satisfiability – p.30/97 cDNF, cCNF

Á Canonical disjunctive and conjunctive normal forms:

Á Four distributive rules

¯

^ _  ^ _ ^

¯

_ ^  ^ _ ^

¯

_ ^  _ ^ _

¯

^ _  _ ^ _

Satisfiability – p.31/97 Handling cDNF

Á Formula is already in cNN form

¯ if is a variable

¯ : : if is a variable

½ ½ ½ ¾ ¾ ¾

¯

_ _ _ _ _ _

Assuming ½ and

½ ¾ ½ ¾

½ ¾

¾ , define

Ï

½ ¾

^ ^

1. ½ ¾

 

½ ¾

_ _

2. ½ ¾ ½ ¾

Á For every formula in negation normal form, the formula is in

. Moreover,  .

Á (Preparing for the complete DNF).

¾

For every formula and a variable there exist two formulas ,

such that

¾

1. ,

i

 ^ _ : ^

2. The formula ½ ¾ is a tautology.

Satisfiability – p.32/97

Á Assuming in cNN form

Á if is a variable

Á : : if is a variable

½ ½ ½ ¾ ¾ ¾

Á ^ ^ ^ ^ ^ ^

Assuming ½ and

½ ¾ ½ ¾

½ ¾

¾ , define

Î

½ ¾

_ _

1. ½ ¾

 

½ ¾

^ ^

2. ½ ¾ ½ ¾

Á For every formula in negation normal form, the formula is in

conjunctive normal form. Moreover,  .

Satisfiability – p.33/97 What if only positive (negative) occurrences?

Á If a variable has only positive occurences in , f g does not have to be an autarky, but...

Á Let be a set of formulas in which a variable has only positive (resp. negative)

occurrences. Then is satisfiable if and only if [ f g (resp. [ f: g ) is

satisfiable. In other words, is satisfiable if and only if it is satisfiable by a

valuation such that (resp. ).

Á Look at the proof: it shows equivalent formulas may not have same autarkies

Satisfiability – p.34/97 Reduced Normal Forms

Á _ _ _ : _ _ :

A clause ½ ½ is a tautology if and only if for

   

some , and , ,

Á j

Given two clauses ½ and ¾ , ½ ¾ if and only if all literals occurring in ½

occur in ¾ , that is ½ subsumes ¾ .

Á Reduced CNF: no subsumption between clauses

Á Subsumption can be eliminated in polynomial time (but it still may be too much work)

Á Similar result for DNF

Á CNF machine a device to convert to

Á CNF machine as a DNF machine

Satisfiability – p.35/97 Complete Normal Forms

Á A minterm is an elementary conjunction containing one literal from each set

f : g

Á For every formula and every minterm , either the formula ^  is a

tautology, or ^ is .

Á

Given a valuation of finite set of variables, is conjunction of literals such

that

Ï

Á

¾ ÅÓ d ´ µ

Á

Each entails

Á 

For every formula , is a tautology. Up to the order of variables, and the

7!

listing of minterms the representation is unique.

Satisfiability – p.36/97 More on canonical forms

Á Minterms: just rows in the table where the value is

Á Maxclauses: clauses non-tautological clauses mentioning all variables

Á

Formula - conjunction of maxclauses entailed by

Á 

For every formula , is a tautology. Up to the order of variables, and the

7!

listing of maxclauses the representation is unique.

Satisfiability – p.37/97 Consequences for Lindenbaum Algebra

Á Equivalence classes of minterms are atoms in the Lindenbaum Algebra

Á Since there are minterms, Lindedenbaum algebra has atoms ( - number of variables)

Á Hence for finite set the Lindenbaum algebra of is a finite Boolean algebra

Á Not every finite Boolean algebra is Lindenbaum algebra

Á But if a finite Boolean algebra has atoms then it is a Lindenbaum algebra

Satisfiability – p.38/97 Other normal forms

Á Implication normal form (only implication, ? and variables)

Á Hence by adding additional variables we can reduce every formula to collection of implications

Á if-then-else normal form

Satisfiability – p.39/97 Compactness of propositional logic

Á König Lemma: an infinite, finitely splitting possesses an infinite branch

Á (Compactness Theorem) If a set of formulas is unsatisfiable then there is a



finite ¼ such that is unsatisfiable

Á Equivalently: when all finite of are satisfiable then is satisfiable

Á Constructing a tree associated with a family of clauses

Á Corollary: The operator is continuous

Satisfiability – p.40/97 Resolution

Á Clausal logic: logic where only formulas are clauses

Á Alternative approach: negation and infinitely many functors, -ary disjunctions, each with its own table

Á Such logic expresses the same theories as the full propositional logic

Á Since such disjunctions are commutative w.r.t. all permutations we treat clauses as sets of literals, no repetition

Á Fundamental operation on clauses: resolution

_ _

½ ¾

_

½ ¾

Á Resolution rule is sound

Satisfiability – p.41/97 Closure under Resolution

Á Given a set of clauses there is a least set of clauses such that

1. 

2. Whenever ½ and ¾ are two clauses in and the operation ½ ¾ is

executable and results in a non-tautological clause then ½ ¾

belongs to .

Á

Operator (in the complete lattice of subsets of the set of clauses)

[ f ¾ [

½ ¾ ½ ¾

g

and ½ ¾ is defined and non-tautological

Á

has a least fixpoint. This is the closure under resolution

Satisfiability – p.42/97 Derivations, proof-theoretic approach

Á Derivation of a clause: a labeled binary tree: leaves labeled with elements of , internal nodes labeled with resolvents

Á Proof-theorists invert those trees. Root is at the bottom

Á As every ordered tree, such trees can be represented as strings (with depth-first traversal)

Á In this way we can define proofs as sequences of clauses: 1. Conclusion of the rule application application occurs always later than

2. If a clause occurs in the sequence then it belongs to or is a conclusion of an application of resolution to earlier elements of the clause 3. The proven clause is last element of the sequence

Á Both approaches (trees, proofs) are equivalent

Á

set of clauses that have proof

Satisfiability – p.43/97 Is resolution complete?

Á Resolution alone is not complete. That is there are clauses semantically entailed, but not provable by resolution

Á : resolution does not add variables

Á Example: f _ g , _ _ . Clearly j , but the only thing we

can prove (using resolution) is the only clause in

Satisfiability – p.44/97 Minimal Resolution Consequence

Á Elements of - resolution consequences

Á Inclusion-minimal elements of - minimal resolution consequences

Á If is a resolution consequence of , then there must be minimal resolution

¼

consequence of included in

Satisfiability – p.45/97 Subsumption rule

Á Subsumption rule:

_

Á Subsumption rule is sound

Á We can define the notion of derivation (tree) using subsumption and resolution

Á We can define the the notion of proof (sequence of clauses)

Á Whatever can be proved with one can be proved with the other

Satisfiability – p.46/97 Quine theorem, completeness

Á A non-tautological clause is a consequence of a set of clauses if and only if

there is a Resolution consequence of , , such that  .

Á A non-tautological clause is a consequence of a CNF if and only if for some

minimal Resolution consequence of ,  .

Á A CNF is satisfiable if and only if ; ¾ .

Á (Quine Theorem Proof system consisting of Resolution and Subsumption rules is

complete for clausal logic. That is, given a set of clauses and a clause ,

j if and only if there exists a derivation (using Resolution and

Subsumption rules) that proves

Á We can limit the proof to admit a single application of Subsumption.

Satisfiability – p.47/97 Resolution refutation

Á Given a clause ,

: f ¾ g

Á If is a clause then : is a set of unit clauses

Á We say that follows from by Resolution refutation if the closure under

Resolution of [ : contains an empty clause (i.e. is inconsistent).

Á Let be a CNF, and let be a clause. Then j if and only if follows

from by Resolution refutation.

Satisfiability – p.48/97 The basis of resolution consequences

Á Basis of

1. 

2.

¾ 

3. forms an antichain, i.e. for ½ ¾ , if ½ ¾ then ½ ¾

4. Every element of is subsumed by some element of

Á Let be a set of clauses. Then possesses a unique basis

Á How to compute a basis w/o computing the entire ?

Satisfiability – p.49/97 Basis, cont’d

Á Start with an CNF . Due to the discussion above we can assume that is subsumption-free.

Á

Non-deterministically, select from a pair of resolvable clauses ½ and ¾ which has not been previously resolved.

Á

If ½ ¾ is subsumed by some other clause in or is a tautology, do nothing and select next pair.

Á

If ½ ¾ is not subsumed by some other clause in , do two things:

(a) Compute f ¾  g . Eliminate from all clauses subsumed

by , that is Ò

(b) Set [ f g .

Á Do this until does not change.

Satisfiability – p.50/97 Basis, cont’d

Á Two invariants:

¯ Antichain

¯ Consequences

Á This implies termination

Satisfiability – p.51/97 Another preprocessing for query ans.

Á Pruning , given :

f ¾ and can not be resolved with g

Á j if and only if j

Satisfiability – p.52/97 Davis-Putnam reduct

Á

The reduct is

f Ò f g ¾ ^ ¾ g

Á The set splits into three sets: of clauses mentioning , of clauses mentioning

and those not mentioning j j at all

Á

arises from the second and the third

Á Let be a set of non-tautological clauses, and let be a literal. Then is



unsatisfiable if and only if both and are unsatisfiable.

Á Dual form: Let be a set of non-tautological clauses, and let be a literal. Then



is satisfiable if and only if at least one of , is satisfiable.

Satisfiability – p.53/97 Free literal

Á is free for if no clause of contain

Á Let be a set of clauses. If is a free literal in then is satisfiable if and only

if is satisfiable.

Á

Moreover, if is a valuation satisfying , then a valuation defined by

´

¾ f g

satisfies .

Satisfiability – p.54/97 Semantic Resolution

Á

given. Let us fix . splits in ¼ – clauses of unsatisfied by , ½ clauses of

satisfied by

Á

If unsatisfiable then ¼ , ½ nonempty

Á Ordering variables induces order of literals in each non-tautological clauses (via ordering of underlying variables)

Á Semantic resolution rule (remember fixed) applied to an ordered pair of

clauses of

(a)

(b)



(c) are resolved on the literal largest in the ordering (i.e. highest in )

Satisfiability – p.55/97 Semantic Resolution, cont’d

Á ¡

Operator 

f ¾ _ 9 ¾ [ ^



¾ [ ^ ^ ^ g



Á

The operator  is monotone. Thus it possesses a least fixpoint.

Á



Á Completeness of semantic resolution; given , ,  , is unsatisfiable if and

;

only if  contains

Satisfiability – p.56/97 Testing satisfiability

Á Table method

Á Tableaux

Á Clausal Logic: Davis-Putnam two-phase algorithm

Á Clausal Logic: Davis-Putnam-Logemann-Loveland algorithm

Satisfiability – p.57/97 Hintikka Sets

Á No immediate (? , no contradictory atoms)

Á Standard decomposition principles for : ^ _

Á Hintikka set is always consistent

Satisfiability – p.58/97 Tableaux

Á Binary trees with nodes decorated with signed formulas

Á Tableau for a theory

Á Open and closed branches

Á Managing branches via expansion rules

Á Finished tableaux

Satisfiability – p.59/97 Fundamental tableaux theorem

Á Open branch in a finished tableau is a Hintikka set

Á Thus if the a tableau for has an open branch then is satisfiable

Á Canonical tableau for

Á is satisfiable if and only if the canonical finished tableau for has an open branch

Á is unsatisfiable if and only if the canonical finished tableau for has no open branches

Á (Completeness for tableaux). j if and only if canonical finished tableau for

[ f: g is closed

Satisfiability – p.60/97 Variable elimination

Á Operation , handling free literals

Á

Variable elimination resolution

¯ Select variable

¯ If , or if is free in ,

¯ O/w clauses without occurrence of , and clauses obtained by resolving w.r.t

, tautologies eliminated

Á

Thus has no occurrence of

Á Clauses of that have maintained separately

Satisfiability – p.61/97 Variable Elimination

Á

If satisfies then satisfies

Á We will assume that we have some heuristic function selecting a

variable from an input set of variables

Á This heuristic funtion guides variable elimination resolution

Á Decomposition of w.r.t :

¼

¯ f ¾ : ¾ g ,

½

¯ f ¾ ¾ g ,

¾

¯

f ¾ : ¾ g

Satisfiability – p.62/97 Introducing DP algorithm, part 1

Á Selection function assumed

Á h i h i h i

Three sequences: , ,

¼ ½

¯

[

¼ , ¼ Î aÖ , ¼ , ½ ¼

F ¼ ¼ ¼

¼

¯

;

If , halt.

j

¼ ½

¯

[

O/w Î aÖ , ,

F

j

·½

j

Á ; f;g

Possible outcomes: ½ or ½

Ë

Á

In the latter case is unsatisfiable because is included in

Á We can stop at any moment once ; computed

Satisfiability – p.63/97 Going back, part II of DP algorithm

Á We assume part I did not return the string “input theory unsatisfiable"

Á

is empty. Why?

Á Two possible rasons:

¯ The last variable selected occurred either positively in all clauses or negatively in all clauses

¯ All we produced during the resolution w.r.t last variables were

tautologies, so ½ is empty

Ò ½

Satisfiability – p.64/97 Going back, part II of DP algorithm, cont’d

Á The idea: construct a sequence of partial valuations, going backwards

Á

This partial valuation defined on all variables occurring in ½ and nothing else

Á

Base Case 1. ½ free in ½ . We set ½ , all other variables still

occurring in ½ zeroed (but we do not have to do so, b.t.w.)

Á :

Base Case 2. ½ free in ½ . We set ½ , all other variables still

occurring in ½ zeroed (but we do not have to do so, b.t.w.)

Á

Base case 3. Some occurrences of ½ in ½ positive, some negative. Tricky!

Satisfiability – p.65/97 Going back, part II of DP algorithm, cont’d

Á Inductive case

Á Reduct w.r.t. a partial valuation - eliminating clauses that are already satisfied, eliminating literals that can not be used for satisfaction

Á 

Inductive assumption is that we satisfied all layers , with a

valuation

Á

Goal: Satisfy ½

Á

We reduce ½ by current . Variables of current no longer occur in the reduced CNF

Á We define an extension of current to new so that is defined on all

variables of ½ , and those occurring in later and nothing else. How?

Satisfiability – p.66/97 Going back, part II of DP algorithm, cont’d

Á Four, not three cases possible

¯

Reduct is empty. That is all clauses in ½ already satisfied. We zero

any variable occurring in ½ but not in current

¯

Literal ½ is free in the reduct. We set the value of ½ to , zero all other variable

¯

:

Literal ½ is free in the reduct. We set the value of ½ to , zero all other variable

¯

½ occurs both positively and negatively in ½ . We proceed similarly to case 3 of base

Á Proof of correctness of this procedure

Satisfiability – p.67/97 Wrapping up DP

Á The DP algorithm is complete. That is, if is a set of clauses, and

¡ is a selection function, then:

1. If is satisfiable then the DP algorithm returns on the input and

the selection function a valuation satisfying

2. If is unsatisfiable, then the DP returns the string ‘input formula unsatisfiable’.

Á In the second phase we have plenty of leverage, we do not have to use anything already computed, but can plug in other partial valuations, as long as they satisfy the rest

Satisfiability – p.68/97 The tree of partial valuations

Á We assume a finite set of clauses

Á We arrange partial valuation in a search tree (i.e. label full binary tree - but see below - with partial valuations)

Á We assume that, like in DP algorithm we have a heuristic function ¡ that

assigns to a partial valuation a variable outside the domain of (providing

6

)

Á [ f g

Then node has two children: ¼ , ½ . The first one labeled by ,

the other labeled by [ f: g

Satisfiability – p.69/97 Pruning, BCP

Á Given a set of literals

f _ _ _ ¾ ¾ g

There is ½ ½

Á ¡ is a monotone operator in the complete lattice of sets of literals

Á is the least fixpoint of the operator ¡

Á Proof-theoretic representation of BCP, unit resolution.

Á Both approaches equivalent

Satisfiability – p.70/97 DPLL algorithm

Á Let be a CNF. Then is satisfiable if and only if consistent and the

reduct of w.r.t. is satisfiable

Á An obvious observation: Given a CNF , is satisfiable if and only if [ f g

is satisfiable or [ f: g is satisfiable

Á If is the reduct of by means of then ;

Á But often it may happen that ; but [ f g 6 ;

Á DPLL: systematic backtracking search of the tree of partial valuations, with BCP as a pruning algorithm and user-provide selection function

Á DPLL is complete

Á Improvements to DPLL

Satisfiability – p.71/97 Craig Lemma

Á Given a valid implication µ , an interpolant is any formula such that both

µ and µ are valid

Á Craig Lemma: Given a valid implication µ , there is an interpolant so that

variables in occur both in and in

Á Stronger form will be shown

Á Recent reports of the use of Craig Lemma in Bounded Model Checking

Satisfiability – p.72/97 Few lemmas etc.

Á _ _ µ

If is DNF, ½ then is a tautology if and only if for all

  µ

, , is a tautology

Á j

If is an elementary conjunction and set of variables, then is the result

of eliminating from literals based on variables not in

Á Let be a noncontradictory elementary conjunction, let be an arbitrary

µ j µ

formula. Then is a tautology if and only if Î aÖ is a tautology

³

Á µ _ _

Thus, assuming is a tautology, ½ a DNF, all non-contradictory. Then

j _ j µ

½ Î aÖ Î aÖ

³ ³

is a tatutolgy

Satisfiability – p.73/97 Craig Lemma

Á For every formula , the formula

_ _ µ j _ _ j

½ ½

Î aÖ ´ µ Î aÖ ´ µ

is a tautology.

Á If µ is a tautology, then there exists a formula such that

 \ and such that both µ and µ are tautologies

Satisfiability – p.74/97 Improving interpolant

Á If is a formula with only positive occurrences of variable then there are two

formulas: ½ and ¾ with no occurrence of so that

¸ ^ _

½ ¾

is a tautology

Á If is a formula with only negative occurrences of variable then there are two

formulas: ½ and ¾ with no occurrence of so that

¸ : ^ _

½ ¾

is a tautology

Satisfiability – p.75/97 Eliminating literals

Á ^ ^ µ

Assume that ½ is a tautology, and ½ does not occur in . Then

^ ^ µ

¾ is a tautology

Á Let be an noncontradictory elementary conjunction, and let us assume that

¼

µ is a tautology. Let be the conjunction of those literals in which

¼

occur in . Then µ is a tautology

Á (Craig Lemma, strong form) If µ is a tautology then there is an interpolant

with the property that whenever a variable occurs in then it occurs in (and

also in ) with the same polarities.

Satisfiability – p.76/97 Is DNF in predecessor needed?

Á Of course not, if we have CNF of the consequent we can do the same

Á We can either transform µ into : µ : and use the previos technique, or prove analogous lemmata for CNF in the consequent

Á We can also compute a "canonical candidate for interpolant”

Satisfiability – p.77/97 Satisfaction for positive and negative formulas

Á Formula is positive if it has no negative occurrences of variables

Á Formula is negative if it has no positive occurrences of variables

Á Valuation ½ satisfies positive formulas and so sets of positive formulas are satisfiable.

Á Valuation ¼ satisfies negative formulas and so sets of negative formulas are satisfiable.

Satisfiability – p.78/97 Satisfying Horn formulas

Á A : at most one positive literal

Á Basic classification of Horn clauses

¯ facts

¯ program clauses

¯ constraints

Satisfiability – p.79/97 Horn theories and families closed under intersection

Á A family F of sets is closed under intersections if for every nonempty Y , Y  X ,

Ì

Y belongs to X

Á Families of sets closed under intersections appear all over CS and Mathematics

Á We will use representation of valuations as sets of variables

Á Let be a finite set of atoms and let Ë  È be a nonempty family of sets.

Then Ë is of the form for some collection of Horn clauses over if

and only if Ë is closed under intersections.

Satisfiability – p.80/97 Program clauses and constraints

Á Program clause: Horn clause with exactly one positive literal

Á Constraint clause: Horn clause with no positive literals

Á CNFs consisting of program clauses are satisfiable

Á CNFs consisting of program clauses has a least model

Á CNFs consisting of constraint clauses are satisfiable

Satisfiability – p.81/97 Model existence for Horn theories

Á

Each Horn theory decomposes into program part ½ and constraint part ¾

Á

If is Horn, then is satisfiable if and only if least model of ½ satisfies ¾

Á

Associating an operator with the Horn program

Á

is monotone and continuous (regardless of the size of )

Á

Least model of the Horn program coincides with the least fixpoint of

Satisfiability – p.82/97 Representability of monotone operators

Á If is finite then for every monotone operator in È there is program

such that

Á Dowling-Gallier algorithm for computation of least model of for programs

Á Testing satisfiability of Horn in linear time

Á Completeness of unit resolution for querying the least model of Horn theory

Satisfiability – p.83/97 Dual Horn formulas

Á Dual Horn clause – at most one negative literal

Á Permutation

Á Permutation is consistent and transforms Horn formulas to dual Horn and conversely

Á j if and only if Ò j

Á is complement operation

Á acts on families of sets, and transforrms families closed under intersections to families closed under unions

Satisfiability – p.84/97 Dual Horn formulas

Á Various results on Horn theories are lifted to dual-Horn case

Á BUT: operator associated with dual-Horn theories is monotone

Á There is largest fixpoint, and this is the largest model of

Á Unit resolution complete for dual-Horn theories, but now one of inputs can be required to be negative literal c

Satisfiability – p.85/97 Krom formulas, 2SAT

Á 2-clause, or Krom clause, a clause with at most two literals

Á The set of 2-clauses is closed under resolution

¾

Á There is 2-clauses

Á Thus in DP the space used by the algorithm (and thus time) is bounded by polynomial

Á DP solves the satisfiability problem for sets of 2-clauses in polynomial time (but we will see better performance)

Satisfiability – p.86/97 A closure property of sets of 2-clauses

Let be a 2-CNF, and let be a literal such that ¾ . Let

[ f g

, and let ½ . Then:



1. ½

2. If is consistent then: is consistent if and only if ½ is consistent

3. If is consistent then a satisfying valuation for can be computed from and a

satisfying valuation for ½ in linear time.

Satisfiability – p.87/97 BCP and 2-SAT

Á \ 6 ;

A partial valuation touches clause if

Á If consists of 2-clauses then for every literal , if [ f g is

consistent then satisfies every clause in which touches

Á If consists of 2-clauses then is satisfiable if and only if for every literal , at

least one of [ f g , [ f g is satisfiable

Á Autarkies for Krom formulas

Satisfiability – p.88/97 G

The graph F

Á After initialization the resulting formula is a subset of and each clause has exactly 2 literals

Á

Vertices of : Literals of

Á _

Edges of : whenever belongs to , generate two edges: ,

Á

is a directed graph

Satisfiability – p.89/97 Strong components and 2-CNF

Á A strong component of a directed graph: for every ¾ , 6 , there is a

directed cycle containing both and

Á

If are in same strongly connected component of then

[ f g [ f g

Á a 2-CNF, all clauses of length . Then is satisfiable if and only if no strong

connected component of contains a pair of dual literals

Á Complexity of testing satisfiability of 2-CNF

Satisfiability – p.90/97 Renameable variants of classes of formulas

Á Given C , a class of CNFs, renameable C , all formulas which can be obtained from

formulas of by consistent permutations of literals

Á Shift permutation: does not change underlying variable, may only change sign

Á is renameable Horn if for some renaming , is Horn, thus if for some

shift , is Horn

Satisfiability – p.91/97 Describing shift permutations

Á There is a one-to-one correspondence between shift permutations and sets of

atoms of the form

Á Representing shifting into Horn clauses Given a clause

_ _ _ : _ _ :

½ ½

Define a collection of 2-clauses consisting of three groups:

_  

Group 1. ,

: _ :  

Group 2. ,

: _    

Group 3. , , .

Satisfiability – p.92/97 Carrying on shifting

Ë

Á

¾

Á

is 2-CNF

Á

There is a one-to-one correspondence between valuations satisfying and shifts of F into a Horn CNF

Á Testing if is renameable Horn is polynomial, in fact quadratic in

Á is renameable Horn if and only if it is renameable dual Horn

Satisfiability – p.93/97 Linear formulas

Á Operation ¨ , a.k.a. XOR

Á Ä Ç Ç hB ¨ ^ ? >i Z

The structure is a field, called ¾

Á >

Linear equation over that field: formula in ½ and possibly

Á Z

Special form of Gauss-Jordan elimination over ¾ – add it!

Á Issues with the number of equations

Á Triangular form of a set of equations (first pass, Gauss)

Á Substitute (second pass, Jordan)

Satisfiability – p.94/97 All you need is 3-CNF

Á 3-clauses

Á With additional variables (linear number of variables) we can reduce to 3-clauses.

Specifically: for every finite set of formulas there is a set of 3-clauses such



that , contains a special variable and there is a

one-to-one correspondence between satisfying valuations for and satisfying

valuations for that evaluate as

Satisfiability – p.95/97 Combinatorial circuits

Á Treating a set of formulas as an input-output devise

Á Acyclic digraphs with at most two parents per node

Á Inputs and outputs

Á Circuit representing a collection of formulas (one output per formula)

Á 3-CNF representation of a circuit

Satisfiability – p.96/97 Some complexity issues

Á The problem SAT (i.e. the language consisting of satisfiable formuals) is NP-complete (proof in the notes, via coding of accepting computations of Turing machines where the length of operation is bounded by a fixed polynomial in the length of the input)

Á Thus, the problem UNSAT is co-NP-complete

Á By our reduction, the problem 3-SAT (satisfiability of the sets of clauses consisting of 3-clauses) is also NP-complete

Á Thus, the problem 3-UNSAT is also co-NP-complete

Á All nontrivial combinations of “easy” classes considered in this lecture also result in NP-complete classes (for instance: unions of Horn and dual-Horn are NP-complete)

Á But there is plenty of other “easy classes”

Satisfiability – p.97/97