Packed state of the 4n - 9d refuter and its invariant #
A word-level representation of the gate-elimination states that the refuter refute visits
(Cslib.Circuits.Boolean.AffineDisperser4n), and the relation Rep saying that packed words
represent a state. This is the pure layer of the Word-RAM refuter of issue #4322
(Milestone 4); no program and no running time is claimed here.
Fix a bound N on the names of parameters, auxiliary variables and gates and a bound E on
equation names. The layout of a circuit C uses N = nameBound C = n + C.size (names along the
run, nameSet_iterate) and E = eqnBound C = 5 n + 7 C.size (equation names at the end of the
run, eqns_refuterLoop). The packed state PackedState consists of:
- masks: the parameters, auxiliary variables and gates as bitmasks
maskOf, bitiset iffiis in the set; - gate table:
Nrows of three words (GateRow),rowOf g = ⟨ttOf g.op, argCode g.left, argCode g.right⟩: the truth table of the operation (bitidx a b = 2a + bisop a b,testBit_ttOf) and the codesconst b ↦ b,node i ↦ i + 2of the arguments; rows of non-gates are junk, but every row is within range (RowLt); - equation table:
Ewords, one per equation name.eqnWord N e alivehas the terms belowNat bits0, …, N - 1, the right-hand side at bitN(the packed rowrowWordof the denseXORSATelimination,eqnWord_mod) and an alive flag at bitN + 1. Equation names are array indices, never bits of a mask; - output: one word
litCode,2 · argCode + neg; - pairs: a duplicate-free list of two-word records
pairCode,(2 fst + fstBias, 2 snd + sndBias), one per pair; - parameter map:
nexplicit affine rows. Rowiis a wordr, read asrowEval N r val = r_N + ∑_{j < N, r_j} val j(the same packed format), andS.phi val iis the value of rowi(PhiWords). Restriction and the affine reparameterisation update every row bysubstWord(PhiWords.restrict,PhiWords.swap): these are the only operations of the refuter that changephi.
Rep records only the words; the bounds that also follow from validity (terms, output and pairs
named below N) are derived from State.Valid (Rep.terms_lt, Rep.out_lt, Rep.pairs_lt).
Word width. At w ≥ N + 2 and w ≥ 4, every stored word of a valid represented state fits
(Rep.fits); with N = n + C.size this is the basis w ≥ n + C.size + 2, plus w ≥ 4 for a
4-bit truth table, which binds only when N < 2. This layer fixes no memory layout: addresses,
counters, scratch cells and the separate instruction and workspace bounds come with the step
programs. Equation words are rows at the fixed width N, while evaluateAux builds its dense rows
at the width varBound S; the step layer relates the two.
Searches of the refuter run over sorted Finsets; on a mask they are the ascending bit scan over
List.range N (find?_sort_eq_find?_range, findSome?_sort_eq_findSome?_range). The first
client is the (D1) search: pFindD1 scans the gate mask and reads only packed rows, and equals
findD1 on every represented state (Rep.pFindD1_eq). The second client is the initial state:
initialPacked C represents initialState C (rep_initialPacked).
Main definitions #
Cslib.Algorithms.WordRAM.Refuter4n.maskOf,argCode,idx,ttOf,GateRow,rowOf,RowLt,litCode,pairCode,eqnWord: encodings.Cslib.Algorithms.WordRAM.Refuter4n.rowEval,substWord,litWord,Cslib.Algorithms.WordRAM.Refuter4n.PhiWords: explicit rows of the parameter map.Cslib.Algorithms.WordRAM.Refuter4n.PackedState,PackedState.Fits,Rep: the packed state, its word-width condition and the representation relation.Cslib.Algorithms.WordRAM.Refuter4n.nameBound,eqnBound: the table sizes of the layout.Cslib.Algorithms.WordRAM.Refuter4n.isDegenerateRow,pFindD1:(D1)on the packed state.Cslib.Algorithms.WordRAM.Refuter4n.initialPacked: the packed initial state.
Main results #
Cslib.Algorithms.WordRAM.Refuter4n.testBit_maskOf,testBit_ttOf,testBit_rowWord_toDenseRow,eqnWord_mod,testBit_eqnWord_alive: the encodings are faithful.Cslib.Algorithms.WordRAM.Refuter4n.maskOf_lt,ttOf_lt,argCode_lt,litCode_lt,rowLt_rowOf,rowWord_toDenseRow_lt,eqnWord_lt,substWord_lt,litWord_lt: the encodings fit in their bit ranges.Cslib.Algorithms.WordRAM.Refuter4n.rowEval_two_pow,rowEval_rowWord,rowEval_litWord: values of coordinate, equation and literal rows.Cslib.Algorithms.WordRAM.Refuter4n.rowEval_substWord,PhiWords.restrict,PhiWords.swap: exact row updates of the parameter map, with no side conditions beyond names belowN.Cslib.Algorithms.WordRAM.Refuter4n.sort_eq_filter_range,find?_sort_eq_find?_range,findSome?_sort_eq_findSome?_range: sorted lists and sorted searches are ascending bit scans.Cslib.Algorithms.WordRAM.Refuter4n.Rep.lt_of_mem_nameSet,Rep.lt_of_mem_params,Rep.lt_of_mem_aux,Rep.lt_of_mem_gates,Rep.terms_lt,Rep.out_lt,Rep.pairs_lt: names of a represented state, and names read by a valid one, are belowN.Cslib.Algorithms.WordRAM.Refuter4n.Rep.fits,Rep.length_pairs,Rep.length_pairs_le: every word fits atw ≥ N + 2,w ≥ 4; the pair list has one record per pair and at mostNrecords.Cslib.Algorithms.WordRAM.Refuter4n.eqnBound_le: the equation table has at most7 · nameBound Cwords.Cslib.Algorithms.WordRAM.Refuter4n.isDegenerateRow_rowOf,Rep.pFindD1_eq,rep_initialPacked: the two clients.
Bitmasks and sorted searches #
The bitmask of a finite set of names: bit i is set iff i ∈ s (the inverse of
Finset.equivBitIndices).
The sorted list of a set of names below N is the ascending filter of List.range N.
A search in a sorted set of names below N is the ascending scan of its mask.
Gate rows #
The word code of an argument: const b ↦ b, node i ↦ i + 2.
The bit index 2a + b of the input pair (a, b) in a truth table.
The code of an argument that reads only names below N is below N + 2.
The row of a gate.
The fields of a gate row are within their ranges for names below N.
The row of a gate reading only names below N is within range.
Output, pairs and equations #
The word code of a literal: 2 · argCode + neg.
The two-word record of a pair: (2 fst + fstBias, 2 snd + sndBias).
The word of an equation: terms below N at bits 0, …, N - 1, the right-hand side at bit
N (the packed row rowWord of toDenseRow), and the alive flag at bit N + 1.
The packed dense row of ∑ T = c at width N fits in N + 1 bits.
The alive flag of an equation word.
Below the alive flag, an equation word is the dense XORSAT row of the equation, in the
packed format of Cslib.Algorithms.WordRAM.XORSATDense.
An equation word fits in N + 2 bits.
Explicit rows of the parameter map #
Substitute, in the row r, the name x by the row u: if x occurs, clear it and add u
(terms and constant at once).
The packed dense row of ∑ T = c is the row c + ∑ T.
The row of a literal: b ^^ neg for a constant b, val y ^^ neg for a node y.
The row of a literal fits in N + 1 bits.
The words W are explicit affine rows of the parameter map of S: S.phi val i is the
value of row i, and every row has its terms below N and its constant at bit N.
One row per output bit.
Every row fits in
N + 1bits.Output bit
iis the value of rowi.
Restriction x := ℓ (State.restrict, hence State.fixConst) updates every row by
substituting the row of ℓ.
Affine reparameterisation (State.swap x Q c T) updates every row by substituting
x := c + val Q + ∑_{T \ {x}} val, the packed row of ∑ ((T \ {x}) ∆ {Q}) = c.
Packed states #
A packed refuter state (pure model of the Word-RAM memory image).
- params : ℕ
Bitmask of the parameters.
- aux : ℕ
Bitmask of the auxiliary variables.
- gates : ℕ
Bitmask of the gates.
The gate table, one row per name below
N.The equation table, one word per equation name below
E.- out : ℕ
The code of the output literal.
The pair records.
The rows of the parameter map.
Instances For
Every word of P is below 2 ^ w.
P represents the state S, with names below N and equation names below E.
- names : Circuits.Boolean.AffineDisperser4n.nameSet S ⊆ Finset.range N
Parameters, auxiliary variables and gates are named below
N. - eqns : S.eqns ⊆ Finset.range E
Equations are named below
E. The parameter mask.
The auxiliary mask.
The gate mask.
The gate table has
Nrows.- gateRow (J : ℕ) : J ∈ S.gates → P.gateRows.getD J { tt := 0, left := 0, right := 0 } = rowOf (S.gate J)
The row of every gate is the row of its gate.
Every row, junk or not, is within range.
The equation table has
Ewords.The word of every equation is its equation word.
The alive flags are the equation names.
Every word of the table, junk or not, fits in
N + 2bits.The output word.
- pairs : ∃ (l : List Circuits.Boolean.AffineDisperser4n.ZeroPair), l.Nodup ∧ l.toFinset = S.pairs ∧ P.pairs = List.map pairCode l
The pair records list the pairs, each once.
The rows of the parameter map.
Every name of a represented state is below N.
Every parameter of a represented state is below N.
Every auxiliary variable of a represented state is below N.
Every gate name of a represented state is below N.
Terms of the equations of a valid represented state are named below N.
The output of a valid represented state reads a name below N.
The pairs of a valid represented state consist of names below N.
There is one pair record per pair.
For a valid state, there are at most N pair records.
Word width. At w ≥ N + 2 and w ≥ 4, every word of a valid represented state fits.
The table sizes of the layout #
The name bound of the layout of C: the names along the run are below n + C.size
(nameSet_iterate).
The equation-name bound of the layout of C: the equation names at the end of the run are
below 5 n + 7 C.size (eqns_refuterLoop).
The equation table has at most 7 · nameBound C words.
First client: the (D1) search #
A gate row is degenerate: a constant argument (code below 2) or two equal arguments.
On the row of a gate, isDegenerateRow is isDegenerate.
(D1) on a packed state: the ascending scan of the gate mask for a degenerate row.
The packed (D1) search returns the gate of findD1.
Second client: the initial state #
The packed initial state of C, with nameBound C gate rows and eqnBound C equation
words.
initialPacked C represents initialState C.