Documentation

CslibFrontier.Algorithms.WordRAM.Refuter4n.PackedSearchCode

Word-RAM code for the searches of the packed step of the 4n - 9d refuter #

Standard-basis Word-RAM routines for the literal of a gate row and the pair search of the packed step pApplyStep on the memory image Stored of a packed state, each with an execution theorem in the library's Word-RAM cost model (Cslib.WordRAM.ExecWithin: every instruction is charged). This file continues PackedScanCode (issue #4322, Milestone 4); it claims no running time for a step or for the refuter.

Main definitions #

Main results #

The literal of a gate row #

rowLit of the gate row Reg.passVar of the image at Reg.base, into Reg.argB (argument code) and Reg.argC (negation bit) (exec_rowLitCode).

theorem Cslib.Algorithms.WordRAM.Refuter4n.exec_rowLitCode_row {w b N J : ℕ} {r : GateRow} (x : WordRAM.Data 32) (hb : x.regs Reg.base = b) (hJ : x.regs Reg.passVar = J) (hJN : J < N) (h4 : 4 ≤ w) (hw : N + 2 ≤ w) (haddr : WordRAM.Fits w (b + 5 + 3 * N)) (hrowAt : GateRowAt (b + 5) J r x.mem) (hrow : RowLt N r) :
∃ (y : WordRAM.Data 32), WordRAM.ExecWithin w rowLitCode x y 25 ∧ y.mem = x.mem ∧ y.regs Reg.argB = (rowLit r).1 ∧ y.regs Reg.argC = (rowLit r).2 ∧ ∀ (i : Fin 32), 14 ≤ ↑i → i ≠ Reg.argB → i ≠ Reg.argC → y.regs i = x.regs i

The literal of a gate row from its three words. With the base address b and a gate name J < N in Reg.base and Reg.passVar, and the three words of a row r within range (RowLt N r) at b + 5 + 3 J (GateRowAt), rowLitCode leaves (rowLit r).1 in Reg.argB and (rowLit r).2 in Reg.argC within 25 instructions, at every width w ≥ max 4 (N + 2) at which b + 5 + 3 N fits. It keeps the memory and every register from 14 on except Reg.argB and Reg.argC.

theorem Cslib.Algorithms.WordRAM.Refuter4n.exec_rowLitCode {w b N E n J : ℕ} {P : PackedState} (x : WordRAM.Data 32) (hb : x.regs Reg.base = b) (hJ : x.regs Reg.passVar = J) (hJN : J < N) (h4 : 4 ≤ w) (hw : N + 2 ≤ w) (haddr : WordRAM.Fits w (b + 5 + 3 * N)) (hI : Stored { base := b, N := N, E := E, n := n } P x.mem) (hgl : P.gateRows.length = N) (hrow : RowLt N (P.gateRows.getD J { tt := 0, left := 0, right := 0 })) :
∃ (y : WordRAM.Data 32), WordRAM.ExecWithin w rowLitCode x y 25 ∧ y.mem = x.mem ∧ y.regs Reg.argB = (rowLit (P.gateRows.getD J { tt := 0, left := 0, right := 0 })).1 ∧ y.regs Reg.argC = (rowLit (P.gateRows.getD J { tt := 0, left := 0, right := 0 })).2 ∧ ∀ (i : Fin 32), 14 ≤ ↑i → i ≠ Reg.argB → i ≠ Reg.argC → y.regs i = x.regs i

The literal of a gate row on the memory image. With the base address b and a gate name J < N in Reg.base and Reg.passVar, for the image of P at b with N gate rows whose gate row J is within range (RowLt N), rowLitCode leaves (rowLit r).1 in Reg.argB and (rowLit r).2 in Reg.argC, r the gate row J, within 25 instructions, at every width w ≥ max 4 (N + 2) at which b + 5 + 3 N fits. It keeps the memory and every register from 14 on except Reg.argB and Reg.argC.

pFindPair N p P scans the parameters r < N and, for each, eight candidate pairs of p and r in a fixed order (pairCandidate p r t for t < 8). As one scan over q < 8 N, the candidate q is pairCand p q = pairCandidate p (q / 8) q: the parameter q / 8, with the low bits of q as the local index. The test of q computes the record of the candidate and looks it up in the pair records with an inner loop.

Candidate q of the pair search of p: the candidate pairCandidate of p with the parameter q / 8, at the local index given by the low bits of q.

theorem Cslib.Algorithms.WordRAM.Refuter4n.pFindPair_eq_getD (N p : ℕ) (P : PackedState) :
pFindPair N p P = if (List.find? (fun (q : ℕ) => P.params.testBit (q / 8) && decide (pairCode (pairCand p q) ∈ P.pairs)) (List.range (8 * N))).getD (8 * N) < 8 * N then some (pairCand p ((List.find? (fun (q : ℕ) => P.params.testBit (q / 8) && decide (pairCode (pairCand p q) ∈ P.pairs)) (List.range (8 * N))).getD (8 * N))) else none

pFindPair from the first candidate: the first candidate Q < 8 N on a parameter with a set parameter bit whose record is present (8 N if there is none) gives pFindPair exactly when Q < 8 N.

The pair search pFindPair on the image, for the name Reg.argB: the parameter mask, the number and base of the pair records and the bound 8 N, the scan of the candidates, then the record of the first hit into Reg.pairFst, Reg.pairSnd (exec_pairSearchCode).

theorem Cslib.Algorithms.WordRAM.Refuter4n.exec_pairSearchCode {w b N E n p k : ℕ} {P : PackedState} (x : WordRAM.Data 32) (hb : x.regs Reg.base = b) (hN : x.regs Reg.argN = N) (hE : x.regs Reg.numE = E) (hn : x.regs Reg.numIn = n) (hp : x.regs Reg.argB = p) (hpN : p < N) (hk : P.pairs.length = k) (h4 : 4 ≤ w) (h8 : WordRAM.Fits w (8 * N + 1)) (haddr : WordRAM.Fits w (b + 5 + 3 * N + E + n + 2 * k + 1)) (hI : Stored { base := b, N := N, E := E, n := n } P x.mem) (hpar : WordRAM.Fits w P.params) :
∃ (y : WordRAM.Data 32), WordRAM.ExecWithin w pairSearchCode x y (8 * N * (12 * k + 32) + 39) ∧ y.mem = x.mem ∧ y.regs Reg.wT = (List.find? (fun (q : ℕ) => P.params.testBit (q / 8) && decide (pairCode (pairCand p q) ∈ P.pairs)) (List.range (8 * N))).getD (8 * N) ∧ (y.regs Reg.wT < 8 * N → y.regs Reg.pairFst = (pairCode (pairCand p (y.regs Reg.wT))).1 ∧ y.regs Reg.pairSnd = (pairCode (pairCand p (y.regs Reg.wT))).2) ∧ ∀ (i : Fin 32), 14 ≤ ↑i → i ≠ Reg.argA → i ≠ Reg.argD → i ≠ Reg.passBase → i ≠ Reg.passLen → i ≠ Reg.pairFst → i ≠ Reg.pairSnd → y.regs i = x.regs i

The pair search on the memory image. With the base address b, the name bound N, the numbers E and n of equation words and parameter rows and a name p in Reg.base, Reg.argN, Reg.numE, Reg.numIn and Reg.argB, for the image of P at b with k pair records and a word-sized parameter mask, pairSearchCode leaves in Reg.wT the first candidate Q = ((List.range (8 N)).find? _).getD (8 N) of the scan of pFindPair_eq_getD, and, when Q < 8 N, the record pairCode (pairCand p Q) in Reg.pairFst and Reg.pairSnd, within 8 N (12 k + 32) + 39 instructions, at every width w ≥ 4 at which 8 N + 1 and the address b + 5 + 3 N + E + n + 2 k + 1 fit, for p < N. It keeps the memory and every register from 14 on except Reg.argA, Reg.argD, Reg.passBase, Reg.passLen, Reg.pairFst and Reg.pairSnd.