63
The Art of Computer Programming 7.2.2.2 Satisfiability p.47-76 VOLUME 4 FASCICLE 6

TAoCP 7.7.7.2 Satisfiability の輪読

Embed Size (px)

Citation preview

Page 1: TAoCP 7.7.7.2 Satisfiability の輪読

The Art of Computer Programming

7.2.2.2 Satisfiability p.47-76

VOLUME 4 FASCICLE 6

Page 2: TAoCP 7.7.7.2 Satisfiability の輪読

Random satisfiability.

Deviations from randomness in combinatorial algorithms often have a dramatic effect, while methods of sorting and searching generally stay reasonably close to their expected behavior.

How many random clauses of 3SAT on 𝑛𝑛 variables before they can't all be satisfied?

p.47

Page 3: TAoCP 7.7.7.2 Satisfiability の輪読

1 2 3 4 5 6 7 8 9

𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3, 𝑥𝑥4, 𝑥𝑥5

¬𝑥𝑥1 ∨ ¬𝑥𝑥2 ∨ ¬𝑥𝑥3 ∧ 𝑥𝑥1 ∨ ¬𝑥𝑥4 ∨ ¬𝑥𝑥5 ∧ 𝑥𝑥3 ∨ 𝑥𝑥4 ∨ 𝑥𝑥5 random 𝑘𝑘-SAT

{{9, 4, 3}, {5, 9, 3}, {8, 4, 3}, {6, 8, 3}, {1, 6, 8}, {1, 6, 7}, {1, 5, 9}, {1, 5, 7}, {9, 2, 4}, {5, 9, 2}, {8, 2, 4}, {6, 8, 2}, {7, 2, 4}, {6, 7, 2}, {5, 7, 2}}

satisfiable cell allocations

{{1, 1, 0, 1, 1}, {1, 1, 0, 1, 0}, {1, 1, 0, 0, 1}, {1, 0, 1, 1, 1}, {1, 0, 1, 1, 0}, {1, 0, 1, 0, 1}, {1, 0, 1, 0, 0}, {1, 0, 0, 1, 1}, {1, 0, 0, 1, 0}, {1, 0, 0, 0, 1}, {0, 1, 1, 1, 0}, {0, 1, 1, 0, 1}, {0, 1, 1, 0, 0}, {0, 1, 0, 1, 0}, {0, 1, 0, 0, 1}, {0, 0, 1, 1, 0}, {0, 0, 1, 0, 1}, {0, 0, 1, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}

satisfiable boolean vectors

possible 𝑁𝑁clauses

2𝑘𝑘𝑛𝑛𝑘𝑘

𝑘𝑘 = 3,𝑚𝑚 = 3,𝑛𝑛 = 5

2353 = 80

15

20

𝑞𝑞𝑚𝑚 = 𝑄𝑄𝑚𝑚𝑁𝑁𝑚𝑚

−1

p.47

Page 4: TAoCP 7.7.7.2 Satisfiability の輪読

𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3, 𝑥𝑥4, 𝑥𝑥5

¬𝑥𝑥1 ∨ ¬𝑥𝑥2 ∨ ¬𝑥𝑥3 ∧ 𝑥𝑥1 ∨ ¬𝑥𝑥4 ∨ ¬𝑥𝑥5 ∧ 𝑥𝑥3 ∨ 𝑥𝑥4 ∨ 𝑥𝑥5 1 2 3 4 5 6 7 8 9

{{9, 4, 3}, {5, 9, 3}, {8, 4, 3}, {6, 8, 3}, {1, 6, 8}, {1, 6, 7}, {1, 5, 9}, {1, 5, 7}, {9, 2, 4}, {5, 9, 2}, {8, 2, 4}, {6, 8, 2}, {7, 2, 4}, {6, 7, 2}, {5, 7, 2}}

{{1, 1, 0, 1, 1}, {1, 1, 0, 1, 0}, {1, 1, 0, 0, 1}, {1, 0, 1, 1, 1}, {1, 0, 1, 1, 0}, {1, 0, 1, 0, 1}, {1, 0, 1, 0, 0}, {1, 0, 0, 1, 1}, {1, 0, 0, 1, 0}, {1, 0, 0, 0, 1}, {0, 1, 1, 1, 0}, {0, 1, 1, 0, 1}, {0, 1, 1, 0, 0}, {0, 1, 0, 1, 0}, {0, 1, 0, 0, 1}, {0, 0, 1, 1, 0}, {0, 0, 1, 0, 1}, {0, 0, 1, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}

random 𝑘𝑘-SAT

satisfiable cell allocations

satisfiable boolean vectors

possible 𝑁𝑁clauses

2𝑘𝑘𝑛𝑛𝑘𝑘

𝑘𝑘 = 3,𝑚𝑚 = 3,𝑛𝑛 = 5

2353 = 80

15

20

<

𝑞𝑞𝑚𝑚 = 𝑄𝑄𝑚𝑚𝑁𝑁𝑚𝑚

−1

p.47

Page 5: TAoCP 7.7.7.2 Satisfiability の輪読

𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3, 𝑥𝑥4, 𝑥𝑥5

{{6, 9, 3}, {6, 8, 3}, {6, 7, 3}, {5, 9, 3}, {5, 8, 3}, {5,7, 3}, {4, 9, 3}, {4, 8, 3}, {4, 7, 3}, {6, 9, 2}, {6, 8, 2}, {6, 7, 2}, {5, 9, 2}, {5, 8, 2}, {5, 7, 2}, {4, 9, 2}, {4, 8, 2}, {4, 7, 2}, {1, 6, 9}, {1, 6, 8}, {1, 6, 7}, {1, 5, 9}, {1, 5, 8}, {1, 5, 7}, {1, 4, 9}, {1, 4, 8}, {1, 4, 7}}

{{1, 0, 0, 1, 1}, {0, 1, 1, 1, 1}, {1, 0, 0, 0, 1}, {0, 0, 1, 1, 1}, {1, 0, 0, 1, 0}, {0, 1, 0, 1, 1}, {1, 0, 0, 0, 0}, {0, 0, 0, 1, 1}, {0, 1, 1, 0, 1}, {0, 0, 1, 0, 1}, {0, 1, 0, 0, 1}, {0, 0, 0, 0, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 1, 0}, {0, 1, 0, 1, 0}, {0, 0, 0, 1, 0}, {0, 1, 1, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 0, 0, 0}}

¬𝑥𝑥1 ∨ ¬𝑥𝑥2 ∨ ¬𝑥𝑥3 ∧ ¬𝑥𝑥1 ∨ ¬𝑥𝑥2 ∨ 𝑥𝑥3 ∧ ¬𝑥𝑥1 ∨ 𝑥𝑥2 ∨ ¬𝑥𝑥3 1 2 3 4 5 6 7 8 9 random

𝑘𝑘-SAT

satisfiable cell allocations

satisfiable boolean vectors

possible 𝑁𝑁clauses

2𝑘𝑘𝑛𝑛𝑘𝑘

𝑘𝑘 = 3,𝑚𝑚 = 3,𝑛𝑛 = 5

2353 = 80

27

20

𝑞𝑞𝑚𝑚 = 𝑄𝑄𝑚𝑚𝑁𝑁𝑚𝑚

−1

p.47

Page 6: TAoCP 7.7.7.2 Satisfiability の輪読

𝑞𝑞𝑚𝑚 = 𝑄𝑄𝑚𝑚𝑁𝑁𝑚𝑚

−1

𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3, 𝑥𝑥4, 𝑥𝑥5

¬𝑥𝑥1 ∨ ¬𝑥𝑥2 ∨ ¬𝑥𝑥3 ∧ ¬𝑥𝑥1 ∨ ¬𝑥𝑥2 ∨ 𝑥𝑥3 ∧ ¬𝑥𝑥1 ∨ 𝑥𝑥2 ∨ ¬𝑥𝑥3 1 2 3 4 5 6 7 8 9

{{6, 9, 3}, {6, 8, 3}, {6, 7, 3}, {5, 9, 3}, {5, 8, 3}, {5,7, 3}, {4, 9, 3}, {4, 8, 3}, {4, 7, 3}, {6, 9, 2}, {6, 8, 2}, {6, 7, 2}, {5, 9, 2}, {5, 8, 2}, {5, 7, 2}, {4, 9, 2}, {4, 8, 2}, {4, 7, 2}, {1, 6, 9}, {1, 6, 8}, {1, 6, 7}, {1, 5, 9}, {1, 5, 8}, {1, 5, 7}, {1, 4, 9}, {1, 4, 8}, {1, 4, 7}}

{{1, 0, 0, 1, 1}, {0, 1, 1, 1, 1}, {1, 0, 0, 0, 1}, {0, 0, 1, 1, 1}, {1, 0, 0, 1, 0}, {0, 1, 0, 1, 1}, {1, 0, 0, 0, 0}, {0, 0, 0, 1, 1}, {0, 1, 1, 0, 1}, {0, 0, 1, 0, 1}, {0, 1, 0, 0, 1}, {0, 0, 0, 0, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 1, 0}, {0, 1, 0, 1, 0}, {0, 0, 0, 1, 0}, {0, 1, 1, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 0, 0, 0}}

random 𝑘𝑘-SAT

satisfiable cell allocations

satisfiable boolean vectors

possible 𝑁𝑁clauses

2𝑘𝑘𝑛𝑛𝑘𝑘

𝑘𝑘 = 3,𝑚𝑚 = 3,𝑛𝑛 = 5

2353 = 80

27

20

<

p.47

Page 7: TAoCP 7.7.7.2 Satisfiability の輪読

𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3, 𝑥𝑥4, 𝑥𝑥5

¬𝑥𝑥1 ∨ ¬𝑥𝑥2 ∨ ¬𝑥𝑥3 ∧ 𝑥𝑥1 ∨ ¬𝑥𝑥4 ∨ ¬𝑥𝑥5 ∧ 𝑥𝑥3 ∨ 𝑥𝑥4 ∨ 𝑥𝑥5 1 2 3 4 5 6 7 8 9

{{9, 4, 3}, {5, 9, 3}, {8, 4, 3}, {6, 8, 3}, {1, 6, 8}, {1, 6, 7}, {1, 5, 9}, {1, 5, 7}, {9, 2, 4}, {5, 9, 2}, {8, 2, 4}, {6, 8, 2}, {7, 2, 4}, {6, 7, 2}, {5, 7, 2}}

{{1, 1, 0, 1, 1}, {1, 1, 0, 1, 0}, {1, 1, 0, 0, 1}, {1, 0, 1, 1, 1}, {1, 0, 1, 1, 0}, {1, 0, 1, 0, 1}, {1, 0, 1, 0, 0}, {1, 0, 0, 1, 1}, {1, 0, 0, 1, 0}, {1, 0, 0, 0, 1}, {0, 1, 1, 1, 0}, {0, 1, 1, 0, 1}, {0, 1, 1, 0, 0}, {0, 1, 0, 1, 0}, {0, 1, 0, 0, 1}, {0, 0, 1, 1, 0}, {0, 0, 1, 0, 1}, {0, 0, 1, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}

全単射でない点に注意

random 𝑘𝑘-SAT

satisfiable cell allocations

satisfiable boolean vectors

possible 𝑁𝑁clauses

2𝑘𝑘𝑛𝑛𝑘𝑘

𝑞𝑞𝑚𝑚 = 𝑄𝑄𝑚𝑚𝑁𝑁𝑚𝑚

−1

p.47

Page 8: TAoCP 7.7.7.2 Satisfiability の輪読

𝑥𝑥1, 𝑥𝑥2, 𝑥𝑥3, 𝑥𝑥4, 𝑥𝑥5

¬𝑥𝑥1 ∨ ¬𝑥𝑥2 ∨ ¬𝑥𝑥3 ∧ 𝑥𝑥1 ∨ ¬𝑥𝑥4 ∨ ¬𝑥𝑥5 ∧ 𝑥𝑥3 ∨ 𝑥𝑥4 ∨ 𝑥𝑥5 1 2 3 4 5 6 7 8 9

{{9, 4, 3}, {5, 9, 3}, {8, 4, 3}, {6, 8, 3}, {1, 6, 8}, {1, 6, 7}, {1, 5, 9}, {1, 5, 7}, {9, 2, 4}, {5, 9, 2}, {8, 2, 4}, {6, 8, 2}, {7, 2, 4}, {6, 7, 2}, {5, 7, 2}}

{{1, 1, 0, 1, 1}, {1, 1, 0, 1, 0}, {1, 1, 0, 0, 1}, {1, 0, 1, 1, 1}, {1, 0, 1, 1, 0}, {1, 0, 1, 0, 1}, {1, 0, 1, 0, 0}, {1, 0, 0, 1, 1}, {1, 0, 0, 1, 0}, {1, 0, 0, 0, 1}, {0, 1, 1, 1, 0}, {0, 1, 1, 0, 1}, {0, 1, 1, 0, 0}, {0, 1, 0, 1, 0}, {0, 1, 0, 0, 1}, {0, 0, 1, 1, 0}, {0, 0, 1, 0, 1}, {0, 0, 1, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 0, 1}}

𝑄𝑄𝑚𝑚 ∶ the number of ways to choose 𝑚𝑚 of the 𝑁𝑁 clauses so that at least one Boolean vector 𝑥𝑥 = 𝑥𝑥1,…,𝑥𝑥𝑛𝑛 satisfies them all.

𝑁𝑁𝑚𝑚 =

803

𝑞𝑞𝑚𝑚 = 𝑄𝑄𝑚𝑚𝑁𝑁𝑚𝑚

−1

𝑞𝑞𝑚𝑚 = Pr(𝑚𝑚 clauses, distinct but otherwise selected at random, are satisfiable)

𝑄𝑄3 = �

p.47

Page 9: TAoCP 7.7.7.2 Satisfiability の輪読

exercise 180 p.148/219

Explain how to use BDDs to compute the numbers 𝑄𝑄𝑚𝑚 that underlie Fig. 40. What is max0≤𝑚𝑚≤80𝑄𝑄𝑚𝑚?

very simple BDD (?)

No natural ordering of the clause variables is evident, but the method of sifting is able to reduce the BDD size.

𝑁𝑁 variables 𝑦𝑦𝑖𝑖 ,one of each possible clause 𝐶𝐶𝑗𝑗

𝑓𝑓 𝑦𝑦1, …𝑦𝑦𝑁𝑁 = ⋀ 𝐶𝐶𝑗𝑗|𝑦𝑦𝑗𝑗 = 1 is satisfiable is ⋁𝑥𝑥𝑓𝑓𝑥𝑥 𝑦𝑦 , where 𝑓𝑓𝑥𝑥 𝑦𝑦 = 𝑥𝑥 satisfies ⋀ 𝐶𝐶𝑗𝑗|𝑦𝑦𝑗𝑗 = 1 is simply ⋀ 𝑦𝑦�𝑖𝑖| 𝑥𝑥 makes 𝐶𝐶𝑗𝑗 false .

if 𝑘𝑘 = 2,𝑛𝑛 = 3 and if 𝐶𝐶1= 𝑥𝑥1 ∨ 𝑥𝑥2 , 𝐶𝐶7= 𝑥𝑥1 ∨ �̅�𝑥3 , 𝐶𝐶11 = 𝑥𝑥2 ∨ �̅�𝑥3 ,

then 𝑓𝑓001 𝑦𝑦1, … ,𝑦𝑦12 = 𝑦𝑦�1 ∧ 𝑦𝑦�7 ∧ 𝑦𝑦�11.

Page 10: TAoCP 7.7.7.2 Satisfiability の輪読

𝑞𝑞20 ≈ 0.776

𝑞𝑞30 ≈ 0.179

𝑞𝑞40 ≈ 0.016

1

𝑇𝑇𝑚𝑚

𝑞𝑞𝑚𝑚

Fig. 40 + 41

𝑘𝑘 = 3, 𝑛𝑛 = 5

0

𝑞𝑞𝑚𝑚 = 1 for 𝑚𝑚 < 15 𝑞𝑞𝑚𝑚 = 0 for 𝑚𝑚 > 55

𝑇𝑇𝑚𝑚: Deviation from randomness 𝜇𝜇 of SAT boolean vectors +𝜎𝜎

−𝜎𝜎

𝑇𝑇2 ≈ 24.5 ± 0.743

𝑇𝑇20 ≈ 1.47 ± 1.17

1 5

𝑇𝑇30 ≈ 0.20 ± 0.45

← 𝑚𝑚 = 70 になっても, 𝑄𝑄70は たかだか 32 を超えない.

←𝑘𝑘 = 3,𝑛𝑛 = 5 で,SAT可能な 最大の 𝑚𝑚 = 2𝑘𝑘 − 1 𝑛𝑛

𝑘𝑘= 1 − 2−𝑘𝑘 𝑁𝑁

は 70. ランダムな70節のCNFが𝑄𝑄70で SATな場合は十分あり得る.

𝑚𝑚 が増えるにつれ 𝑞𝑞𝑚𝑚 が限りなく 0 に近づくなかで, 偏差を考慮した 𝑇𝑇𝑚𝑚 が 1 を取るような 𝑚𝑚 に注目する.

p.48

Page 11: TAoCP 7.7.7.2 Satisfiability の輪読

1 < 𝑘𝑘 < 4, 𝑛𝑛 = 5

E𝑃𝑃: The expected “stopping time”

𝑆𝑆𝑘𝑘,𝑛𝑛 = E𝑃𝑃𝑘𝑘,𝑛𝑛 if 𝑃𝑃𝑘𝑘,𝑛𝑛 is the stopping time for 𝑘𝑘SAT on 𝑛𝑛 variables

𝐸𝐸𝑃𝑃 ≈ 25.22, V𝑃𝑃 ≈ 35.73

𝑆𝑆𝑘𝑘,5 4.06 ± 1.19 11.60 ± 3.04 25.22 ± 5.98 43.39 ± 7.62

𝑃𝑃 = 𝑚𝑚 : the number of clauses first unable to satisfy them all

𝑝𝑝𝑚𝑚 = 𝑞𝑞𝑚𝑚−1 − 𝑞𝑞𝑚𝑚 :the probability that 𝑚𝑚 − 1 random clauses are satisfiable but 𝑚𝑚 are not

SATがほぼ 1 しかなくなる 𝑚𝑚 と, 全てUNSATになり始める 𝑚𝑚 は ほぼ一致する.

2−𝑘𝑘𝑁𝑁�𝑃𝑃𝑃𝑃 𝑇𝑇𝑚𝑚 = 1𝑁𝑁 −𝑚𝑚

≈ 0.8853𝑚𝑚

一番最期のSAT集合の累積.

E𝑃𝑃 = � 𝑞𝑞𝑚𝑚𝑚𝑚

E𝑃𝑃2 = � 2𝑚𝑚 + 1𝑚𝑚

𝑞𝑞𝑚𝑚

p.48

Page 12: TAoCP 7.7.7.2 Satisfiability の輪読

𝑁𝑁𝑚𝑚ordered sequences after 𝑚𝑚 steps, not 𝑁𝑁

𝑚𝑚 sets 𝑞𝑞�𝑚𝑚 : the probability that 𝑚𝑚 random clauses 𝐶𝐶1 ∧ ⋯∧ 𝐶𝐶𝑚𝑚 are satisfiable, each 𝐶𝐶𝑗𝑗 is randomly chosen from the 𝑁𝑁 = 2𝑘𝑘 𝑛𝑛

𝑘𝑘 possibilities

𝑁𝑁 = 2𝑘𝑘𝑛𝑛𝑘𝑘

𝑁𝑁𝑚𝑚

2𝑛𝑛

𝑥𝑥3 ∨ 𝑥𝑥4 ∨ 𝑥𝑥5 ∧ 𝑥𝑥3 ∨ 𝑥𝑥4 ∨ 𝑥𝑥5 ∧ 𝑥𝑥3 ∨ 𝑥𝑥4 ∨ 𝑥𝑥5 も可なのでSATは増える.

“birthday paradox” 23個のキーを365の大きさの表に対応づける

ランダムな関数を選ぶとき, 2つのキーが同じ場所に対応しない確率は

0.4927(1/2以下)である.

𝑞𝑞�𝑚𝑚 ≥ 𝑞𝑞𝑚𝑚

Fig. 45 𝑘𝑘 = 3, 𝑛𝑛 = 5

𝑞𝑞𝑚𝑚

𝑞𝑞�𝑚𝑚

The expected behavior of 𝑃𝑃� is very much like that of 𝑃𝑃, if 𝑞𝑞𝑚𝑚 is small whenever 𝑚𝑚/𝑁𝑁 isn't small.

= ∑ 𝑚𝑚𝑡𝑡 𝑡𝑡! 𝑞𝑞𝑡𝑡𝑁𝑁

𝑡𝑡=0𝑁𝑁𝑡𝑡 /𝑁𝑁𝑚𝑚

E𝑃𝑃� = �𝑁𝑁

𝑁𝑁 −𝑚𝑚

𝑁𝑁−1

𝑚𝑚=0

𝑞𝑞𝑚𝑚 D𝑃𝑃�2 = �𝑁𝑁

𝑁𝑁 −𝑚𝑚

𝑁𝑁−1

𝑚𝑚=0

𝑞𝑞𝑚𝑚 1 + 2𝑁𝑁

𝑁𝑁 − 1+ ⋯+

𝑁𝑁𝑁𝑁 −𝑚𝑚

p.50

Page 13: TAoCP 7.7.7.2 Satisfiability の輪読

𝛼𝛼𝑘𝑘: Satisfiability thresholds 𝑆𝑆𝑘𝑘 𝑚𝑚,𝑛𝑛 : 𝑆𝑆𝑘𝑘 𝑚𝑚,𝑛𝑛 = Pr 𝑚𝑚 random clauses of 𝑘𝑘SAT are satisfiable ,

where the 𝑚𝑚 clauses are "sampled with replacement"(they needn't be distinct).

Fig. 46 𝑘𝑘 = 3

𝛼𝛼𝑘𝑘 = lim𝑛𝑛→∞

𝑆𝑆𝑘𝑘,𝑛𝑛/𝑛𝑛

Random 3SAT problems shows “phase transition” of satisfiability when the clauses exceeds about 4.27𝑛𝑛.

経験的に推定される 𝛼𝛼𝑘𝑘 を使えば,𝛼𝛼𝑘𝑘𝑛𝑛節の 困難なベンチマーク𝑘𝑘SAT問題を得られる.

※ 𝛼𝛼3 = 4.26675 ± 0.00015

2𝑘𝑘 ln 2 −1 + ln 2

2 − 𝑂𝑂 2−𝑘𝑘3 ≤ lim inf

𝑛𝑛→∞𝛼𝛼𝑘𝑘 𝑛𝑛 ≤ lim sup

𝑛𝑛→∞𝛼𝛼𝑘𝑘 𝑛𝑛 ≤ 2𝑘𝑘 ln 2 −

1 + ln 22 + 𝑂𝑂 2−

𝑘𝑘3

2𝑘𝑘 ln 2 − 𝑂𝑂 𝑘𝑘 𝑛𝑛 なランダム 𝑘𝑘SAT は,ベクトル 𝑥𝑥 ; ν𝑥𝑥 ≈ 𝑛𝑛2

で,ほぼ常に充足する. exercise 195

lim𝑛𝑛→∞

𝑆𝑆𝑘𝑘 𝛼𝛼𝑘𝑘 𝑛𝑛 − 𝜖𝜖 𝑛𝑛 ,𝑛𝑛 = 1, lim𝑛𝑛→∞

𝑆𝑆𝑘𝑘 𝛼𝛼𝑘𝑘 𝑛𝑛 + 𝜖𝜖 𝑛𝑛 ,𝑛𝑛 = 0, 𝑘𝑘 ≥ 2 において

となる関数𝛼𝛼𝑘𝑘 𝑛𝑛 が存在する. 𝜀𝜀 ∶ 任意の正の数

𝛼𝛼𝑘𝑘 𝑛𝑛 は,Θ 2𝑘𝑘 で押さえられ,𝑘𝑘が十分に大きい時 定数になる.

p.50

Page 14: TAoCP 7.7.7.2 Satisfiability の輪読

Analysis of random 2SAT

2 SAT problem corresponds to an implication digraph, with arcs 𝑙𝑙 ̅ → 𝑙𝑙′ and 𝑙𝑙𝑙� → 𝑙𝑙 for each clause 𝑙𝑙 ∨ 𝑙𝑙′ .

𝑐𝑐: a fixed constant

lim𝑛𝑛→∞

𝑆𝑆2 𝑐𝑐𝑛𝑛 ,𝑛𝑛 = �1, if 𝑐𝑐 < 1;0, if 𝑐𝑐 > 1.

The satisfiability threshold 𝛼𝛼2 = 1 𝑛𝑛が増えるにつれて 転移は急激に切り立っていく.

Fig. 47 𝑘𝑘 = 2

𝑆𝑆2,𝑛𝑛

MPR 21 22      非負の確率変数 𝑋𝑋 において Pr 𝑋𝑋 > 0 ≤ E𝑋𝑋; “the first moment principle” Pr (𝑋𝑋 > 0) ≥ E𝑋𝑋 2/ E𝑋𝑋2 “the second moment principle” 充足確率の閾値を有界とみなして 証明を導く.

p.51

Page 15: TAoCP 7.7.7.2 Satisfiability の輪読

𝑥𝑥7

�̅�𝑥7

𝑥𝑥9

�̅�𝑥9

a set of 2SAT clauses is satisfiable iff no strong component of its digraph contains both 𝑥𝑥 and �̅�𝑥 for variable 𝑥𝑥. If it were a random digraph,

only 𝑂𝑂(log𝑛𝑛) vertices are reachable from any given vertex when 𝑐𝑐 < 1,

Analysis of random 2SAT p.50

Page 16: TAoCP 7.7.7.2 Satisfiability の輪読

�̅�𝑥8

𝑥𝑥8

a set of 2SAT clauses is satisfiable iff no strong component of its digraph contains both 𝑥𝑥 and �̅�𝑥 for variable 𝑥𝑥. If it were a random digraph,

only 𝑂𝑂(log𝑛𝑛) vertices are reachable from any given vertex when 𝑐𝑐 < 1,

but that there is a unique "giant strong component"

of size Ω 𝑛𝑛 when 𝑐𝑐 > 1. 𝑛𝑛 が増えるにつれ,強連結成分のシェアは急に大きくなる.

Analysis of random 2SAT

一対有向グラフから, 強連結成分への 転移とSATの関連性?

p.50

Page 17: TAoCP 7.7.7.2 Satisfiability の輪読

“snares and snakes” 𝑙𝑙1̅ ∨ 𝑙𝑙2 , 𝑙𝑙2̅ ∨ 𝑙𝑙3 , ..., 𝑙𝑙�̅�𝑠−1 ∨ 𝑙𝑙𝑠𝑠

𝑠𝑠-chain 𝐶𝐶 ;

𝑠𝑠 = 9

𝑙𝑙𝑡𝑡 ∨ 𝑙𝑙1 and 𝑙𝑙�̅�𝑠 ∨ 𝑙𝑙−̅𝑢𝑢 if 𝑢𝑢 < 0

𝑙𝑙�̅�𝑠 ∨ 𝑙𝑙𝑢𝑢 if 𝑢𝑢 > 0, 𝑙𝑙𝑡𝑡 ∨ 𝑙𝑙1 and

𝑡𝑡-snake

𝑠𝑠-snare (𝐶𝐶; 𝑡𝑡,𝑢𝑢) 𝑡𝑡 = 5, 𝑢𝑢 = −𝑡𝑡

対有向グラフのままなら 同一強連結成分内に同時に,

𝑙𝑙𝑠𝑠 と 𝑙𝑙𝑠𝑠� が存在しない. →必ず充足可能

充足不能な2SATは 必ず最低一つは snareを

持っている.

snare を持つ2SATでも 𝑠𝑠 と 𝑡𝑡 と 𝑢𝑢 の関係によっては

充足可能となる.

𝑙𝑙𝑡𝑡

𝑙𝑙�̅�𝑡

𝑙𝑙𝑡𝑡 𝑙𝑙�̅�𝑡

要 𝑡𝑡 で 対の 𝑠𝑠 − 𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑛𝑛 同士を つなぐ際, 𝑢𝑢 の正負が

直流 交流 をスイッチする仕掛け S A T U N S A T

p.52

Page 18: TAoCP 7.7.7.2 Satisfiability の輪読

“snares and snakes” 𝑙𝑙1̅ ∨ 𝑙𝑙2 , 𝑙𝑙2̅ ∨ 𝑙𝑙3 , ..., 𝑙𝑙�̅�𝑠−1 ∨ 𝑙𝑙𝑠𝑠

𝑠𝑠-chain 𝐶𝐶 ;

𝑠𝑠 = 9

𝑙𝑙𝑡𝑡 ∨ 𝑙𝑙1 and 𝑙𝑙�̅�𝑠 ∨ 𝑙𝑙−̅𝑢𝑢 if 𝑢𝑢 < 0

𝑙𝑙�̅�𝑠 ∨ 𝑙𝑙𝑢𝑢 if 𝑢𝑢 > 0, 𝑙𝑙𝑡𝑡 ∨ 𝑙𝑙1 and

𝑡𝑡-snake

𝑠𝑠-snare (𝐶𝐶; 𝑡𝑡,𝑢𝑢) 𝑡𝑡 = 5, 𝑢𝑢 = −𝑡𝑡

対有向グラフのままなら 同一強連結成分内に同時に,

𝑙𝑙𝑠𝑠 と 𝑙𝑙𝑠𝑠� が存在しない. →必ず充足可能

充足不能な2SATは 必ず最低一つは snareを

持っている.

snare を持つ2SATでも 𝑠𝑠 と 𝑡𝑡 と 𝑢𝑢 の関係によっては

充足可能となる.

𝑙𝑙𝑡𝑡

𝑙𝑙�̅�𝑡

𝑙𝑙𝑡𝑡 𝑙𝑙�̅�𝑡

p.52

Page 19: TAoCP 7.7.7.2 Satisfiability の輪読

Proof of Theorem C p.53

E𝑋𝑋 is only 𝑂𝑂 𝑛𝑛−1 4⁄ when 𝑚𝑚 = 𝑛𝑛 − 𝑛𝑛3 4⁄ > 𝑐𝑐𝑛𝑛 ※ c > 1 ⇔𝑚𝑚 > 0

E𝑋𝑋 ≥ Pr 𝑋𝑋 > 0 ; “the first moment principle” ※Pr 𝑋𝑋 = 0 = 1 − Pr 𝑋𝑋 > 0 ≥ 1 − E𝑋𝑋

2𝑠𝑠+1 𝑠𝑠 − 1 2𝑛𝑛𝑠𝑠 ≤ 2𝑠𝑠+1 𝑠𝑠 − 1 2𝑛𝑛𝑠𝑠

𝑝𝑝 𝑠𝑠 + 1,𝑚𝑚,2𝑛𝑛(𝑛𝑛 − 1) ≤𝑚𝑚𝑠𝑠+1

2𝑛𝑛(𝑛𝑛 − 1) 𝑠𝑠+1 ≤𝑚𝑚𝑠𝑠+1

2𝑛𝑛(𝑛𝑛 − 1) 𝑠𝑠+1

※2𝑛𝑛(𝑛𝑛 − 1)個の2SAT組からランダムに,𝑚𝑚節を抜き出してスネアを作るときの最大数と その中に特定の𝑠𝑠 − 1個の変数が含まれている確率 𝑝𝑝 𝑠𝑠 + 1,𝑚𝑚,2𝑛𝑛(𝑛𝑛 − 1) の上限は

E 𝑋𝑋 𝐶𝐶; 𝑡𝑡,𝑢𝑢 ≤ 𝑚𝑚𝑠𝑠+1/ 2𝑛𝑛 𝑛𝑛 − 1 𝑠𝑠+1

E 𝑋𝑋 = �E 𝑋𝑋 𝐶𝐶; 𝑡𝑡,𝑢𝑢 ≤� 2𝑠𝑠+1𝑠𝑠≥0

𝑠𝑠 𝑠𝑠 − 1 𝑛𝑛𝑠𝑠𝑚𝑚

2𝑛𝑛 𝑛𝑛 − 1

𝑠𝑠+1=

2𝑛𝑛

𝑚𝑚𝑛𝑛 − 1 −𝑚𝑚

3

𝑚𝑚 > 𝑐𝑐𝑛𝑛, 𝑐𝑐 > 1 における 2𝑆𝑆𝑆𝑆𝑇𝑇の充足確率= 0 である ⇔ 少なくとも 𝑠𝑠𝑛𝑛𝑐𝑐𝑃𝑃𝑠𝑠 の期待値が常に 1 に漸近する

𝑆𝑆2 𝑛𝑛 − 𝑛𝑛3/4 ,𝑛𝑛 ≥ Pr 𝑋𝑋 = 0 ≥ 1 − 𝑂𝑂 𝑛𝑛−1/4

1 − 𝑂𝑂 𝑛𝑛−1/4

𝑛𝑛

Page 20: TAoCP 7.7.7.2 Satisfiability の輪読

Proof of Theorem C p.53

𝑡𝑡 = 𝑛𝑛1/5 𝑚𝑚 = 𝑛𝑛 + 𝑛𝑛5/6  にとれば、

𝑡𝑡 − 𝑠𝑠𝑛𝑛𝑐𝑐𝑘𝑘𝑠𝑠 分だけ 𝑆𝑆2 𝑚𝑚,𝑛𝑛 をより鋭利に押し下げられる.

Pr (𝑋𝑋 > 0) ≥ E𝑋𝑋 2/ E𝑋𝑋2 “the second moment principle”

1 − E𝑋𝑋 2/ E𝑋𝑋2 ≥ 1 − Pr 𝑋𝑋 > 0 = Pr (𝑋𝑋 = 0)

𝑂𝑂 𝑛𝑛−130 ≥ 1 − Pr 𝑋𝑋 > 0 = Pr (𝑋𝑋 = 0)

E 𝑋𝑋2

E 𝑋𝑋 2 = �𝑝𝑝𝑟𝑟

2𝑡𝑡

𝑟𝑟=0

2𝑛𝑛(𝑛𝑛 − 1)𝑚𝑚

𝑟𝑟

1 + 𝑂𝑂𝑡𝑡2

𝑛𝑛= 𝑂𝑂

𝑡𝑡4

𝑛𝑛= 𝑂𝑂 𝑛𝑛−1/30

given any chain 𝑙𝑙1, … , 𝑙𝑙𝑡𝑡, … 𝑙𝑙2𝑡𝑡−1 , with 𝑠𝑠 = 2𝑡𝑡 − 1 and 𝑙𝑙𝑡𝑡 in the middle, generates 𝑙𝑙1̅ ∨ 𝑙𝑙2 , 𝑙𝑙2̅ ∨ 𝑙𝑙3 , ..., 𝑙𝑙�̅�𝑠−1 ∨ 𝑙𝑙𝑠𝑠 together with 𝑙𝑙𝑡𝑡 ∨ 𝑙𝑙1 and 𝑙𝑙�̅�𝑠 ∨ 𝑙𝑙�̅�𝑡 .

𝑡𝑡 −snake, which is the special case (𝐶𝐶; 𝑡𝑡,−𝑡𝑡) of a (2𝑡𝑡 − 1) −snare.

𝑋𝑋𝐶𝐶= [ each clause of (𝐶𝐶; 𝑡𝑡,−𝑡𝑡) occurs exactly once ] 𝑋𝑋 = �𝑋𝑋𝐶𝐶

𝑆𝑆2 𝑛𝑛 + 𝑛𝑛5/6 ,𝑛𝑛 = 𝑂𝑂 𝑛𝑛−1/30

𝑐𝑐𝑛𝑛 𝑛𝑛 + 𝑛𝑛5/6 𝑛𝑛 + 𝑛𝑛3/4

−Θ 𝑛𝑛1/4 𝑂𝑂 𝑛𝑛−1/30

(97)

(95)

Page 21: TAoCP 7.7.7.2 Satisfiability の輪読

p.50

Stirling 数 1.2.6

𝑥𝑥の累乗で表現されている多項式から, 二項係数で表現されている多項式への変換で使われる係数

𝑛𝑛𝑘𝑘 : 𝑘𝑘本の閉路をもつ𝑛𝑛個の文字の順列 第一種

𝑛𝑛𝑘𝑘

: 𝑛𝑛個の要素を持つ集合を 𝑘𝑘個の要素を持つ 異なる部分集合に分割する方法の数

第二種

階乗冪→通常の冪

通常の冪→階乗冪

𝑥𝑥𝑛𝑛 = 𝑥𝑥 𝑥𝑥 − 1 … (𝑥𝑥 − 𝑛𝑛 + 1) = � −1 𝑛𝑛−𝑘𝑘 𝑛𝑛𝑘𝑘

𝑘𝑘

𝑥𝑥𝑘𝑘

𝑥𝑥𝑛𝑛 = � 𝑛𝑛𝑘𝑘

𝑘𝑘

𝑥𝑥𝑘𝑘

Page 22: TAoCP 7.7.7.2 Satisfiability の輪読

Resolution p.54

𝑆𝑆 = 123� , 234� , 341,41�2, 1�2�3, 2�3�4, 3�4�1� , 4�12� axiom

resolvent clause In-degree 2

directed acyclic graph (dag) “Resolution proof of 𝑆𝑆”

“resolution refutation. ” 123 12�4

1�24� 1�2�3�

12 12�

1�2� 1�2

1

1�

𝜖𝜖

Page 23: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm D and refutation tree p.55

we can prove the empty clause by resolution from 𝐹𝐹|�̅�𝑥 iff we can prove 𝑥𝑥 by resolution from 𝐹𝐹 without resolving on 𝑥𝑥.

if 𝐹𝐹 has no short refutation tree, Algorithm D cannot conclude those unsatisfiable unless it runs for a long time.

exercise 224 𝐹𝐹|𝑥𝑥 �を縮減して得られるラベルは,

元々の𝐹𝐹からのものではなくても, その祖先の葉の中に 𝑥𝑥 が含まれている限り,

根は 𝑥𝑥 か 𝜖𝜖 となる.

Fig.39.

Fig.48.

SATを反駁ステップの 最小化問題に置き替える.

Page 24: TAoCP 7.7.7.2 Satisfiability の輪読

Prover-Delayer game p.55

Pudlák, Pavel, and Russell Impagliazzo. "A lower bound for DLL algorithms for k-SAT." (1999).

P 12�,1�3�, 1�2�3

D 𝑇𝑇2�,𝐹𝐹3�,𝐹𝐹2�3 𝐹𝐹2�,𝑇𝑇3�,𝑇𝑇2�3

P 𝑇𝑇2�,𝐹𝐹3�,𝐹𝐹2�3 𝑇𝑇2�,𝐹𝐹3�,𝐹𝐹2�3 𝐹𝐹2�,𝑇𝑇3�,𝑇𝑇2�3 𝐹𝐹2�,𝑇𝑇3�,𝑇𝑇2�3

D 𝑇𝑇F,𝐹𝐹3�,𝐹𝐹𝐹𝐹3 𝑇𝑇T,𝐹𝐹3� ,𝐹𝐹𝑇𝑇3 end 𝑇𝑇2�,𝐹𝐹𝑇𝑇,𝐹𝐹2�𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇3�,𝑇𝑇𝑇𝑇3 end 𝐹𝐹2�,𝑇𝑇𝐹𝐹,𝑇𝑇2�𝑇𝑇 𝐹𝐹2�,𝑇𝑇𝑇𝑇,𝑇𝑇2�𝐹𝐹

P 𝑇𝑇F,𝐹𝐹3�,𝐹𝐹𝐹𝐹3 𝑇𝑇T,𝐹𝐹3� ,𝐹𝐹𝑇𝑇3 𝑇𝑇2�,𝐹𝐹𝑇𝑇,𝐹𝐹2�𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇3�,𝑇𝑇𝑇𝑇3 𝐹𝐹2�,𝑇𝑇𝐹𝐹,𝑇𝑇2�𝑇𝑇 𝐹𝐹2�,𝑇𝑇𝑇𝑇,𝑇𝑇2�𝐹𝐹

D end 𝑇𝑇T,𝐹𝐹𝑇𝑇,𝐹𝐹𝑇𝑇𝐹𝐹 end end end 𝑇𝑇T,𝐹𝐹𝑇𝑇,𝐹𝐹𝑇𝑇𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇𝐹𝐹,𝑇𝑇𝑇𝑇𝑇𝑇 𝐹𝐹𝑇𝑇,𝑇𝑇𝑇𝑇,𝑇𝑇𝑇𝑇𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇𝐹𝐹,𝑇𝑇𝑇𝑇𝑇𝑇 end end 𝐹𝐹𝑇𝑇,𝑇𝑇𝑇𝑇,𝑇𝑇𝑇𝑇𝐹𝐹

P proved

Page 25: TAoCP 7.7.7.2 Satisfiability の輪読

Prover-Delayer game p.55

Pudlák, Pavel, and Russell Impagliazzo. "A lower bound for DLL algorithms for k-SAT." (1999).

P 12�,1�3�, 1�2�3

D 𝑇𝑇2�,𝐹𝐹3�,𝐹𝐹2�3 𝐹𝐹2�,𝑇𝑇3�,𝑇𝑇2�3

P 𝑇𝑇2�,𝐹𝐹3�,𝐹𝐹2�3 𝑇𝑇2�,𝐹𝐹3�,𝐹𝐹2�3 𝐹𝐹2�,𝑇𝑇3�,𝑇𝑇2�3 𝐹𝐹2�,𝑇𝑇3�,𝑇𝑇2�3

D 𝑇𝑇F,𝐹𝐹3�,𝐹𝐹𝐹𝐹3 𝑇𝑇T,𝐹𝐹3� ,𝐹𝐹𝑇𝑇3 end 𝑇𝑇2�,𝐹𝐹𝑇𝑇,𝐹𝐹2�𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇3�,𝑇𝑇𝑇𝑇3 end 𝐹𝐹2�,𝑇𝑇𝐹𝐹,𝑇𝑇2�𝑇𝑇 𝐹𝐹2�,𝑇𝑇𝑇𝑇,𝑇𝑇2�𝐹𝐹

P 𝑇𝑇F,𝐹𝐹3�,𝐹𝐹𝐹𝐹3 𝑇𝑇T,𝐹𝐹3� ,𝐹𝐹𝑇𝑇3 𝑇𝑇2�,𝐹𝐹𝑇𝑇,𝐹𝐹2�𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇3�,𝑇𝑇𝑇𝑇3 𝐹𝐹2�,𝑇𝑇𝐹𝐹,𝑇𝑇2�𝑇𝑇 𝐹𝐹2�,𝑇𝑇𝑇𝑇,𝑇𝑇2�𝐹𝐹

D end 𝑇𝑇T,𝐹𝐹𝑇𝑇,𝐹𝐹𝑇𝑇𝐹𝐹 end end end 𝑇𝑇T,𝐹𝐹𝑇𝑇,𝐹𝐹𝑇𝑇𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇𝐹𝐹,𝑇𝑇𝑇𝑇𝑇𝑇 𝐹𝐹𝑇𝑇,𝑇𝑇𝑇𝑇,𝑇𝑇𝑇𝑇𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇𝐹𝐹,𝑇𝑇𝑇𝑇𝑇𝑇 end end 𝐹𝐹𝑇𝑇,𝑇𝑇𝑇𝑇,𝑇𝑇𝑇𝑇𝐹𝐹

P proved

Proverは,最短で確実にSATとなるように ①変数の選択順位を宣言する. ②Delayerが * を選択した際の 割り当て真偽を宣言する.

Delayerは,より高得点を得られるように ①なるべく*を宣言する. ②ゲームが継続する=UNSATにもSATにもならない 真偽割り当てを実現する.

Proverがすべての変数を宣言し終える前に,かつ誤ってゲームを終了させてしまう前に,Delayerが何点獲得できているかが勝負.

Page 26: TAoCP 7.7.7.2 Satisfiability の輪読

Prover-Delayer game p.55

P 12�,1�3�, 1�2�3

D 𝑇𝑇2�,𝐹𝐹3�,𝐹𝐹2�3 𝐹𝐹2�,𝑇𝑇3�,𝑇𝑇2�3

P 𝑇𝑇2�,𝐹𝐹3�,𝐹𝐹2�3 𝑇𝑇2�,𝐹𝐹3�,𝐹𝐹2�3 𝐹𝐹2�,𝑇𝑇3�,𝑇𝑇2�3 𝐹𝐹2�,𝑇𝑇3�,𝑇𝑇2�3

D 𝑇𝑇T,𝐹𝐹3� ,𝐹𝐹𝑇𝑇3 𝑇𝑇2�,𝐹𝐹𝑇𝑇,𝐹𝐹2�𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇3�,𝑇𝑇𝑇𝑇3 𝐹𝐹2�,𝑇𝑇𝐹𝐹,𝑇𝑇2�𝑇𝑇 𝐹𝐹2�,𝑇𝑇𝑇𝑇,𝑇𝑇2�𝐹𝐹 * 1P * 1P * 1P

P 𝑇𝑇T,𝐹𝐹3� ,𝐹𝐹𝑇𝑇3 𝑇𝑇2�,𝐹𝐹𝑇𝑇,𝐹𝐹2�𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇3�,𝑇𝑇𝑇𝑇3 𝐹𝐹2�,𝑇𝑇𝐹𝐹,𝑇𝑇2�𝑇𝑇 𝐹𝐹2�,𝑇𝑇𝑇𝑇,𝑇𝑇2�𝐹𝐹

D 𝑇𝑇T,𝐹𝐹𝑇𝑇,𝐹𝐹𝑇𝑇𝐹𝐹 𝑇𝑇T,𝐹𝐹𝑇𝑇,𝐹𝐹𝑇𝑇𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇𝐹𝐹,𝑇𝑇𝑇𝑇𝑇𝑇 𝐹𝐹𝑇𝑇,𝑇𝑇𝑇𝑇,𝑇𝑇𝑇𝑇𝐹𝐹 𝐹𝐹𝑇𝑇,𝑇𝑇𝐹𝐹,𝑇𝑇𝑇𝑇𝑇𝑇 𝐹𝐹𝑇𝑇,𝑇𝑇𝑇𝑇,𝑇𝑇𝑇𝑇𝐹𝐹

* 1P * 1P * 1P * 1P

P Proved

If the Delayer has a strategy that guarantees a score of at least 𝑚𝑚 points, every refutation tree has at least 2𝑚𝑚 leaves; hence at least 2𝑚𝑚 − 1 resolutions must be done, and every backtrack-based solver needs Ω 2𝑚𝑚 operations to declare the clauses unsatisfiable.

Proverが迷わず一方を選ばざるを得ない状況で, Delayerが * 宣言する戦略

Page 27: TAoCP 7.7.7.2 Satisfiability の輪読

Theorem R p.56

P

D

* 1P

𝑗𝑗𝑚𝑚−3 𝑆𝑆 = 𝑗𝑗1, … ,

�̅�𝑥𝑗𝑗𝑗𝑗 ,

(�̅�𝑥𝑖𝑖𝑗𝑗 ∨ �̅�𝑥𝑗𝑗𝑘𝑘 ∨ 𝑥𝑥𝑖𝑖𝑘𝑘),

(𝑥𝑥𝑗𝑗1 ∨ 𝑥𝑥𝑗𝑗2 ∨ ⋯∨ 𝑥𝑥𝑗𝑗𝑚𝑚)

for 1 ≤ 𝑗𝑗 ≤ 𝑚𝑚; (99)

for 1 ≤ 𝑐𝑐, 𝑗𝑗, 𝑘𝑘 ≤ 𝑚𝑚; (100)

for 1 ≤ 𝑗𝑗 ≤ 𝑚𝑚. (101)

irreflexive

transitive “𝑗𝑗 ≺ 𝑘𝑘 ” is a partial ordering.

Prover は𝑗𝑗固定で順に流していく.

for every 𝑗𝑗, there's a 𝑘𝑘 with 𝑗𝑗 ≺ 𝑘𝑘

𝑚𝑚2variables 𝑥𝑥𝑗𝑗𝑘𝑘, for 1 ≤ 𝑗𝑗, 𝑘𝑘 ≤ 𝑚𝑚, the incidence matrix for a binary relation “𝑗𝑗 ≺ 𝑘𝑘 ”

𝑥𝑥11 ⋯ 𝑥𝑥1𝑚𝑚⋮ ⋱ ⋮

𝑥𝑥𝑚𝑚1 ⋯ 𝑥𝑥𝑚𝑚𝑚𝑚

𝑥𝑥∗∗ 𝑗𝑗

𝑘𝑘

(99)(100)(101)節の適用→その中に極大値を持たない{1, … ,𝑚𝑚}の半順序集合の存在 →すべての節がSATには なり得ないが 𝑚𝑚 − 1点まで必ず取れる戦略がある.

この時点で Delayer が,𝑆𝑆 点獲得しているとする時 Proverに選ばせた 変数の履歴集合が 𝑆𝑆

𝑥𝑥𝑗𝑗𝑘𝑘

if 𝑗𝑗 = 𝑘𝑘 if 𝑗𝑗 ∉ 𝑆𝑆, 𝑘𝑘 ∉ 𝑆𝑆 if 𝑗𝑗 ∈ 𝑆𝑆, 𝑘𝑘 ∉ 𝑆𝑆 if 𝑗𝑗 = 𝑗𝑗𝑎𝑎 ∈ 𝑆𝑆, 𝑘𝑘 = 𝑗𝑗𝑏𝑏 ∈ 𝑆𝑆 if 𝑗𝑗 ∉ 𝑆𝑆, 𝑘𝑘 ∈ 𝑆𝑆

𝑥𝑥𝑗𝑗𝑘𝑘 ← 0 𝑥𝑥𝑗𝑗𝑘𝑘 ← 0 𝑥𝑥𝑗𝑗𝑘𝑘 ← 1 𝑥𝑥𝑗𝑗𝑘𝑘 ← 𝑐𝑐 < 𝑏𝑏 𝑥𝑥𝑗𝑗𝑘𝑘 ←∗

Proverの割り当てる真偽に応じて,𝑗𝑗𝑚𝑚−2 に 𝑗𝑗 か 𝑘𝑘 を定義. 得点を 𝑠𝑠 + 1 へ変更. (101)節は,この時点まで Falseになることがない.

Every refutation tree for the clauses (99) ,(100), (101)

represents at least 2𝑚𝑚−1 − 1 resolution steps.

Page 28: TAoCP 7.7.7.2 Satisfiability の輪読

Lower bounds for general resolution. p.57

4.6.3 加算連鎖 1 = 𝑐𝑐0, 𝑐𝑐1, … , 𝑐𝑐𝑟𝑟= 𝑛𝑛 ただし各要素は,すべての i=1,2,…,r について ある 𝑘𝑘 ≤ 𝑗𝑗 < 𝑐𝑐 に対して, 𝑐𝑐𝑖𝑖 = 𝑐𝑐𝑗𝑗 + 𝑐𝑐𝑘𝑘

7.1.2 𝐵𝐵𝐵𝐵𝐵𝐵𝑙𝑙𝑠𝑠連鎖 𝑛𝑛変数(𝑥𝑥1,…,𝑥𝑥𝑛𝑛)の関数の𝐵𝐵𝐵𝐵𝐵𝐵𝑙𝑙𝑠𝑠連鎖とは, 各ステップで先立つステップの2つを 結ぶような列(𝑥𝑥𝑛𝑛+1, … , 𝑥𝑥𝑛𝑛+𝑟𝑟)である. 𝑥𝑥𝑖𝑖 = 𝑥𝑥𝑗𝑗(𝑖𝑖) ∘𝑖𝑖 𝑥𝑥𝑘𝑘 𝑖𝑖 , 𝑛𝑛 + 1 ≤ 𝑐𝑐 ≤ 𝑛𝑛 + 𝑃𝑃 について.

It’s a refutation chain for 𝐶𝐶1, … ,𝐶𝐶𝑚𝑚 if 𝐶𝐶𝑚𝑚+𝑟𝑟 = 𝜖𝜖.

The short clauses are crucial if we want short chains.

If 𝑥𝑥𝑗𝑗𝑘𝑘 means that pigeon 𝑗𝑗 occupies hole 𝑘𝑘, there is relevant unsatisfiable clauses for resolution in general.

Page 29: TAoCP 7.7.7.2 Satisfiability の輪読

p.58

Lemma B. 𝛼𝛼 : any sequence of clauses 𝑤𝑤 𝛼𝛼 ∶ "𝑤𝑤𝑐𝑐𝑤𝑤𝑡𝑡𝑐" the length of its longest clause or clauses

𝑤𝑤 𝛼𝛼0 ⊢ 𝜖𝜖 : the min. of 𝑤𝑤 𝛼𝛼 over all refutation chains α = 𝐶𝐶1, … ,𝐶𝐶𝑚𝑚+𝑟𝑟 for 𝛼𝛼0 𝛼𝛼0 ⊢ 𝜖𝜖 : the minimum length 𝑃𝑃 of all such chains.

𝛼𝛼0 = 𝐶𝐶1, … ,𝐶𝐶𝑚𝑚

𝛼𝛼0 ⊢ 𝜖𝜖 ≥ 𝑠𝑠 𝑤𝑤 𝛼𝛼0⊢𝜖𝜖 −1 2 8𝑛𝑛⁄ − 2 , for clauses in 𝑛𝑛 ≥ 𝑤𝑤 𝛼𝛼0 2 variables.

Thus there‘s exponential growth if 𝑤𝑤 𝛼𝛼0 = 𝑂𝑂 1 , and 𝑤𝑤 𝛼𝛼0 ⊢ 𝜖𝜖 = Ω 𝑛𝑛 .

𝑊𝑊 ≥ 𝑤𝑤 𝛼𝛼0 特定のリテラルは 𝑊𝑊𝑓𝑓/(2𝑛𝑛) 回でてくる. 𝜌𝜌 = 1 −𝑊𝑊/(2𝑛𝑛) で 値𝑙𝑙 で反駁した𝛼𝛼0には 高々 𝜌𝜌𝑓𝑓 回のfatな節. 𝑓𝑓 < 𝜌𝜌−𝑏𝑏 な整数 𝑏𝑏 に対して,𝛼𝛼0 の反駁 𝛽𝛽,𝛽𝛽0 ,𝛽𝛽1,𝛽𝛽2,𝛽𝛽3を以下のように定義.

𝑏𝑏 > 0,𝛼𝛼0|𝑙𝑙, 𝑤𝑤 𝛽𝛽0 ≤ 𝑊𝑊 + 𝑏𝑏 − 1 𝛽𝛽 = 𝛽𝛽1,𝛽𝛽2,𝛽𝛽3 with 𝛼𝛼0|𝑙𝑙 ,̅

𝑤𝑤 𝛽𝛽 = max 𝑤𝑤 𝛽𝛽0 + 1,𝑤𝑤 𝛽𝛽2 ,𝑤𝑤 𝛽𝛽3 ≤ max 𝑊𝑊 + 𝑏𝑏 ,𝑤𝑤 𝛼𝛼0 ,𝑊𝑊 + 𝑏𝑏 = 𝑊𝑊 + 𝑏𝑏

Exercise 238 : 𝑐𝑐 = 12𝑛𝑛

, 𝑏𝑏 = 𝑊𝑊 , 𝑊𝑊 = 2𝑛𝑛 ln 𝑃𝑃 , なら 𝑓𝑓 ≤ 𝑃𝑃 < 𝜌𝜌−𝑏𝑏. 𝑛𝑛 ≥ 𝑤𝑤 𝛼𝛼0 2, 𝑃𝑃 ≥ 2 で 𝑊𝑊 ≥ 𝑤𝑤 𝛼𝛼0 , 𝑤𝑤 𝛼𝛼0 ⊢ 𝜖𝜖 ≤ 𝑊𝑊 + 𝑏𝑏 ≤ 8𝑛𝑛 ln 𝑃𝑃 + 1

𝑃𝑃 𝑚𝑚

Page 30: TAoCP 7.7.7.2 Satisfiability の輪読

p.58 Restricted pigeonhole principle 𝑆𝑆 = 𝑐𝑐0,𝑐𝑐1, … ,𝑐𝑐𝑚𝑚

𝐵𝐵 = 𝑏𝑏1, 𝑏𝑏2, … , 𝑏𝑏𝑚𝑚

二部グラフの部分集合𝑆𝑆′において あらゆる

𝑏𝑏𝑘𝑘の集合が必ず対となる𝑆𝑆′の部分集合を一

つは持っているような境界領域

a bipartite graph 𝐺𝐺0 on those vertices for which each 𝑐𝑐𝑗𝑗 has degree ≤ 5 and such that the following strong "expansion" condition is satisfied as follows.

All refutation chains for 𝛼𝛼 𝐺𝐺0 have length expΩ 𝑚𝑚 if we can prove that they all have width Ω 𝑚𝑚 .

the pigeonhole clauses are unsatisfiable if we also require �̅�𝑥𝑗𝑗𝑘𝑘 whenever 𝑐𝑐𝑗𝑗 𝑏𝑏𝑘𝑘 in 𝐺𝐺0.

(106)(107)を条件にもつ全ての�̅�𝑥𝑗𝑗𝑘𝑘 から帰結する節を𝛼𝛼 𝐺𝐺0 とすると,

𝑤𝑤 𝛼𝛼 𝐺𝐺0 ≤ 5 となり,特定されずに残る変数𝑥𝑥𝑗𝑗𝑘𝑘 は高々5𝑚𝑚 + 5 個である.

Page 31: TAoCP 7.7.7.2 Satisfiability の輪読

p.60 SAT solving via resolution. by E. W.Samson and R. K. Mueller in 1955.

𝐹𝐹 → {1234,12� , 1�2�3� , 1�3,23� , 34�}

123

℘ 12

1�2� 1�2

1� 1

𝜖𝜖

← 𝐹𝐹’

← 𝑥𝑥

𝑆𝑆𝑙 𝑆𝑆𝑙𝑙 𝑆𝑆𝑙𝑙 SAT is the problem of evaluating the quantified formula

∃𝑥𝑥1 …∃𝑥𝑥𝑛𝑛−1∃𝑥𝑥𝑛𝑛𝐹𝐹 𝑥𝑥1, … , 𝑥𝑥𝑛𝑛−1, 𝑥𝑥𝑛𝑛

where 𝐹𝐹 is a Boolean function given in CNF as a conjunction of clauses.

How to transform the CNF for 𝐹𝐹 into the CNF for 𝐹𝐹𝑙 in the reduced problem ?

∃𝑥𝑥1 …∃𝑥𝑥𝑛𝑛−1𝐹𝐹𝑙 𝑥𝑥1, … , 𝑥𝑥𝑛𝑛−1 , 𝐹𝐹𝑙 𝑥𝑥1, … , 𝑥𝑥𝑛𝑛−1 =

𝐹𝐹 𝑥𝑥1, … , 𝑥𝑥𝑛𝑛−1, 0 ∨ 𝐹𝐹 𝑥𝑥1, … , 𝑥𝑥𝑛𝑛−1, 1 .

, .

.

Suppose clauses of contain and clauses contain . Then the elimination of will give us at most new clauses, in the worst case;

so will have no more clauses than did, whenever , namely when . * This condition clearly holds whenever or ; or , and even when .

Therefore repeated elimination of variables doesn't always cause the set of clauses to explode.In the worst case, however, it can be quite inefficient.

Page 32: TAoCP 7.7.7.2 Satisfiability の輪読

p.61 Algorithm I. 𝐶𝐶1 ∧ ⋯∧ 𝐶𝐶𝑚𝑚 : 𝑚𝑚 nonempty clauses on 𝑛𝑛 Boolean variables 𝑥𝑥1 … 𝑥𝑥𝑛𝑛

1972, Stephen Cook (𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝑐𝑐𝑙𝑙𝑐𝑐𝑢𝑢𝑠𝑠𝑠𝑠 𝑙𝑙𝑠𝑠𝑐𝑐𝑃𝑃𝑛𝑛𝑐𝑐𝑛𝑛𝑙𝑙)

𝐶𝐶1 𝐶𝐶2 𝐶𝐶3 𝐶𝐶4 𝐶𝐶5 𝐶𝐶6 𝐶𝐶7 𝐶𝐶8 𝐶𝐶9 𝐶𝐶10 𝐶𝐶11𝐶𝐶𝑖𝑖 𝐶𝐶𝑗𝑗

1234 12� 1�2�3� 1�3 23� 34�

𝑤𝑤 𝑙𝑙1 𝑙𝑙2 𝑙𝑙3 𝑙𝑙4

3 2 1

1� 2�3�

2 2� 23�

1�2�3�

12�

3�

1 3� 4� 1� 2� 1234

2

12�

134

1 1�3

34

𝐶𝐶12

4 34� 3

3

𝜖𝜖

3�

I3.I4.

I5.

𝐹𝐹

𝑙𝑙𝑑𝑑 :Choose a literal that occurs most frequently in the set of currently unsatisfied clauses that have the fewest unspecified literals.

Algorithm I is to minimize the number of resolution steps, but tends to fill memory with a great many new clauses when it is applied to large problems, and there's no obvious way to deal with those clauses efficiently.

Page 33: TAoCP 7.7.7.2 Satisfiability の輪読

p.63

123,234,345,456,567,678,789,135,246,357,468,579,147,258,369,159, 1�2�3�, 2�3�4�, 3�4�5�, 4�5�6�, 5�6�7�, 6�7�8�, 7�8�9�, 1�3�5�, 2�4�6�, 3�5�7�, 4�6�8�, 5�7�9�, 1�4�7�, 2�5�8�, 3�6�9�, 1�5�9�.

𝑤𝑤𝑐𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑠𝑠𝑛𝑛(3,3; 9)

0 ≤ 𝐹𝐹 < 𝑛𝑛 = 18

𝐿𝐿0 𝐿𝐿1 𝐿𝐿2 𝐿𝐿3 𝐿𝐿4 𝐿𝐿5 𝐿𝐿6 𝐿𝐿7 𝐿𝐿8 𝐿𝐿9 𝐿𝐿10 𝐿𝐿11 𝐿𝐿12 𝐿𝐿13 𝐿𝐿14 𝐿𝐿15 𝐿𝐿16 𝐿𝐿17 trail

6� 9� 2 𝜖𝜖 3

396 246

5

546

8

846

2�

2�5�8�

7�

7�5�3� reason

level

Λ

1

Λ

2

4�

Λ

3

depends directly on

depends on

Every conflict allows to construct a new clause 𝑐𝑐 that is true whenever the existing clauses are 𝑠𝑠𝑐𝑐𝑡𝑡,

with “learning" 𝑐𝑐 by adding it to the existing clauses, we will find a solution or learn 𝜖𝜖.

Conflict clause 𝑐𝑐 on level 3

CDCL: toward algorithm C.

Page 34: TAoCP 7.7.7.2 Satisfiability の輪読

p.64

45�68�

New clause 𝑐𝑐′

45�6

46 𝐿𝐿0 𝐿𝐿1 𝐿𝐿2 𝐿𝐿3 𝐿𝐿4 𝐿𝐿5 𝐿𝐿6 𝐿𝐿7 𝐿𝐿8 𝐿𝐿9 𝐿𝐿10 𝐿𝐿11 𝐿𝐿12 𝐿𝐿13 𝐿𝐿14 𝐿𝐿15 𝐿𝐿16 𝐿𝐿17

trail reason

level

6� 4 5 9 8 2 2� 1� 7� 3� Λ Λ 46 369 678 123 3�4�5� 5�7�9� 1�5�9� 2�5�8�

1 2

𝐿𝐿0 𝐿𝐿1 𝐿𝐿2 𝐿𝐿3 𝐿𝐿4 𝐿𝐿5 𝐿𝐿6 𝐿𝐿7 𝐿𝐿8 𝐿𝐿9 𝐿𝐿10 𝐿𝐿11 𝐿𝐿12 𝐿𝐿13 𝐿𝐿14 𝐿𝐿15 𝐿𝐿16 𝐿𝐿17 trail

6� 9� 2 𝜖𝜖 3 396 246

5 546

8 846

2� 2�5�8�

7� 7�5�3� reason

level

Λ

1

Λ

2

Conflict clause 𝑐𝑐 on level 3

4� Λ

3

135�8� → 135�67→ 35�679� → 35�69� → 35�6→ 4�5�6→ 5�6

Setting 𝐿𝐿2 ← 5� ,now forces 7, 1�,3,9,2�,8�,8, all at level 1; finally learn the 𝑢𝑢𝑛𝑛𝑐𝑐𝑡𝑡 𝑐𝑐𝑙𝑙𝑐𝑐𝑢𝑢𝑠𝑠𝑠𝑠 6

CDCL: toward algorithm C.

Page 35: TAoCP 7.7.7.2 Satisfiability の輪読

p.64

𝑙𝑙 ̅ 𝜖𝜖 trail

reason

Initial conflict clause

𝑙𝑙�̅�𝑐�1..𝑐𝑐�𝑖𝑖..𝑐𝑐�𝑘𝑘

𝑏𝑏 array

. . . . .

𝑏𝑏1 ← 𝑐𝑐1

𝑏𝑏�1 . . . 𝑏𝑏�𝑟𝑟

𝐿𝐿0 𝐿𝐿1 𝐿𝐿2 𝐿𝐿3 𝐿𝐿4 𝐿𝐿𝑡𝑡 𝐿𝐿9 … . . . . . .

counter 1 . . .

level 𝑤𝑤 𝑤𝑤’

𝐿𝐿𝑡𝑡𝑐𝑐𝑙�1..𝑐𝑐𝑙� 𝑖𝑖 ..𝑐𝑐𝑙�𝑘𝑘′

𝑐𝑐𝑙𝑖𝑖

𝑏𝑏�𝑖𝑖

𝐿𝐿0 𝐿𝐿1 𝐿𝐿2 𝐿𝐿3 𝐿𝐿4 𝐿𝐿𝑡𝑡 𝐿𝐿9 … trail

𝑐𝑐1 𝑙𝑙 ̅ 𝜖𝜖 𝑐𝑐𝑠𝑠 reason

stamp

𝑙𝑙�̅�𝑐�1..𝑐𝑐�𝑖𝑖..𝑐𝑐�𝑘𝑘

𝑏𝑏 array

level 𝑤𝑤 𝑤𝑤’

. . .

𝑐𝑐𝑟𝑟 . . . . . . . .

𝑏𝑏�1 . . . 𝑏𝑏�𝑟𝑟

𝑠𝑠 . .

. . .

counter 1 . . .

𝑐𝑐𝑘𝑘

𝐿𝐿𝑡𝑡𝑐𝑐𝑙�1..𝑐𝑐𝑙� 𝑖𝑖 ..𝑐𝑐𝑙�𝑘𝑘′

𝑐𝑐𝑙𝑖𝑖

𝑏𝑏�𝑖𝑖

𝐿𝐿𝑡𝑡 𝐿𝐿0 𝐿𝐿1 𝐿𝐿2 … trail

𝑐𝑐1 𝜖𝜖 reason

stamp

𝑏𝑏 array

level 𝑤𝑤 𝑤𝑤’

. . .

𝑐𝑐𝑟𝑟 . . . . .

𝑠𝑠 . .

. . .

counter 1

𝐿𝐿�𝑡𝑡

𝐿𝐿𝑡𝑡

𝐿𝐿�𝑡𝑡𝑏𝑏�1..𝑏𝑏�𝑟𝑟

. . . 𝑏𝑏�1 𝑏𝑏�𝑟𝑟

Stamp.

Eventually the count of unresolved literals decrease to 1 ; the learned clause is then 𝐿𝐿�𝑡𝑡 ∨ 𝑏𝑏�1 ∨ ⋯∨ 𝑏𝑏�𝑟𝑟 .

But the learned clauses by the efficient resolution steps might turn out to be quite large.

𝑐𝑐1 . . . 𝑐𝑐𝑘𝑘 𝑐𝑐𝑠𝑠

stamp 𝑠𝑠 . . 𝑃𝑃

𝑐𝑐𝑟𝑟

Page 36: TAoCP 7.7.7.2 Satisfiability の輪読

Redundancy of CDCL p.65

a CDCL solver was applied to the 2779 clauses of 𝑤𝑤𝑐𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑠𝑠𝑛𝑛(3, 10; 97), after about 10,000 clauses had been learned.

the clauses learned unsat had an average length of 19.9 → 11.2 ; simplification run about 33% faster.

that decision eventually lead to a conflict when trying to set 𝑳𝑳𝟔𝟔𝟔𝟔.

The complexity of a CDCL is devoted to unit propagation. Key is the value of a literal forced by previous assignments .

Page 37: TAoCP 7.7.7.2 Satisfiability の輪読

Exercise 257.

A literal 𝑙𝑙′� is said to be 𝑃𝑃𝑠𝑠𝑤𝑤𝑢𝑢𝑛𝑛𝑤𝑤𝑐𝑐𝑛𝑛𝑡𝑡, w.r.t. a given clause 𝑐𝑐 and the current trail, (i) 𝑙𝑙 is defined at level 0, or (ii) 𝑙𝑙 is not a decision literal and every false literal in 𝑙𝑙's reason is either in 𝑐𝑐 or (recursively) redundant.

𝐿𝐿0 𝐿𝐿1 𝐿𝐿2 … trail

𝜖𝜖 reason

stamp

𝑏𝑏 array

level

1

𝑤𝑤 𝑤𝑤’

. . . 𝑠𝑠

. . .

𝑙𝑙𝑙�

𝐿𝐿𝑡𝑡

𝑙𝑙𝑙�𝑏𝑏�1..𝑏𝑏�4

. . . 𝑏𝑏�1 𝑏𝑏�4

conflict clause 𝑐𝑐

the reason for 𝑏𝑏4 = 𝑏𝑏4 ∨ 𝑏𝑏�1 ∨ 𝑐𝑐�1 ,

the reason for 𝑐𝑐1 = 𝑐𝑐1 ∨ 𝑏𝑏�2 ∨ 𝑐𝑐�2 the reason for 𝑐𝑐2 = 𝑐𝑐2 ∨ 𝑏𝑏�1 ∨ 𝑏𝑏�3 .

𝑏𝑏4 is redundant, because 𝑐𝑐�2 and 𝑐𝑐�1 are redundant.

a) Suppose 𝑐𝑐 = 𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨ ⋯∨ 𝑏𝑏�𝑟𝑟 is a newly learned clause. Prove that if 𝑏𝑏�𝑗𝑗 ∈ 𝑐𝑐 is redundant, some other 𝑏𝑏�𝑖𝑖 ∈ 𝑐𝑐 became false on the same level of the trail as 𝑏𝑏𝑗𝑗 did.

b) Devise an efficient algorithm that discovers all of the redundant literals 𝑏𝑏�𝑖𝑖 in a given newly learned clause 𝑐𝑐 = 𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨ ⋯∨ 𝑏𝑏�𝑟𝑟 Hint: Use stamps.

p.155

Page 38: TAoCP 7.7.7.2 Satisfiability の輪読

Answer to Exercise 257 (b). p.233

b) Devise an efficient algorithm that discovers all of the redundant literals 𝑏𝑏�𝑖𝑖 in a given newly learned clause 𝑐𝑐 = 𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨ ⋯∨ 𝑏𝑏�𝑟𝑟 Hint: Use stamps. We can assume that the stamp value 𝒔𝒔 used when resolving conflicts is a multiple of 𝟑𝟑, and that all stamps are ≤ 𝒔𝒔. Then we can stamp literal 𝑙𝑙 with S 𝑙𝑙 ← 𝑠𝑠 + 1 if 𝑙𝑙 ̅ is known to be redundant, or 𝑠𝑠 + 2 if 𝑙𝑙 � is known to be nonredundant and not in 𝑐𝑐. (These stamps serve as a '‘memo cache" to avoid repeated work.) While building 𝑐𝑐 we can also stamp levels as well as literals, setting LS[𝑤𝑤𝑑] ← 𝑠𝑠 if level 𝑤𝑤𝑑 has exactly one of the 𝑏𝑏𝑖𝑖 , or 𝑠𝑠 + 1 if it has more than one. Then for 1 ≤ 𝑗𝑗 ≤ 𝑃𝑃, 𝑏𝑏𝑗𝑗 is redundant if and only if LS 𝑙𝑙𝑠𝑠𝑙𝑙 𝑏𝑏𝑗𝑗 ← 𝑠𝑠 + 1 and 𝑃𝑃𝑠𝑠𝑤𝑤 𝑏𝑏�𝑗𝑗 is true, where 𝑙𝑙𝑠𝑠𝑙𝑙(𝑙𝑙) = VAL 𝑙𝑙 ≫1 and where 𝑃𝑃𝑠𝑠𝑤𝑤(𝑙𝑙) is the following recursive procedure: “ If 𝑙𝑙 is a decision literal, return false. Otherwise let 𝑙𝑙 ∨ 𝑐𝑐�1 ∨ ⋯∨ 𝑐𝑐�𝑘𝑘 be 𝑙𝑙𝑙s reason. For 1 ≤ 𝑐𝑐 ≤ 𝑘𝑘 with 𝑙𝑙𝑠𝑠𝑙𝑙 𝑐𝑐𝑖𝑖 > 0, if S 𝑐𝑐𝑖𝑖 = s + 2 return false; if S 𝑐𝑐𝑖𝑖 < s and either LS 𝑙𝑙𝑠𝑠𝑙𝑙 𝑐𝑐𝑖𝑖 < 𝑠𝑠 or 𝑃𝑃𝑠𝑠𝑤𝑤 𝑐𝑐�𝑖𝑖 is false, set S 𝑐𝑐𝑖𝑖 ← 𝑠𝑠 + 2 and return false . But if none of these conditions hold, S 𝑙𝑙 ← 𝑠𝑠 + 1 and return true. “

𝑙𝑙

𝑠𝑠 + 1 𝑠𝑠 + 2

𝐿𝐿0 𝐿𝐿1 𝐿𝐿2 … trail

reason

stamp : S( )

𝑏𝑏 array

level : 𝑙𝑙𝑠𝑠𝑙𝑙( )

1

𝑤𝑤 𝑤𝑤’

. . . 𝑠𝑠

. . .

𝑙𝑙𝑙�

𝐿𝐿𝑡𝑡

𝑙𝑙𝑙�𝑏𝑏�1..𝑏𝑏�𝑟𝑟

. . . 𝑏𝑏�1 𝑏𝑏�𝑟𝑟

LS( ) 𝑠𝑠 𝑠𝑠 + 1

conflict clause 𝑐𝑐

𝑏𝑏𝑗𝑗

Page 39: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68+69

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

-1

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

c5.[New level? ]

c6.[Make a decision.]

c7.[Resolve a conflict.]

c8.[Backjump.]

c9.[Learn.]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

if 𝐹𝐹 = 𝑛𝑛 ⇔ if 𝑀𝑀 ≥ 𝑀𝑀p ⇔ if 𝑀𝑀 ≥ 𝑀𝑀f

terminatesuccesfully

prepare topurge excess

clauses

flush literalsas expected

⇔ otherwise

𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.

𝑘𝑘 ←HEAP 0delete k from the heap

if VAL 𝑘𝑘 ≥ 0 ⇔𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠

𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1 𝐿𝐿𝐹𝐹 ← 𝑙𝑙

TLOC( 𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1if 𝑤𝑤 = 0 ⇔ otherwise

terminateunsuccesfully

use the conflict clause 𝑐𝑐to construct𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨…∨ 𝑏𝑏�𝑟𝑟

ACT( 𝑙𝑙 )← ACT( 𝑙𝑙 ) +DELfor all literals 𝑙𝑙 stamped set d' to the max. level

occupied by 𝑏𝑏1, … ,𝑏𝑏𝑟𝑟 while 𝐹𝐹 > 𝑐𝑐𝑑𝑑′+1

𝐹𝐹 ← 𝐹𝐹 − 1

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

(Increasing ACT 𝑙𝑙 may change HEAP. )𝑙𝑙 ← 𝐿𝐿𝐹𝐹𝑘𝑘 ← 𝑙𝑙 OVAL(𝑘𝑘) ← VAL 𝑘𝑘𝑅𝑅𝑙𝑙 ← Λ if HLOC 𝑙𝑙 < 0 insert 𝑘𝑘 into HEAP.

𝐺𝐺 ← 𝐹𝐹𝑤𝑤 ← 𝑤𝑤𝑙

set 𝑐𝑐 ←MAXLIf 𝑤𝑤 > 0

store the new clause in MEM at position 𝑐𝑐advance MAXL to the next available position in MEM

𝑀𝑀 ←𝑀𝑀 + 1𝐿𝐿𝐹𝐹 ← 𝑙𝑙𝑙 TLOC( 𝑙𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙′ ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1 DEL←DEL/𝜌𝜌

Given a set of clauses on 𝑛𝑛 Boolean variables, this algorithm finds a solution 𝐿𝐿0𝐿𝐿1 … 𝐿𝐿𝑛𝑛−1 if and only if the clauses are satisfiable,

meanwhile discovering 𝑀𝑀 new ones that are consequences of the originals. After discovering 𝑀𝑀p new clauses, it will purge some of them from its memory and reset 𝑀𝑀p ;

after discovering 𝑀𝑀f of them, it will flush part of its trail, reset 𝑀𝑀f , and start over. (Details of purging and flushing will be discussed later.)

Page 40: TAoCP 7.7.7.2 Satisfiability の輪読

p.66+67

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

𝑐𝑐 − 1 𝑐𝑐 − 2

𝑐𝑐 − 3

𝑐𝑐 − 4

𝑐𝑐 − 5

c1.[Initialize]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

A monolithic array MEM hold all of the literals in all of the clauses Each clause 𝑐𝑐 = 𝑙𝑙0 ∨ 𝑙𝑙1 ∨ ⋯∨ 𝑙𝑙𝑘𝑘−1 with 𝑘𝑘 > 1 is represented by its starting position in MEM , with MEM 𝑐𝑐 + 𝑗𝑗 = 𝑙𝑙𝑗𝑗 for 0 ≤ 𝑗𝑗 < 𝑘𝑘.

Its two watched literals are 𝑙𝑙0 and 𝑙𝑙1, and its size 𝑘𝑘 is stored in MEM [𝑐𝑐 − 1].

MAXL is set equal to MINL, the smallest cell in MEM that is available for learned clauses; then MAXL grows as new clauses are added to the repertoire.

𝑥𝑥𝑘𝑘 and �̅�𝑥𝑘𝑘 , for 1 ≤ 𝑘𝑘 ≤ 𝑛𝑛, are represented by 2𝑘𝑘 and 2𝑘𝑘 + 1 each of these 2𝑛𝑛 literals 𝑙𝑙 has a list pointer 𝑊𝑊𝑙𝑙, which begins a linked list of the clauses in which 𝑙𝑙 is watched.

And We have 𝑊𝑊𝑙𝑙 = 0 if there is no such clause; but if 𝑊𝑊𝑙𝑙 = 𝑐𝑐 > 0, the next link in this "watch list" is in MEM [𝑐𝑐 − 2] if 𝑙𝑙 = 𝑙𝑙0, in MEM [𝑐𝑐 − 3]if 𝑙𝑙 = 𝑙𝑙1.

𝑥𝑥𝑘𝑘 for 1 ≤ 𝑘𝑘 ≤ 𝑛𝑛 has six current attributes

S(𝑘𝑘) is the "stamp"

If neither 𝑥𝑥𝑘𝑘 𝑛𝑛𝐵𝐵𝑃𝑃 �̅�𝑥𝑘𝑘 appears in the current trail, then VAL 𝑘𝑘 = −1, and we say that 𝒙𝒙𝒌𝒌 and its two literals are "free."

But if 𝐿𝐿𝑡𝑡 = 𝑙𝑙 is a literal of the trail, belonging to level 𝑤𝑤, we have

VAL 𝑙𝑙 ≤ 2𝑤𝑤 + 𝑙𝑙 &1 and TLOC 𝑙𝑙 = 𝑡𝑡 where 𝑙𝑙 = 𝑙𝑙 ≫ 1,

and we say that 𝑙𝑙 is "true" and 𝑙𝑙 ̅ is "false." Thus a given literal 𝑙𝑙 is false if and only if

VAL 𝑙𝑙 is nonnegative and VAL(|𝑙𝑙|) + 𝑙𝑙 is odd.

𝑥𝑥𝑘𝑘 has an activity score ACT(𝒌𝒌), which heuristically estimates its desirability for branching.

All of the free variables, and possibly others, are kept in an array called HEAP, which is arranged so that

ACT HEAP 𝑗𝑗 ≤ ACT HEAP 𝑗𝑗 − 1 ≫ 1 for 0 < 𝑗𝑗 < 𝑐

the variable DEL holds the current scaling factor 𝜌𝜌−𝑀𝑀 , divided by 10100each time all of the activities have been rescaled. where 𝜌𝜌 is a damping factor (say 𝜌𝜌 = .95)

OVAL(𝑘𝑘), to control the polarity of each new decision Algorithm 𝑪𝑪 starts by simply making each OVAL 𝑘𝑘 odd, Afterwards it sets OVAL 𝑘𝑘 ←VAL 𝑘𝑘 whenever 𝑥𝑥𝑘𝑘 leaves the trail and becomes free

Page 41: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

𝑐𝑐 − 1 𝑐𝑐 − 2

𝑐𝑐 − 3

𝑐𝑐 − 4

𝑐𝑐 − 5

c1.[Initialize]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

Exercise 260: Describe in detail step C1's setting-up of MEM, the watch lists, and the trail.

First, to get a random permutation in the heap we can use a variant of Algorithm 3.4.2P: For 𝑘𝑘 ← 1, 2, … ,𝑛𝑛, let 𝑗𝑗 be a random integer in [0 . . 𝑘𝑘 − 1] and set HEAP[𝑘𝑘 − 1] ←HEAP[𝑗𝑗], HEAP[ 𝑗𝑗 ] ← 𝑘𝑘. Then set HLOC HEAP [ 𝑗𝑗 ] ← 𝑗𝑗 for 0 ≤ 𝑗𝑗 < 𝑛𝑛. Next, set 𝐹𝐹 ← 0 and 𝑊𝑊𝑙𝑙 ← 0 for 2 ≤ 𝑙𝑙 ≤ 2𝑛𝑛 + 1 and 𝑐𝑐 ← 3. Do the following for each input clause 𝑙𝑙0𝑙𝑙1 … 𝑙𝑙𝑘𝑘−1: Terminate unsuccessfully if 𝑘𝑘 = 0, or if 𝑘𝑘 = 1 and 0 ≤VAL 𝑙𝑙0 ≠ 𝑙𝑙0 & 1. If 𝑘𝑘 = 1 and VAL 𝑙𝑙0 < 0 , set VAL 𝑙𝑙0 ← 𝑙𝑙0 & 1, TLOC 𝑙𝑙0 ← 𝐹𝐹 , 𝐹𝐹 ← 𝐹𝐹 + 1. If 𝑘𝑘 > 1, set MEM 𝑐𝑐 + 𝑗𝑗 ← 𝑙𝑙0 for 0 ≤ 𝑗𝑗 < 𝑘𝑘 ; also MEM 𝑐𝑐 − 1 ← 𝑘𝑘, MEM 𝑐𝑐 − 2 ← 𝑊𝑊𝑙𝑙0, 𝑊𝑊𝑙𝑙0 ← 𝑐𝑐, MEM 𝑐𝑐 − 3 ← 𝑊𝑊𝑙𝑙1, 𝑊𝑊𝑙𝑙1 ← 𝑐𝑐, 𝑐𝑐 ← 𝑐𝑐 + 𝑘𝑘 + 3, Finally, set MINL ← MAXL ← 𝑐𝑐 + 2 (allowing two cells for extra data in the preamble of the first learned clause). Of course we must also ensure that MEM is large enough.

Page 42: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

c5.[New level? ]

Page 43: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅ ⇔ 𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

c7.[Resolve a conflict.]

c5.[New level? ]

Exercise 261: The main loop of Algorithm C is the unit-propagation process of steps C3 and C4. Describe the low-level details of link adjustment, etc., to be done in those steps.

(Throughout this answer, 𝑙𝑙𝑗𝑗 is an abbreviation for MEM 𝑐𝑐 + 𝑗𝑗 .) Set 𝑞𝑞 ← 0 and 𝑐𝑐 ← 𝑊𝑊𝑙𝑙̅. While 𝑐𝑐 ≠ 0, do the following: Set 𝑙𝑙𝑙 ← 𝑙𝑙0. If 𝑙𝑙′ ≠ 𝑙𝑙 ̅(hence 𝑙𝑙1 = 𝑙𝑙)̅, set 𝑐𝑐𝑙 ← 𝑙𝑙−3 ; otherwise set 𝑙𝑙𝑙 ← 𝑙𝑙1, 𝑙𝑙0← 𝑙𝑙𝑙, 𝑙𝑙1 ← 𝑙𝑙 ̅, 𝑐𝑐𝑙 ← 𝑙𝑙−2, 𝑙𝑙−2 ← 𝑙𝑙−3, and 𝑙𝑙−3← 𝑐𝑐𝑙. If VAL 𝑙𝑙0 ≥ 0 and VAL 𝑙𝑙0 + 𝑙𝑙0 is even (that is, if 𝑙𝑙0 is true), perform the steps if 𝑞𝑞 ≠ 0, set MEM 𝑞𝑞 − 3 ← 𝑐𝑐, else set 𝑊𝑊𝑙𝑙̅ ← 𝑐𝑐 ; then set 𝑞𝑞 ← 𝑐𝑐. * Otherwise set 𝑗𝑗 ← 2; while 𝑗𝑗 < 𝑙𝑙−1 and VAL 𝑙𝑙𝑗𝑗 ≥ 0 and VAL 𝑙𝑙𝑗𝑗 + 𝑙𝑙𝑗𝑗 is odd, set 𝑗𝑗 = 𝐽𝐽 + 1. If now 𝑗𝑗 < 𝑗𝑗−1, set 𝑙𝑙1 ← 𝑙𝑙𝑗𝑗, 𝑙𝑙𝑗𝑗 ← 𝑙𝑙,̅ 𝑙𝑙−3 ← 𝑊𝑊𝑙𝑙1 , 𝑊𝑊𝑙𝑙1 ← 𝑐𝑐. But if 𝑗𝑗 = 𝑙𝑙−1, do(*) above; jump to C7 if VAL 𝑙𝑙0 ≥ 0 ; otherwise set 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0, etc. (see step C4) and 𝑐𝑐 ← 𝑐𝑐𝑙. Finally, when 𝑐𝑐 = 0, do(*) above to terminate 𝑙𝑙’̅s new watch list.

Page 44: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

c7.[Resolve a conflict.]

c5.[New level? ]

Reason

Page 45: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

c5.[New level? ]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

if 𝐹𝐹 = 𝑛𝑛 ⇔ if 𝑀𝑀 ≥ 𝑀𝑀p ⇔ if 𝑀𝑀 ≥ 𝑀𝑀f

terminatesuccesfully

prepare topurge excess

clauses

flush literalsas expected

⇔ otherwise

𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

c7.[Resolve a conflict.]

Page 46: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

c5.[New level? ]

c6.[Make a decision.]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

if 𝐹𝐹 = 𝑛𝑛 ⇔ if 𝑀𝑀 ≥ 𝑀𝑀p ⇔ if 𝑀𝑀 ≥ 𝑀𝑀f

terminatesuccesfully

prepare topurge excess

clauses

flush literalsas expected

⇔ otherwise

𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.

𝑘𝑘 ←HEAP 0delete k from the heap

if VAL 𝑘𝑘 ≥ 0 ⇔𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠

𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1 𝐿𝐿𝐹𝐹 ← 𝑙𝑙

TLOC( 𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

c7.[Resolve a conflict.]

Exercise 262 : What low-level operations underlie changes to the heap in steps C6-C8?

Otherwise set 𝑐𝑐 ← HEAP 𝑐 , 𝛼𝛼 ←ACT 𝑐𝑐 , 𝑗𝑗 ← 0, 𝑗𝑗𝑙 ← 1, and do the following while 𝑗𝑗𝑙 < 𝑐: Set 𝛼𝛼𝑙 ← ACT HEAP 𝑗𝑗𝑙 ; if 𝑗𝑗𝑙 + 1 < 𝑐 and ACT HEAP 𝑗𝑗′ + 1 > α′, set 𝑗𝑗′ ← 𝑗𝑗𝑙 + 1 and 𝛼𝛼𝑙 ← ACT HEAP 𝑗𝑗𝑙 ; if 𝛼𝛼 > 𝛼𝛼𝑙, set 𝑗𝑗𝑙 ← 𝑐, otherwise set HEAP[ 𝑗𝑗 ] ← HEAP[𝑗𝑗𝑙], HLOC HEAP[ 𝑗𝑗𝑙 ] ← 𝑗𝑗 , 𝑗𝑗 ← 𝑗𝑗𝑙, and 𝑗𝑗𝑙 ← 2𝑗𝑗 + 1. Then set HEAP[ 𝑗𝑗] ← 𝑐𝑐 and HLOC(𝑐𝑐 ) ← 𝑗𝑗.

To delete 𝑘𝑘 = HEAP 0 in C6: Set 𝑐 ← 𝑐 − 1 and HLOC 𝑘𝑘 ← −1. Stop if 𝑐 = 0.

Page 47: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

c5.[New level? ]

c6.[Make a decision.]

c7.[Resolve a conflict.]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

if 𝐹𝐹 = 𝑛𝑛 ⇔ if 𝑀𝑀 ≥ 𝑀𝑀p ⇔ if 𝑀𝑀 ≥ 𝑀𝑀f

terminatesuccesfully

prepare topurge excess

clauses

flush literalsas expected

⇔ otherwise

𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.

𝑘𝑘 ←HEAP 0delete k from the heap

if VAL 𝑘𝑘 ≥ 0 ⇔𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠

𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1 𝐿𝐿𝐹𝐹 ← 𝑙𝑙

TLOC( 𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1if 𝑤𝑤 = 0 ⇔ otherwise

terminateunsuccesfully

use the conflict clause 𝑐𝑐to construct𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨…∨ 𝑏𝑏�𝑟𝑟

ACT( 𝑙𝑙 )← ACT( 𝑙𝑙 ) +DELfor all literals 𝑙𝑙 stamped set d' to the max. level

occupied by 𝑏𝑏1, … ,𝑏𝑏𝑟𝑟

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

(Increasing ACT 𝑙𝑙 may change HEAP. )In C7, set 𝑘𝑘 ← 𝑙𝑙 , 𝛼𝛼 ← ACT(𝑘𝑘), ACT( 𝑘𝑘) ← α +DEL, 𝑗𝑗 ← HLOC(𝑘𝑘), and if 𝑗𝑗 > 0 perform the "siftup" operation: "Looping repeatedly, set 𝑗𝑗𝑙 ← (𝑗𝑗 − 1) ≫ 1 and 𝑐𝑐 ←HEAP[𝑗𝑗𝑙], exit if ACT(𝑐𝑐) ≥ α, else set HEAP 𝑗𝑗 ← 𝑐𝑐, HLOC(𝑐𝑐) ← 𝑗𝑗 , 𝑗𝑗 ← 𝑗𝑗𝑙, and exit if 𝑗𝑗 = 0. Then set HEAP[ 𝑗𝑗] ← 𝑘𝑘 and HLOC(𝑘𝑘) ← 𝑗𝑗."

Exercise 262 : What low-level operations underlie changes to the heap in steps C6-C8?

Page 48: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

-1

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

c5.[New level? ]

c6.[Make a decision.]

c7.[Resolve a conflict.]

c8.[Backjump.]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

if 𝐹𝐹 = 𝑛𝑛 ⇔ if 𝑀𝑀 ≥ 𝑀𝑀p ⇔ if 𝑀𝑀 ≥ 𝑀𝑀f

terminatesuccesfully

prepare topurge excess

clauses

flush literalsas expected

⇔ otherwise

𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.

𝑘𝑘 ←HEAP 0delete k from the heap

if VAL 𝑘𝑘 ≥ 0 ⇔𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠

𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1 𝐿𝐿𝐹𝐹 ← 𝑙𝑙

TLOC( 𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1if 𝑤𝑤 = 0 ⇔ otherwise

terminateunsuccesfully

use the conflict clause 𝑐𝑐to construct𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨…∨ 𝑏𝑏�𝑟𝑟

ACT( 𝑙𝑙 )← ACT( 𝑙𝑙 ) +DELfor all literals 𝑙𝑙 stamped set d' to the max. level

occupied by 𝑏𝑏1, … ,𝑏𝑏𝑟𝑟 while 𝐹𝐹 > 𝑐𝑐𝑑𝑑′+1

𝐹𝐹 ← 𝐹𝐹 − 1

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

(Increasing ACT 𝑙𝑙 may change HEAP. )𝑙𝑙 ← 𝐿𝐿𝐹𝐹𝑘𝑘 ← 𝑙𝑙 OVAL(𝑘𝑘) ← VAL 𝑘𝑘𝑅𝑅𝑙𝑙 ← Λ if HLOC 𝑙𝑙 < 0 insert 𝑘𝑘 into HEAP.

𝐺𝐺 ← 𝐹𝐹𝑤𝑤 ← 𝑤𝑤𝑙

Exercise 262 : What low-level operations underlie changes to the heap in steps C6-C8?

To insert 𝑘𝑘 in C8, set 𝛼𝛼 ← ACT(𝑘𝑘), 𝑗𝑗 ← 𝑐, 𝑐 ← 𝑐 + 1; if 𝑗𝑗 = 0 set HEAP 0 ← 𝑘𝑘 and HLOC(𝑘𝑘) ← 0; otherwise perform the siftup operation.

Page 49: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

c5.[New level? ]

c6.[Make a decision.]

c7.[Resolve a conflict.]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

if 𝐹𝐹 = 𝑛𝑛 ⇔ if 𝑀𝑀 ≥ 𝑀𝑀p ⇔ if 𝑀𝑀 ≥ 𝑀𝑀f

terminatesuccesfully

prepare topurge excess

clauses

flush literalsas expected

⇔ otherwise

𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.

𝑘𝑘 ←HEAP 0delete k from the heap

if VAL 𝑘𝑘 ≥ 0 ⇔𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠

𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1 𝐿𝐿𝐹𝐹 ← 𝑙𝑙

TLOC( 𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1if 𝑤𝑤 = 0 ⇔ otherwise

terminateunsuccesfully

use the conflict clause 𝑐𝑐to construct𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨…∨ 𝑏𝑏�𝑟𝑟

ACT( 𝑙𝑙 )← ACT( 𝑙𝑙 ) +DELfor all literals 𝑙𝑙 stamped set d' to the max. level

occupied by 𝑏𝑏1, … ,𝑏𝑏𝑟𝑟

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

(Increasing ACT 𝑙𝑙 may change HEAP. )

Exercise 263: Write out the gory details by which step C7 constructs a new clause and step C9 puts it into the data structures of Algorithm C.

(This answer also sets the level stamps LS [𝑤𝑤] needed in answer 257, assuming that the LS array is initially zero.) Let “ bump 𝑙𝑙 " mean “ increase ACT 𝑙𝑙 by DEL" as in answer 262. Also let 𝑏𝑏𝑙𝑙𝑐𝑐𝑡𝑡(𝑙𝑙) be the following subroutine: "If S 𝑙𝑙 = 𝑠𝑠 , do nothing. Otherwise set S 𝑙𝑙 ← 𝑠𝑠, 𝑝𝑝 ← 𝑙𝑙𝑠𝑠𝑙𝑙 (𝑙𝑙). If 𝑝𝑝 > 0, bump 𝑙𝑙 ; then if 𝑝𝑝 = 𝑤𝑤, set 𝑞𝑞 ← 𝑞𝑞 + 1; else set 𝑃𝑃 ← 𝑃𝑃 + 1, 𝑏𝑏𝑟𝑟 ← 𝑙𝑙,̅ 𝑤𝑤𝑙 ← max (𝑤𝑤𝑙,𝑝𝑝), and if LS[𝑝𝑝] ≤ 𝑠𝑠 set LS 𝑝𝑝 ← 𝑠𝑠 + LS[𝑝𝑝] = 𝑠𝑠 ."

Page 50: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

c5.[New level? ]

c6.[Make a decision.]

c7.[Resolve a conflict.]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

if 𝐹𝐹 = 𝑛𝑛 ⇔ if 𝑀𝑀 ≥ 𝑀𝑀p ⇔ if 𝑀𝑀 ≥ 𝑀𝑀f

terminatesuccesfully

prepare topurge excess

clauses

flush literalsas expected

⇔ otherwise

𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.

𝑘𝑘 ←HEAP 0delete k from the heap

if VAL 𝑘𝑘 ≥ 0 ⇔𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠

𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1 𝐿𝐿𝐹𝐹 ← 𝑙𝑙

TLOC( 𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1if 𝑤𝑤 = 0 ⇔ otherwise

terminateunsuccesfully

use the conflict clause 𝑐𝑐to construct𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨…∨ 𝑏𝑏�𝑟𝑟

ACT( 𝑙𝑙 )← ACT( 𝑙𝑙 ) +DELfor all literals 𝑙𝑙 stamped set d' to the max. level

occupied by 𝑏𝑏1, … ,𝑏𝑏𝑟𝑟

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

(Increasing ACT 𝑙𝑙 may change HEAP. )

Exercise 263: Write out the gory details by which step C7 constructs a new clause and step C9 puts it into the data structures of Algorithm C.

When step C7 is entered from C4, assuming that 𝑤𝑤 > 0, set 𝑤𝑤𝑙 ← 𝑞𝑞 ← 𝑃𝑃 ← 0, 𝑠𝑠 ← 𝑠𝑠 + 3, S( 𝑙𝑙0 ) ← 𝑠𝑠, bump 𝑙𝑙0, and do 𝑏𝑏𝑙𝑙𝑐𝑐𝑡𝑡(𝑙𝑙𝑗𝑗) for 1 ≤ 𝑗𝑗 < 𝑘𝑘. Also set 𝑡𝑡 ← max ( TLOC 𝑙𝑙1 ,…,TLOC 𝑙𝑙𝑘𝑘−1 ). Then, while 𝑞𝑞 > 0, set 𝑙𝑙 ← 𝑙𝑙𝑡𝑡, 𝑡𝑡 ← 𝑡𝑡 − 1; if S 𝑙𝑙 = 𝑠𝑠 then set 𝑞𝑞 ← 𝑞𝑞 − 1, and if 𝑅𝑅𝑙𝑙 ≠ Λ let clause 𝑅𝑅𝑙𝑙 be 𝑙𝑙0𝑙𝑙1 … 𝑙𝑙𝑘𝑘−1 and do 𝑏𝑏𝑙𝑙𝑐𝑐𝑡𝑡(𝑙𝑙𝑗𝑗) for 1 ≤ 𝑗𝑗 < 𝑘𝑘. Finally set 𝑙𝑙′ ← 𝐿𝐿𝑡𝑡 , and while S 𝑙𝑙𝑙 ≠ 𝑠𝑠 set 𝑡𝑡 ← 𝑡𝑡 − 1 and 𝑙𝑙′ ← 𝐿𝐿𝑡𝑡.

Page 51: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

-1

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

c5.[New level? ]

c6.[Make a decision.]

c7.[Resolve a conflict.]

c8.[Backjump.]

c9.[Learn.]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

if 𝐹𝐹 = 𝑛𝑛 ⇔ if 𝑀𝑀 ≥ 𝑀𝑀p ⇔ if 𝑀𝑀 ≥ 𝑀𝑀f

terminatesuccesfully

prepare topurge excess

clauses

flush literalsas expected

⇔ otherwise

𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.

𝑘𝑘 ←HEAP 0delete k from the heap

if VAL 𝑘𝑘 ≥ 0 ⇔𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠

𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1 𝐿𝐿𝐹𝐹 ← 𝑙𝑙

TLOC( 𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1if 𝑤𝑤 = 0 ⇔ otherwise

terminateunsuccesfully

use the conflict clause 𝑐𝑐to construct𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨…∨ 𝑏𝑏�𝑟𝑟

ACT( 𝑙𝑙 )← ACT( 𝑙𝑙 ) +DELfor all literals 𝑙𝑙 stamped set d' to the max. level

occupied by 𝑏𝑏1, … ,𝑏𝑏𝑟𝑟 while 𝐹𝐹 > 𝑐𝑐𝑑𝑑′+1

𝐹𝐹 ← 𝐹𝐹 − 1

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

(Increasing ACT 𝑙𝑙 may change HEAP. )𝑙𝑙 ← 𝐿𝐿𝐹𝐹𝑘𝑘 ← 𝑙𝑙 OVAL(𝑘𝑘) ← VAL 𝑘𝑘𝑅𝑅𝑙𝑙 ← Λ if HLOC 𝑙𝑙 < 0 insert 𝑘𝑘 into HEAP.

𝐺𝐺 ← 𝐹𝐹𝑤𝑤 ← 𝑤𝑤𝑙

set 𝑐𝑐 ←MAXLIf 𝑤𝑤 > 0

store the new clause in MEM at position 𝑐𝑐advance MAXL to the next available position in MEM

𝑀𝑀 ←𝑀𝑀 + 1𝐿𝐿𝐹𝐹 ← 𝑙𝑙𝑙 TLOC( 𝑙𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙′ ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1 DEL←DEL/𝜌𝜌

Exercise 263: Write out the gory details by which step C7 constructs a new clause and step C9 puts it into the data structures of Algorithm C.

The new clause can now be checked for redundancies as in answer 257. To install it during step C9, there's a subtle point: We must watch a literal that was defined on level 𝑤𝑤𝑙. Thus we set 𝑐𝑐 ← MAXL, MEM[𝑐𝑐] ← 𝑙𝑙 ̅𝑙 , 𝑘𝑘 ← 0, 𝑗𝑗 𝑙 ← 1; and for 1 ≤ 𝑗𝑗 ≤ 𝑃𝑃 if S 𝑏𝑏𝑗𝑗 = 𝑠𝑠 set 𝑘𝑘 ← 𝑘𝑘 + 1 and do this: If 𝑗𝑗𝑙 = 0 or 𝑙𝑙𝑠𝑠𝑙𝑙( 𝑏𝑏𝑗𝑗 ) < 𝑤𝑤𝑙, Set MEM[𝑐𝑐 + 𝑘𝑘 + 𝑗𝑗𝑙] ← 𝑏𝑏�𝑗𝑗, otherwise set MEM[𝑐𝑐 + 1] ← 𝑏𝑏�𝑗𝑗, 𝑗𝑗𝑙 ← 0, MEM 𝑐𝑐 − 2 ← 𝑊𝑊𝑙𝑙′� , 𝑊𝑊𝑙𝑙′� ← 𝑐𝑐, MEM[𝑐𝑐 − 3] ← 𝑊𝑊𝑏𝑏�𝑗𝑗, 𝑊𝑊𝑏𝑏�𝑗𝑗 ← 𝑐𝑐. Finally set MEM[𝑐𝑐 − 1] ← 𝑘𝑘 + 1, MAXL← 𝑐𝑐 + 𝑘𝑘 + 6.

Page 52: TAoCP 7.7.7.2 Satisfiability の輪読

Algorithm C p.68

(𝑆𝑆𝑐𝑐𝑡𝑡𝑐𝑐𝑠𝑠𝑓𝑓𝑐𝑐𝑐𝑐𝑏𝑏𝑐𝑐𝑙𝑙𝑐𝑐𝑡𝑡𝑦𝑦 𝑏𝑏𝑦𝑦 𝐶𝐶𝐶𝐶𝐶𝐶𝐿𝐿).

0 0 0 0 1 0 -1 -1 -1 0

MEM[ ] 𝑊𝑊 S(𝑘𝑘) VAL(𝑘𝑘) OVAL(𝑘𝑘) TLOC(𝑘𝑘) HLOC(𝑘𝑘) ACT(𝑘𝑘) HEAP[ ]

c1.[Initialize]

c2.[Level

complete?]

c3.[Advance 𝐺𝐺.]

c4.[Does 𝑐𝑐 force a unit? ]

c5.[New level? ]

c6.[Make a decision.]

𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠

𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛

MINL andMAXLto 1st available position

𝑐𝑐0 ← 0

DEL 𝑐

𝑛𝑛

𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains allliterals

forced by 𝐿𝐿0 …𝐿𝐿𝐺−1if 𝐺𝐺 = 𝐹𝐹

𝑙𝑙 ← 𝐿𝐿𝐺 𝐺𝐺 = 𝐺𝐺 + 1

for all c in the watch list of 𝑙𝑙 ̅

𝑙𝑙0𝑙𝑙1...𝑙𝑙𝑘𝑘−1be the literals of clause 𝑐𝑐, where 𝑙𝑙1=𝑙𝑙.̅(Swap 𝑙𝑙0↔ 𝑙𝑙1if necessary. )⇔𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭 if no conflict ⇔

if 𝑙𝑙0 is true ⇔ otherwise𝐥𝐨𝐨𝐤 𝐟𝐨𝐫 𝐚 𝐥𝐢𝐭𝐞𝐫𝐚𝐥 𝒍𝒋with 1 < 𝑗𝑗 < 𝑘𝑘 that is not falsefound ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false

𝑙𝑙0 false ⇔ 𝑙𝑙0 free𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗

𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈 𝐿𝐿𝐹𝐹 ← 𝑙𝑙0 TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0 ← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1

if 𝐹𝐹 = 𝑛𝑛 ⇔ if 𝑀𝑀 ≥ 𝑀𝑀p ⇔ if 𝑀𝑀 ≥ 𝑀𝑀f

terminatesuccesfully

prepare topurge excess

clauses

flush literalsas expected

⇔ otherwise

𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.

𝑘𝑘 ←HEAP 0delete k from the heap

if VAL 𝑘𝑘 ≥ 0 ⇔𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠

𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1 𝐿𝐿𝐹𝐹 ← 𝑙𝑙

TLOC( 𝑙𝑙 )← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1

𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 …𝐿𝐿𝐹𝐹−1But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲

if clause 𝑙𝑙 and 𝑙𝑙𝑙contradiction

𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEMand the watch list

𝑝𝑝1 …𝑝𝑝𝑛𝑛 is a random permutation of 1,… ,𝑛𝑛

c7.[Resolve a conflict.]

Exercise 266 : CDCL solvers are often designed to make decisions at random, with a small probability 𝑝𝑝 (say 𝑝𝑝 = .02), instead of always choosing a variable of maximum activity. How would this policy change step C6?

If 𝑈𝑈 < 𝑝𝑝, where 𝑈𝑈 is a uniform deviate between 0 and 1, do this:

Set 𝑗𝑗 to a random integer with 0 ≤ 𝑗𝑗 < 𝑐, and 𝑘𝑘 ←HEAP[𝑗𝑗]. If 𝑗𝑗 = 0, or if VAL(𝑘𝑘) ≥ 0, use the normal C6.

Otherwise branch on 𝑘𝑘 (and don't bother to remove 𝑘𝑘 from the heap).

Page 53: TAoCP 7.7.7.2 Satisfiability の輪読

Reality check

Random choices make the running time of this algorithm more variable than it was in Algorithms A, B, D, or L; sometimes we're lucky, sometimes we're not.

The running time of Algorithms A, B, D, and L on 𝑓𝑓𝑠𝑠𝑛𝑛𝑐𝑐𝑃𝑃𝑘𝑘(𝑞𝑞) is proportional to 2𝑞𝑞, so it's way off the chart well over a gigamem already when 𝑞𝑞 = 19. But Algorithm C polishes off the case 𝑞𝑞 = 99 in that same amount of time (thus winning by 24 orders of magnitude)! On the other hand, no satisfactory theoretical explanation for the apparently linear behavior in Fig. is presently known.

Computation times (in megamems) are shown for nine trials at each value of 𝑞𝑞.

Algorithm C often speeds things up much more dramatically, in fact. For example, how it whips through a sequence of three-coloring problems based on "flower snarks."

It is not possible to color the edges of the flower snark graph 𝐽𝐽𝑞𝑞 with three colors, when 𝑞𝑞 is odd.

p.69

Page 54: TAoCP 7.7.7.2 Satisfiability の輪読

Certificates of unsatisfiability. p.70

if SAT solver report is 𝑛𝑛𝑠𝑠𝑙𝑙𝑐𝑐𝑡𝑡𝑐𝑐𝑙𝑙𝑠𝑠 - UNSAT how confident can we be that such a claim is true?

Fig.48.

let 𝑅𝑅 be Rivest's clauses (6), which were proved unsatisfiable in Fig. 48.

𝑅𝑅 ∧ 1� ∧ 2� ⊢1 3� ⊢1 4� ⊢1 𝜖𝜖 (using 123�, 234�, and 341); 𝑅𝑅 ∧ 12 ∧ 1� ⊢1 2 ⊢1 4� ⊢1 3� ⊢1 𝜖𝜖 ( using 12, 4�12�, 2�3�4, and 341); 𝑅𝑅 ∧ 12 ∧ 1 ⊢1 2� ⊢1 4 ⊢1 3 ⊢1 𝜖𝜖 (using 41�2, 234�, and 3�4�1�); 𝑅𝑅 ∧ 12 ∧ 1 ⊢1 2 ⊢1 3 ⊢1 4 ⊢1 𝜖𝜖 (using 1�2�3, 2�3�4, and 3�4�1�).

Then (12, 1, 2, 𝜖𝜖) is a certificate of unsatisfiability, because

Page 55: TAoCP 7.7.7.2 Satisfiability の輪読

Theorem G. p.70

𝐹𝐹 ∧ 𝐶𝐶1 ∧ ⋯∧ 𝐶𝐶𝑖𝑖−1 ∧ �̅�𝐶𝑖𝑖 ⊢1 𝜖𝜖 for 1 ≤ 𝑐𝑐 ≤ 𝑡𝑡.

‘𝐺𝐺 ⊢1 𝜖𝜖’ : the clauses 𝐺𝐺 lead to a contradiction by unit propagation; and if 𝐶𝐶𝑖𝑖 : the clause 𝑐𝑐1,∨ ⋯∨ 𝑐𝑐𝑘𝑘 𝐶𝐶 = 𝑆𝑆0 and 𝑅𝑅𝑙𝑙𝑖𝑖 = 𝑙𝑙𝑖𝑖 ∨ 𝑆𝑆𝑖𝑖 , where all literals of 𝑆𝑆0 ∪ 𝑆𝑆1 ∪ ⋯∪ 𝑆𝑆𝑠𝑠 are false

If Algorithm C terminates unsuccessfully, the sequence 𝐶𝐶1,𝐶𝐶2, … ,𝐶𝐶𝑡𝑡 of clauses that it has learned is a certificate of unsatisfiability.

for a family of clauses 𝐹𝐹 if 𝐶𝐶𝑡𝑡 = 𝜖𝜖,and if we have

𝐶𝐶′ = 𝑙𝑙𝑙� ∨ 𝑏𝑏�1 …∨ 𝑏𝑏�𝑟𝑟 ,

𝐶𝐶′ = … 𝐶𝐶 ⋄ 𝑅𝑅𝑙𝑙1 ⋄ 𝑅𝑅𝑙𝑙2 ⋄ ⋯ ⋄ 𝑅𝑅𝑙𝑙𝑛𝑛

𝚤𝚤�̅�𝑖 ∈ 𝑆𝑆0 ∪ ⋯∪ 𝑆𝑆𝑖𝑖−1, for 1 ≤ 𝑐𝑐 ≤ 𝑠𝑠; 𝑆𝑆0 ∪ 𝑆𝑆1 ∪ ⋯∪ 𝑆𝑆𝑠𝑠 = 𝑙𝑙𝑙�, 𝑙𝑙1̅, … , 𝑙𝑙�̅�𝑠, 𝑏𝑏�1, … , 𝑏𝑏�𝑟𝑟 .

Unit propagations can be done without the "reason“, however, 𝑅𝑅𝑙𝑙 as the certificate checker purge clauses

that will no longer be relevant to the proof.

Page 56: TAoCP 7.7.7.2 Satisfiability の輪読

p.71+P.157 Exercise 284.

Mark 𝑐𝑐, stamp S( 𝑙𝑙𝑗𝑗 ) ← 𝑐𝑐 for 0 ≤ 𝑗𝑗 < 𝑘𝑘, set 𝑝𝑝 ← max ( TLOC 𝑙𝑙1 ,… , TLOC ( 𝑙𝑙𝑘𝑘−1 )) . While 𝑝𝑝 ≥ 𝐸𝐸, we set 𝑙𝑙 ← 𝐿𝐿𝑝𝑝, 𝑝𝑝 ← 𝑝𝑝 − 1, and if S ( 𝑙𝑙 ) = 𝑐𝑐 we also "resolve with the reason of 𝑙𝑙" as follows: Let clause 𝑅𝑅𝑙𝑙 be 𝑙𝑙0𝑙𝑙1 … 𝑙𝑙𝑘𝑘−1, mark 𝑅𝑅𝑙𝑙, and set S 𝑙𝑙𝑗𝑗 ← 𝑐𝑐 for 1 ≤ 𝑗𝑗 < 𝑘𝑘.

Explain how to use reasons so that clauses are marked by the verifier only if they actually participate in the proof of a marked clause 𝐶𝐶𝑖𝑖.

VAL(𝑗𝑗) ← 0 for 0 ≤ 𝑗𝑗 ≤ 𝑛𝑛, 𝑙𝑙0 ← 0: 𝐿𝐿1 ← 𝑐𝑐�1, … , 𝐿𝐿𝑘𝑘 ← 𝑐𝑐�𝑘𝑘, 𝐸𝐸 ← 𝐹𝐹 ← 𝑘𝑘 + 1,𝐺𝐺 ← 0, and VAL 𝐿𝐿𝑝𝑝 ← 𝐿𝐿𝑝𝑝 & 1 for 0 ≤ 𝑗𝑗 ≤ 𝑛𝑛;

Give preference to already-marked clauses when doing the unit propagations.

trail

reason

Initial conflict clause

.. ..

array

. . . . .

. . .

. . . . . .

counter . . .

level ’

.. .

. . .

stamp . .

trail

reason

stamp

.. ..

array

level ’

. . .

. . . . . . . .

. . .

. .

. . .

counter . . .

.. .

trail

reason

stamp

array

level ’

. . .

. . . . .

. .

. . .

counter

..

. . .

Algorithm C can inform

Page 57: TAoCP 7.7.7.2 Satisfiability の輪読

*Purging unhelpful clauses. p.71

Algorithm C periodically weed out the clauses that appear to be more harmful than helpful, as soon as it has learned 𝑀𝑀 ≥ 𝑀𝑀𝑝𝑝 clauses and arrived at a reasonably stable state (step C5).

a CDCL solver was applied to the clauses of after about clauses had been learned.

#learned clauses computation time GM

typical run 48,000 800

50,000 500𝑀𝑀P = 10000

learned 10002 clauses

6252 clauses actually present in MEM

at most 3126 clauses will be removed by the

purging process

Some clauses had length 2, while the maxi size was 24 and the median was 11;

12 of the 6252 fell into this category; for instance, 30 appeared on level 10 of the trail

because ’ 30 33 39 41 42 45 46 48 54 57 ’ had been learned, and we may need to know that clause in a future resolution step.

Short clauses tend to be more useful, because they reduce more quickly to units.

Page 58: TAoCP 7.7.7.2 Satisfiability の輪読

literal block distance p.72

Gilles Audemard and Laurent Simon [Proc. Int. Joint Conference on Artificial Intelligence 21 (2009), 399 − 404].

If 𝐶𝐶 has signature (𝑝𝑝, 𝑞𝑞) and 𝐶𝐶𝑑 has signature 𝑝𝑝′, 𝑞𝑞′ , where 𝑝𝑝 ≤ 𝑝𝑝′and 𝑞𝑞 ≤ 𝑞𝑞𝑙 and (𝑝𝑝, 𝑞𝑞) ≠ (𝑝𝑝𝑙 ,𝑞𝑞𝑙),

then 𝐶𝐶 is more likely than 𝐶𝐶𝑑 to be useful in future propagations.

We can't predict the future, but small (𝑝𝑝, 𝑞𝑞) tends to

increase the ratio of black to gray.

all the literals of a clause 𝐶𝐶 = 𝑙𝑙1 ∨ ⋯∨ 𝑙𝑙𝑟𝑟, positively as 𝑙𝑙𝑗𝑗 or negatively as 𝑙𝑙�̅�𝑗. where 𝑝𝑝 of the levels contain at least one positive 𝑙𝑙𝑗𝑗

and the other 𝑞𝑞 contain nothing but 𝑙𝑙�̅�𝑗. (𝑝𝑝, 𝑞𝑞) is the 𝑠𝑠𝑐𝑐𝑙𝑙𝑛𝑛𝑐𝑐𝑡𝑡𝑢𝑢𝑃𝑃𝑠𝑠 of 𝐶𝐶 w.r.t the trail, and 𝑝𝑝 + 𝑞𝑞 level is the literal block distance.

how many of eligible clauses had a given signature (𝑝𝑝, 𝑞𝑞), for 1 ≤ 𝑝𝑝 ≤ 7 and 0 ≤ 𝑞𝑞 ≤ 8;

how many would have been used to resolve future conflict

Page 59: TAoCP 7.7.7.2 Satisfiability の輪読

RANGE( ) and “tie breakers” p.74

RANGE 𝑐𝑐 ← 𝑚𝑚𝑐𝑐𝑛𝑛 16 𝑝𝑝 + 𝛼𝛼𝑞𝑞 , 255

When 𝛼𝛼 has the relatively high value 1516

= .9375, this rule essentially preserves as many clauses of small literal block distance as it can;

and for constant 𝑝𝑝 + 𝑞𝑞 it favors those with small 𝑝𝑝.

to each clause 𝑐𝑐; here 𝛼𝛼 is a parameter, 0 ≤ 𝛼𝛼 ≤ 1. RANGE(𝑐𝑐) ← 0 if 𝑐𝑐 is the reason for some literal in the trail; RANGE 𝑐𝑐 ← 256 if 𝑐𝑐 is satisfied at level 0. If there are 𝑚𝑚𝑗𝑗 clauses of range 𝑗𝑗, and if we want to keep at most 𝑇𝑇 clauses in memory, we find the largest 𝑗𝑗 ≤ 256 such that

𝑚𝑚𝑗𝑗 > 0 and 𝑠𝑠𝑗𝑗 = 𝑚𝑚0 + 𝑚𝑚1 + ⋯+ 𝑚𝑚𝑗𝑗−1 ≤ 𝑇𝑇. Then we retain all clauses for which RANGE(𝑐𝑐) < 𝑗𝑗, together with 𝑇𝑇 − 𝑠𝑠𝑗𝑗 "tie breakers" that have RANGE(𝑐𝑐) = 𝑗𝑗 (unless 𝑗𝑗 = 256).

safely resolve conflicts on several different levels later, learning new clauses at that time.

A full trail allows us to compute signatures based on VAL fields.

Page 60: TAoCP 7.7.7.2 Satisfiability の輪読

tie breakers with “activity” p.74

learned 10002 clauses

6252 clauses actually present in MEM

at most 3126 clauses will be removed by the

purging process

For example, with 𝛼𝛼 = 1516

and the data from Fig. 50, we save clauses that have 𝑝𝑝 = (1, 2, 3, 4, 5) when 𝑞𝑞 ≤ (5, 4, 3, 2, 0), respectively.

This gives us 𝑠𝑠95 = 12 + 3069 clauses, just 45 shy of our target 𝑇𝑇 = 3126.

So 45 tie-breakers from among the 59 clauses that have RANGE 𝑐𝑐 = 95, 𝑝𝑝, 𝑞𝑞 = 5, 1 , that are arranged in order of increasing secondary heuristic ACT(𝑐𝑐),

the gray-and-black pattern is

So if we retain the 45 with highest activity, we pick up 8 of the 10 that turn out to be useful.

Page 61: TAoCP 7.7.7.2 Satisfiability の輪読

*Flushing literals and restarting. p.75

Peter van der Tak, Antonio Ramos, and Marijn Heule [J. Satisfiability, Bool. Modeling and Comp. 7 (2011), 133— 138],

Algorithm C interrupts itself in step C5 not only to purge clauses but also to "flush literals" that is a useful way to rejuvenate the trail periodically by

following trends in the activity scores ACT(𝑘𝑘).

Set 𝑤𝑤′ ← 0. While ACT 𝐿𝐿𝑖𝑖𝑑𝑑′+1 ≥ACT 𝑘𝑘 , set 𝑤𝑤′ = 𝑤𝑤′ + 1. Then if 𝑤𝑤′ < 𝑤𝑤, jump back to level 𝑤𝑤′.

This is the technique called "literal flushing," because it removes the literals on levels 𝑤𝑤𝑙 + 1 through 𝑤𝑤

and leaves the others assigned. It effectively redirects the search into new territory,

without being as drastic as a full restart.

Page 62: TAoCP 7.7.7.2 Satisfiability の輪読

AGILITY p.76

Armin Biere [LNCS 4996 (2008), 28 − 33]

High agility: lots of the recent propagations are flipping the values of variables and trying new possibilities; low agility : the algorithm is basically in a rut, spinning its wheels and getting nowhere.

which tends to be correlated with the desirability of flushing at any given moment.

a 32-bit integer variable called AGILITY, initially zero. Whenever a literal 𝑙𝑙 is placed on the trail in steps C4, C6, or C9,

we update the agility by setting

AGILITY← AGILITY −(AGILITY≫13) + (((OVAL( 𝑙𝑙 ) −VAL( 𝑙𝑙 ) )&1) ≪19)

the fraction AGILITY/232 is essentially multiplied by 1 − δ, increased by 𝛿𝛿 if the new polarity of 𝑙𝑙 differs from its previous polarity, 𝛿𝛿 = 2−13 ≈ .0001.

Page 63: TAoCP 7.7.7.2 Satisfiability の輪読

AGILITY p.76

Armin Biere [LNCS 4996 (2008), 28 − 33]

the agility is compared to a threshold, depending on Δf , according to the schedule in Table 4.

(The parameter 𝜓𝜓 in that table can be raised or lowered,

if you want to increase or decrease the amount of flushing.)

If the agility is sufficiently small, 𝑥𝑥𝑘𝑘 is found and (126) is performed. Nothing changes if the agility is large or if 𝑤𝑤𝑙 = 𝑤𝑤; otherwise (126) has flushed some literals,

using the operations of step C8.