Word-RAM code for the packed state of the 4n - 9d refuter #
Standard-basis Word-RAM routines on the memory image of the packed state PackedState, each with
an execution theorem in a caller-given memory window, in the library's Word-RAM cost model
(Cslib.WordRAM.ExecWithin: every instruction is charged). This file is the first part of the
step code of issue #4322 (Milestone 4); it claims no running time for a step or for the refuter.
Register file. All routines run in Code .standard 32. Registers 0 to 13 form the callee
bank (calleeBank, the identity embedding of Fin 14) in which the dense elimination routines
XORSATDense.elimPass and XORSATDense.elimCode run, so every register from 14 on survives a
call (calleeBank_injective, calleeBank_val, calleeBank_ne). The arguments of the routines
live in the registers of Reg.
Memory image. The packed state lives at the addresses of a Layout and is described by the
predicate Stored of InputLayout, the one that exec_initCode establishes. Stored does not
relate the sizes of the layout to the table lengths of the state, so the execution theorems take
the lengths they need as separate hypotheses. Stored.gateRow, Stored.eqnRow, Stored.phiRow
and Stored.pair read the words of a stored state, row by row; Stored.of_words of InputLayout
is the other direction. Stored.of_eq_below keeps a stored state with at most L.N gate rows,
L.E equation words, L.n parameter rows and L.N pair records over a memory that agrees with
it below L.top.
Row substitution. Substituting the name v by the row u in a row r (substWord v u r) is
the elimination step elimWord v (2 ^ v ^^^ u) r with pivot word 2 ^ v ^^^ u
(substWord_eq_elimWord). The substitution pass substPass over a window of rows is therefore one
call of XORSATDense.elimPass, after six instructions that set its arguments.
Main definitions #
Cslib.Algorithms.WordRAM.Refuter4n.calleeBank: the callee bank of the dense elimination routines.Cslib.Algorithms.WordRAM.Refuter4n.Reg.passBase,Reg.passLen,Reg.passVar,Reg.passWord: the argument registers ofsubstPass;Reg.argA,Reg.argB,Reg.argC,Reg.argD,Reg.argN,Reg.result: the argument and result registers of the word primitives;Reg.base,Reg.numE: the base address of the image and the number of equation words;Reg.wT,Reg.wQ,Reg.wS: scratch registers below14of the word primitives and of the routines on the image.Cslib.Algorithms.WordRAM.Refuter4n.substPass: substitution of a name by a row in every row of a window, a fixedCode .standard 32.Cslib.Algorithms.WordRAM.Refuter4n.clearBitCode,setBitCode,argWordCode,litWordCode,substOutCode: the word primitivesclearBit,setBit,argWord,litWordOfandsubstOutofPackedOps, fixedCode .standard 32.Cslib.Algorithms.WordRAM.Refuter4n.GateRowAt: a gate row in memory, as a row of a window;GateRowAt.wordsreads its three words at the addressesG + (J + J + J),+ 1,+ 1 + 1that the routines compute.Cslib.Algorithms.WordRAM.Refuter4n.substStateCode: the packed substitution stepPackedState.subston the memory image, a fixedCode .standard 32.Cslib.Algorithms.WordRAM.Refuter4n.gatePass: rerouting of a name to a literal in every gate row of a window (substRow), a fixedCode .standard 32.
Main results #
Cslib.Algorithms.WordRAM.Refuter4n.substWord_eq_elimWord: row substitution is an elimination step.Cslib.Algorithms.WordRAM.Refuter4n.exec_substPass:substPassreplaces every rowrof a caller-given window bysubstWord v u rwithin14 m + 9instructions, and preserves every cell outside the window and every register from14on.Cslib.Algorithms.WordRAM.Refuter4n.exec_clearBitCode,exec_setBitCode,exec_argWordCode,exec_litWordCode,exec_substOutCode: each word primitive computes itsPackedOpsword in a constant number of instructions (at most4,3,6,8,9) under the width hypotheses of its theorem, changing no memory and no register from14on.Cslib.Algorithms.WordRAM.Refuter4n.Stored.subst: substitution in the gate and equation tables and the output code, keeping every other cell, gives the image ofPackedState.subst.Cslib.Algorithms.WordRAM.Refuter4n.exec_substStateCode:substStateCodeturns the image ofPat a layoutLinto the image ofP.subst L.N v la lnwithin37 L.N + 14 L.E + 49instructions, with its register and memory frame.Cslib.Algorithms.WordRAM.Refuter4n.exec_gatePass:gatePassreplaces every gate rowrof a caller-given window ofmrows bysubstRow v la ln rwithin37 m + 7instructions, and preserves every cell outside the window and every register from14on.
The callee bank: registers 0 to 13 of the step code, where the dense elimination routines
run.
The callee bank is an injective embedding.
The callee bank keeps the register number.
A register from 14 on is outside the callee bank.
The base address of the window of a pass.
The number of rows of the window of a pass.
The substituted name of a pass.
The substituted row of a pass.
First argument of a word primitive.
Second argument of a word primitive.
Third argument of a word primitive.
Fourth argument of a word primitive.
The name bound N of a word primitive.
The result of a word primitive (a register of the callee bank).
The base address of the image of the packed state.
The number E of equation words.
First scratch register of the word primitives and of the routines on the image (a register of the callee bank).
Second scratch register of the word primitives and of the routines on the image (a register of the callee bank).
Third scratch register of the word primitives and of the routines on the image (a register of the callee bank).
Row substitution as an elimination step #
Substituting the name x by the row u is the elimination step at column x with pivot word
2 ^ x ^^^ u.
The substitution pass #
Substitute the name in register Reg.passVar by the row in register Reg.passWord in every
row of the window of Reg.passLen words at Reg.passBase (exec_substPass).
The substitution pass in a caller-given memory window. Let the caller's state x hold a
base address a, the number m of rows, a name v ≤ n and a row u < 2 ^ (n + 1) in the
registers Reg.passBase, Reg.passLen, Reg.passVar and Reg.passWord, with the row
W[j] < 2 ^ (n + 1) at address a + j for j < m. Memory outside this window and the other
registers are arbitrary. At every width w at which a + m and 2 ^ (n + 1) - 1 fit,
substPass replaces cell a + j by substWord v u W[j] within 14 m + 9 instructions,
preserves every register from 14 on, and preserves every memory cell outside [a, a + m).
Word primitives #
Straight-line or one-branch routines that compute the word operations of PackedOps from
argument registers into Reg.result, using only registers below 14.
clearBit of Reg.argA at the index Reg.argB, into Reg.result (exec_clearBitCode).
At every width at which a and 2 ^ i fit, clearBitCode computes clearBit a i in 4
instructions, changing no memory and no register from 14 on.
setBit of Reg.argA at the index Reg.argB, into Reg.result (exec_setBitCode).
At every width at which a and 2 ^ i fit, setBitCode computes setBit a i in 3
instructions, changing no memory and no register from 14 on.
argWord of the name bound Reg.argN and the argument code Reg.argA, into
Reg.result (exec_argWordCode).
argWordCode computes argWord N a for an argument code a < N + 2 in at most 6
instructions at every width w ≥ 4 at which 2 ^ (N + 1) - 1 fits, changing no memory and no
register from 14 on.
The row litWordOf of the literal with argument code Reg.argA and negation bit Reg.argC,
at the name bound Reg.argN, into Reg.result (exec_litWordCode).
litWordCode computes litWordOf N la ln for an argument code la < N + 2 and a negation
bit ln ≤ 1 in at most 8 instructions at every width w ≥ 4 at which 2 ^ (N + 1) - 1 fits,
changing no memory and no register from 14 on.
substOut of the name Reg.argA, the argument code Reg.argB, the negation bit
Reg.argC and the output code Reg.argD, into Reg.result (exec_substOutCode).
substOutCode computes substOut v la ln o for a negation bit ln ≤ 1 in at most 9
instructions, changing no memory and no register from 14 on, at every width at which o,
v + 2 and 2 la + 1 fit.
The gate-row pass #
One pass over a window of gate rows (three words each) that reroutes the name v to the literal
with argument code la and negation bit ln in every row (substRow): the two arguments are
compared with v + 2, the matching ones are overwritten by la and contribute ln to the
negation mask m, and the truth table absorbs the mask by the two conditional swaps swapLo and
swapHi of TruthTable (absorbNeg, the operation of the input decoder).
Reroute the name in register Reg.passVar to the literal with argument code Reg.argB and
negation bit Reg.argC in every row of the window of Reg.passLen gate rows (three words each) at
Reg.passBase (exec_gatePass).
The gate-row pass in a caller-given memory window. Let the caller's state x hold a base
address G, the number m of rows, a name v, an argument code la and a negation bit ln ≤ 1
in the registers Reg.passBase, Reg.passLen, Reg.passVar, Reg.argB and Reg.argC, with
the words tt, left, right of the gate row R[J] at G + 3 J, G + 3 J + 1, G + 3 J + 2
for J < m. Memory outside this window and the other registers are arbitrary. At every width
w ≥ 4 at which G + 3 m, v + 2 and every truth-table word fit, gatePass replaces row J by
substRow v la ln R[J] within 37 m + 7 instructions, preserves every register from 14 on,
and preserves every memory cell outside [G, G + 3 m).
The memory image of a packed state #
The packed state P lives at the addresses of a layout L (Layout and Stored of
InputLayout): the masks params, aux, gates and the output code at L.base to
L.base + 3, the number of pair records at L.base + 4, the gate table (three words per row)
from L.rowAddr 0 0, the equation table from L.eqnAddr 0, the parameter rows from L.phiAddr 0
and the pair records (two words each) from L.pairAddr 0 0. Stored is over the full lists of
P and carries no list length; the execution theorems take the lengths they need as separate
hypotheses (Rep fixes them). The lemmas below read a stored state word by word; Stored.of_words
is the other direction.
Gate row J of a stored state, as row J of the window at the first gate row.
The image of a state with at most L.N gate rows, L.E equation words, L.n parameter rows
and L.N pair records reads only the cells below L.top.
Substitution in the gate and equation tables and the output code gives the image of
PackedState.subst, when every other cell is kept.
The packed substitution step #
The packed substitution step PackedState.subst on the image at Reg.base: the gate-row
pass, the substitution pass on the equation table with the row litWordOf of the literal, and the
output code (exec_substStateCode).
The packed substitution step on the memory image. Let the caller's state x hold the
base address L.base, the name bound L.N, the number L.E of equation words, a name
v < L.N, an argument code la < L.N + 2 and a negation bit ln ≤ 1 in the registers
Reg.base, Reg.argN, Reg.numE, Reg.passVar, Reg.argB and Reg.argC, and let the memory
hold the image of P at the layout L (Stored), with L.N gate rows, L.E equation words
below 2 ^ (L.N + 2), word-sized truth tables and output code. At every width
w ≥ max 4 (L.N + 2) at which the end L.phiAddr 0 of the equation table fits, substStateCode
leaves the image of P.subst L.N v la ln within 37 L.N + 14 L.E + 49 instructions, leaves the
row litWordOf L.N la ln of the literal in Reg.passWord, changes no register from 14 on
except Reg.passBase, Reg.passLen, Reg.passWord, Reg.argA and Reg.argD, and changes no
memory cell outside the output code, the gate table and the equation table.