The fuel of evaln as a Blum complexity measure #
Mathlib's Nat.Partrec.Code.evaln k c n evaluates the code c on n with fuel k. It fails when
the evaluation recurses too deeply or meets a number ≥ k. The fuel is monotone
(Code.evaln_mono) and sufficient fuel always exists for halting computations
(Code.evaln_complete). The fuel of c on n, evalnFuel c n, is the least k for which
evaln k c n succeeds. It satisfies Blum's axioms [Blu67]: it is defined exactly when c halts
on n, and evalnFuel c n = k is decidable because evaln is primitive recursive
(Code.primrec_evaln). This gives the complexity measure fuelMeasure.
The fuel bounds both the recursion depth of the evaluation and the size of every number it
inspects. In particular n < evalnFuel c n whenever it is defined (lt_of_mem_evalnFuel), so
complexity classes of bounds t ≤ id are empty for this measure. The fuel is not the step count
of a machine model; it is the natural cost measure of Mathlib's evaluator.
Main definitions #
Cslib.BlumComplexity.evalnFuel: the least fuel with whichevalnsucceeds.Cslib.BlumComplexity.fuelMeasure: the Blum complexity measure given byevalnFuel.
Main results #
Cslib.BlumComplexity.mem_evalnFuel_iff:evalnFuel c n = kexactly whenevaln k c nsucceeds andevaln j c nfails for everyj < k.Cslib.BlumComplexity.dom_evalnFuel_iff: Blum's first axiom.Cslib.BlumComplexity.computablePred_mem_evalnFuel: Blum's second axiom.Cslib.BlumComplexity.lt_of_mem_evalnFuel: the fuel exceeds the input.
References #
The least fuel k with which Code.evaln k c n succeeds. It is defined exactly when c halts
on n.
evalnFuel c n = k exactly when evaln k c n succeeds and evaln j c n fails for every
j < k.
Blum's first axiom for the fuel: it is defined exactly when the code halts.
The fuel measure: the Blum complexity measure whose cost is the least fuel with which
Code.evaln succeeds.
The cost of the fuel measure is evalnFuel.
The fuel exceeds the input, since evaln k c n fails unless n < k.