/- Copyright 2026 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

Minimal primes in radix bases

Fix an integer base $b \ge 2$. A prime $p$ is minimal in base $b$ if no proper subsequence (not necessarily contiguous) of its canonical base-$b$ expansion represents a prime—equivalently, no prime $q \neq p$ has its canonical base-$b$ digit list as a sublist of Nat.digits b p. By Higman's lemma, the set of minimal primes in base $b$ is finite for every $b \ge 2$. Jeffrey Shallit (2000) classified all $26$ base-$10$ minimal primes (OEIS A071062, up to $66600049$). Curtis Bright, Raymond Devillers, and Shallit (2016) extended minimal-prime classifications to larger bases; in base $17$, they already reduced the classification to $1279$ minimal probable primes (not all certified prime) together with the single unresolved candidate family $\mathrm{F}1{9}$ (base-$17$ digits $15, 1, 9, \dots, 9$).

References:

    Wikipedia

    OEIS A071062

    J. Shallit, Minimal primes, J. Recreational Math. 30 (1999–2000), 113–117.

    C. Bright, R. Devillers, and J. Shallit, Minimal elements for the prime numbers, Exp. Math. 25 (2016), 321–331.

@[expose] public sectionnamespace MinimalPrime

Prime $p$ is minimal in base $b \ge 2$ when no prime $q \neq p$ has Nat.digits b q as a sublist of Nat.digits b p.

def IsMinimalPrimeInBase (b p : ℕ) : Prop := 2 ≤ b ∧ p.Prime ∧ ¬∃ q : ℕ, q.Prime ∧ q ≠ p ∧ (Nat.digits b q).Sublist (Nat.digits b p)

Base $10$ includes $2$ as minimal and excludes $13$ (via proper sublist $3$), while bases $b \in {0, 1}$ are excluded.

q:ℕhq:Nat.Prime qhne:q ≠ 2hd:Nat.digits 10 2 = [2]h2:Nat.digits 10 q = [2]this:q = Nat.ofDigits 10 [2]⊢ False All goals completed! 🐙 ⊢ ¬IsMinimalPrimeInBase 10 13 left✝¹:2 ≤ 10left✝:Nat.Prime 13hno:¬∃ q, Nat.Prime q ∧ q ≠ 13 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 13)⊢ False exact hno ⟨3, left✝¹:2 ≤ 10left✝:Nat.Prime 13hno:¬∃ q, Nat.Prime q ∧ q ≠ 13 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 13)⊢ Nat.Prime 3 All goals completed! 🐙, left✝¹:2 ≤ 10left✝:Nat.Prime 13hno:¬∃ q, Nat.Prime q ∧ q ≠ 13 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 13)⊢ 3 ≠ 13 All goals completed! 🐙, left✝¹:2 ≤ 10left✝:Nat.Prime 13hno:¬∃ q, Nat.Prime q ∧ q ≠ 13 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 13)⊢ (Nat.digits 10 3).Sublist (Nat.digits 10 13) All goals completed! 🐙⟩

Single-digit primes $p \in {3, 5, 7}$ satisfy IsMinimalPrimeInBase 10 p, whereas $1$ satisfies ¬ IsMinimalPrimeInBase b 1 for every $b$.

hmin:∀ (p : ℕ), Nat.Prime p → p < 10 → IsMinimalPrimeInBase 10 p⊢ IsMinimalPrimeInBase 10 3 ∧ IsMinimalPrimeInBase 10 5 ∧ IsMinimalPrimeInBase 10 7 ∧ ∀ (b : ℕ), ¬IsMinimalPrimeInBase b 1 exact ⟨hmin 3 (hmin:∀ (p : ℕ), Nat.Prime p → p < 10 → IsMinimalPrimeInBase 10 p⊢ Nat.Prime 3 All goals completed! 🐙) (hmin:∀ (p : ℕ), Nat.Prime p → p < 10 → IsMinimalPrimeInBase 10 p⊢ 3 < 10 All goals completed! 🐙), hmin 5 (hmin:∀ (p : ℕ), Nat.Prime p → p < 10 → IsMinimalPrimeInBase 10 p⊢ Nat.Prime 5 All goals completed! 🐙) (hmin:∀ (p : ℕ), Nat.Prime p → p < 10 → IsMinimalPrimeInBase 10 p⊢ 5 < 10 All goals completed! 🐙), hmin 7 (hmin:∀ (p : ℕ), Nat.Prime p → p < 10 → IsMinimalPrimeInBase 10 p⊢ Nat.Prime 7 All goals completed! 🐙) (hmin:∀ (p : ℕ), Nat.Prime p → p < 10 → IsMinimalPrimeInBase 10 p⊢ 7 < 10 All goals completed! 🐙), fun _ h => Nat.not_prime_one h.2.1⟩

In binary ($b = 2$), $2 = (10)_2$ is minimal, whereas in base $10$ neither $23$ nor $37$ is minimal.

q:ℕhq:Nat.Prime qhne:Nat.ofDigits 2 [0, 1] ≠ 2hsub:(Nat.digits 2 q).Sublist [0, 1]hd:Nat.digits 2 2 = [0, 1]l:List ℕhval:q = Nat.ofDigits 2 [0, 1]hdig:Nat.digits 2 q = 0 :: lhsub1:l.Sublist [1]h1:l = [1]⊢ False; q:ℕhq:Nat.Prime qhsub:(Nat.digits 2 q).Sublist [0, 1]hd:Nat.digits 2 2 = [0, 1]l:List ℕhval:q = Nat.ofDigits 2 [0, 1]hdig:Nat.digits 2 q = 0 :: lhsub1:l.Sublist [1]h1:l = [1]⊢ Nat.ofDigits 2 [0, 1] ≠ 2 → False; All goals completed! 🐙 ⊢ ¬IsMinimalPrimeInBase 10 23 left✝¹:2 ≤ 10left✝:Nat.Prime 23hno:¬∃ q, Nat.Prime q ∧ q ≠ 23 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 23)⊢ False exact hno ⟨3, left✝¹:2 ≤ 10left✝:Nat.Prime 23hno:¬∃ q, Nat.Prime q ∧ q ≠ 23 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 23)⊢ Nat.Prime 3 All goals completed! 🐙, left✝¹:2 ≤ 10left✝:Nat.Prime 23hno:¬∃ q, Nat.Prime q ∧ q ≠ 23 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 23)⊢ 3 ≠ 23 All goals completed! 🐙, left✝¹:2 ≤ 10left✝:Nat.Prime 23hno:¬∃ q, Nat.Prime q ∧ q ≠ 23 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 23)⊢ (Nat.digits 10 3).Sublist (Nat.digits 10 23) All goals completed! 🐙⟩ ⊢ ¬IsMinimalPrimeInBase 10 37 left✝¹:2 ≤ 10left✝:Nat.Prime 37hno:¬∃ q, Nat.Prime q ∧ q ≠ 37 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 37)⊢ False exact hno ⟨7, left✝¹:2 ≤ 10left✝:Nat.Prime 37hno:¬∃ q, Nat.Prime q ∧ q ≠ 37 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 37)⊢ Nat.Prime 7 All goals completed! 🐙, left✝¹:2 ≤ 10left✝:Nat.Prime 37hno:¬∃ q, Nat.Prime q ∧ q ≠ 37 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 37)⊢ 7 ≠ 37 All goals completed! 🐙, left✝¹:2 ≤ 10left✝:Nat.Prime 37hno:¬∃ q, Nat.Prime q ∧ q ≠ 37 ∧ (Nat.digits 10 q).Sublist (Nat.digits 10 37)⊢ (Nat.digits 10 7).Sublist (Nat.digits 10 37) All goals completed! 🐙⟩

Finiteness of minimal primes (empty for $b < 2$, and finite by Higman's lemma for $b \ge 2$): for every $b \in \mathbb{N}$, the set of primes satisfying IsMinimalPrimeInBase b p is finite.

@[category textbook, AMS 11 68] theorem minimal_primes_finite_in_every_base (b : ℕ) : {p : ℕ | IsMinimalPrimeInBase b p}.Finite := b:ℕ⊢ {p | IsMinimalPrimeInBase b p}.Finite All goals completed! 🐙

Base-$10$ classification (Shallit 2000): exactly $26$ primes satisfy IsMinimalPrimeInBase 10 p.

@[category research solved, AMS 11 68] theorem base_ten_minimal_primes_card : {p : ℕ | IsMinimalPrimeInBase 10 p}.ncard = 26 := ⊢ {p | IsMinimalPrimeInBase 10 p}.ncard = 26 All goals completed! 🐙

Explicit base-$10$ minimal prime set (Shallit 2000, OEIS A071062): the primes satisfying IsMinimalPrimeInBase 10 p are precisely the $26$ integers listed below.

@[category research solved, AMS 11 68] theorem base_ten_minimal_primes_eq : {p : ℕ | IsMinimalPrimeInBase 10 p} = {2, 3, 5, 7, 11, 19, 41, 61, 89, 409, 449, 499, 881, 991, 6469, 6949, 9001, 9049, 9649, 9949, 60649, 666649, 946669, 60000049, 66000049, 66600049} := ⊢ {p | IsMinimalPrimeInBase 10 p} = {2, 3, 5, 7, 11, 19, 41, 61, 89, 409, 449, 499, 881, 991, 6469, 6949, 9001, 9049, 9649, 9949, 60649, 666649, 946669, 60000049, 66000049, 66600049} All goals completed! 🐙

Unresolved base-$17$ candidate family $\mathrm{F}1{9}$: does there exist $k \in \mathbb{N}$ such that the integer with base-$17$ digits $15, 1, \underbrace{9, \dots, 9}{k}$ (namely $15 \cdot 17^{k + 1} + 17^k + \sum{i < k} 9 \cdot 17^i$) satisfies IsMinimalPrimeInBase 17?

@[category research open, question, AMS 11 68] theorem base_seventeen_f19_family_minimal_prime_question : ∃ k : ℕ, IsMinimalPrimeInBase 17 (15 * 17 ^ (k + 1) + 17 ^ k + ∑ i ∈ Finset.range k, 9 * 17 ^ i) := ⊢ ∃ k, IsMinimalPrimeInBase 17 (15 * 17 ^ (k + 1) + 17 ^ k + ∑ i ∈ Finset.range k, 9 * 17 ^ i) All goals completed! 🐙end MinimalPrime