Documentation

MIPRE.Tailored.Repeat.Calls

Programs in stages, and a loop of calls to a stored program #

The programs of the repeated tailored verifier (Phase 2 of planning/aldous-lyons-track.md, issue #280) are built in stages: polynomial-time functions, which prepare the next stage's input while carrying what later stages need, alternate with calls to the input programs through the universal machine. This module is the glue.

Sequencing #

Run q on the result of p.

Equations
Instances For
    theorem MIPRE.Tailored.Calls.seq_runs {p q : Cost.Prog} (hq : Cost.Prog.WellScoped 1 q) {x v r : Cost.Data} {s t : ℕ} (hp : p.Runs x v s) (hq' : q.Runs v r t) :
    (seq p q).Runs x r (s + t + 1)
    theorem MIPRE.Tailored.Calls.seq_inv {p q : Cost.Prog} (hq : Cost.Prog.WellScoped 1 q) {x r : Cost.Data} {t : ℕ} (h : (seq p q).Runs x r t) :
    ∃ (v : Cost.Data) (s : ℕ) (t' : ℕ), s + t' + 1 = t ∧ p.Runs x v s ∧ q.Runs v r t'
    theorem MIPRE.Tailored.Calls.seq_pure_runs {α : Type u_1} {β : Type u_2} [Cost.SizedEncoding α] [Cost.SizedEncoding β] (F : Cost.PolyTimeFun α β) {q : Cost.Prog} (hq : Cost.Prog.WellScoped 1 q) (a : α) {r : Cost.Data} {t : ℕ} (h : q.Runs (Cost.encode (F.toFun a)) r t) :
    ∃ s ≤ Polynomial.eval (Cost.esize a) F.timeBound, (seq F.code q).Runs (Cost.encode a) r (s + t + 1)

    A polynomial-time stage followed by q: a run of q on the stage's value is a run of the sequence.

    theorem MIPRE.Tailored.Calls.seq_pure_inv {α : Type u_1} {β : Type u_2} [Cost.SizedEncoding α] [Cost.SizedEncoding β] (F : Cost.PolyTimeFun α β) {q : Cost.Prog} (hq : Cost.Prog.WellScoped 1 q) (a : α) {r : Cost.Data} {t : ℕ} (h : (seq F.code q).Runs (Cost.encode a) r t) :
    ∃ (t' : ℕ), q.Runs (Cost.encode (F.toFun a)) r t'

    Inversion of a polynomial-time stage followed by q.

    theorem MIPRE.Tailored.Calls.seq_det_inv {p q : Cost.Prog} (hq : Cost.Prog.WellScoped 1 q) {x v r : Cost.Data} {s t : ℕ} (hp : p.Runs x v s) (h : (seq p q).Runs x r t) :
    ∃ (t' : ℕ), q.Runs v r t'

    Inversion of a sequence whose first stage has a known run.

    Keeping a context #

    theorem MIPRE.Tailored.Calls.withCtx_runs {p : Cost.Prog} (hp : Cost.Prog.WellScoped 1 p) (a : Cost.Data) {b r : Cost.Data} {t : ℕ} (h : p.Runs b r t) :
    (withCtx p).Runs (a.cons b) (a.cons r) (a.size + b.size + t + 5)
    theorem MIPRE.Tailored.Calls.withCtx_inv {p : Cost.Prog} (hp : Cost.Prog.WellScoped 1 p) {a b r : Cost.Data} {t : ℕ} (h : (withCtx p).Runs (a.cons b) r t) :
    ∃ (r' : Cost.Data), ∃ t' ≤ t, p.Runs b r' t' ∧ r = a.cons r'

    The loop of calls #

    The body of the loop, on the state cons c (cons rem acc): stop with acc when rem is empty; otherwise run univ on cons c q for the head q of rem, push the result onto acc and continue with the tail.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      The loop of calls: on cons c (list qs), the list of the results of univ on cons c q, q ∈ qs, in order.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        The state of the loop.

        Equations
        Instances For
          theorem MIPRE.Tailored.Calls.mapBody_step {univ : Cost.Prog} (hU : Cost.Prog.WellScoped 1 univ) (c q : Cost.Data) (rest acc : List Cost.Data) {r : Cost.Data} {t : ℕ} (h : univ.Runs (c.cons q) r t) :
          Cost.Eval [mapState c (q :: rest) acc] (mapBody univ) ((Cost.Data.nil.cons Cost.Data.nil).cons (mapState c rest (r :: acc))) (t + 3 * c.size + 2 * q.size + r.size + (Cost.Data.list rest).size + (Cost.Data.list acc).size + 22)
          theorem MIPRE.Tailored.Calls.mapBody_inv {univ : Cost.Prog} (hU : Cost.Prog.WellScoped 1 univ) (c : Cost.Data) (rem acc : List Cost.Data) {out : Cost.Data} {t : ℕ} (h : Cost.Eval [mapState c rem acc] (mapBody univ) out t) :
          rem = [] ∧ out = Cost.Data.nil.cons (Cost.Data.list acc) ∨ ∃ (q : Cost.Data) (rest : List Cost.Data) (r : Cost.Data), rem = q :: rest ∧ (∃ (t' : ℕ), univ.Runs (c.cons q) r t') ∧ out = (Cost.Data.nil.cons Cost.Data.nil).cons (mapState c rest (r :: acc))

          Inversion of the body: on an empty rem it stops with acc; otherwise it ran univ on the head and continues.

          theorem MIPRE.Tailored.Calls.mapLoop_runs {univ : Cost.Prog} (hU : Cost.Prog.WellScoped 1 univ) (c : Cost.Data) (f : Cost.Data → Cost.Data) (T Z : ℕ) (env : Cost.Env) (rem acc : List Cost.Data) :
          (∀ q ∈ rem, ∃ t ≤ T, univ.Runs (c.cons q) (f q) t) → (Cost.Data.list rem).size + (Cost.Data.list (List.map f rem)).size + (Cost.Data.list acc).size ≤ Z → ∃ t ≤ (rem.length + 1) * (T + 3 * c.size + 2 * Z + 25), Cost.Eval (mapState c rem acc :: env) (mapBody univ).loop (Cost.Data.list ((List.map f rem).reverse ++ acc)) t

          The loop with the results known: from the state (c, rem, acc), the loop stops with the results on rem, reversed, before acc.

          theorem MIPRE.Tailored.Calls.mapLoop_inv {univ : Cost.Prog} (hU : Cost.Prog.WellScoped 1 univ) (c : Cost.Data) (env : Cost.Env) (rem acc : List Cost.Data) {r : Cost.Data} {t : ℕ} :
          Cost.Eval (mapState c rem acc :: env) (mapBody univ).loop r t → ∃ (rs : List Cost.Data), List.Forall₂ (fun (q r : Cost.Data) => ∃ (t' : ℕ), univ.Runs (c.cons q) r t') rem rs ∧ r = Cost.Data.list (rs.reverse ++ acc)

          Inversion of the loop: a halting loop ran every call.

          The cost of mapCall with calls of cost at most T, m queries and sizes at most Z.

          Equations
          Instances For
            theorem MIPRE.Tailored.Calls.mapCall_runs {univ : Cost.Prog} (hU : Cost.Prog.WellScoped 1 univ) (c : Cost.Data) (qs : List Cost.Data) (f : Cost.Data → Cost.Data) (T Z : ℕ) (hq : ∀ q ∈ qs, ∃ t ≤ T, univ.Runs (c.cons q) (f q) t) (hZ : (Cost.Data.list qs).size + (Cost.Data.list (List.map f qs)).size + 1 ≤ Z) :
            ∃ t ≤ mapCallCost qs.length T c.size Z, (mapCall univ).Runs (c.cons (Cost.Data.list qs)) (Cost.Data.list (List.map f qs)) t

            The loop of calls with the results known.

            theorem MIPRE.Tailored.Calls.mapCall_inv {univ : Cost.Prog} (hU : Cost.Prog.WellScoped 1 univ) (c : Cost.Data) (qs : List Cost.Data) {r : Cost.Data} {t : ℕ} (h : (mapCall univ).Runs (c.cons (Cost.Data.list qs)) r t) :
            ∃ (rs : List Cost.Data), List.Forall₂ (fun (q r : Cost.Data) => ∃ (t' : ℕ), univ.Runs (c.cons q) r t') qs rs ∧ r = Cost.Data.list rs

            Inversion of the loop of calls: a halting run ran univ on every query, and returned the results in order.

            Runs within a bound #

            p runs on x to r within cost T.

            Equations
            Instances For
              theorem MIPRE.Tailored.Calls.RunsLe.runs {p : Cost.Prog} {x r : Cost.Data} {T : ℕ} (h : RunsLe p x r T) :
              ∃ (t : ℕ), p.Runs x r t
              theorem MIPRE.Tailored.Calls.RunsLe.mono {p : Cost.Prog} {x r : Cost.Data} {T T' : ℕ} (h : RunsLe p x r T) (hT : T ≤ T') :
              RunsLe p x r T'
              theorem MIPRE.Tailored.Calls.RunsLe.seq {p q : Cost.Prog} (hq : Cost.Prog.WellScoped 1 q) {x v r : Cost.Data} {S T : ℕ} (hp : RunsLe p x v S) (hq' : RunsLe q v r T) :
              RunsLe (Calls.seq p q) x r (S + T + 1)
              theorem MIPRE.Tailored.Calls.RunsLe.withCtx {p : Cost.Prog} (hp : Cost.Prog.WellScoped 1 p) (a : Cost.Data) {b r : Cost.Data} {T : ℕ} (h : RunsLe p b r T) :
              RunsLe (Calls.withCtx p) (a.cons b) (a.cons r) (a.size + b.size + T + 5)
              theorem MIPRE.Tailored.Calls.RunsLe.size_le {p : Cost.Prog} {x r : Cost.Data} {T : ℕ} (h : RunsLe p x r T) :
              r.size ≤ T
              theorem MIPRE.Tailored.Calls.RunsLe.mapCall {univ : Cost.Prog} (hU : Cost.Prog.WellScoped 1 univ) (c : Cost.Data) (qs : List Cost.Data) (f : Cost.Data → Cost.Data) (T Z : ℕ) (hq : ∀ q ∈ qs, RunsLe univ (c.cons q) (f q) T) (hZ : (Cost.Data.list qs).size + (Cost.Data.list (List.map f qs)).size + 1 ≤ Z) :