practicalsat solving · 2 16.07.2019 lectureoutline derandomizinglocalsearch sat upperbounds...
TRANSCRIPT
KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association
Institute for Theoretical Computer ScienceResearch Group “Verification meets Algorithm Engineering”
www.kit.edu
Practical SAT Solving
Lecture 13
Carsten Sinz, Tomas Balyo | July 16, 2019
2 16.07.2019
Lecture Outline
Derandomizing Local SearchSAT Upper BoundsCovering Codes
Carsten Sinz, Tomas Balyo – SAT Solving
3 16.07.2019
Repetition: Local Search
Carsten Sinz, Tomas Balyo – SAT Solving
4 16.07.2019
Open questions
How often should the inner/outerloop be repeated?How good are the chances to find a satisfying assignment?Can the algorithm be modified toprove unsatisfiability?Is there a general upper bound fordeciding SAT that is better than2n?
Carsten Sinz, Tomas Balyo – SAT Solving
5 16.07.2019
Complexity of k-SAT: Upper Bounds
Source: Iwama&Tamaki: Improved Upper Bounds for 3-SAT (2003)
Carsten Sinz, Tomas Balyo – SAT Solving
6 16.07.2019
Algorithm of Dantsin et al.Maybe[Assignment] Local-Search(ClauseSet S){
for i = 1 to MAX_TRIES doα = random-assignmentfor j = 1 to MAX_FLIPS do
if α satisfies all clauses in S return αchoose variable x to flipflip x
return Nothing}
Variant of local search algorithmus (as above)Input: Formula in k-CNF with n variables.
Idea:1. Make inner loop deterministic: systematically check all
assignments in the „neighborhood“ of α.2. Choose starting assignment α in outer loop deterministically.
Carsten Sinz, Tomas Balyo – SAT Solving
7 16.07.2019
Idea 1: Hamming Ball Algorithm
Hamming distance between two assignments α, β:Def.: d(α,β) := |{x | α(x) ≠ β(x)}|Ex.: α=(0,1,1,0,0), β=(1,0,1,0,1), d(α,β) = 3
Hamming ball of radius r around α:Def.: H(α,r) := { β | d(α,β)≤r }
Volume V(r) of the Hamming ball: (given n variables, i.e. assignments are vectors of length n):
Define normalized radius ρ := r/n (i.e. 0≤ρ≤1)
independent of α.𝑉 𝑟 ≔ 𝐻 𝛼, 𝑟 =()*+
,𝑛𝑖
Carsten Sinz, Tomas Balyo – SAT Solving
8 16.07.2019
Illustration: Hamming Ball
Example: n=4
(0011) (1100)
(0000)
(0001) (0010) (0100) (1000)
(1111)Ball around α=(0001)with radius 1 und radius 2.
Carsten Sinz, Tomas Balyo – SAT Solving
9 16.07.2019
Hamming Ball Algorithm
Known approximation of the Hamming ball volume (frominformation theory, Shannon) for 𝜌 ≤ 1/2:
where(Entropy function; log = logarithm for base 2).I.e.: V(ρn) ≈ 2h(ρ)n (within polynomial factor)
18𝑛𝜌(1 − 𝜌)
28 9 : ≤ 𝑉(𝑟) ≤ 28 9 :
ℎ 𝜌 ≔ − 𝜌 log 𝜌 − (1 − 𝜌 )log(1 − 𝜌)
Carsten Sinz, Tomas Balyo – SAT Solving
10 16.07.2019
Search in Hamming BallMaybe[Assignment] HB-Search(α,r){
if(α ⊨ F) then return αif (r = 0) return Nothingchoose C=(L1∨...∨Lk) with α(C)=0for i = 1 to k do
αi = α with α(Li)=1β = HB-Search(αi, r-1)if(β ≠ Nothing) return β
return Nothing}
Run time HB-Search: kr
Note: kr can be considerably smaller than V(r).E.g.: k = 3, r = n/2:V(r) = 2n-1, kr = 3n/2 ≈ 1.7321n
Carsten Sinz, Tomas Balyo – SAT Solving
11 16.07.2019
Search in Hamming Ball
HB-Search provides simple deterministic algorithm for 3-SAT:
Execute two HB searches around α0=(0,...,0) and α1=(1,...,1) withradius n/2.Runtime (as seen): 1.7321n
Can we improve that?Idea: Choose radius r = ρn with ρ<1/2.Of course, more than two starting points for α in the outer loop areneeded then.
Carsten Sinz, Tomas Balyo – SAT Solving
12 16.07.2019
Probabilistic Variant of HB LS AlgorithmMaybe[Assignment] Local-Search-HB-Prob{
for i = 1 to w doαi = random-assignment
β = HB-Search(αi, ρ⋅n)if(β ≠ Nothing) return β
return Nothing}
Choose αi uniformly and independently at random from the 2n
possibilities, w iterations.Runtime: w⋅kρn.Goal: Choose w and ρ such that (a) error probability is neglectablysmall and (b) runtime is optimized.
Carsten Sinz, Tomas Balyo – SAT Solving
13 16.07.2019
Probabilistic Algorithm: Error Probability (I)
Only possible error: F satisfiable, algorithm doesn’t find a satisfyingassignmentAssumption: F satisfiable, α ⊨ F.HB-Search(αi, ρn) finds α, if α∈H(αi, ρn).Probability for that: V(ρn)⋅2-n
With Shannon approximation V(ρn) ≈ 2h(ρ)n: probability approx. 2h(ρ)n⋅2-n = 2h(ρ)n-n = 2-(1-h(ρ))n
Probability that α is not found in w iterations:
(with approximation 1+x ≤ ex for all x)
1 − 2B CB8 9 : D≤ 𝑒BDFGH IHJ K L
Carsten Sinz, Tomas Balyo – SAT Solving
14 16.07.2019
Error Probability and Runtime Optimization
Probability that α is not found in w iterations:
(with approximation 1+x ≤ ex for all x)If error shall be below e-c: iterations needed.Runtime thus: (within polynomial factor):
(*)(with def. entropy: )Minimize runtime by differentiating (*) w.r.t. ρ and solving for ρ.Result: ρ = 1/(k+1).Substituing that in (*) provides runtime:
Carsten Sinz, Tomas Balyo – SAT Solving
1 − 2B CB8 9 : D≤ 𝑒BDFGH IHJ K L
𝑤 F 𝑘9: ≈ 2 CB8 9 F 𝑘9:= 2 F 𝜌9 F (1 − 𝜌)(CB9)F 𝑘9 :
ℎ 𝜌 = − 𝜌 log 𝜌 − (1 − 𝜌 )log(1 − 𝜌)
15 16.07.2019
Result for Probabilistic Algorithm
Runtime:
Base for small values of k:
Next step: Derandomize this algorithm (i.e. outer loop)
k 3 4 5 6 72k/(k+1) 1.5 1.6 1.66667 1.71429 1.75
Carsten Sinz, Tomas Balyo – SAT Solving
16 16.07.2019
Covering Codes
Derandomization: Deterministic algorithm for selecting startingassignments αi.Definition: A set C of assignments is a covering code of radius r, if foreach assignment α: α∈H(γ,r) for at least one γ∈C.Example:
Covering code ofradius 1.
Carsten Sinz, Tomas Balyo – SAT Solving
17 16.07.2019
Construction of Covering Codes
Problem is a special case of SET-COVER:
Given: Set S and family F ⊆ 2S of subsets of S
Wanted: Subset C ⊆ F, which covers S, i.e.,
Goal: Minimize |C|
Greedy algorithm provides log|S|-approximation for SET-COVER
Carsten Sinz, Tomas Balyo – SAT Solving
18 16.07.2019
Construction of Covering Codes
Problem is a special case of SET-COVER:
Given: Set S and family F ⊆ 2S of subsets of S
Wanted: Subset C ⊆ F, which covers S, i.e.,
Goal: Minimize |C|
Greedy algorithm provides log|S|-approximation for SET-COVER
Set of all possibleassignments α
Hamming balls ofradius r
Hamming balls chosen bythe algorithm
Carsten Sinz, Tomas Balyo – SAT Solving
19 16.07.2019
Greedy algorithm for SET-COVER1. Set C=∅ .2. As long as there are not-covered elements in S:
a) Choose c ∈ F, covering largest number of yet not-coveredelements from S.
b) Add c to C.3. If ∪C = S, then C is a solution; otherwise none exists.
Known:Result of greedy alg. is log|S|-approximation for SET-COVER, i.e.. |C| ≤ log|S|⋅|C*|, where C* is optimal solution.(in our case: |S|=2n, i.e. log|S| ∈ O(n))
Needed for approximation of |C|:Upper bound for C*
Carsten Sinz, Tomas Balyo – SAT Solving
20 16.07.2019
Upper Bound for C*
Obviously, for all covering codes C (for a given radius r) the followingholds: 𝐶 ≥ TGL
U(,).Next lemma: optimal code is at most by a factor of n larger.
Carsten Sinz, Tomas Balyo – SAT Solving
21 16.07.2019
Lemma: Size of Optimal Covering Code
For all n and r = ρn with 0≤ρ≤1/2, there is a covering code for radius r
of size .
Proof: probabilistic methodA randomly selected set of s assignments is with high probability a covering code. Thus, in particular, such a code must exist.
Carsten Sinz, Tomas Balyo – SAT Solving
𝑠 ≔ 𝑛 F 8𝑛𝜌(1 − 𝜌) F 2 CB8(9) :
22 16.07.2019
Proof of Lemma
β fixed assignment, α selected at random.Then: β∈H(α,r) with probability V(r)/2n.C: set of s independently selected random assignments.Then: Probability that β is not covered by C:
In total: probabilty that C is covering code:≥ (approaches 1 for n → ∞)
(with approximation 1+x ≤ ex for all x,
and )
Carsten Sinz, Tomas Balyo – SAT Solving
1 −𝑉(𝑟)2:
W
≤ 𝑒BWU(,)GL ≤ 𝑒
BW GJ K HI L
X:9(CB9) ≤ 𝑒B:
𝑉(𝑟) ≥28 9 :
8𝑛𝜌(1 − 𝜌)𝑠 = 𝑛 F 8𝑛𝜌(1 − 𝜌) F 2 CB8 9 :
23 16.07.2019
Analysis of the Greedy Algorithm
Optimal code: |C*| ≤ sGreedy algorithm:
|C| ≤ O(n)⋅s = O((5/2)n)⋅2(1-h(ρ))n
Runtime of greedy algorithm: 23n (without proof)Result: |C| ok, but runtime of SET-COVER algorithm too high!Idea:
Reduce runtime by allowing increased |C|.
Carsten Sinz, Tomas Balyo – SAT Solving
24 16.07.2019
Block Codes
Idea:Let C be a covering code of radius r for n variablesObtain covering code Cd of radius d⋅r for d⋅n variables by repeatingcovering code C for d times
Example:
d=4, |C|=3: covering code for 4n variables with |C|4 elements.In general:
Block code Cd has size |C|d and radius r⋅d.
× ××
Carsten Sinz, Tomas Balyo – SAT Solving
:
25 16.07.2019
Deterministic Hamming-Ball Algorithm
Choose d=6 and use block code C6.Generate covering code C for n/6 variables with radius ρn/6 usinggreedy SET-COVER algorithm
Runtime: 23n/6 ≤ 1.414n
Size of covering code C6:
Same as non-blockcode, ignoring polynomial factor
Complete run time of algorithm:1. Generating covering code: O(1.414n)
(once befoe start of Hamming-ball search)2. Hamming-ball search with radius r = n/(1+k): O(2k/(k+1))n
--> The latter dominates for k>=3, thus: O(2k/(k+1))n (i.e. same run-time asprobabilististic algorithm, e.g. 1.5n for 3-SAT)
Carsten Sinz, Tomas Balyo – SAT Solving
𝑂𝑛6
[/GF 2 CB8 9 :
\
\
= 𝑂(𝑛C[) F 2 CB8 9 :
26 16.07.2019
Further Improvements
Hamming-ball search can also be done in time 2.848r (instead of 3r). Refined algorithm: Dantsin et al., 2002.
Therefore:Run-time of 1.481n for determinististic 3-SAT algorithm (best upper bound for determinististic 3-SAT so far)
Carsten Sinz, Tomas Balyo – SAT Solving