Documentation

MIPRE.Foundations.Cost.Partrec

Ambient evaluation is partial recursive #

The step of the evaluation machine on data is primitive recursive (primrec_stepData), so evaluation — its PFun.fix from the initial configuration — is partial recursive (partrec_evalData), and agrees with Eval (mem_evalData_iff). Consequently a polynomial-time function of the ambient model is Mathlib-computable, as soon as its input is produced by a computable encoding (PolyTimeFun.computable_comp). This is the bridge from the ambient model to Mathlib's computability used by the halting-problem form of the compression lemma; the other bridge (from Nat.Partrec.Code into the model) is Cost/FromPartrec.lean.

The step is primitive recursive #

p ↦ unaryToNat p.left, the tag of an encoded program or frame.

Evaluation as a fixed point #

One iteration of the evaluation loop: stop with the value on a final configuration, otherwise step.

Equations
Instances For

    Evaluation of the program p (as data) on x, as a partial function: the fixed point of the evaluation loop from the initial configuration.

    Equations
    Instances For
      theorem MIPRE.Cost.Machine.mem_fix_of_iterate (d : Data) (N : ) (hfin : IsFinalD (stepData^[N] d)) (hstep : n < N, ¬IsFinalD (stepData^[n] d)) :
      theorem MIPRE.Cost.Machine.mem_fix_of_steps (N : ) (c : Cfg) (r : Data) (e : Env) :
      step^[N] c = { ctrl := Ctrl.ret r, env := e, kont := [] }r PFun.fix (fun (d : Data) => Part.some (evalStep d)) c.toData
      theorem MIPRE.Cost.Machine.mem_evalData_iff (c : Prog) (x r : Data) :
      r evalData c.toData x ∃ (t : ), c.Runs x r t

      Evaluation on data agrees with Eval.

      Polynomial-time functions are computable #

      theorem MIPRE.Cost.evalData_encode {α : Type u_1} {β : Type u_2} [SizedEncoding α] [SizedEncoding β] (F : PolyTimeFun α β) (a : α) :
      theorem MIPRE.Cost.PolyTimeFun.computable_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} [SizedEncoding α] [SizedEncoding β] [Primcodable γ] [Primcodable β] [Inhabited β] (F : PolyTimeFun α β) (h : γα) (hh : Computable fun (c : γ) => encode (h c)) ( : Computable fun (d : Data) => decode d) :
      Computable fun (c : γ) => F.toFun (h c)

      A polynomial-time function of the ambient model, precomposed with a computable encoding of its input and followed by a computable decoding of its output, is Mathlib-computable.