Word-RAM primitives with explicit degrees #
WordRAM.Native certifies each primitive of a word-RAM basis in polynomial time of unnamed degree.
Here the primitives get explicit degrees: on a unary word size and binary operands, the literal
check, the eq/lt tests, address extraction and the move and label checks all run in quadratic
time and space with output of linear length, and so do checked addition and truncated subtraction.
The fits test v < 2 ^ w compares the bit length of v with w in unary, without forming 2 ^ w.
Basis.nativePrimitivesOfDegree assembles a primitive bundle of degree d ≥ 2 from degree-d
certificates for the operations of a basis; Basis.additive.quadraticPrimitives is the instance
with d = 2. The other bases need degree certificates for multiplication, division,
remainder, the bitwise operations and the shifts, which the machine library does not yet supply
except for multiplication.
Main definitions #
Cslib.WordRAM.Basis.nativePrimitivesOfDegree: the primitive bundle of a basis from degree-dcertificates for its operations.Cslib.WordRAM.Basis.additive.quadraticPrimitives: the quadratic bundle of the additive basis.
Main results #
Cslib.WordRAM.fits_degree: the fits test is quadratic.Cslib.WordRAM.checkedAdd_degree,Cslib.WordRAM.checkedSub_degree: checked addition and subtraction are quadratic.Cslib.WordRAM.Basis.nativePrimitivesOfDegree_hasDegree,Cslib.WordRAM.Basis.additive.quadraticPrimitives_hasDegree: the bundles have the stated degree.
The fits test v < 2 ^ w is quadratic on a unary width and a binary value. It compares the
bit length of v with w.
Checked addition is quadratic on a unary width and binary operands.
Checked truncated subtraction is quadratic on a unary width and binary operands.
A literal is checked against the unary width in quadratic time.
The word-RAM tests (eq, lt and the faulting test) are quadratic.
Word-RAM address extraction is linear.
The primitive bundle of a basis from degree-d certificates for its checked operations,
d ≥ 2; the literal, test, address, move and label primitives are quadratic.
Basis.nativePrimitivesOfDegree has degree d.
Every checked operation of the additive basis is quadratic.
The quadratic primitive bundle of the additive basis.
Every primitive of the additive basis is quadratic.