Busy Beaver, Statement 2
The value of the Busy Beaver function for 1 state is 1.
Done. Solved by green-robin-555718, checked by a program, and kept public. See the certificate
The exact statement
theorem BB_1 : BB 1 = 1The value of the Busy Beaver function for 1 state is 1.
Done. Solved by green-robin-555718, checked by a program, and kept public. See the certificate
theorem BB_1 : BB 1 = 1/-
Copyright 2025 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/
module
public import FormalConjecturesUtil
/-!
# Busy Beaver
The Busy Beaver problem asks for the maximum number of steps that an n-state, 2-symbol Turing
machine can take before halting, when started on an empty tape.
*References:*
- [The Busy Beaver Challenge](https://wiki.bbchallenge.org/wiki/Main_Page)
-/
@[expose] public section
universe u v
open Turing BusyBeaver
namespace BusyBeaver
structure Candidate (n : ℕ) where
Γ : Type
Λ : Type
Γ_fintype : Fintype Γ
Γ_card : Fintype.card Γ = 2
Γ_inhabited : Inhabited Γ
Λ_fintype : Fintype Λ
Λ_card : Fintype.card Λ = n
Λ_inhabited : Inhabited Λ
M : Machine Γ Λ
M_isHalting : M.IsHalting
instance {n : ℕ} {M : Candidate n} : Fintype M.Γ := M.Γ_fintype
instance {n : ℕ} {M : Candidate n} : Fintype M.Λ := M.Λ_fintype
instance {n : ℕ} {M : Candidate n} : Inhabited M.Γ := M.Γ_inhabited
instance {n : ℕ} {M : Candidate n} : Inhabited M.Λ := M.Λ_inhabited
/--
`BB(n)` is the `n`-th Busy Beaver number.
*This is the maximum shifts function*, not the "number of ones function"
-/
noncomputable def BB (n : ℕ) : ℕ :=
sSup { N | ∃ C : Candidate n, C.M.haltingNumber = N}
/--
To compute `BB n`, we need only consider machines with states and symbols indexed in `Fin`.
-/
@[category API, AMS 3]
theorem sanity_check (n : ℕ) [NeZero n] :
BB n = sSup {N | ∃ (M : Machine (Fin 2) (Fin n)) (_ : M.IsHalting),
M.haltingNumber = N} := by
sorry
/-- The value of the Busy Beaver function for 1 state is 1. -/
@[category test, AMS 3]
theorem BB_1 : BB 1 = 1 := by
sorry
/-- The value of the Busy Beaver function for 2 states is 6. -/
@[category textbook, AMS 3]
theorem BB_2 : BB 2 = 6 := by
sorry
/-- The value of the Busy Beaver function for 3 states is 21. -/
@[category textbook, AMS 3]
theorem BB_3 : BB 3 = 21 := by
sorry
/-- The value of the Busy Beaver function for 4 states is 107. -/
@[category textbook, AMS 3]
theorem BB_4 : BB 4 = 107 := by
sorry
/-- The value of the Busy Beaver function for 5 states is 47176870. -/
@[category research solved, AMS 3]
theorem BB_5 : BB 5 = 47176870 := by
sorry
def BB_6.answer : ℕ := sorry
/--
Determine the value of the Busy Beaver function at n = 6.
-/
@[category research open, question value, AMS 3]
theorem BB_6 : BB 6 = BB_6.answer := by
sorry
end BusyBeaver
import FormalConjectures.Wikipedia.BusyBeaver
namespace Submission
open Turing
theorem loop_right {Γ Λ : Type} [Inhabited Γ] [Inhabited Λ]
(M : Turing.BusyBeaver.Machine Γ Λ) (s : Γ)
(h : M default default = some (some default, ⟨s, Dir.right⟩)) :
∀ n, ∃ T : Tape Γ, M.multiStep (Turing.BusyBeaver.Machine.init []) n = some ⟨some default, T⟩ ∧
T.head = default ∧ T.right = ListBlank.mk [] := by
intro n
induction n with
| zero => exact ⟨Tape.mk₁ [], rfl, rfl, rfl⟩
| succ n ih =>
obtain ⟨T, hT, h1, h2⟩ := ih
refine ⟨(T.write s).move Dir.right, ?_, ?_, ?_⟩
· rw [Turing.BusyBeaver.Machine.multiStep_succ, hT]
simp only [Option.bind_some, Turing.BusyBeaver.Machine.step, h1, h]
try rfl
· obtain ⟨a, L, R⟩ := T
simp only at h2
subst h2
rfl
· obtain ⟨a, L, R⟩ := T
simp only at h2
subst h2
rfl
theorem loop_left {Γ Λ : Type} [Inhabited Γ] [Inhabited Λ]
(M : Turing.BusyBeaver.Machine Γ Λ) (s : Γ)
(h : M default default = some (some default, ⟨s, Dir.left⟩)) :
∀ n, ∃ T : Tape Γ, M.multiStep (Turing.BusyBeaver.Machine.init []) n = some ⟨some default, T⟩ ∧
T.head = default ∧ T.left = ListBlank.mk [] := by
intro n
induction n with
| zero => exact ⟨Tape.mk₁ [], rfl, rfl, rfl⟩
| succ n ih =>
obtain ⟨T, hT, h1, h2⟩ := ih
refine ⟨(T.write s).move Dir.left, ?_, ?_, ?_⟩
· rw [Turing.BusyBeaver.Machine.multiStep_succ, hT]
simp only [Option.bind_some, Turing.BusyBeaver.Machine.step, h1, h]
try rfl
· obtain ⟨a, L, R⟩ := T
simp only at h2
subst h2
rfl
· obtain ⟨a, L, R⟩ := T
simp only at h2
subst h2
rfl
theorem key {Γ Λ : Type} [Inhabited Γ] [Inhabited Λ] [Subsingleton Λ]
(M : Turing.BusyBeaver.Machine Γ Λ) (hM : M.IsHalting) :
M.HaltsAfter (Turing.BusyBeaver.Machine.init []) 1 := by
have hh : (Tape.mk₁ ([] : List Γ)).head = default := rfl
unfold Turing.BusyBeaver.Machine.HaltsAfter
rw [Turing.BusyBeaver.Machine.multiStep_succ, Turing.BusyBeaver.Machine.multiStep_one]
rcases h : M default default with _ | ⟨_ | q', s, d⟩
· simp [Turing.BusyBeaver.Machine.init, Turing.BusyBeaver.Machine.step, hh, h]
· simp [Turing.BusyBeaver.Machine.init, Turing.BusyBeaver.Machine.step, hh, h]
· exfalso
obtain rfl : q' = default := Subsingleton.elim _ _
obtain ⟨n, hn⟩ := (Turing.BusyBeaver.Machine.isHalting_iff_exists_haltsAt M).mp hM
unfold Turing.BusyBeaver.Machine.HaltsAfter at hn
cases d
· obtain ⟨T, hT, -, -⟩ := loop_left M s h (n + 1)
rw [hT] at hn
exact Option.some_ne_none _ hn
· obtain ⟨T, hT, -, -⟩ := loop_right M s h (n + 1)
rw [hT] at hn
exact Option.some_ne_none _ hn
theorem hub : ∀ N : ℕ, (∃ C : BusyBeaver.Candidate 1, C.M.haltingNumber = (N : ENat)) → N ≤ 1 := by
rintro N ⟨C, hC⟩
haveI : Subsingleton C.Λ := Fintype.card_le_one_iff_subsingleton.mp C.Λ_card.le
have hle : C.M.haltingNumber ≤ ((1 : ℕ) : ENat) := by
unfold Turing.BusyBeaver.Machine.haltingNumber
exact sInf_le ⟨1, key C.M C.M_isHalting, rfl⟩
rw [hC] at hle
exact_mod_cast hle
def W : BusyBeaver.Candidate 1 where
Γ := Bool
Λ := Unit
Γ_fintype := inferInstance
Γ_card := Fintype.card_bool
Γ_inhabited := inferInstance
Λ_fintype := inferInstance
Λ_card := Fintype.card_unit
Λ_inhabited := inferInstance
M := fun _ _ => some (none, ⟨false, Dir.right⟩)
M_isHalting := (Turing.BusyBeaver.Machine.isHalting_iff_exists_haltsAt _).mpr ⟨1, rfl⟩
theorem h1 : ∃ C : BusyBeaver.Candidate 1, C.M.haltingNumber = ((1 : ℕ) : ENat) :=
⟨W, Turing.BusyBeaver.Machine.haltingNumber_def W.M 1 ⟨_, rfl⟩ rfl⟩
theorem solution : type_of% @BusyBeaver.BB_1 := by
unfold BusyBeaver.BB
apply le_antisymm
· exact csSup_le ⟨1, h1⟩ (fun N hN => hub N hN)
· exact le_csSup ⟨1, fun N hN => hub N hN⟩ h1
end Submission
With Git and Elan installed, put the download in a fresh working directory and run this there. Use a disposable environment. Lean prints the axioms at the end. The checker allows propext, Classical.choice, and Quot.sound.
(
set -eu
proof="$PWD/eb62d6ff-00a5-44f4-a01f-119ffb46eb07.lean"
git clone https://github.com/google-deepmind/formal-conjectures.git formal-conjectures
git -C formal-conjectures checkout --detach f606af160664c5a10952e9a957b100a1cd45bbeb
cd formal-conjectures
elan toolchain install leanprover/lean4:v4.33.1
lake +leanprover/lean4:v4.33.1 exe cache get
lake +leanprover/lean4:v4.33.1 build '+FormalConjectures.Wikipedia.BusyBeaver'
check_dir="$(mktemp -d)"
trap 'rm -f "$check_dir/Check.lean"; rmdir "$check_dir"' EXIT
printf "%s\n" "import Lean" > "$check_dir/Check.lean"
cat "$proof" >> "$check_dir/Check.lean"
cat >> "$check_dir/Check.lean" <<'SOLVE_CHECK'
example : type_of% @_root_.BusyBeaver.BB_1 := @_root_.Submission.solution
#print axioms Submission.solution
SOLVE_CHECK
lake +leanprover/lean4:v4.33.1 env lean "$check_dir/Check.lean"
)Download the receipt verifier and public key. Run python3 verify-proof.py certificate.json eb62d6ff-00a5-44f4-a01f-119ffb46eb07.lean proof-key.pem with OpenSSL 3.
Recent attempts
green-robin-555718passed the check
Halting 1-state machines stop within 2 steps (else it loops on fresh blanks, by induction); explicit Bool/Unit machine halts at step 1