Outline
- Finish Up SAT Algorithms
- Deterministic Time Hierarchy Theorem
- Quiz
- Nondeterministic Time Hierarchy Theorem
General SAT Algorithms
- So far we've looked at SAT-solvers that work for specific special cases. We now turn our attention to general purpose SAT solvers.
- There are two important classes of such solvers:
- The first of these are based on the DPLL algorithm (Davis, Putnam, Logemann, and Loveland, 1962).
- The second class of solvers is based on a randomized algorithm called PPSZ (Paturi, Pudlak, Saks, Zane, 2005). We won't cover the class much except to say that PPSZ does a single pass through the variables, checks for each variables if its value has been implied by the clauses after the previous assignments. If yes, assign accordingly, otherwise pick the variables value at random. The paper shows that if a formula has a unique satisfying assignment the odds this algorithm will find it are `Omega(1.3071^-n)`.)
More on DPLL
DPLL tries to either find a refutation from a set of clauses or find a satisfying assignment. One way to do this would be in a loop to consider all pairs of clauses and resolve them against each other and see if one got any new clauses. If find empty clause halt and output 0. If generated new clauses, repeat. Else output 1 (in this case we can actually find an assignment).
DPLL tries to optimize this. In our discussion sometimes we will use the word model to mean assignment.
It performs the following three optimizations over the basic resolution algorithm and creates an partial assignment as it goes:
- Early Termination: If in our partial assignment so far, we have made at least one literal in each clause true, then we know the whole statement must be satisfied. So we can stop and output satisfiable given the assignment we have so far. Also, if under the partial assignment, we find some clause in which all the variables are mapped to false, then it stops and outputs false. This case implies a refutation exists.
- Pure symbol heuristic: A pure symbol is a symbol that always appears with the same sign in all clauses. For example, in `{A, bar(B)}`, `{bar(B), bar(C)}`, and `{C, A}`, both `A` and `B` are pure and `C` is impure. Setting a pure symbol's literal so as to make it true can never a clause false. In this case, we can set `A` true and `B` false and not affect the validity of our clauses. This causes the first two clauses to be true so we can remove them from our set of clauses to consider, leaving `{C, A}` since `A` has been set to true this is really just the clause `{C}`. For this one clause `C` is pure so we can set it true, completing a model.
- Unit Clause Heuristic: A unit clause is a clause with just one literal. For DPLL, it can also be clause in which all variables but one have been assigned. There is one truth assignment which can make a unit clause true. So we make this assignment. This might generate more unit clauses. So we then iterate until no more unit clauses derived.
DPLL Algorithm
function DPLL-Satisfiable?(clauses) returns true or false
input:clauses := the set of clauses in the CNF formula
symbols := a list of literals that appear in clauses
return DPLL(clauses, symbols, {})
function DPLL(clauses, symbols, model) returns true or false
if every clause in clauses is true in model then return true
if some clause in clauses is false in model then return false
P, value := FIND-PURE-SYMBOL(symbols, clauses, model)
if P is non-null then return DPLL(clauses, symbols - P - bar{P}, model ∪ {P=value})
P, value := FIND-UNIT-CLAUSE(clauses, model)
if P is non-null then return DPLL(clauses, symbols - P - bar{P}, model ∪ {P=value})
P := CHOOSE(symbols); //symbols is a list, CHOOSE gets some literal in the list into P
rest = REST(symbols, P); //all the elements in the list excluding P
return DPLL(clauses, rest, model ∪ {P=true}) or
DPLL(clauses, rest, model ∪ {P=false})
Conflict Driven Clause Learning
- The key part of the previous algorithm, the secret sauce of modern SAT solvers, is how to implement CHOOSE(symbols).
- In addition, to determining how to do this, modern SAT solvers typically, add new clauses to the set of clauses as the algorithm proceeds.
- One way to do this is called conflict driven clause learning (CDCL): whenever we need to backtrack in the above procedure we add a clause to our list of clauses which would be falsified by the assignment that caused the backtrack.
- If CDCL is used, there are several common heuristics for how CHOOSE is implemented, the most popular of which is VSIDS (Moskewicz et al 2001), variable state independent decaying sum.
- VSIDS is defined as follows:
- Each literal has a counter, initialized to 0
- When a clause is added to the set of clauses, the
counter associated with each literal in the clause is
incremented. The counter keeps track of how often
the literal is used.
- The unassigned literal with highest counter is chosen
at each decision point.
- Ties are broken by random choice.
- All counters are divided by a constant, periodically.
- Notice this is randomness in the above. Different random choices could result in substantially different amounts of time to find a satisfying assignment (as more or less backtracking might be needed).
- Many modern solvers will have a restart policy which, if the current random choices do not seem to be resulting if finding an assignment, ditch all the work so far and restart the algorithm from scratch.
- Many modern solvers also have a clause deletion policy which deletes the learned clauses at regular intervals.
- It can be shown for unsatisfiable formulas that CDCL provers run in polynomial time in the shortest resolution refutation
of that formula. (Pipatsrisawat Darwiche 2011).
- Unfortunately, Haken 1985 showed that for `m>n` clauses, `PHP_n^m` expressing that m pigeons cannot be placed into n holes without two pigeons ending up in the same hole requires resolution refutations of size `2^{Omega(|PHP_n^m|)}`
- Beame Pitassi 1996 actually show that if you pick a random, n-variable 3-CNF of `n^{8/7 - epsilon}` clauses
(by our earlier observation this will almost surely be unsatisfiable), that it almost surely requires resolution refutations of size bigger than `2^{Omega(n)}`.
Hierarchy Theorems
- Up till now, we have shown some inclusions between complexity classes such as
`P subseteq NP subseteq EXP subseteq NEXP`. We have not shown any class is strictly contained in another.
- Today, we are going to do just that.
- We will first present a classic result of Hartmanis and Stearns (1965) that shows `P ne EXP`.
- Then we prove a nondeterministic variant due to Cook (1972).
- Both of these proofs make use of the technique of diagonalization, which we have previously used to show our first
undecidability results.
Time Hierarchy Theorem
Theorem. If `f`, `g` are time-constructible functions satisfying `f(n)log f(n) = o(g(n))`, then
`DTIME(f(n)) stackrel(subset)(ne) DTIME(g(n))`.
Proof. We prove the simpler statement `DTIME(n) stackrel(subset)(ne) DTIME(n^(1.5))` and indicate how to modify the proof
to the general result.
Consider the Turing Machine `D` which computes: "On input `x`, run for `|x|^(1.4)` steps the UTM `U` that simulates the execution of `M_x` on `x`. If `U` outputs some bit `b in {0, 1}` in this time, then output the opposite answer. Else output `0`." Recall `M_x` is the machine represented by the string `x`.
Given its definition, `D` halts after at most `n^(1.4)` steps. So it is decided within time `n^(1.5)`. Let `L` be the language of `D`. We claim that `L !in DTIME(n)`. For contradiction's sake, assume there is some TM `M` and constant `c` such that TM `M`, given any input `x \in{0, 1}^star`, halts within `c|x|` steps and outputs `D(x)`...
Time Hierarchy Theorem (proof cont'd)
The time to simulate `M` by the UTM `U` on every input `x` is at most `c' c |x|log |x|` for some number `c'` that depends on the alphabet size and number of tapes and states of `M`, but is independent of `|x|`. There is some number `n_0` such that `n^(1.4) > c' c n log n` for every `n > n_0`. Let `x` be a string representing `M` whose length is at least `n_0` (such a strings exists since `M` is represented by infinitely many strings). Then `D(x)` will obtain `b=M(x)` within `|x|^(1.4)` steps, but by the definition of `D`, we have `D(x) = 1 -b ne M(x)`. Thus, giving a contradiction.
The proof of the general case for `f` and `g` is similar and uses the observation that the slowdown of the simulating machine `U` is at most
logarithmic. Showing the general case is the first problem of HW3.
Quiz
Which of the following statements is true?
- The argument we used to show if `EXP != NEXP` then `P!=NP` can be modified to show if `DTIME(2^{kn}) != NTIME(2^{kn})` then `P!=NP`.
- We showed 2-SAT is NP-complete.
- We showed that for a clause to variable ratio greater than 6, a random CNF formula was equally likely to be satifiable as unsatisfiable.
The Nondeterministic time Hierarchy Theorem
The analogous result to the last, but for NDTM's, is the following:
Theorem. If `t_1` and `t_2` are time-constructible functions and `t_1(n+1) = o(t_2(n))` then `NTIME(t_1(n))` is strictly contained in `NTIME(t_2(n))`.
This kind of result was first proved by Cook (1972), then improved by Seiferas, Fischer and Meyer(1973) and simplified by Zak (book's proof). The version we are giving is due to Fortnow and Santhanam (2010).
Proof. Let `M_1, ...` be an enumeration of nondeterministic Turing machines. We define a nondeterministic machine `M` that acts as follows on input `w=1^i01^m01^k`:
- If `k < m^{t_1(m)}` then simulate `M_i` on input `1^i01^m01^{k+1}` for `t_2(|w|)` steps. If `M_i` hasn't halted then accept.
- If `k = m^{t_1(m)}` then accept iff `M_i` rejects input `1^i01^m0` in `t_2(|w|)` steps on all computation paths. Notice `1^i01^m01^{m^{t_1(m)}}` is exponentially longer than `1^i01^m0`, so we can check all paths of `1^i01^m0` deterministically in the length of the input.
This machine uses time `O(t_2(n))`. If `NTIME(t_1(n))= NTIME(t_2(n))` then there is an equivalent machine to M, `M_i`, that uses time `O(t_1(n))`.
Since `t_1(n+1)=o(t_2(n))` we have for sufficiently large `m`,
`1^i01^m0 in L(M)=L(M_i) iff 1^i01^m01 in L(M)=L(M_i) iff ...`
` iff 1^i01^m01^{m^{t_1(m)}} in L(M)=L(M_i) iff M(1^i01^m0)` rejects a contradiction.