Documentation

CslibFrontier.Computability.GenericRAM.Simulation.Degree

Explicit-degree overhead of the finite-state RAM simulation #

When every primitive certificate of a RAM model has degree D ≥ 3 (Model.NativePrimitives.HasDegree), one step of the native finite-state simulator has degree D in the encoded runtime configuration and state. The 3 is the sparse-memory scan, which is cubic in the encoded memory (SparseMemory.scanTime_le_cube). A clocked run of n steps under the runtime configuration k, whose step outcomes have encoded length at most B, therefore costs O(|input| + (n + 1) · (X ^ D + (log n + 1) ^ 2)) machine steps, where X = 2 |k| + B + 2 bounds the encoded loop states plus one. Whole-run transport inherits this bound with every constant outside the degree.

These are the degree analogues of the *_isPolynomial lemmas of CslibFrontier.Computability.GenericRAM.Simulation.Run, which give polynomial bounds of unnamed degree.

Main results #

References #

theorem Cslib.GenericRAM.FiniteState.Native.fields_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} (enc : M.Encoding) (c : NativeCertificate s ei (encoding enc)) (hc : c.HasDegree D) :
(fields enc c).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.register_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} (enc : M.Encoding) (c : NativeCertificate s ei (encoding enc)) (i : Fin r) (hc : c.HasDegree D) :
(register enc c i).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.operands_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} (enc : M.Encoding) (c : NativeCertificate s ei (encoding enc)) {n : ℕ} (args : Fin n → Fin r) (hc : c.HasDegree D) :
(operands enc c args).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.setCertificate_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} {v : α → M.Value} (enc : M.Encoding) (c : NativeCertificate s ei (encoding enc)) (d : Fin r) (value : NativeCertificate v ei enc.value) (hc : c.HasDegree D) (hv : value.HasDegree D) :
(setCertificate enc c d value).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.moveCertificate_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} {k : α → M.Config} {v : α → M.Value} (enc : M.Encoding) (N : M.NativePrimitives enc) (config : NativeCertificate k ei enc.config) (c : NativeCertificate s ei (encoding enc)) (d : Fin r) (value : NativeCertificate v ei enc.value) (hD : 1 ≤ D) (hN : N.HasDegree D) (hk : config.HasDegree D) (hc : c.HasDegree D) (hv : value.HasDegree D) :
(moveCertificate enc N config c d value).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.readRaw_hasDegree {M : Model} {D : ℕ} (enc : M.Encoding) (hD : 3 ≤ D) :
{ time := SparseMemory.readTime enc.address enc.value, space := SparseMemory.readSpace enc.address enc.value, computes := ⋯ }.HasDegree D

The certificate of the raw sparse-memory lookup has degree D for every D ≥ 3: time and space bounds of degree D and encoded output of linear length. The cubic time and linear space bounds behind it are SparseMemory.readTime_le_cube and SparseMemory.readSpace_le_linear.

theorem Cslib.GenericRAM.FiniteState.Native.writeRaw_hasDegree {M : Model} {D : ℕ} (enc : M.Encoding) (hD : 3 ≤ D) :
{ time := SparseMemory.writeTime enc.address enc.value, space := SparseMemory.writeSpace enc.address enc.value, computes := ⋯ }.HasDegree D

The certificate of the raw sparse-memory update has degree D for every D ≥ 3: time and space bounds of degree D and encoded output of linear length. The cubic time and linear space bounds behind it are SparseMemory.writeTime_le_cube and SparseMemory.writeSpace_le_linear.

theorem Cslib.GenericRAM.FiniteState.Native.readCertificate_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} (enc : M.Encoding) (c : NativeCertificate s ei (encoding enc)) {a : α → M.Address} (address : NativeCertificate a ei enc.address) (hD : 3 ≤ D) (hc : c.HasDegree D) (ha : address.HasDegree D) :
(readCertificate enc c address).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.writeCertificate_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} {v : α → M.Value} (enc : M.Encoding) (c : NativeCertificate s ei (encoding enc)) {a : α → M.Address} (address : NativeCertificate a ei enc.address) (value : NativeCertificate v ei enc.value) (hD : 3 ≤ D) (hc : c.HasDegree D) (ha : address.HasDegree D) (hv : value.HasDegree D) :
(writeCertificate enc c address value).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.evalOpCertificate_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} {k : α → M.Config} (enc : M.Encoding) (N : M.NativePrimitives enc) (config : NativeCertificate k ei enc.config) (c : NativeCertificate s ei (encoding enc)) (o : Op M r) (hD : 3 ≤ D) (hN : N.HasDegree D) (hk : config.HasDegree D) (hc : c.HasDegree D) :
(evalOpCertificate enc N config c o).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.resumeCertificate_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} {k : α → M.Config} (enc : M.Encoding) (N : M.NativePrimitives enc) (config : NativeCertificate k ei enc.config) (c : NativeCertificate s ei (encoding enc)) (pc : ℕ) (hD : 1 ≤ D) (hN : N.HasDegree D) (hk : config.HasDegree D) (hc : c.HasDegree D) :
(resumeCertificate enc N config c pc).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.evalInstrCertificate_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} {k : α → M.Config} (enc : M.Encoding) (N : M.NativePrimitives enc) (config : NativeCertificate k ei enc.config) (c : NativeCertificate s ei (encoding enc)) (nextPC : ℕ) (i : Instr M r) (hD : 3 ≤ D) (hN : N.HasDegree D) (hk : config.HasDegree D) (hc : c.HasDegree D) :
(evalInstrCertificate enc N config c nextPC i).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.pcEquals_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} (enc : M.Encoding) (c : NativeCertificate s ei (encoding enc)) (pc : ℕ) (hD : 2 ≤ D) (hc : c.HasDegree D) :
(pcEquals enc c pc).HasDegree D
theorem Cslib.GenericRAM.FiniteState.Native.dispatchCertificate_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} {s : α → FiniteState M r} {k : α → M.Config} (enc : M.Encoding) (N : M.NativePrimitives enc) (config : NativeCertificate k ei enc.config) (c : NativeCertificate s ei (encoding enc)) (p : Program M r) (pc : ℕ) (hD : 3 ≤ D) (hN : N.HasDegree D) (hk : config.HasDegree D) (hc : c.HasDegree D) :
(dispatchCertificate enc N config c p pc).HasDegree D
theorem Cslib.GenericRAM.FiniteState.stepCertificate_hasDegree {M : Model} {r D : ℕ} (enc : M.Encoding) (N : M.NativePrimitives enc) (p : Program M r) (hN : N.HasDegree D) (hD : 3 ≤ D) :

One simulated step has degree D when every primitive certificate has degree D ≥ 3.

theorem Cslib.GenericRAM.FiniteState.roundCertificate_hasDegree {M : Model} {r D : ℕ} (enc : M.Encoding) (N : M.NativePrimitives enc) (p : Program M r) (hN : N.HasDegree D) (hD : 3 ≤ D) :

One clocked round of the simulator has degree D when every primitive certificate has degree D ≥ 3.

Clocked runs with explicit bounds #

theorem Cslib.GenericRAM.FiniteState.length_loopEncoding_iterate_round {M : Model} {r : ℕ} (enc : M.Encoding) (p : Program M r) (j : ℕ) (k : M.Config) (s : FiniteState M r) :
((loopEncoding enc) ((round p)^[j] (k, some (Sum.inl s)))).length = 2 * (enc.config k).length + 1 + ((resultEncoding enc) (run k p j s)).length

The loop state after j rounds from a continuing state has the encoded length of the runtime configuration and the j-step outcome.

theorem Cslib.GenericRAM.FiniteState.runTime_le {M : Model} {r D : ℕ} (enc : M.Encoding) (N : M.NativePrimitives enc) (p : Program M r) {C : ℕ} (hround : ∀ (x : M.Config × Result M r), (roundCertificate enc N p).time x ≤ C * (((loopEncoding enc) x).length + 1) ^ D) (n : ℕ) (k : M.Config) (s : FiniteState M r) {B : ℕ} (hB : ∀ j ≤ n, ((resultEncoding enc) (run k p j s)).length ≤ B) :
runTime enc N p (n, k, s) ≤ 3 * ((runInputEncoding enc) (n, k, s)).length + (n + 1) * (C * (2 * (enc.config k).length + B + 2) ^ D + (2 * (enc.config k).length + B + 2) + ((Turing.MultiTapeTM.encNat n).length + 1) ^ 2)

Explicit clocked run time. If every round costs at most C (ℓ + 1) ^ D on a loop state of encoded length ℓ, and the outcomes of the first n steps have encoded length at most B, then n clocked steps cost at most 3 |input| + (n + 1) (C X ^ D + X + (|n| + 1) ^ 2), where X = 2 |k| + B + 2 bounds the encoded loop states plus one.

theorem Cslib.GenericRAM.FiniteState.runSpace_le {M : Model} {r D : ℕ} (enc : M.Encoding) (N : M.NativePrimitives enc) (p : Program M r) {C : ℕ} (hround : ∀ (x : M.Config × Result M r), (roundCertificate enc N p).space x ≤ C * (((loopEncoding enc) x).length + 1) ^ D) (n : ℕ) (k : M.Config) (s : FiniteState M r) {B : ℕ} (hB : ∀ j ≤ n, ((resultEncoding enc) (run k p j s)).length ≤ B) :
runSpace enc N p (n, k, s) ≤ 3 * ((runInputEncoding enc) (n, k, s)).length + C * (2 * (enc.config k).length + B + 2) ^ D + (2 * (enc.config k).length + B + 2) + (Turing.MultiTapeTM.encNat n).length

Explicit clocked run space. The space analogue of runTime_le.

theorem Cslib.GenericRAM.FiniteState.transport_inO_of_hasDegree {M : Model} {r : ℕ} {α : Type} {ei : α ↪ List Bool} {D : ℕ} (enc : M.Encoding) (N : M.NativePrimitives enc) (hN : N.HasDegree D) (hD : 3 ≤ D) (p : Program M r) {f : α → M.Value} {cfg : α → M.Config} {initState : α → FiniteState M r} {steps : α → ℕ} (cSteps : NativeCertificate steps ei Turing.MultiTapeTM.encNat) (cCfg : NativeCertificate cfg ei enc.config) (cInit : NativeCertificate initState ei (encoding enc)) (hExec : ∀ (a : α), ∃ m ≤ steps a, Executes (cfg a) p (initState a).denote (f a) m) {B : α → ℕ} (hOutLen : ∀ (a : α), ∀ j ≤ steps a, ((resultEncoding enc) (run (cfg a) p j (initState a))).length ≤ B a) :
Turing.MultiTapeTM.ComputableInO f ei enc.value (fun (a : α) => cSteps.time a + cCfg.time a + cInit.time a + ((runInputEncoding enc) (steps a, cfg a, initState a)).length + (steps a + 1) * ((2 * (enc.config (cfg a)).length + B a + 2) ^ D + ((Turing.MultiTapeTM.encNat (steps a)).length + 1) ^ 2)) fun (a : α) => cSteps.space a + cCfg.space a + cInit.space a + ((runInputEncoding enc) (steps a, cfg a, initState a)).length + (2 * (enc.config (cfg a)).length + B a + 2) ^ D + (Turing.MultiTapeTM.encNat (steps a)).length

Whole-run transport with an explicit degree. Suppose every primitive certificate of the model has degree D ≥ 3, a halting run of p from initState a takes at most steps a instructions, and the outcomes of its first steps a clocked steps have encoded length at most B a. Then f is computable in time O(Tsteps + Tcfg + Tinit + |input| + (steps + 1) · (X ^ D + (|steps| + 1) ^ 2)), where X = 2 |cfg| + B + 2 and |input| is the encoded length of (steps, cfg, initState). Only the constant factor is hidden.