Word-RAM dense Gaussian elimination over π½β with one row per word #
A checked standard-basis Word-RAM implementation of the dense elimination decider
Cslib.Complexity.XORSAT.Dense.decide, with a word-parallel instruction bound.
Representation and width condition. A well-formed m Γ n instance (Instance: every row has
the declared width n) is laid out in input memory as [n, m] followed by one word per row,
rowWord e, with coefficient j at bit j and the right-hand side at bit n. Admitted widths
(FitsWidth) satisfy w β₯ n + 1, so that one row fits in one word, and fit the row addresses
3, β¦, m + 2. Each ^^^ instruction therefore processes a whole row of n + 1 coefficient
bits: the bound 30 (m + 1) (n + 1) counts word instructions under this one-row-per-word
convention, and is not the Ξ(m nΒ²) bit-operation cost. The packed input is an uncharged
representation convention (the Word-RAM input placement convention); it differs from the
multi-tape encoding encInput of XORSAT.Dense, and this module makes no claim about running
time on that bit encoding.
Domain. The packed words cannot record row lengths, so the domain is restricted to
well-formed instances. On that domain the row-width conjunct of XORSAT.Dense.decide is constantly
true, and the program computes exactly the elimination part; mem_satisfiable_iff relates the
decided set to {q : Input | Width q.width q.rows β§ Satisfiable q.width q.rows}.
Algorithm. For each column c < n, the program scans the rows for the first word with bit
c set (the pivot of XORSAT.Dense.step), then XORs the pivot into every row with bit c set
(the pivot row itself becomes zero in its live bits, matching clear p p). It finally checks that
no row has bit n set. Every address calculation, load, store, shift, mask, XOR, comparison, loop
test and the final halt is charged by the Word-RAM semantics.
Calling convention. The elimination itself is the callable routine elimCode, which takes
n, m and the base address b of the packed rows in registers 0, 1 and 2, and
returns the answer in register 12. exec_elimCode holds at any base b and any width
w β₯ n + 1 at which b + m fits, with arbitrary memory outside the window [b, b + m) and
arbitrary values in the other registers: the routine returns the same answer within the same
30 (m + 1) (n + 1) bound, and preserves every cell outside the window and registers 0, 1
and 2. program reads the header [n, m] and runs elimCode at b = 3.
Main definitions #
Cslib.Algorithms.WordRAM.XORSATDense.rowWord: the packed word of a dense row.Cslib.Algorithms.WordRAM.XORSATDense.RowRel: a packed word represents a partially eliminated row.Cslib.Algorithms.WordRAM.XORSATDense.colStep,cols: elimination columns on packed rows.Cslib.Algorithms.WordRAM.XORSATDense.Instance,encode,FitsWidth: well-formed instances, their word layout and the admitted widths.Cslib.Algorithms.WordRAM.XORSATDense.elimCode: the callable elimination routine, a fixedCode .standard 14.Cslib.Algorithms.WordRAM.XORSATDense.elimPass: one callable elimination pass with a given column and pivot word, a fixedCode .standard 14.Cslib.Algorithms.WordRAM.XORSATDense.program: a fixedProgram .standard 14.
Main results #
Cslib.Algorithms.WordRAM.XORSATDense.rowRel_rowWord: the packed word of a row of lengthnrepresents it before elimination.Cslib.Algorithms.WordRAM.XORSATDense.forallβ_cols,decide_eq_cols: packed elimination representsXORSAT.Dense.step^[c]bit for bit and agrees withXORSAT.Dense.decide.Cslib.Algorithms.WordRAM.XORSATDense.exec_elimCode:elimCodein a caller-given memory window computes(XORSAT.Dense.decide q).toNatin at most30 (m + 1) (n + 1)instructions and preserves every cell outside the window and registers0,1and2.Cslib.Algorithms.WordRAM.XORSATDense.exec_elimCode_words: the same routine on any packed words below2 ^ (n + 1), leaving the check ofcolsat columnn.Cslib.Algorithms.WordRAM.XORSATDense.exec_elimPass:elimPassin a caller-given memory window applieselimWord c pvto every row word in at most14 m + 3instructions and preserves every cell outside the window and registers0to5.Cslib.Algorithms.WordRAM.XORSATDense.computesInTime_decide:programcomputes(XORSAT.Dense.decide q).toNatin at most30 (m + 1) (n + 1)instructions at every admitted widthw β₯ n + 1.Cslib.Algorithms.WordRAM.XORSATDense.decidesInTime_decide,uniformDecidableInTime_decide: uniform Word-RAM decision of dense XOR-SAT satisfiability within the same bound, withinputAdmissible.
References #
- H. Chen, A rendezvous of logic, complexity, and algebra, the elimination
argument formalized in
XORSAT.Dense.
Packed rows #
The packed word of a dense row: coefficients at bits 0, β¦, n - 1, right-hand side at bit
n, where n is the number of coefficients (least significant bit first, lsbValue).
Packed rows representing a partially eliminated row #
After c elimination columns of an n-column system, the word x represents the row e
(which has n - c remaining coefficients): bit c + j is coefficient j, bit n is the
right-hand side, and x has at most n + 1 bits. Bits below c are unconstrained.
The packed word of a row with n coefficients represents it before elimination.
One elimination column on packed rows #
Eliminate column c from one packed row using the pivot word pv.
After c β€ n packed columns, the packed rows represent step^[c] of the system.
On a well-formed instance, the dense decider is the right-hand-side check on the packed rows
after width packed columns.
The Word-RAM program #
Pure facts used by the loop invariants #
The elimination pass, a callable routine: every row word x of the window becomes
elimWord c pv x. It reads the number of rows m, the base address b, the constant 1, the
column c and the word pv from registers 1, 2, 3, 5 and 10 (exec_elimPass).
One elimination pass in a caller-given memory window. Let the caller's state y hold m
in register 1, a base address b in register 2, 1 in register 3, a column c in
register 5 and a word pv < 2 ^ (n + 1) in register 10, with the word W[j] < 2 ^ (n + 1) at
address b + j for j < m. Memory outside this window and the other registers are arbitrary. At
every width w at which b + m and 2 ^ (n + 1) - 1 fit, elimPass replaces cell b + j by
elimWord c pv W[j] within 14 m + 3 instructions, preserves registers 0 to 5, and preserves
every memory cell outside [b, b + m).
The callable elimination routine: constants, all elimination columns, the final check.
It reads n, m and the base address of the packed rows from registers 0, 1 and 2, and
leaves the answer in register 12 (exec_elimCode).
The fixed standard-basis program; its answer is register rOk.
Instances, encoding and the running-time theorem #
A dense XOR-SAT instance whose rows all have the declared width.
Word-RAM input layout [n, m] ++ packed rows.
Admitted widths: a packed row (n + 1 bits) fits in one word, and so do the row addresses
3, β¦, m + 2. This is the word-width condition of the bit-packed representation.
Callable dense elimination in a caller-given memory window. Let the caller's state x
hold n (the width of q) in register 0, m (the number of rows) in register 1 and a base
address b in register 2, with the packed row rowWord of row j at address b + j for
j < m. Memory outside this window and the other eleven registers are arbitrary. At every width
w β₯ n + 1 at which b + m fits, elimCode leaves (XORSAT.Dense.decide q).toNat in register
12 within 30 (m + 1) (n + 1) instructions (no final halt is charged), preserves registers
0, 1 and 2, and preserves every memory cell outside [b, b + m). Window cells and the other
registers are left unspecified. A caller with a larger register bank can run elimCode in a
renamed bank with ExecWithin.call, which also keeps every register outside that bank.
Callable dense elimination on packed words in a caller-given memory window. Let the
caller's state x hold n in register 0, m = W.length in register 1 and a base address b
in register 2, with the word W[j] < 2 ^ (n + 1) at address b + j for j < m. Memory outside
this window and the other eleven registers are arbitrary. At every width w β₯ n + 1 at which
b + m fits, elimCode leaves ((cols W n).all fun v => !v.testBit n).toNat in register 12
within 30 (m + 1) (n + 1) instructions, preserves registers 0, 1 and 2, and preserves
every memory cell outside [b, b + m).
Word-RAM running time of dense Gaussian elimination over π½β (one row per word).
The fixed standard-basis program program computes (XORSAT.Dense.decide q).toNat on every
well-formed m Γ n instance, laid out as [n, m] and one packed word per row, in at most
30 (m + 1) (n + 1) word instructions, at every word width w β₯ n + 1 at which the row
addresses fit (FitsWidth). On this domain the row-width check of decide is constantly
true.
Word-RAM decision of dense XOR-SAT. program decides satisfiability of every
well-formed m Γ n dense system in at most 30 (m + 1) (n + 1) word instructions at admitted
widths, which have w β₯ n + 1 (one packed row per word).
On well-formed instances, the decided set is upstream's satisfiable dense systems.
Every well-formed instance has an admitted width at which its encoding fits.
Uniform Word-RAM decidability of dense XOR-SAT by Gaussian elimination with one packed
row per word, in at most 30 (m + 1) (n + 1) standard-basis word instructions at word widths
w β₯ n + 1, bundling width admissibility (inputAdmissible).