Mixed-radix variable loading and literal emission #
The Cook–Levin tableau's flat variable indices are mixed-radix numerals
(((tag·A + a)·B + b)·C + c)·D + d. loadFlatVarTM computes one such
index into the scratch register tmp by a setConstTM followed by four
Horner layers, where each digit comes either from a register (a loop
counter) or a hardwired constant, and each radix comes from a register.
emitVarLitTM then appends the encoded literal for that variable to the
output accumulator.
These two machines are the per-literal unit of every clause-family emitter:
a clause is a bigSeqTM of emitVarLitTMs followed by the clause
separator.
A digit source for the mixed-radix loader: a register index or a hardwired constant.
Equations
- Complexity.TM.DigitSrc n = (Fin n ⊕ ℕ)
Instances For
The source s supplies the value w: either a register (disjoint from
the scratches) currently holding w, or the constant w itself.
Equations
- Complexity.TM.DigitSrcSpec work₀ tmp tmp2 (Sum.inl r) x✝ = (work₀ r = Complexity.TM.regTape x✝ ∧ r ≠ tmp ∧ r ≠ tmp2)
- Complexity.TM.DigitSrcSpec work₀ tmp tmp2 (Sum.inr c) x✝ = (c = x✝)
Instances For
One mixed-radix step: tmp := tmp · X + (digit from s).
Equations
- Complexity.TM.hornerStepTM X tmp tmp2 (Sum.inl r) = Complexity.TM.hornerLayerRegTM X r tmp tmp2
- Complexity.TM.hornerStepTM X tmp tmp2 (Sum.inr c) = Complexity.TM.hornerLayerConstTM X tmp tmp2 c
Instances For
hornerStepTM Hoare specification (raw form, arbitrary scratch
values).
The canonical scratch state after a mixed-radix stage: both scratches
hold z, everything else is work₀.
Equations
- Complexity.TM.scratch work₀ tmp tmp2 z = Function.update (Function.update work₀ tmp2 (Complexity.TM.regTape z)) tmp (Complexity.TM.regTape z)
Instances For
Source specifications survive scratching (sources avoid the scratches).
hornerStepTM on canonical scratch states. The composable form:
scratches at v in, scratches at v·x + w out.
Load the mixed-radix numeral (((tag·A + a)·B + b)·C + c)·D + d into
tmp (and tmp2), with radices read from registers rA rB rC rD and
digits from the sources sa sb sc sd.
Equations
- One or more equations did not get rendered due to their size.
Instances For
loadFlatVarTM Hoare specification. All four radices from registers,
all intermediate numeral values capped by M; ends on the canonical
scratch state at the full numeral.
Emit one literal: load the mixed-radix variable index into tmp,
then append the encoded literal with sign sign to the output.
Equations
- Complexity.TM.emitVarLitTM rA rB rC rD tmp tmp2 sign tag sa sb sc sd = (Complexity.TM.loadFlatVarTM rA rB rC rD tmp tmp2 tag sa sb sc sd).seqTM (Complexity.TM.emitLitTM sign tmp)
Instances For
emitVarLitTM Hoare specification. Appends
[sign, sign] ++ 2·var trues ++ [false, true] for the mixed-radix
variable index var, leaving the scratches at var and everything else
untouched.
emitVarLitTM on canonical scratch states — the composable form used
by the clause emitters: scratches at any z ≤ M in, scratches at the
emitted variable out.
Zero both scratch registers (the fixed point of every clause emitter).
Equations
- Complexity.TM.resetScratchTM tmp tmp2 = (Complexity.TM.setConstTM tmp 0).seqTM (Complexity.TM.setConstTM tmp2 0)
Instances For
resetScratchTM Hoare specification: canonical scratches at z to
canonical scratches at 0.