Documentation

Complexity.Computability.GenericRAM.Native

Native certificates for RAM primitives #

A NativeCertificate records arbitrary input-dependent time and space bounds, including the encoded output size, for an actual finite native multi-tape machine. Model.NativePrimitives collects these certificates for the scalar obligations of a RAM model. Configuration and all operands are encoded runtime inputs; a single machine handles all of them for each fixed symbol. Constants may depend on the symbol, and hence on a fixed finite source program. Symbols themselves are not encoded inputs: this is not a uniform interpreter for arbitrary programs.

The semantic Model remains independent of finite encodings. In particular, this interface does not require an exact real RAM to admit a bit representation. It also supplies neither a memory representation nor a whole-machine simulation. Loads/stores still require charged lookup/update; control, initialization and output require their own certificates. Deriving an input-only bound from a configuration-and-input bound additionally requires charged, computable configuration selection and an input-fit guarantee, rather than instance-dependent width advice.

Main definitions #

Main results #

References #

structure Cslib.GenericRAM.NativeCertificate {α β : Type} (f : α → β) (encIn : α ↪ List Bool) (encOut : β ↪ List Bool) :

An actual native implementation, with bounds also charging its encoded output length.

  • time : α → ℕ

    Input-dependent time bound, up to a constant factor and additive constant.

  • space : α → ℕ

    Input-dependent work space and encoded output bound, up to constants.

  • computes : Turing.MultiTapeTM.ComputableTidilyInO f encIn encOut self.time self.space

    One finite machine implements the function on every encoded input.

Instances For
    theorem Cslib.GenericRAM.NativeCertificate.isComputable {α β : Type} {f : α → β} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} (c : NativeCertificate f encIn encMid) :

    Forgetting resource bounds retains native computability.

    def Cslib.GenericRAM.NativeCertificate.IsPolynomial {α β : Type} {f : α → β} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} (c : NativeCertificate f encIn encMid) :

    Polynomiality is a separate property of both bounds in the encoded input length.

    Instances For
      theorem Cslib.GenericRAM.NativeCertificate.polyTime {α β : Type} {f : α → β} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} (c : NativeCertificate f encIn encMid) (h : c.IsPolynomial) :

      Derive the existing native polynomial-time predicate, for use by its compositional calculus.

      def Cslib.GenericRAM.NativeCertificate.comp {α β γ : Type} {f : α → β} {g : β → γ} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {encOut : γ ↪ List Bool} (d : NativeCertificate g encMid encOut) (c : NativeCertificate f encIn encMid) :
      NativeCertificate (g ∘ f) encIn encOut

      Compose implementations, charging the second bound at the first result.

      Instances For
        theorem Cslib.GenericRAM.NativeCertificate.comp_isPolynomial {α β γ : Type} {f : α → β} {g : β → γ} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {encOut : γ ↪ List Bool} (d : NativeCertificate g encMid encOut) (c : NativeCertificate f encIn encMid) (hd : d.IsPolynomial) (hc : c.IsPolynomial) :

        Composing polynomial certificates preserves polynomiality in the original input encoding.

        def Cslib.GenericRAM.NativeCertificate.ofTimeAndSpace {α β : Type} {f : α → β} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} {t s : α → ℕ} (h : Turing.MultiTapeTM.ComputableTidilyInTimeAndSpace f encIn encMid t s) :
        NativeCertificate f encIn encMid

        Package exact native bounds, including the running time in the space allowance to charge encoded output length. No polynomial hypothesis is needed.

        Instances For
          theorem Cslib.GenericRAM.NativeCertificate.nonempty_iff_isComputable {α β : Type} {f : α → β} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} :

          Arbitrary-bound certificates impose exactly native computability, not an efficiency assumption. Polynomial resource bounds remain a separate property.

          theorem Cslib.GenericRAM.NativeCertificate.exists_polynomial {α β : Type} {f : α → β} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} (h : Turing.MultiTapeTM.ComputableTidilyInPolyTime f encIn encMid) :
          ∃ (c : NativeCertificate f encIn encMid), c.IsPolynomial

          Every native polynomial-time proof supplies a certificate with polynomial bounds. The space bound includes the running time so that it also bounds the emitted output.

          noncomputable def Cslib.GenericRAM.NativeCertificate.ofPolyTime {α β : Type} {f : α → β} {encIn : α ↪ List Bool} {encMid : β ↪ List Bool} (h : Turing.MultiTapeTM.ComputableTidilyInPolyTime f encIn encMid) :
          NativeCertificate f encIn encMid

          Select resource bounds from an existing polynomial-time implementation proof.

          Instances For

            Bounds selected by ofPolyTime are polynomial in the encoded input length.

            Finite bit representations are separate from the semantic model. Configuration encoding is chosen explicitly; in particular, unary and binary widths have different resource costs.

            Instances For

              A fixed literal's result, including the admissibility check performed by Data.put.

              Instances For

                A fixed operation's result, including the admissibility check performed by Data.put. A native implementation can reject overflow without materializing the unchecked result.

                Instances For
                  theorem Cslib.GenericRAM.Model.eval_const_eq_map_checkedConstant {M : Model} {r : ℕ} (k : M.Config) (x : Data M r) (d : Fin r) (c : M.Const) :

                  A constant instruction stores exactly the checked literal result, preserving faults.

                  theorem Cslib.GenericRAM.Model.eval_alu_eq_map_checkedOp {M : Model} {r : ℕ} (k : M.Config) (x : Data M r) (op : M.operations.Op) (d : Fin r) (args : Fin (M.operations.Arity op) → Fin r) :
                  Op.eval k (Op.alu op d args) x = Option.map (x.set d) (M.checkedOp op (k, x.regs ∘ args))

                  An ALU instruction stores exactly the checked operation result, preserving faults.

                  Scalar certificates needed by a fixed-program RAM simulation. Memory lookup/update and finite-program dispatch are additional obligations. There is no uniform symbol dispatcher here.

                  Instances For

                    All six primitive certificates in a bundle have polynomial time and space bounds.

                    • constant (c : M.Const) : (N.constant c).IsPolynomial

                      Every literal symbol's certificate has polynomial time and space bounds.

                    • operation (op : M.operations.Op) : (N.operation op).IsPolynomial

                      Every ALU operation symbol's certificate has polynomial time and space bounds.

                    • test (t : M.tests.Op) : (N.test t).IsPolynomial

                      Every test symbol's certificate has polynomial time and space bounds.

                    • address : N.address.IsPolynomial

                      The address extraction certificate has polynomial time and space bounds.

                    • validMove : N.validMove.IsPolynomial

                      The move validation certificate has polynomial time and space bounds.

                    • validPC : N.validPC.IsPolynomial

                      The control-label validation certificate has polynomial time and space bounds.

                    Instances For