Native primitive certificates and whole-run transport for WordRAM #
The width is a runtime input encoded in unary; operand values and addresses are encoded in binary
(Basis.encoding). For each operation symbol, a single native machine handles every encoded width
and operand tuple, returning none when an operation is undefined or overflows 2 ^ w. Left shift
caps the shift count at the unary width before exponentiating (checkedShiftLeft_eq), rejecting
overflow when x > 0 and y ≥ w without materializing x <<< y. Polynomial bounds are in the
complete encoded input length, including the unary width, not the bit length of a binary-encoded
width. Computable width selection with charged costs and input fit remain separate obligations.
Every word-RAM basis shares the same checked-constant, equality/comparison test, address, move,
and control-label certificates (Basis.nativePrimitivesOfPolyTime). Supplying operation
certificates yields complete GenericRAM.Model.NativePrimitives bundles and IsPolynomial proofs
for Basis.standard, Basis.additive, Basis.arithmetic, and Basis.exact, as well as arbitrary
sub-bases (Basis.restrict) and homomorphic preimages (Basis.Hom.checkedOp_polyTime).
Via WordRAM.Program.toGeneric, halting WordRAM.Executes runs correspond to halting
GenericRAM.FiniteState.run executions and inherit whole-run native transport
(WordRAM.transportCertificate, WordRAM.transport_inO, WordRAM.transport_polyTime, and
WordRAM.transport_polyTime_of_le_const) whenever a NativePrimitives bundle is supplied for
B.genericModel.
Main definitions #
Basis.encoding: binary value and address encodings with unary runtime word width.Basis.nativePrimitivesOfPolyTime: complete scalar primitive bundle for a word-RAM basis from polynomial-time operation certificates.Basis.standard.nativePrimitives,Basis.additive.nativePrimitives,Basis.arithmetic.nativePrimitives,Basis.exact.nativePrimitives: complete scalar certificate bundles for the standard, additive, arithmetic, and exact word-RAM bases.
Main results #
checkedConstant_polyTime,evalTest_polyTime,address_polyTime,validMove_polyTime,validPC_polyTime: basis-independent polynomial-time scalar certificates.checkedShiftLeft_eq: left shift fits aw-bit word iff shifting bymin w yfits, with equal output.checkedAdd_polyTime,checkedAddCertificate,checkedBinOp_polyTime,checkedWidth_polyTime,checkedOp_polyTime,checkedExactOp_polyTime: native polynomial time for all checked operations ofBasis.standardandBasis.exact.Basis.Hom.checkedOp_polyTime,Basis.restrict_checkedOp_polyTime: transport of polynomial-time operation certificates along basis homomorphisms and restrictions.Basis.nativePrimitivesOfPolyTime_isPolynomial,Basis.standard.nativePrimitives_isPolynomial,Basis.additive.nativePrimitives_isPolynomial,Basis.arithmetic.nativePrimitives_isPolynomial,Basis.exact.nativePrimitives_isPolynomial: bundle polynomiality for arbitrary and named bases.executes_iff_exists_finiteRun,transportCertificate,transport_inO,transport_polyTime,transport_polyTime_of_le_const: whole-run native transport forWordRAMprograms viaGenericRAM.FiniteState.
References #
Uses Christian Reitwiessner's binary natural encodings and native machine arithmetic through the library's polynomial-time calculus.
Binary encodings for word values and addresses, with the runtime word width encoded in unary.
Instances For
A literal is checked against 2 ^ w at every unary-encoded runtime width w.
Both word-RAM register tests (eq and lt) are polynomial-time at every encoded width.
Word-RAM address extraction is the total identity into Option ℕ.
Copies, loads, stores and halts move existing words without an extra range check.
Control labels in WordRAM are unbounded natural numbers validated at instruction fetch.
Left shift fits a w-bit word if and only if shifting by min w y fits, and when it fits
both shifts produce the same word. This avoids materializing x <<< y when y > w.
Checked addition is polynomial in the full encoding: unary width and binary operands.
One native checked-add implementation works at every encoded width.
Instances For
Every binary operation in Basis.standard has a polynomial-time checked implementation.
Reading the word size in Basis.standard is polynomial-time.
Every operation in Basis.standard has a polynomial-time checked implementation.
Every operation in Basis.exact has a polynomial-time checked implementation, preserving
exact subtraction-underflow and zero-divisor faults.
Pull back polynomial-time checked-operation certificates along any map of bases.
Restricting a basis preserves polynomial-time checked-operation certificates definitionally.
Package a complete NativePrimitives bundle for a word-RAM basis from polynomial-time
certificates for its operations.
Instances For
Every primitive certificate in Basis.nativePrimitivesOfPolyTime has polynomial resource
bounds.
Complete native scalar primitive bundle for Basis.standard.
Instances For
The standard word-RAM primitive bundle has polynomial time and space bounds in all fields.
Complete native scalar primitive bundle for Basis.additive.
Instances For
The additive word-RAM primitive bundle has polynomial time and space bounds in all fields.
Complete native scalar primitive bundle for Basis.arithmetic.
Instances For
The arithmetic word-RAM primitive bundle has polynomial time and space bounds in all fields.
Complete native scalar primitive bundle for Basis.exact.
Instances For
The exact word-RAM primitive bundle has polynomial time and space bounds in all fields.
Whole-run transport adapter #
Halting WordRAM.Executes runs correspond to halting FiniteState.run executions of
p.toGeneric.
Transport a halting WordRAM.Executes certificate within steps a instructions to a native
multitape Turing-machine certificate for f : α → ℕ.
Instances For
Parameterized ComputableInO transport theorem from WordRAM.Executes.
Automatic ComputableInPolyTime transport corollary from WordRAM.Executes.
Automatic ComputableInPolyTime transport corollary from WordRAM.Executes under a
constant step-budget bound ∀ a, steps a ≤ K.