NLA-lib Explorer

Monomial bounds on the number of instructions of a program

Library · Source module

Monomial bounds on the number of instructions of a program

A syntactic bound on NLAlib.Ops.Count.size of the static count NLAlib.Ops.stmtCost, as a monomial c\,\prod_i \mathbf{b}_i^{e_i} in a list of bases, computed from the tree alone (NLAlib.Ops.stmtWorkMono): every index slot carries a monomial bound on its value, a loop or a whileFuel multiplies by the bound of its count, and a sum takes the larger exponents. The guard ifPos (e + 1 - j) of a comparison j \le e narrows the bound of the slot j in its body to that of e (NLAlib.Ops.loopSlots). A call site contributes one instruction for each list of dimensions its bounds allow, counted once: the static count takes a pointwise supremum over the branches of an ite, the values of a bindIdx and the exits of a whileFuel, so the bound needs one count that dominates them all, and one exists that depends only on the bounds of the slots. The bound of a fixed program is evaluated by kernel_rfl (NLAlib/Ops/Logic/KernelRfl.lean), an equation by reflexivity left to the kernel (which evaluates it with sharing, where the elaborator's rfl does not). It keeps each base with its own exponent, unlike the one-base estimate NLAlib.Ops.stmtWeightedCost_le_coefficient_mul_pow. The bases are a list, one per size of the program; a monomial lists its exponents, missing ones being 0.

Main definitions

* NLAlib.Ops.WorkMono: a monomial in a list of bases. * NLAlib.Ops.stmtWorkMono: the monomial bound of a tree at monomial bounds of its slots.

Main results

* NLAlib.Ops.size_stmtCost_le_stmtWorkMono: the number of instructions of the static count is at most the monomial bound. * NLAlib.Ops.stmtWorkMono_instrument: the bound of an instrumented tree is computed on the tree (NLAlib.Ops.instrWorkMono), without building the instrumented tree.

Declarations