Iterating a polynomial-time step, and running programs in sequence #
Two program combinators for routines whose running time is not polynomial in the size of their
input, such as the computation of (λn + 1)^μ from binary λ, n, μ:
whileProg fiterates a total stepf : Data → Bool × Datafrom a state, continuing on(true, s')with the states'and stopping on(false, r)with the resultr; a run ofN + 1steps costs the sum of the steps' bounds (whileProg_runs);seqProg p qrunsqon the output ofp(seqProg_runs).
Iterate the step f until it stops.
Equations
Instances For
theorem
MIPRE.Cost.whileProg_closed
(f : PolyTimeFun Data (Bool × Data))
:
Prog.WellScoped 1 (whileProg f)
theorem
MIPRE.Cost.whileProg_runs
(f : PolyTimeFun Data (Bool × Data))
(N : ℕ)
(s : ℕ → Data)
(r : Data)
(hcont : ∀ i < N, f.toFun (s i) = (true, s (i + 1)))
(hstop : f.toFun (s N) = (false, r))
:
∃ t ≤ ∑ i ∈ Finset.range (N + 1), (Polynomial.eval (s i).size f.timeBound + 1), (whileProg f).Runs (s 0) r t
A run of the loop through the states s 0, …, s N, stopping at s N with r.
theorem
MIPRE.Cost.seqProg_closed
{p q : Prog}
(hp : Prog.WellScoped 1 p)
(hq : Prog.WellScoped 1 q)
:
Prog.WellScoped 1 (seqProg p q)