Blum complexity measures #
Blum's axioms describe a complexity measure without fixing a machine model
Blum, A machine-independent theory of the complexity of recursive functions. Fix an
acceptable numbering φ of the partial recursive functions; here it is Mathlib's
Nat.Partrec.Code with Code.eval. A complexity measure is a family Φ of partial functions,
one for each program, such that
Φ c nis defined exactly whenφ_c nis defined, and- the predicate
Φ c n = mis decidable, as a predicate of(c, n, m).
Running time and space of Turing machines are the motivating examples.
Cslib.BlumComplexity.fuelMeasure, in CslibFrontier.Computability.BlumComplexity.Fuel, is an
instance for Mathlib's evaluator Code.evaln.
The complexity class Φ.complexityClass t of a total bound t is the class of total functions
f that some program c computes with Φ c n ≤ t n for almost all n, that is, for all
sufficiently large n. This is the class C_t of Borodin
Borodin, Computational complexity and the existence of complexity gaps. The
bound applies almost everywhere, not at every input. For each such f, finitely many inputs may
exceed the bound.
Main definitions #
Cslib.BlumComplexity.BlumMeasure: a complexity measure satisfying Blum's axioms overNat.Partrec.Code.Cslib.BlumComplexity.BlumMeasure.complexityClass: the classC_tof total functions computable with cost at mosttalmost everywhere.
Main results #
Cslib.BlumComplexity.BlumMeasure.partrec_cost: every complexity measure is partial recursive.Cslib.BlumComplexity.BlumMeasure.computablePred_cost_le: the predicateΦ c n ≤ bis decidable. In particular, whetherφ_c nhalts within costbis decidable.Cslib.BlumComplexity.BlumMeasure.computable_of_mem_complexityClass: complexity classes contain only computable functions.Cslib.BlumComplexity.BlumMeasure.exists_computable_mem_complexityClass: every computable function lies inC_tfor some computablet.
References #
A Blum complexity measure [Blu67] over the acceptable numbering Nat.Partrec.Code: a
cost cost c n for each program c and input n, defined exactly when c halts on n, such
that the predicate m ∈ cost c n (that is, Φ c n = m) is computable.
The cost
Φ c nof running the programcon the inputn.Blum's first axiom: the cost is defined exactly when the program halts.
- computablePred_mem_cost : ComputablePred fun (x : (Nat.Partrec.Code × ℕ) × ℕ) => match x with | ((c, n), m) => m ∈ self.cost c n
Blum's second axiom: the predicate
Φ c n = mis computable.
Blum's second axiom, with computable functions substituted for the program, the input and the cost.
A program that computes a total function has its cost defined on every input.
For a program that computes a total function, a property holds of every value of its cost at
n exactly when it holds of some value: the cost is defined and single-valued.
Every complexity measure is partial recursive: the least m with Φ c n = m is found by
unbounded search.
The predicate Φ c n ≤ b is computable. In particular, whether c halts on n within cost
b is decidable.
The complexity class C_t of a bound t: total functions f computed by some program c
(f n ∈ c.eval n for every n) whose cost satisfies Φ c n ≤ t n for all sufficiently large n
[Bor72].
Complexity classes are monotone in the bound, compared almost everywhere.
Complexity classes contain only computable functions.
Every computable function lies in the complexity class of some computable bound: the cost of any program computing it.