Chapter 37
Solved by hand
With the constants folded, the smallest problem's formula solves on paper, and the start of the hardest problem's proof reads as plain statements about the program.
{0} in one line §
is_tiny accepts exactly {0} (code 1), and its shortest program has one line (Theorem 4). With lines 2 to 6 forced to nada (sat 1 len=1), the formula opens with ten unit clauses, -3 to -12, and ends with four, one an input. Unit propagation repeats one rule: a clause whose literals are all false but one makes that one true. From the formula's own unit clauses, src/sat_hand_main.c finds that the rule decides every variable:
{0} at length 1: 416 variables, 1226 clauses; unit propagation fixes 416 of the variables in 9 passes, with 0 conflicts
v65 = 1 by `65`: core 0's accepted after line 6
v55 = 1 by `-65 55 62`: core 0's accepted after line 5
v45 = 1 by `-55 45 52`: core 0's accepted after line 4
v35 = 1 by `-45 35 42`: core 0's accepted after line 3
v25 = 1 by `-35 25 32`: core 0's accepted after line 2
v14 = 1 by `-25 14 22`: core 0's accepted after line 1
v1 = 0 by `-14 -1`: line 1's hb
v2 = 1 by `-14 2`: line 1's lb
the program: line 1 is `zero`, lines 2 to 6 `nada`
Input 0's unit clause sets core 0's final accepted, v65. Each line's accepted is an OR of the one above and that line's new accept, which is 0 on a nada line (v62 at line 6, and so on), so each OR's third clause passes the demand one line up, to v14, line 1's zero decoder. Its two clauses -14 -1 and -14 2 then set the program's bits. rocsat agrees: sat/proofs/1-len1.model records 0 conflicts and 0 decisions.
The other three ops §
Run through the gates, each other op on line 1 leaves core 0's final accepted at 0 and breaks the unit clause 65:
| line 1 | accepted after line 6, inputs 0 1 2 3 | {0} asks for | unit clauses broken |
|---|---|---|---|
nada |
0 0 0 0 | 1 0 0 0 | 65 (input 0) |
zero |
1 0 0 0 | 1 0 0 0 | all four hold |
decr |
0 0 0 0 | 1 0 0 0 | 65 (input 0) |
mod2 |
0 0 0 0 | 1 0 0 0 | 65 (input 0) |
nada and mod2 keep core 0 at 0 with both flags 0, and decr at 0 halts it.
Five lines for {0, 2, 3} §
is_not_one accepts {0, 2, 3} (code 13), and its one program uses all six lines (Theorem 5). For the programs of nada, zero and decr, counting lines settles it. Input 0 needs a zero before any decr, since decr at 0 halts. Input 2 reaches 0 after two decrs and input 3 after three, on different lines, and each then needs a zero. Input 1 reaches 0 after the first decr, so the second decr has to come before any later zero, and it halts input 1. That is three zeros and three decrs: six lines. Theorem 3's search, over all 4,096 programs, settles the ones with mod2 too.
The formula says the same. sat 13 len=5 is the full formula plus the unit clauses -11 and -12. Asked to solve it, rocsat answers UNSATISFIABLE, the answer expected, with a DRAT proof. Such a proof is a list of lemmas, each a clause that follows from the formula and the lemmas before it by unit propagation, with deletions mixed in, ending at the empty clause; a checker replays it, and once the empty clause follows, the formula is unsatisfiable. The first 12 distinct lemmas of this one, each literal named by src/sat_hand_main.c from the encoder's own record of its wires:
`-11 0`: v11 = 0 (line 6's hb)
`-12 0`: v12 = 0 (line 6's lb)
`57 0`: v57 = 1 (1 when line 6 is `nada`)
`-58 0`: v58 = 0 (1 when line 6 is `zero`)
`-59 0`: v59 = 0 (1 when line 6 is `decr`)
`-60 0`: v60 = 0 (1 when line 6 is `mod2`)
`61 0`: v61 = 1 (v56 OR v57)
`-62 0`: v62 = 0 (-v56 AND v58)
`-63 0`: v63 = 0 (-v56 AND v59)
`-64 0`: v64 = 0 (-v56 AND v60)
`55 -65 0`: v55 = 1 (core 0's accepted after line 5), or v65 = 0 (core 0's accepted after line 6)
`56 -66 0`: v56 = 1 (core 0's halted after line 5), or v66 = 0 (core 0's halted after line 6)
The first two restate the length bound, and the next four decode line 6 as nada. v61 to v64 say which op core 0 runs on line 6, v56 being its halted after line 5: it runs nada. The last two say that core 0's flags after line 6 are those after line 5. “The solver's work, in full” prints the whole proof, 286 lemmas, and checks it.