The Art of Computer Programming volume 4 fascicle 6 7.7.7.2 p.47-76
1. The Art of
Computer Programming
7.2.2.2 Satisfiability p.47-76
VOLUME 4 FASCICLE 6
2. 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
9. 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.
14. 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
15. 𝑥𝑥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
16. 𝑥𝑥̅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
17. “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
23. 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を反駁ステップの
最小化問題に置き替える.
24. 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�, 𝑇𝑇𝑇𝑇3end 𝐹𝐹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
25. 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�, 𝑇𝑇𝑇𝑇3end 𝐹𝐹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が何点獲得できているかが勝負.
26. 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が * 宣言する戦略
27. Theorem R p.56
P
D
*1P
𝑗𝑗𝑚𝑚−3
𝑆𝑆 = 𝑗𝑗1, … ,
𝑥𝑥̅𝑗𝑗𝑗𝑗 ,
(𝑥𝑥̅𝑖𝑖𝑗𝑗 ∨ 𝑥𝑥̅𝑗𝑗𝑘𝑘 ∨ 𝑥𝑥𝑖𝑖 𝑖𝑖),
(𝑥𝑥𝑗𝑗𝑗 ∨ 𝑥𝑥𝑗𝑗𝑗 ∨ ⋯ ∨ 𝑥𝑥𝑗𝑗𝑗𝑗)
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𝑚𝑚
⋮ ⋱ ⋮
𝑥𝑥 𝑚𝑚𝑚 ⋯ 𝑥𝑥 𝑚𝑚𝑚𝑚
𝑥𝑥∗∗
𝑗𝑗
𝑘𝑘
(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.
28. 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.
29. 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 : 𝑐𝑐 =
1
2𝑛𝑛
, 𝑏𝑏 = 𝑊𝑊 , 𝑊𝑊 = 2𝑛𝑛 ln 𝑟𝑟 , なら 𝑓𝑓 ≤ 𝑟𝑟 < 𝜌𝜌−𝑏𝑏
.
𝑛𝑛 ≥ 𝑤𝑤 𝛼𝛼0
2
, 𝑟𝑟 ≥ 2 で 𝑊𝑊 ≥ 𝑤𝑤 𝛼𝛼0 , 𝑤𝑤 𝛼𝛼0 ⊢ 𝜖𝜖 ≤ 𝑊𝑊 + 𝑏𝑏 ≤ 8𝑛𝑛 ln 𝑟𝑟 + 1
𝑟𝑟𝑚𝑚
30. 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 個である.
32. 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を反駁ステップの
最小化問題に置き替える.
33. 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�, 𝑇𝑇𝑇𝑇3end 𝐹𝐹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
34. 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が * 宣言する戦略
35. Theorem R p.56
P
D
*1P
𝑗𝑗𝑚𝑚−3
𝑆𝑆 = 𝑗𝑗1, … ,
𝑥𝑥̅𝑗𝑗𝑗𝑗 ,
(𝑥𝑥̅𝑖𝑖𝑗𝑗 ∨ 𝑥𝑥̅𝑗𝑗𝑘𝑘 ∨ 𝑥𝑥𝑖𝑖 𝑖𝑖),
(𝑥𝑥𝑗𝑗𝑗 ∨ 𝑥𝑥𝑗𝑗𝑗 ∨ ⋯ ∨ 𝑥𝑥𝑗𝑗𝑗𝑗)
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𝑚𝑚
⋮ ⋱ ⋮
𝑥𝑥 𝑚𝑚𝑚 ⋯ 𝑥𝑥 𝑚𝑚𝑚𝑚
𝑥𝑥∗∗
𝑗𝑗
𝑘𝑘
(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.
36. 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.
37. 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 : 𝑐𝑐 =
1
2𝑛𝑛
, 𝑏𝑏 = 𝑊𝑊 , 𝑊𝑊 = 2𝑛𝑛 ln 𝑟𝑟 , なら 𝑓𝑓 ≤ 𝑟𝑟 < 𝜌𝜌−𝑏𝑏
.
𝑛𝑛 ≥ 𝑤𝑤 𝛼𝛼0
2
, 𝑟𝑟 ≥ 2 で 𝑊𝑊 ≥ 𝑤𝑤 𝛼𝛼0 , 𝑤𝑤 𝛼𝛼0 ⊢ 𝜖𝜖 ≤ 𝑊𝑊 + 𝑏𝑏 ≤ 8𝑛𝑛 ln 𝑟𝑟 + 1
𝑟𝑟𝑚𝑚
38. 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.
39. 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.
40. 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.
43. 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 .
44. 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
45. 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 𝑐𝑐
𝑏𝑏𝑗𝑗
46. 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 𝑐𝑐 forceaunit?]
c5.
[New level?]
c6.
[Makeadecision.]
c7.
[Resolveaconflict.]
c8.
[Backjump.]
c9.
[Learn.]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙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
terminate
succesfully
prepare to
purge excess
clauses
flush literals
as expected
⇔ otherwise
𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.
𝑘𝑘 ← HEAP 0
deletek from the heap
if VAL 𝑘𝑘 ≥ 0 ⇔ 𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃 𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠
𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1
𝐿𝐿𝐹𝐹 ← 𝑙𝑙
TLOC( 𝑙𝑙 ) ← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1
if 𝑤𝑤 = 0 ⇔ otherwise
terminate
unsuccesfully
use the conflictclause 𝑐𝑐
to construct
𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨ …∨ 𝑏𝑏�𝑟𝑟
ACT( 𝑙𝑙 ) ← ACT( 𝑙𝑙 ) +DEL
for all literals 𝑙𝑙 stampedset d' to the max. level
occupied by 𝑏𝑏1,… , 𝑏𝑏𝑟𝑟 while 𝐹𝐹 > 𝑐𝑐𝑑𝑑′+1
𝐹𝐹 ← 𝐹𝐹 − 1
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and the watch list
𝑝𝑝1 … 𝑝𝑝𝑛𝑛 is a random permutation of 1,… , 𝑛𝑛
(Increasing ACT 𝑙𝑙 may change HEAP.)
𝑙𝑙 ← 𝐿𝐿𝐹𝐹𝑘𝑘 ← 𝑙𝑙 OVAL(𝑘𝑘) ← VAL 𝑘𝑘𝑅𝑅𝑙𝑙 ← Λ if HLOC 𝑙𝑙 < 0 insert 𝑘𝑘 into HEAP.
𝐺𝐺 ← 𝐹𝐹𝑤𝑤 ← 𝑤𝑤𝑙
set 𝑐𝑐 ←MAXL
If 𝑤𝑤 > 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.)
47. 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 and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and 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
10100
each 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
48. 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 and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and 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.
49. 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 and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and the watch list
𝑝𝑝1 … 𝑝𝑝𝑛𝑛 is a random permutation of 1,… , 𝑛𝑛
c5.
[New level?]
50. 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 and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 1
for all c in the watch list of 𝑙𝑙̅ ⇔ 𝐝𝐞𝐭𝐞𝐜𝐭𝐬 𝐚 𝐜𝐨𝐧𝐟𝐥𝐢𝐜𝐭if no conflict ⇔
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and the watch list
𝑝𝑝1 … 𝑝𝑝𝑛𝑛 is a random permutation of 1,… , 𝑛𝑛
c7.
[Resolveaconflict.]
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.
51. 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 𝑐𝑐 forceaunit?]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙2...𝑙𝑙𝑘𝑘−1all false
𝑙𝑙0 false ⇔ 𝑙𝑙0 free
𝐦𝐨𝐯𝐞 𝒄 to the watch list of 𝑙𝑙𝑗𝑗
𝐦𝐚𝐤𝐞 𝐢𝐭 𝐭𝐫𝐮𝐞 𝐛𝐲 𝒔𝒔𝒆𝒕𝒕𝒊𝒏𝒈
𝐿𝐿𝐹𝐹 ← 𝑙𝑙0
TLOC( 𝑙𝑙0 ) ← 𝐹𝐹VAL( 𝑙𝑙0 ) ← 2𝑤𝑤+ 𝑙𝑙0&1𝑅𝑅𝑙𝑙0
← 𝑐𝑐𝐹𝐹 ← 𝐹𝐹 + 1
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and the watch list
𝑝𝑝1 … 𝑝𝑝𝑛𝑛 is a random permutation of 1,… , 𝑛𝑛
c7.
[Resolveaconflict.]
c5.
[New level?]
Reason
52. 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 𝑐𝑐 forceaunit?]
c5.
[New level?]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙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
terminate
succesfully
prepare to
purge excess
clauses
flush literals
as expected
⇔ otherwise
𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and the watch list
𝑝𝑝1 … 𝑝𝑝𝑛𝑛 is a random permutation of 1,… , 𝑛𝑛
c7.
[Resolveaconflict.]
53. 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 𝑐𝑐 forceaunit?]
c5.
[New level?]
c6.
[Makeadecision.]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙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
terminate
succesfully
prepare to
purge excess
clauses
flush literals
as expected
⇔ otherwise
𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.
𝑘𝑘 ← HEAP 0
deletek from the heap
if VAL 𝑘𝑘 ≥ 0 ⇔ 𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃 𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠
𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1
𝐿𝐿𝐹𝐹 ← 𝑙𝑙
TLOC( 𝑙𝑙 ) ← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and the watch list
𝑝𝑝1 … 𝑝𝑝𝑛𝑛 is a random permutation of 1,… , 𝑛𝑛
c7.
[Resolveaconflict.]
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.
54. 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 𝑐𝑐 forceaunit?]
c5.
[New level?]
c6.
[Makeadecision.]
c7.
[Resolveaconflict.]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙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
terminate
succesfully
prepare to
purge excess
clauses
flush literals
as expected
⇔ otherwise
𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.
𝑘𝑘 ← HEAP 0
deletek from the heap
if VAL 𝑘𝑘 ≥ 0 ⇔ 𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃 𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠
𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1
𝐿𝐿𝐹𝐹 ← 𝑙𝑙
TLOC( 𝑙𝑙 ) ← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1
if 𝑤𝑤 = 0 ⇔ otherwise
terminate
unsuccesfully
use the conflictclause 𝑐𝑐
to construct
𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨ …∨ 𝑏𝑏�𝑟𝑟
ACT( 𝑙𝑙 ) ← ACT( 𝑙𝑙 ) +DEL
for all literals 𝑙𝑙 stampedset d' to the max. level
occupied by 𝑏𝑏1,… , 𝑏𝑏𝑟𝑟
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and 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?
55. 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 𝑐𝑐 forceaunit?]
c5.
[New level?]
c6.
[Makeadecision.]
c7.
[Resolveaconflict.]
c8.
[Backjump.]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙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
terminate
succesfully
prepare to
purge excess
clauses
flush literals
as expected
⇔ otherwise
𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.
𝑘𝑘 ← HEAP 0
deletek from the heap
if VAL 𝑘𝑘 ≥ 0 ⇔ 𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃 𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠
𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1
𝐿𝐿𝐹𝐹 ← 𝑙𝑙
TLOC( 𝑙𝑙 ) ← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1
if 𝑤𝑤 = 0 ⇔ otherwise
terminate
unsuccesfully
use the conflictclause 𝑐𝑐
to construct
𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨ …∨ 𝑏𝑏�𝑟𝑟
ACT( 𝑙𝑙 ) ← ACT( 𝑙𝑙 ) +DEL
for all literals 𝑙𝑙 stampedset d' to the max. level
occupied by 𝑏𝑏1,… , 𝑏𝑏𝑟𝑟 while 𝐹𝐹 > 𝑐𝑐𝑑𝑑′+1
𝐹𝐹 ← 𝐹𝐹 − 1
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and 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.
56. 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 𝑐𝑐 forceaunit?]
c5.
[New level?]
c6.
[Makeadecision.]
c7.
[Resolveaconflict.]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙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
terminate
succesfully
prepare to
purge excess
clauses
flush literals
as expected
⇔ otherwise
𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.
𝑘𝑘 ← HEAP 0
deletek from the heap
if VAL 𝑘𝑘 ≥ 0 ⇔ 𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃 𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠
𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1
𝐿𝐿𝐹𝐹 ← 𝑙𝑙
TLOC( 𝑙𝑙 ) ← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1
if 𝑤𝑤 = 0 ⇔ otherwise
terminate
unsuccesfully
use the conflictclause 𝑐𝑐
to construct
𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨ …∨ 𝑏𝑏�𝑟𝑟
ACT( 𝑙𝑙 ) ← ACT( 𝑙𝑙 ) +DEL
for all literals 𝑙𝑙 stampedset d' to the max. level
occupied by 𝑏𝑏1,… , 𝑏𝑏𝑟𝑟
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and 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[𝑝𝑝] = 𝑠𝑠 ."
57. 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 𝑐𝑐 forceaunit?]
c5.
[New level?]
c6.
[Makeadecision.]
c7.
[Resolveaconflict.]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙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
terminate
succesfully
prepare to
purge excess
clauses
flush literals
as expected
⇔ otherwise
𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.
𝑘𝑘 ← HEAP 0
deletek from the heap
if VAL 𝑘𝑘 ≥ 0 ⇔ 𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃 𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠
𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1
𝐿𝐿𝐹𝐹 ← 𝑙𝑙
TLOC( 𝑙𝑙 ) ← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1
if 𝑤𝑤 = 0 ⇔ otherwise
terminate
unsuccesfully
use the conflictclause 𝑐𝑐
to construct
𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨ …∨ 𝑏𝑏�𝑟𝑟
ACT( 𝑙𝑙 ) ← ACT( 𝑙𝑙 ) +DEL
for all literals 𝑙𝑙 stampedset d' to the max. level
occupied by 𝑏𝑏1,… , 𝑏𝑏𝑟𝑟
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and 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 𝑙𝑙′
← 𝐿𝐿𝑡𝑡.
58. 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 𝑐𝑐 forceaunit?]
c5.
[New level?]
c6.
[Makeadecision.]
c7.
[Resolveaconflict.]
c8.
[Backjump.]
c9.
[Learn.]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙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
terminate
succesfully
prepare to
purge excess
clauses
flush literals
as expected
⇔ otherwise
𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.
𝑘𝑘 ← HEAP 0
deletek from the heap
if VAL 𝑘𝑘 ≥ 0 ⇔ 𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃 𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠
𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1
𝐿𝐿𝐹𝐹 ← 𝑙𝑙
TLOC( 𝑙𝑙 ) ← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1
if 𝑤𝑤 = 0 ⇔ otherwise
terminate
unsuccesfully
use the conflictclause 𝑐𝑐
to construct
𝑙𝑙𝑙� ∨ 𝑏𝑏�1 ∨ …∨ 𝑏𝑏�𝑟𝑟
ACT( 𝑙𝑙 ) ← ACT( 𝑙𝑙 ) +DEL
for all literals 𝑙𝑙 stampedset d' to the max. level
occupied by 𝑏𝑏1,… , 𝑏𝑏𝑟𝑟 while 𝐹𝐹 > 𝑐𝑐𝑑𝑑′+1
𝐹𝐹 ← 𝐹𝐹 − 1
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and the watch list
𝑝𝑝1 … 𝑝𝑝𝑛𝑛 is a random permutation of 1,… , 𝑛𝑛
(Increasing ACT 𝑙𝑙 may change HEAP.)
𝑙𝑙 ← 𝐿𝐿𝐹𝐹𝑘𝑘 ← 𝑙𝑙 OVAL(𝑘𝑘) ← VAL 𝑘𝑘𝑅𝑅𝑙𝑙 ← Λ if HLOC 𝑙𝑙 < 0 insert 𝑘𝑘 into HEAP.
𝐺𝐺 ← 𝐹𝐹𝑤𝑤 ← 𝑤𝑤𝑙
set 𝑐𝑐 ←MAXL
If 𝑤𝑤 > 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.
59. 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 𝑐𝑐 forceaunit?]
c5.
[New level?]
c6.
[Makeadecision.]
𝐹𝐹𝐺𝐺𝐿𝐿 𝑀𝑀𝑅𝑅𝑐𝑐𝑤𝑤𝑐𝑐𝑘𝑘 𝑠𝑠
𝑅𝑅2𝑘𝑘 ← 𝑅𝑅2𝑘𝑘+1 ← Λ
𝑝𝑝𝑘𝑘 − 1 𝑝𝑝𝑘𝑘 − 1 ← 𝑘𝑘1 ≤ 𝑘𝑘 ≤ 𝑛𝑛
MINL and MAXL
to 1st available position
𝑐𝑐0 ← 0
DEL 𝑐
𝑛𝑛
𝐿𝐿0 … 𝐿𝐿𝐹𝐹−1 contains all
literals
forcedby 𝐿𝐿0 … 𝐿𝐿 𝐺−1
if 𝐺𝐺 = 𝐹𝐹
𝑙𝑙 ← 𝐿𝐿 𝐺 𝐺𝐺 = 𝐺𝐺 + 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 false
found ⇔ 𝑙𝑙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
terminate
succesfully
prepare to
purge excess
clauses
flush literals
as expected
⇔ otherwise
𝑤𝑤 ← 𝑤𝑤 + 1𝑐𝑐𝑑𝑑 ← 𝐹𝐹.
𝑘𝑘 ← HEAP 0
deletek from the heap
if VAL 𝑘𝑘 ≥ 0 ⇔ 𝐵𝐵𝑡𝑡𝑐𝑠𝑠𝑃𝑃 𝑤𝑤𝑐𝑐𝑠𝑠𝑠𝑠
𝑙𝑙 ← 2𝑘𝑘 + OVAL 𝑘𝑘 &1 VAL(𝑘𝑘) ← 2𝑤𝑤 + OVAL 𝑘𝑘 &1
𝐿𝐿𝐹𝐹 ← 𝑙𝑙
TLOC( 𝑙𝑙 ) ← 𝐹𝐹𝑅𝑅𝑙𝑙 ← Λ𝐹𝐹 ← 𝐹𝐹 + 1
𝐏𝐮𝐭 𝐝𝐢𝐬𝐭𝐢𝐧𝐜𝐭 𝐮𝐧𝐢𝐭 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into 𝐿𝐿0 … 𝐿𝐿𝐹𝐹 −1
But 𝐭𝐞𝐫𝐧𝐢𝐦𝐚𝐭𝐞 𝐮𝐧𝐬𝐮𝐜𝐜𝐞𝐬𝐟𝐮𝐥𝐥𝐲
if clause 𝑙𝑙 and 𝑙𝑙𝑙
contradiction
𝐢𝐧𝐩𝐮𝐭 𝐭𝐡𝐞 𝐜𝐥𝐚𝐮𝐬𝐞𝐬 into MEM
and the watch list
𝑝𝑝1 … 𝑝𝑝𝑛𝑛 is a random permutation of 1,… , 𝑛𝑛
c7.
[Resolveaconflict.]
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).
60. 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