Compositional polynomial resource bounds #
growth_poly proves Turing.MultiTapeTM.PolyBounded size cost by the existing constant,
input-size, addition, multiplication and fixed-power rules, together with logarithm, square
root, maximum, truncated subtraction and division bounds. It also accepts
Cslib.PolynomiallyBounded goals through the existing fun_prop rules.
The leaves come from the local context:
PolyBoundedhypotheses, also inside conjunctions and inside definitions that unfold to them, such as a native certificate'sIsPolynomial;- certificates whose output length is polynomially bounded, such as
ComputableInPolyTime f encIn encOut; withencOut = encUnarythe valuef aitself is bounded, and withencOut = encBitsthe length of the wordf a; Cslib.PolynomiallyBounded phypotheses, orfun_propfacts, applied asp (u a);- a
PolyBounded size' vhypothesis at another size applied asv (g a), which leaves the substitutionPolyBounded size (fun a => size' (g a)).
A certificate supplies a leaf only through a lemma, and this module does not import those lemmas,
so that it stays below the machine layers. For each kind of certificate the proof uses, import
the module that proves its lemma (names relative to CslibFrontier.Computability.Machines.Turing,
the last one to CslibFrontier.Computability):
ComputableInPolyTime, output length:MultiTape.Internal.PolyTimePrimitives, whichMultiTape.Complexity.PolyTime.Basicimports;ComputableInPolyTimewithencUnaryoutput, the value:MultiTape.Internal.PolyTimeLoops, whichMultiTape.Complexity.PolyTime.Foldimports;ComputableInPolySpace:MultiTape.Complexity.PolySpace.Plain;ComputableInLogSpace:MultiTape.Complexity.LogSpace;DegreeBounded:MultiTape.ResourceBounds.Degree;Cslib.GenericRAM.NativeCertificate:GenericRAM.Native.Certificate.
When a certificate in the context gives no leaf because its lemma is not imported, the failure message names the module to import.
Local let values, and definitions whose bodies are arithmetic, are unfolded. The tactic proves
polynomial growth only. Word admission, exact time bounds and signed overflow conditions remain
separate obligations, and it does not guess an intermediate size measure: a substitution needs
the outer bound as a fact. Each step follows the syntax of the bound without backtracking, so a
goal outside these rules fails at once and names the term it could not bound.
Main declarations #
Turing.MultiTapeTM.PolyBounded.log,sqrt,max,sub,div: further closure rules.Turing.MultiTapeTM.PolyBounded.of_polynomiallyBounded_comp: substitution into a polynomially bounded function of one natural number.growth_poly,growth_poly [h₁, h₂]: prove polynomial growth from these rules and the local context, with extra factsh₁andh₂.Cslib.Tactic.GrowthPoly.certificateLemmas: the certificate lemmas the tactic uses, with the modules that prove them.
The closure layer adapts Samuel Schlesinger's existing polynomial-bound API. The input-size
logarithm and square-root rules and the first growth_poly tactic are by Erik Demaine.
Natural logarithms preserve polynomial growth in any input-size measure.
Natural square roots preserve polynomial growth in any input-size measure.
The maximum of two polynomially bounded functions is polynomially bounded.
Truncated subtraction preserves a polynomial bound on its first argument.
Natural division preserves a polynomial bound on its dividend.
Substitute a polynomially bounded argument into a polynomially bounded function of one natural number.
growth_poly proves Turing.MultiTapeTM.PolyBounded size cost by the closure rules for
constants, the input size, +, *, fixed powers, Nat.log, Nat.sqrt, max, truncated -
and /. The leaves come from local PolyBounded facts, also inside conjunctions and definitions
that unfold to them; from local certificates, through their output-length bound; and from local
Cslib.PolynomiallyBounded functions or PolyBounded facts at another size, applied to a
bounded argument. growth_poly [h₁, h₂] adds the facts h₁ and h₂.
A certificate gives a leaf only when the module proving its bound is imported; the module
docstring lists them, for example MultiTape.Internal.PolyTimePrimitives for the output length
of ComputableInPolyTime. When a certificate in the context gives no leaf for this reason, the
failure names the module to import.
Local let values and arithmetic definitions are unfolded. The search follows the syntax of the
bound without backtracking: a goal outside these rules fails at once and names the term it could
not bound. Cslib.PolynomiallyBounded goals go to fun_prop.
Instances For
A lemma from a certificate to a PolyBounded fact or to another certificate.
- name : Lean.Name
The lemma, applied to the local hypotheses whose head it matches when it is in scope.
- head : Lean.Name
The head constant of the certificate it takes, its last explicit hypothesis.
The output encoding, the certificate's last argument, that the lemma requires, if any.
- module : Lean.Name
The module proving the lemma, named when the lemma is not in scope.
Instances For
The certificate lemmas, applied when they are in scope. This module does not import them,
which would make it depend on the machine layers. A lemma that requires an output encoding comes
before the general lemma with the same head, and its module imports that lemma's module.
The drift check in the PolynomialGrowth test checks that each lemma is proved in its module.