Documentation

Complexity.Computability.WordRAM.Generic

Word RAMs as generic RAMs #

Every word-RAM basis determines a GenericRAM.Model. Values, addresses, constants and the configuration are natural numbers, with the configuration interpreted as word width. Operations use the original basis; equality and unsigned comparison are the tests. Only constants and operation results check word fit, exactly as in WordRAM.Defs; existing values and control labels remain unchecked. Address extraction is the identity, including on arbitrary initial states.

The adapter preserves each step, including faults, and every fuel-bounded result and exact instruction count. It does not impose new validity assumptions on existing WordRAM states.

Main definitions #

Main results #

References #

@[reducible, inline]

Natural word values and addresses, with exactly the existing word-RAM checking policy. The two test symbols are false for equality and true for unsigned comparison.

Instances For

    Identical registers and memory in the generic representation.

    Instances For

      Identical control label, registers and memory in the generic representation.

      Instances For

        Translate an equality or comparison test.

        Instances For

          Translate a data instruction without changing its registers or operation.

          Instances For

            Translate an instruction without changing its control labels.

            Instances For

              Instruction-for-instruction translation to the generic core.

              Instances For

                Translation preserves the number of instructions.

                theorem Cslib.WordRAM.Data.toGeneric_init {r : ℕ} (B : Basis) (input : List ℕ) :
                toGeneric B (init input) = GenericRAM.Data.init 0 fun (a : B.genericModel.Address) => if a = 0 then input.length else input.getD (a - 1) 0

                The original input convention is an explicit generic initialization, with no charged work.

                Translate a step outcome without changing its meaning.

                Instances For
                  theorem Cslib.WordRAM.Op.eval_toGeneric {B : Basis} {r : ℕ} (o : Op B r) (w : ℕ) (x : Data r) :

                  Data instructions preserve success and failure, even on unbounded initial data.

                  theorem Cslib.WordRAM.Cond.eval_toGeneric {B : Basis} {r : ℕ} (c : Cond r) (w : ℕ) (x : Data r) :

                  Tests have precisely the original truth value and never fail.

                  theorem Cslib.WordRAM.step_toGeneric {B : Basis} {r : ℕ} (w : ℕ) (p : Program B r) (s : State r) :

                  Exact step correspondence, including faults and arbitrary initial states.

                  theorem Cslib.WordRAM.run_toGeneric {B : Basis} {r : ℕ} (w : ℕ) (p : Program B r) (fuel : ℕ) (s : State r) :
                  GenericRAM.run w p.toGeneric fuel (State.toGeneric B s) = run w p fuel s

                  The interpreter returns exactly the original output and instruction count at every fuel.

                  theorem Cslib.WordRAM.executes_toGeneric_iff {B : Basis} {r w : ℕ} {p : Program B r} {s : State r} {v n : ℕ} :

                  Halting executions agree in both directions, with the exact same instruction count.