Running word-RAM programs over a larger or simulating basis #
A map of bases φ : B.Hom B' (Cslib.WordRAM.Basis.Hom) sends every operation of B to an
operation of B' with the same meaning at every word size. Replacing each operation of a program
by its image (Cslib.WordRAM.Program.mapOp, Cslib.WordRAM.Code.mapOp) leaves every other
instruction in place, so the translated program takes exactly the same steps: the same states,
faults, outputs and instruction counts (Cslib.WordRAM.step_mapOp). Decision procedures and
the classes of Cslib.WordRAM.LinearTime and Cslib.WordRAM.PolynomialTime therefore grow with
the basis. This is the word-RAM analogue of translating circuits along a map of signatures
(Cslib.Circuits.Circuit.mapOp), with a budget of one instruction for every operation.
A result proved over a small basis thus holds over every basis containing it: over
Cslib.WordRAM.Basis.standard, and over any other basis that interprets the same operations in the
same way. More generally, a defined-evaluation simulation ψ : B.Simulates B'
(Cslib.WordRAM.Basis.Simulates) only requires B' to agree with B on operations that evaluate
to some v in B, allowing B' to define values on inputs where B faults (as in
Cslib.WordRAM.Basis.Simulates.exactStandard : Basis.Simulates .exact .standard). Every
non-faulting structured execution transfers instruction-for-instruction along ψ
(Cslib.WordRAM.Exec.mapSimulates, Cslib.WordRAM.ExecWithin.mapSimulates), and every basis
homomorphism φ : B.Hom B' induces a simulation Basis.Simulates.ofHom φ with
Op.mapOp φ = Op.mapSimulates (.ofHom φ) and Code.mapOp φ = Code.mapSimulates (.ofHom φ).
Main definitions #
Cslib.WordRAM.Basis.Simulates,Cslib.WordRAM.Basis.Simulates.ofHom,Cslib.WordRAM.Basis.Simulates.exactStandard: defined-evaluation basis simulation and the canonical simulation ofBasis.exactbyBasis.standard.Cslib.WordRAM.Op.mapSimulates,Cslib.WordRAM.Code.mapSimulates: translation of data instructions and structured programs along a defined-evaluation simulation.Cslib.WordRAM.Op.mapOp,Cslib.WordRAM.Instr.mapOp,Cslib.WordRAM.Program.mapOp,Cslib.WordRAM.Code.mapOp,Cslib.WordRAM.WordSizeDependentProgram.mapOp: translation along a map of bases.
Main results #
Cslib.WordRAM.Op.eval_mapSimulates_of_some,Cslib.WordRAM.Exec.mapSimulates,Cslib.WordRAM.ExecWithin.mapSimulates: non-faulting structured executions transfer along a defined-evaluation simulation.Cslib.WordRAM.Op.eval_mapOp,Cslib.WordRAM.step_mapOp: translated instructions have the same effect.Cslib.WordRAM.executes_mapOp_iff,Cslib.WordRAM.Exec.mapOp: translated programs halt in the same way, with the same instruction count.Cslib.WordRAM.Code.assemble_mapOp: translation commutes with assembly.Cslib.WordRAM.DecidableInTime.mapOp,Cslib.WordRAM.LinearTime.mapOp,Cslib.WordRAM.PolynomialTime.mapOp: decision transfers to a larger basis with the same time bound and word-size threshold.
References #
Defined-evaluation basis simulation #
B is simulated by B' on defined evaluations when every non-faulting operation in B
evaluates to the same value in B' without introducing ReadsWidth. Unlike Basis.Hom, B' may
define values on inputs where B faults (such as Basis.exact vs Basis.standard).
- eval_some (w : ℕ) (f : B.Op) (args : Fin (B.Arity f) → ℕ) {v : ℕ} : B.interp w f args = some v → (B'.interp w (self.toHom f) fun (a : Fin (B'.Arity (self.toHom f))) => args (Fin.cast ⋯ a)) = some v
Every defined operation value in
Bis preserved inB'. - readsWidth_of_map (f : B.Op) : B'.ReadsWidth (self.toHom f) → B.ReadsWidth f
Simulation does not introduce word-size reads.
Instances For
Identity basis simulation.
Instances For
Every exact basis homomorphism induces a defined-evaluation simulation.
Instances For
Every non-faulting Basis.exact operation evaluates to the same value in Basis.standard.
Instances For
Instructions #
Translating a program along a basis homomorphism preserves its length.
Translating along a basis simulation preserves compiled program size.
Any non-faulting evaluation of a data instruction is preserved under Op.mapSimulates.
A data instruction translated along a simulation reads the word size only if the instruction does.
A translated data instruction reads the word size only if the instruction does.
A translated instruction reads the word size only if the instruction does.
A translated program reads the word size only if the program does.
A structured program translated along a simulation reads the word size only if the program does.
A translated structured program reads the word size only if the program does.
Translating an instruction along a basis homomorphism preserves IsRandFree.
Translating a flat program along a basis homomorphism preserves IsRandFree.
Translating a structured program along a basis simulation preserves IsRandFree.
Translating a structured program along a basis homomorphism preserves IsRandFree.
Runs #
Structured programs #
Bounded-step structured executions transfer along Simulates.
Bounded-step execution of a structured program transfers along a basis homomorphism.
A structured program that answers a question continues to answer it after translation.
Decision #
A flat decision procedure transfers along a basis homomorphism with the same time bound.
Translate each member of a width-indexed family.
Instances For
Translation preserves the code-length bound.
Translation preserves family decision at the same width and instruction count.
Nonuniform decision grows with the operation basis, preserving code length.
Uniform decision grows with the operation basis.
Linear time over a basis is linear time over every larger basis.
Uniform linear time grows with the operation basis.
Polynomial time over a basis is polynomial time over every larger basis.
Uniform polynomial time grows with the operation basis.
Functoriality #
Translating a data instruction along the identity basis homomorphism leaves it unchanged.
Translating a program along the identity basis homomorphism leaves it unchanged.