Documentation

CslibFrontier.Computability.BusyBeaver.Partrec

Radó's busy beaver functions for partial recursive codes #

Radó's busy beaver function Σ(n) is the largest number of ones that a halting n-state Turing machine leaves on a blank tape, and his shift function S(n) is the largest number of steps such a machine takes Radó, On non-computable functions, Sections V and VI. Each eventually exceeds every computable function, so neither is computable.

This file formalizes the two functions for Mathlib's acceptable numbering Nat.Partrec.Code, started on the input 0 (the analogue of the blank tape). The size of a code c is its Gödel number encode c under Mathlib's Denumerable Code instance. Since encode is a bijection onto ℕ, exactly n + 1 codes have size at most n, so the maxima below range over finite sets.

Both maxima are attained, because the code Code.zero (of size 0) halts.

For a computable f, let H m = ∑_{i < m} f i. The domination proof adapts Radó's argument: H plays the role of his majorant F, and the recursion theorem replaces his double application F(F(x)) and machine chaining to absorb the program's own size. By the recursion theorem (Nat.Partrec.Code.fixed_point₂) there is a code G that, on input k, outputs H (encode (w (k + 1))), where w k is the code succ ∘ G ∘ const k. The code w k halts on 0 with output H (encode (w (k + 1))) + 1, which exceeds f n whenever n < encode (w (k + 1)), and it needs at least as much fuel as its output. Since encode (w k) grows without bound, every large n satisfies encode (w k) ≤ n < encode (w (k + 1)) for some k, so f n < bbOutput (encode (w k)) ≤ bbOutput n, and likewise for bbFuel.

Independently, fuel bbFuel n suffices for every halting code of size at most n, so a computable upper bound on bbFuel would decide the halting problem (not_exists_computable_bbFuel_le). This is the unrelativized corollary of Aaronson, Proposition 1, which solves the halting problem with oracle access to any upper bound on the shift function. The two functions bound each other up to computable changes of size: bbOutput n < bbFuel (4 * n ^ 2 + 14), and bbFuel n ≤ bbOutput (h n) for a computable h. So a computable upper bound on bbOutput would also decide the halting problem.

The model differs from Radó's: programs are partial recursive codes measured by Gödel number, not Turing machines measured by their number of states, and the output is a number rather than a count of ones. The closest analogues in the literature are Aaronson's busy beaver functions for an arbitrary programming language L whose programs are bit strings Aaronson, Section 1: BB_L(n) is the largest number of steps of a halting program of at most n bits, and a variant defined through Kolmogorov complexity is the largest m with K_L(m) ≤ n, that is, the largest output of such a program. Aaronson states Propositions 1 and 2 for Turing machines, noting in Section 2 that they hold for any universal model of computation. The results transfer to Turing machines only through a translation between the two program classes, which this file does not provide. Within the model, coarser size measures are covered: whenever n ≤ σ n, the function n ↦ bbOutput (σ n) still dominates every computable function (eventually_lt_bbOutput_comp). For example, Nat.size (encode c) ≤ ℓ exactly when encode c ≤ 2 ^ ℓ - 1, so the busy beaver function indexed by bit length is ℓ ↦ bbOutput (2 ^ ℓ - 1).

Main definitions #

Main results #

References #

noncomputable def Cslib.BusyBeaver.bbOutput (n : ℕ) :

Busy beaver, output version [Rad62]: the largest output on input 0 of a code with Gödel number at most n that halts on 0.

noncomputable def Cslib.BusyBeaver.bbFuel (n : ℕ) :

Busy beaver, fuel version [Rad62]: the largest fuel evalnFuel c 0 needed by a code c with Gödel number at most n that halts on 0. This is the analogue of Radó's shift function for the evaluator Code.evaln; the fuel is not the step count of a machine.

theorem Cslib.BusyBeaver.le_bbOutput {n : ℕ} {c : Nat.Partrec.Code} (hc : Encodable.encode c ≤ n) {x : ℕ} (hx : x ∈ c.eval 0) :

Every output of a halting code of size at most n is at most bbOutput n.

Some code of size at most n outputs bbOutput n on input 0.

The fuel needed by a halting code of size at most n is at most bbFuel n.

Some code of size at most n needs fuel exactly bbFuel n on input 0.

Radó's theorem for partial recursive codes [Rad62] [Aar20]: every computable function is eventually below bbOutput.

Radó's theorem for the fuel version [Rad62]: every computable function is eventually below bbFuel.

theorem Cslib.BusyBeaver.eventually_lt_bbOutput_comp {f : ℕ → ℕ} (hf : Computable f) {σ : ℕ → ℕ} (hσ : ∀ (n : ℕ), n ≤ σ n) :
∀ᶠ (n : ℕ) in Filter.atTop, f n < bbOutput (σ n)

Domination survives any reindexing σ of sizes with n ≤ σ n, computable or not. For σ ℓ = 2 ^ ℓ - 1 this is domination for the busy beaver function indexed by bit length.

Fuel bbFuel n suffices for every halting code of size at most n: such a code halts on 0 exactly when evaln succeeds with fuel bbFuel n.

theorem Cslib.BusyBeaver.computablePred_dom_eval_of_bbFuel_le {g : ℕ → ℕ} (hg : Computable g) (hle : ∀ (n : ℕ), bbFuel n ≤ g n) :

A computable upper bound on bbFuel decides whether a code halts on 0. This is the unrelativized corollary of Aaronson, Proposition 1, which solves the halting problem with oracle access to any upper bound.

No computable function bounds bbFuel from above, since it would decide the halting problem (ComputablePred.halting_problem). This is a second proof that bbFuel is not computable.

The fuel version outgrows the output version, up to the size overhead 4 * n ^ 2 + 14 of composing a code with succ.

bbFuel is bounded by bbOutput after a computable change of size: the fuel of a code is the output of another code, of computably bounded size.

theorem Cslib.BusyBeaver.computablePred_dom_eval_of_bbOutput_le {g : ℕ → ℕ} (hg : Computable g) (hle : ∀ (n : ℕ), bbOutput n ≤ g n) :

A computable upper bound on bbOutput decides whether a code halts on 0, through exists_computable_bbFuel_le_bbOutput and computablePred_dom_eval_of_bbFuel_le.

No computable function bounds bbOutput from above, since it would decide the halting problem. This is a second proof that bbOutput is not computable.