The closure library, part I: calls, projections, pairing, branching #
Program-layer combinators on Prog with their Eval lemmas, and the corresponding
PolyTimeFun combinators (const, pair, fst, snd, ite). Two conventions keep
composition free of de Bruijn bookkeeping:
- a closed program
qis called on the value of variableibylet_ (var i) q(Prog.callVar): the callee sees its input at variable0and, being well-scoped, ignores the rest of the environment (Eval.append_of_wellScoped); - branches re-bind the original input by copying it (
PolyTimeFun.ite), rather than shifting indices.
Costs are exact at the program layer and packaged as polynomials at the function layer
(planning/compression-track.md, K2).
Program layer #
Call the closed program q on the value of variable i.
Equations
- MIPRE.Cost.Prog.callVar i q = (MIPRE.Cost.Prog.var i).let_ q
Instances For
First component of the input (variable 0).
Equations
Instances For
Second component of the input (variable 0).
Equations
Instances For
Function layer #
The constant function, in constant time.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pairing.
Equations
Instances For
First projection.
Equations
- MIPRE.Cost.PolyTimeFun.fst = { toFun := Prod.fst, code := MIPRE.Cost.Prog.fstProg, closed := MIPRE.Cost.Prog.fstProg_wellScoped, timeBound := Polynomial.X + Polynomial.C 2, computes := ⋯ }
Instances For
Second projection.
Equations
- MIPRE.Cost.PolyTimeFun.snd = { toFun := Prod.snd, code := MIPRE.Cost.Prog.sndProg, closed := MIPRE.Cost.Prog.sndProg_wellScoped, timeBound := Polynomial.X + Polynomial.C 2, computes := ⋯ }
Instances For
Branching on a boolean: ite c F G a = if c a then F a else G a. The condition is bound
as variable 0; the nil (false) branch calls G on the original input (variable 1),
the cons (true) branch calls F on it (variable 3, after elim bound the two nil
components of encode true).
Equations
- One or more equations did not get rendered due to their size.