Witness extraction and scratch-register setup (extractAssignmentCode, setupWorkRegsCode) #
Internal Pass 4 subroutines comparing literal SCC indices and writing answerWords G.
Loop body checking comp[2i] ≠ comp[2i + 1] and writing variable i's bit.
Extract the satisfying assignment from compB or write 0 on conflict.
theorem Cslib.Algorithms.WordRAM.TwoSAT.extractVarLoop_spec (G : Instance) {w : ℕ} (hfit : WordRAM.Fits w G.wordBound) (compIdx : Logic.PL.Literal (Fin G.n) → ℕ) (vs : List (Fin G.n)) (idx : ℕ) (ok : Bool) (x : WordRAM.Data 28) :
idx + vs.length = G.n →
(∀ (q : ℕ) (hq : q < vs.length), ↑vs[q] = idx + q) →
(∀ (u : Fin (2 * G.n)),
x.mem (DFS.kCompAddr G.workBase (2 * G.n) (2 * List.length G.φ) + ↑u) = compIdx ((litEquiv G.n).symm u)) →
(∀ (q : Fin G.n),
↑q < idx →
compIdx (q, true) ≠ compIdx (q, false) →
x.mem (G.outAddrBase + 2 + ↑q) = (decide (compIdx (q, false) < compIdx (q, true))).toNat) →
x.regs DFS.Reg.cZero = 0 →
x.regs DFS.Reg.cOne = 1 →
x.regs Reg.cTwo = 2 →
x.regs Reg.nv = G.n →
x.regs Reg.outBase = G.outAddrBase →
x.regs DFS.Reg.compB = DFS.kCompAddr G.workBase (2 * G.n) (2 * List.length G.φ) →
x.regs DFS.Reg.iReg = idx →
x.regs DFS.Reg.compIdxReg = ok.toNat →
∃ (y : WordRAM.Data 28),
WordRAM.ExecWithin w (WordRAM.Code.loop (WordRAM.Cond.lt DFS.Reg.iReg Reg.nv) extractVarBody)
x y (16 * vs.length + 2) ∧ y.regs Reg.outBase = G.outAddrBase ∧ y.regs Reg.nv = G.n ∧ y.regs DFS.Reg.cZero = 0 ∧ y.regs DFS.Reg.cOne = 1 ∧ y.regs DFS.Reg.compIdxReg = (List.foldl
(fun (acc : Bool) (v : Fin G.n) =>
acc && decide (compIdx (v, true) ≠ compIdx (v, false)))
ok vs).toNat ∧ ∀ (v : Fin G.n),
compIdx (v, true) ≠ compIdx (v, false) →
y.mem (G.outAddrBase + 2 + ↑v) = (decide (compIdx (v, false) < compIdx (v, true))).toNat
Populate all DFS scratch base-address registers starting at G.workBase.