Word-RAM code for the scans of the packed 4n - 9d refuter #
Standard-basis Word-RAM routines for scans over a range and for the searches built from them on the
memory image Stored of a packed state (the fresh equation name, the term searches of the
constraint deletion and the reader search), each with an execution theorem in the library's
Word-RAM cost model (Cslib.WordRAM.ExecWithin: every instruction is charged). This file continues
PackedOpsCode (issue #4322, Milestone 4); it claims no running time for a step or for the
refuter.
Main definitions #
Cslib.Algorithms.WordRAM.Refuter4n.Reg.scanIdx: the index register of a scan (a register of the callee bank); a scan keeps the constant1inReg.wS, the last hit plus one inReg.wQand the first hit inReg.wT.Cslib.Algorithms.WordRAM.Refuter4n.scanCode,freshEqnCode: a scan over a range with a given test, and the fresh equation namepFreshEqnas a scan, fixedCode .standard 32.Cslib.Algorithms.WordRAM.Refuter4n.bothBitsCode,otherBitCode: the least common bit of two words and the least bit of a word other than a given name (the term searches ofpDeleteEqn), fixedCode .standard 32.Cslib.Algorithms.WordRAM.Refuter4n.gateReadsCode: the live-gate reader test of one gate, shared by the reader search and the children search.Cslib.Algorithms.WordRAM.Refuter4n.readerCode: the reader searchpFindReaderon the memory image, a fixedCode .standard 32.
Main results #
Cslib.Algorithms.WordRAM.Refuter4n.exec_scanCode: a scan leaves the first hit (List.find?) and the last hit plus one of its test withinN (T + 8) + 6instructions, for a test of costT.Cslib.Algorithms.WordRAM.Refuter4n.exec_freshEqnCode:freshEqnCodeleavespFreshEqn N E Pwithin13 E + 12instructions.Cslib.Algorithms.WordRAM.Refuter4n.exec_bothBitsCode,exec_otherBitCode: the term searches leave theirList.find?results within13 N + 6and15 N + 6instructions.Cslib.Algorithms.WordRAM.Refuter4n.exec_gateReadsCode:gateReadsCodeleaves(gates.testBit K && rowReads r p).toNatwithin18instructions.Cslib.Algorithms.WordRAM.Refuter4n.exec_readerCode:readerCodeleaves(pFindReader N G P).getD Nwithin28 N + 12instructions.
The index of a scan (a register of the callee bank).
Scans over a range #
scanCode test runs the test test for K = 0, 1, … below the bound in Reg.passLen; the test
leaves p K (as 0 or 1) in Reg.result. The scan leaves the first K with p K (or the
bound if there is none, List.find?) in Reg.wT, and the last such K plus one (or 0,
a List.foldl) in Reg.wQ. The searches of the packed step are scans.
The scan of the test test over K < Reg.passLen (exec_scanCode).
A scan over a range. Let the caller's state x hold the bound N in Reg.passLen, and
let test be a routine that, from any state with the memory of x, the registers from 14 on of
x, an index K < N in Reg.scanIdx and 1 in Reg.wS, leaves (p K).toNat in
Reg.result within T instructions, keeps the memory and keeps Reg.scanIdx, Reg.wS,
Reg.wQ, Reg.wT and every register from 14 on. At every width at which N + 1
fits, scanCode test leaves ((List.range N).find? p).getD N in Reg.wT and
(List.range N).foldl (fun a K => if p K then K + 1 else a) 0 in Reg.wQ within
N (T + 8) + 6 instructions, keeping the memory and every register from 14 on.
The fresh equation name #
pFreshEqn on the image: the equation table and its size, then the scan of the alive flags;
the fresh name is left in Reg.wQ (exec_freshEqnCode).
The fresh equation name on the memory image. With the base address b, the name bound
N and the number E of equation words in Reg.base, Reg.argN and Reg.numE, for the image
of P at b with E word-sized equation words, freshEqnCode leaves pFreshEqn N E P in
Reg.wQ within 13 E + 12 instructions, at every width w ≥ N + 2 at which
b + 5 + 3 N + E + 1 fits. It keeps the memory and every register from 14 on except
Reg.passBase and Reg.passLen.
The term searches of the constraint deletion #
The least name below Reg.passLen that is a bit of both Reg.argA and Reg.argD, into
Reg.wT (exec_bothBitsCode).
The least common bit. With words W and A in Reg.argA and Reg.argD and the bound
N in Reg.passLen, bothBitsCode leaves ((List.range N).find? fun i => W.testBit i && A.testBit i).getD N in Reg.wT within 13 N + 6 instructions, at every width at which
W, A and N + 1 fit, keeping the memory and every register from 14 on.
The least name below Reg.passLen other than Reg.argB that is a bit of Reg.argA, into
Reg.wT (exec_otherBitCode).
The least other bit. With a word W in Reg.argA, a name v in Reg.argB and the bound
N in Reg.passLen, otherBitCode leaves ((List.range N).find? fun i => W.testBit i && i != v).getD N in Reg.wT within 15 N + 6 instructions, at every width at which W
and N + 1 fit, keeping the memory and every register from 14 on.
The reader search #
Whether the gate Reg.scanIdx is live (its bit of the gate mask in Reg.argA) and reads the
name Reg.argB (rowReads of its row in the gate table at Reg.passBase), into Reg.result
(exec_gateReadsCode). The reader search and the children search share it.
The live-gate reader test. For the gate K in Reg.scanIdx, a gate mask in Reg.argA,
a gate table at G in Reg.passBase with the row r of K, and a name p in Reg.argB,
gateReadsCode leaves (gates.testBit K && rowReads r p).toNat in Reg.result within 18
instructions, at every width at which G + 3 K + 2, p + 2 and the mask fit. It keeps the memory
and the registers Reg.scanIdx, Reg.wS, Reg.wQ, Reg.wT and every register from 14 on.
pFindReader on the image: the gate mask, the gate table, then the scan; the reader (or N)
is left in Reg.wT (exec_readerCode).
The reader search on the memory image. With the base address b, the name bound N and
a gate name G < N in Reg.base, Reg.argN and Reg.argB, for the image of P at b with
N gate rows and a word-sized gate mask, readerCode leaves (pFindReader N G P).getD N in
Reg.wT within 28 N + 12 instructions, at every width w ≥ N + 2 at which b + 5 + 3 N
fits. It keeps the memory and every register from 14 on except Reg.argA, Reg.passBase and
Reg.passLen.