Implication-graph CSR out-degree counting (implDegBody, implDegLoop_spec) #
Internal Pass 2a loop counting out-degrees of the implication graph G.adjFin in O(|φ|) steps.
Loop body incrementing CSR out-degrees in curB for one clause of width 1 or 2.
theorem Cslib.Algorithms.WordRAM.TwoSAT.implDegLoop_spec (G : Instance) {w : ℕ} (hfit : WordRAM.Fits w G.wordBound) (cs : Logic.PL.CNF (Fin G.n)) (g : Logic.PL.Literal (Fin G.n) → List (Logic.PL.Literal (Fin G.n))) (idx p : ℕ) (x : WordRAM.Data 28) :
(∀ c ∈ cs, 1 ≤ List.length c ∧ List.length c ≤ 2) →
G.φ = [] ∨ List.foldl Lean.TwoSAT.addClauseEdges g cs = Lean.TwoSAT.implicationAdj G.φ →
idx + List.length cs = List.length G.φ →
p + (List.flatMap (ClauseCode.encodeClauseBy Fin.val) cs).length = G.encode.length + 1 →
ClauseMemAt x.mem p cs →
(∀ (u : Fin (2 * G.n)),
x.mem (DFS.kCurAddr G.workBase (2 * G.n) (2 * List.length G.φ) + ↑u) = (mapAdj (litEquiv G.n) g u).length) →
x.regs DFS.Reg.cOne = 1 →
x.regs Reg.mClauses = List.length G.φ →
x.regs DFS.Reg.curB = DFS.kCurAddr G.workBase (2 * G.n) (2 * List.length G.φ) →
x.regs DFS.Reg.iReg = idx →
x.regs DFS.Reg.pReg = p →
∃ (y : WordRAM.Data 28),
WordRAM.ExecWithin w (WordRAM.Code.loop (WordRAM.Cond.lt DFS.Reg.iReg Reg.mClauses) implDegBody)
x y (21 * List.length cs + 2) ∧ (∀ (u : Fin (2 * G.n)),
y.mem (DFS.kCurAddr G.workBase (2 * G.n) (2 * List.length G.φ) + ↑u) = (mapAdj (litEquiv G.n) (List.foldl Lean.TwoSAT.addClauseEdges g cs) u).length) ∧ (∀ (a : ℕ),
¬(DFS.kCurAddr G.workBase (2 * G.n) (2 * List.length G.φ) ≤ a ∧ a < DFS.kCurAddr G.workBase (2 * G.n) (2 * List.length G.φ) + 2 * G.n) →
y.mem a = x.mem a) ∧ ∀ (r : Fin 28), ↑r < 18 → y.regs r = x.regs r