Imports
/-
Copyright (c) 2026 Google LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
-/
module
public import Cryptids.ErdosTernary15
public import Cryptids.Propositions
Semantics of the Erdős Ternary Turing Machine (erdos_ternary_15)
This file proves that the 15-state Turing machine erdosTernary15 (erdos_ternary_15) halts on the
blank tape if and only if Erdős's ternary conjecture is false (i.e., there exists n > 8 such that
the base-3 expansion of 2 ^ n has no digit 2).
Cryptids.ErdosTernary15 proves Halts erdosTernary15 ↔ ∃ n, 8 < n ∧ 2 ∉ pw n without
Classical.choice, where pw n is the digit list of 2 ^ n computed by repeated doubling. This
file identifies pw n with Mathlib's Nat.digits 3 (2 ^ n), whose definition and lemmas use
Classical.choice. The negated form ¬ ErdosTernaryConjecture also uses Markov's Principle
(not_forall), as for ¬ GoldbachConjecture.
Provenance and Attribution
Tristan Stérin and Damien Woods, Hardness of busy beaver value BB(15) (https://arxiv.org/abs/2107.12475, 2021; machine file in https://github.com/tcosmo/bbsim): the machine and its pen-and-paper correctness proof.
Paul Erdős, Some unconventional problems in number theory, Math. Mag. 52 (1979): the conjecture.
@[expose] public sectionnamespace ConjectureMachines.ErdosTernary15
Doubling with carry c ≤ 1 on base-3 digit lists agrees with Nat.digits.
theorem dbl_digits (x c : ℕ) (hc : c ≤ 1) :
dbl (Nat.digits 3 x) c = Nat.digits 3 (2 * x + c) := x:ℕc:ℕhc:c ≤ 1⊢ dbl (Nat.digits 3 x) c = Nat.digits 3 (2 * x + c)
induction x using Nat.strong_induction_on generalizing c with
x:ℕih:∀ m < x, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)c:ℕhc:c ≤ 1⊢ dbl (Nat.digits 3 x) c = Nat.digits 3 (2 * x + c)
c:ℕhc:c ≤ 1ih:∀ m < 0, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)⊢ dbl (Nat.digits 3 0) c = Nat.digits 3 (2 * 0 + c)x:ℕih:∀ m < x, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)c:ℕhc:c ≤ 1hx:x > 0⊢ dbl (Nat.digits 3 x) c = Nat.digits 3 (2 * x + c)
c:ℕhc:c ≤ 1ih:∀ m < 0, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)⊢ dbl (Nat.digits 3 0) c = Nat.digits 3 (2 * 0 + c) ih:∀ m < 0, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)hc:0 ≤ 1⊢ dbl (Nat.digits 3 0) 0 = Nat.digits 3 (2 * 0 + 0)ih:∀ m < 0, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)hc:1 ≤ 1⊢ dbl (Nat.digits 3 0) 1 = Nat.digits 3 (2 * 0 + 1)
ih:∀ m < 0, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)hc:0 ≤ 1⊢ dbl (Nat.digits 3 0) 0 = Nat.digits 3 (2 * 0 + 0) All goals completed! 🐙
ih:∀ m < 0, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)hc:1 ≤ 1⊢ dbl (Nat.digits 3 0) 1 = Nat.digits 3 (2 * 0 + 1) All goals completed! 🐙
x:ℕih:∀ m < x, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)c:ℕhc:c ≤ 1hx:x > 0⊢ dbl (Nat.digits 3 x) c = Nat.digits 3 (2 * x + c) h.inr x:ℕih:∀ m < x, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)c:ℕhc:c ≤ 1hx:x > 0⊢ (2 * (x % 3) + c) % 3 :: Nat.digits 3 (2 * (x / 3) + (2 * (x % 3) + c) / 3) =
(2 * x + c) % 3 :: Nat.digits 3 ((2 * x + c) / 3)
have e₁ : (2 * (x % 3) + c) % 3 = (2 * x + c) % 3 := by x:ℕc:ℕhc:c ≤ 1⊢ dbl (Nat.digits 3 x) c = Nat.digits 3 (2 * x + c) omega h.inr x:ℕih:∀ m < x, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)c:ℕhc:c ≤ 1hx:x > 0e₁:(2 * (x % 3) + c) % 3 = (2 * x + c) % 3⊢ (2 * (x % 3) + c) % 3 :: Nat.digits 3 (2 * (x / 3) + (2 * (x % 3) + c) / 3) =
(2 * x + c) % 3 :: Nat.digits 3 ((2 * x + c) / 3)
have e₂ : 2 * (x / 3) + (2 * (x % 3) + c) / 3 = (2 * x + c) / 3 := by x:ℕc:ℕhc:c ≤ 1⊢ dbl (Nat.digits 3 x) c = Nat.digits 3 (2 * x + c) omega h.inr x:ℕih:∀ m < x, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)c:ℕhc:c ≤ 1hx:x > 0e₁:(2 * (x % 3) + c) % 3 = (2 * x + c) % 3e₂:2 * (x / 3) + (2 * (x % 3) + c) / 3 = (2 * x + c) / 3⊢ (2 * (x % 3) + c) % 3 :: Nat.digits 3 (2 * (x / 3) + (2 * (x % 3) + c) / 3) =
(2 * x + c) % 3 :: Nat.digits 3 ((2 * x + c) / 3)
rw [e₁, h.inr x:ℕih:∀ m < x, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)c:ℕhc:c ≤ 1hx:x > 0e₁:(2 * (x % 3) + c) % 3 = (2 * x + c) % 3e₂:2 * (x / 3) + (2 * (x % 3) + c) / 3 = (2 * x + c) / 3⊢ (2 * x + c) % 3 :: Nat.digits 3 (2 * (x / 3) + (2 * (x % 3) + c) / 3) =
(2 * x + c) % 3 :: Nat.digits 3 ((2 * x + c) / 3) e₂ h.inr x:ℕih:∀ m < x, ∀ c ≤ 1, dbl (Nat.digits 3 m) c = Nat.digits 3 (2 * m + c)c:ℕhc:c ≤ 1hx:x > 0e₁:(2 * (x % 3) + c) % 3 = (2 * x + c) % 3e₂:2 * (x / 3) + (2 * (x % 3) + c) / 3 = (2 * x + c) / 3⊢ (2 * x + c) % 3 :: Nat.digits 3 ((2 * x + c) / 3) = (2 * x + c) % 3 :: Nat.digits 3 ((2 * x + c) / 3)] All goals completed! 🐙
pw n is the list of base-3 digits of 2 ^ n, least significant first.
theorem pw_eq (n : ℕ) : pw n = Nat.digits 3 (2 ^ n) := by n:ℕ⊢ pw n = Nat.digits 3 (2 ^ n)
induction n with
| zero => zero ⊢ pw 0 = Nat.digits 3 (2 ^ 0) simp [pw] All goals completed! 🐙
| succ n ih => succ n:ℕih:pw n = Nat.digits 3 (2 ^ n)⊢ pw (n + 1) = Nat.digits 3 (2 ^ (n + 1)) rw [pw, succ n:ℕih:pw n = Nat.digits 3 (2 ^ n)⊢ dbl (pw n) 0 = Nat.digits 3 (2 ^ (n + 1)) ih, succ n:ℕih:pw n = Nat.digits 3 (2 ^ n)⊢ dbl (Nat.digits 3 (2 ^ n)) 0 = Nat.digits 3 (2 ^ (n + 1)) dbl_digits _ _ (by n:ℕih:pw n = Nat.digits 3 (2 ^ n)⊢ 0 ≤ 1 omega All goals completed! 🐙), pow_succ, succ n:ℕih:pw n = Nat.digits 3 (2 ^ n)⊢ Nat.digits 3 (2 * 2 ^ n + 0) = Nat.digits 3 (2 ^ n * 2) Nat.mul_comm, succ n:ℕih:pw n = Nat.digits 3 (2 ^ n)⊢ Nat.digits 3 (2 ^ n * 2 + 0) = Nat.digits 3 (2 ^ n * 2) Nat.add_zero succ n:ℕih:pw n = Nat.digits 3 (2 ^ n)⊢ Nat.digits 3 (2 ^ n * 2) = Nat.digits 3 (2 ^ n * 2)] All goals completed! 🐙
The 15-state machine erdosTernary15 (erdos_ternary_15) halts on the blank tape if and only
if some power 2 ^ n with n > 8 has no digit 2 in base 3.
theorem halts_erdosTernary15_iff_exists_counterexample :
ConjectureMachines.Halts erdosTernary15 ↔ ∃ n : ℕ, 8 < n ∧ 2 ∉ Nat.digits 3 (2 ^ n) := by ⊢ ConjectureMachines.Halts erdosTernary15 ↔ ∃ n, 8 < n ∧ 2 ∉ Nat.digits 3 (2 ^ n)
simp only [← pw_eq] ⊢ ConjectureMachines.Halts erdosTernary15 ↔ ∃ n, 8 < n ∧ 2 ∉ pw n
exact halts_erdosTernary15_iff_exists_free All goals completed! 🐙
The 15-state machine erdosTernary15 (erdos_ternary_15) halts on the blank tape if and only
if Erdős's ternary conjecture is false.
theorem halts_erdosTernary15_iff_not_erdosTernary :
ConjectureMachines.Halts erdosTernary15 ↔ ¬ ErdosTernaryConjecture := by ⊢ ConjectureMachines.Halts erdosTernary15 ↔ ¬ErdosTernaryConjecture
rw [halts_erdosTernary15_iff_exists_counterexample ⊢ (∃ n, 8 < n ∧ 2 ∉ Nat.digits 3 (2 ^ n)) ↔ ¬ErdosTernaryConjecture] ⊢ (∃ n, 8 < n ∧ 2 ∉ Nat.digits 3 (2 ^ n)) ↔ ¬ErdosTernaryConjecture
simp only [ErdosTernaryConjecture, not_forall, exists_prop] All goals completed! 🐙end ConjectureMachines.ErdosTernary15