How large would a unique totient preimage have to be?

7 of 10 main results in Lean (70%); 3 of 10 Lean + certificate (external 1,965,316,556-prime and 8,243-root forest runs with Lean-proved soundness and transfer theorems; the totient-value bound also uses the paper's written Section 3 reciprocal-sum estimate, a hypothesis of the Lean transfer theorem); 0 written-only; 1 open conjecture · AI-generated and directed by Tyler B. Hughes · No human mathematician has yet refereed the proof.

Carmichael guessed that every value of Euler's totient function is shared by at least two numbers. Lean proves that a number that shares its value with no other number would have more than 10,117 digits.

Every whole number x ≥ 1 such that no other whole number y has φ(y) = φ(x) is larger than 10¹⁰¹¹⁷.

Euler's totient φ(x) counts the numbers from 1 to x that share no prime factor with x, and its values are often shared: φ(36) = φ(42) = 12. Carmichael conjectured in 1922 that no value is taken by exactly one number, and Ford proved in 1998 that a number taking its value alone would have more than 10,003,700,000 digits. Lean checks a smaller bound from scratch, more than 10,117 digits, together with the rules that turn the companion paper's outside computer certificates into its larger bounds.

Why a counterexample is a multiple of 4, 9 and 49

Call x ≥ 1 a counterexample if no other number y has φ(y) = φ(x). Since φ(36) = φ(42) = 12, neither 36 nor 42 is one.

If x is odd, then φ(2x) = φ(x), for example φ(9) = φ(18) = 6. If x is twice an odd number, then φ(x/2) = φ(x), for example φ(7) = φ(14) = 6. Either way x has a partner, so a counterexample is a multiple of 4.

Now suppose 4 divides x. If 3 does not divide x, then φ(3x/2) = φ(x), for example φ(6) = φ(4) = 2. If 3 divides x only once, write x = 3z; then φ(2z) = φ(x), for example φ(8) = φ(12) = 4. So a counterexample is a multiple of 9.

Next, 7 − 1 = 6 = 2·3, and 2 and 3 both divide x more than once. If 7 does not divide x, swap a factor 6 for 7: from 36 this gives 42. If 7 divides x only once, swap that 7 for a 6. Either swap keeps φ the same, so 49 divides x too.

Lean checks these steps. The same swaps force 43², since 1 + 2·3·7 = 43. Splitting into two cases by the power of 3, Lean then builds 81 primes in one case and 80 in the other whose squares must divide x, which gives more than 10,117 digits in both.

Counterexamples and the switching rule

A counterexample is a number x ≥ 1 that no other number y matches with φ(y) = φ(x). Lean proves that a counterexample is a multiple of 4, and proves Ford's switching rule: if d divides x with no common factor with x/d, every prime factor of φ(d) divides x, e divides x/d divided by the product of its different prime factors, and P = 1 + e·φ(d) is prime, then P² divides x. Otherwise a swap would give a second number with the same totient.

  • Ford's switching rule

    Let x be a counterexample and d a divisor of x with no common factor with x/d. If rad(φ(d)) divides x, e divides (x/d)/rad(x/d), and P = 1 + e·φ(d) is prime, then P² divides x.

    theorem CarmichaelChallenge.ford_lemma_7_2 {x : ℕ} {d : ℕ} {e : ℕ} (hx : IsCarmichaelCounterexample x) (hd : d ∣ x) (hcop : d.Coprime (x / d)) (hrad : rad d.totient ∣ x) (he : e ∣ x / d / rad (x / d)) (hP : Nat.Prime (1 + e * d.totient)) :
      (1 + e * d.totient) ^ 2 ∣ x
  • Every counterexample is a multiple of 4

    If x is a counterexample, 4 divides x.

    theorem CarmichaelTotient.four_dvd_counterexample {x : ℕ} (hx : IsCarmichaelCounterexample x) :
      4 ∣ x
  • Under the switching rule's conditions, P divides x

    Let x be a counterexample and d a divisor of x with no common factor with x/d. If e divides (x/d)/rad(x/d) and P = 1 + e·φ(d) is prime, then P divides x.

  • If P divides x and so do the primes of P − 1, then P² divides x

    Let x be a counterexample and P a prime dividing x. If every prime factor of P − 1 divides x, then P² divides x.

Forced prime squares in two cases

Applying the switching rule with d = 1 forces 3², 7² and 43² to divide every counterexample, and the chain stops because 1 + 2·3·7·43 = 1807 = 13·139 is not prime. Lean then splits on the power of 3: either 9 divides x but 27 does not (Case I, which forces 13²), or 27 divides x (Case II, which forces 19²). In each case, if the squares of some primes K at least 5 divide x, then the square of 6·∏K + 1 divides x whenever it is prime, and so does the square of 12·∏K + 1 in Case I or 18·∏K + 1 in Case II.

  • Every counterexample is in Case I or Case II

    If x is a counterexample, then either 9 divides x, 27 does not and 13² does (Case I), or 27 divides x (Case II).

  • Every counterexample is a multiple of 9

    If x is a counterexample, 9 divides x.

  • Every counterexample is a multiple of 49

    If x is a counterexample, 49 divides x.

  • Every counterexample is a multiple of 43²

    If x is a counterexample, 43² divides x.

  • The chain with d = 1 stops at 43

    1807 = 13·139 is not prime, and for each of the 16 divisors e of 2·3·7·43 = 1806, 1 + e is prime exactly when e is 1, 2, 6 or 42.

  • The rule 6k + 1

    Let x be a counterexample and K a set of primes at least 5 whose squares divide x. If 6·∏K + 1 is prime, its square divides x.

  • The rule 12k + 1 in Case I

    Let x be a counterexample not divisible by 27, and K a set of primes at least 5 whose squares divide x. If 12·∏K + 1 is prime, its square divides x.

  • The rule 18k + 1 in Case II

    Let x be a counterexample divisible by 27, and K a set of primes at least 5 whose squares divide x. If 18·∏K + 1 is prime, its square divides x.

  • The square of a forced prime of Case I divides every Case I counterexample

    If x is a counterexample not divisible by 27 and p is a forced prime of Case I, then p is a prime at least 5 and p² divides x.

  • The square of a forced prime of Case II divides every Case II counterexample

    If x is a counterexample divisible by 27 and p is a forced prime of Case II, then p is a prime at least 5 and p² divides x.

  • 36 times the forced squares divides a counterexample

    If x is a counterexample and S is a set of primes at least 5 whose squares divide x, then 36·∏ p² over S divides x.

  • In Case II, 108 times the forced squares divides a counterexample

    If x is a counterexample divisible by 27 and S is a set of primes at least 5 whose squares divide x, then 108·∏ p² over S divides x.

From forced squares to a digit count

A certificate lists groups of forced primes for each case, a lower bound on the number of binary digits of each group's squared product, and a fraction u/v with 10ᵘ < 2ᵛ. Lean proves that any such pair of certificates gives 10ᵈ ≤ x for every counterexample, and 10ᵈ < x when d ≥ 1, where d is the smaller of the two digit counts. As a worked case, Lean rebuilds Carmichael's 1922 chains of 7 primes in each case, checks their primality, and gets 10³⁷ < x.

  • A two-case certificate bounds every counterexample, strictly

    If the certificate's digit count D is at least 1, then 10ᴰ < x for every counterexample x.

  • A two-case certificate bounds every counterexample

    For every counterexample x, 10ᴰ ≤ x, where D is the certificate's digit count.

  • A Case I certificate bounds every Case I counterexample

    If x is a counterexample not divisible by 27, then 10ᴰ ≤ x, where D is the certificate's digit count.

  • A Case II certificate bounds every Case II counterexample

    If x is a counterexample divisible by 27, then 10ᴰ ≤ x, where D is the certificate's digit count.

  • Counting binary digits gives decimal digits, strictly

    The same, with "less than x" when the digit count is at least 1.

  • Counting binary digits gives decimal digits

    If x ≥ 1, B·∏ G(c)² divides x, 2ᵇ ≤ B, each group c has a bit count β(c) with 2 to the power β(c) at most G(c)², v > 0 and 10ᵘ < 2ᵛ, then 10 to the power ⌊u·(b + ∑ β(c))/v⌋ is at most x.

  • The Lucas test for primality

    If p ≥ 2 and for each prime q dividing p − 1 there is an a for which aᵖ⁻¹ leaves remainder 1 on division by p and aᵉ, with e = (p − 1)/q, does not, then p is prime.

  • Every counterexample is larger than 10³⁷

    For every counterexample x, 10³⁷ < x, obtained through the certificate rule.

Two ladders of 81 and 80 primes

A ladder builds forced primes in layers: each step multiplies 6, or 12 in Case I and 18 in Case II, by a product of primes chosen from the latest 16, adds 1, and proves the result prime with a Lucas test. Lean runs the Case I ladder of 81 primes and the Case II ladder of 80 primes, checks every step, and turns them into certificates of 10,240 and 10,117 digits. So every counterexample is larger than 10¹⁰²⁴⁰ in Case I and larger than 10¹⁰¹¹⁷ in Case II, and so larger than 10¹⁰¹¹⁷ in both.

  • Every counterexample is larger than 10¹⁰¹¹⁷

    If x ≥ 1 and no other whole number has the same totient as x, then x > 10¹⁰¹¹⁷, so x has more than 10,117 digits.

    theorem CarmichaelChallenge.carmichael_counterexample_gt_10_pow_10117 {x : ℕ} (hx : IsCarmichaelCounterexample x) :
      10 ^ 10117 < x
  • In Case I every counterexample is larger than 10¹⁰²⁴⁰

    If x is a counterexample and 27 does not divide x, then x > 10¹⁰²⁴⁰.

    theorem CarmichaelChallenge.carmichael_case1_gt_10_pow_10240 {x : ℕ} (hx : IsCarmichaelCounterexample x) (h27 : ¬27 ∣ x) :
      10 ^ 10240 < x
  • In Case II every counterexample is larger than 10¹⁰¹¹⁷

    If x is a counterexample and 27 divides x, then x > 10¹⁰¹¹⁷.

    theorem CarmichaelChallenge.carmichael_case2_gt_10_pow_10117 {x : ℕ} (hx : IsCarmichaelCounterexample x) (h27 : 27 ∣ x) :
      10 ^ 10117 < x
  • The Case I ladder check passes with 10,240 digits

    Lean computes the full check for the Case I ladder, with 5 base bits and 10³¹ < 2¹⁰³, and gets true, so ⌊31·(5 + 34,019)/103⌋ = 10,240.

  • The Case II ladder check passes with 10,117 digits

    Lean computes the full check for the Case II ladder, with 6 base bits and 10³¹ < 2¹⁰³, and gets true, so ⌊31·(6 + 33,610)/103⌋ = 10,117.

  • A passed Case I ladder check gives a Case I certificate

    If 2ᵇ ≤ 36 and the full check passes with multipliers 6 and 12, some Case I certificate has at least the target digit count.

  • A passed Case II ladder check gives a Case II certificate

    If 2ᵇ ≤ 108 and the full check passes with multipliers 6 and 18, some Case II certificate has at least the target digit count.

  • A passed Case I ladder gives forced primes without repeats

    If the ladder with multipliers 6 and 12 returns a list, then the list has no repeats and holds only forced primes of Case I.

  • A passed Case II ladder gives forced primes without repeats

    If the ladder with multipliers 6 and 18 returns a list, then the list has no repeats and holds only forced primes of Case II.

  • A passed ladder step gives a prime

    If the multiplier is 6, 12 or 18, the chosen entries are prime, and the factor check of the Lucas test passes for p = multiplier·∏ + 1, then p is prime.

Values taken only once are rare

V(X) counts the numbers from 1 to X that are values of φ, and V₁(X) counts those that are φ(x) for a counterexample x. Lean proves Ford's Lemmas 7.4 and 7.5: for a ≥ 2, the values all of whose preimages are multiples of a² number at most V(X/a). If every counterexample is a multiple of a₁² or of a₂², this gives V₁(X) ≤ 2·V(X/min(a₁, a₂)), and with the count of primes it makes V₁(X)/V(X) small for arbitrarily large X. With the primes of the two ladders, the lower limit of V₁(X)/V(X) is below 1/10⁵⁰⁵⁷.

  • The lower limit of V₁(X)/V(X) is below 1/10⁵⁰⁵⁷

    As X grows, the lower limit of V₁(X)/V(X) is less than 1/10⁵⁰⁵⁷.

    theorem CarmichaelChallenge.carmichael_liminf_density_lt_10_pow_neg_5057 :
      Filter.liminf (fun X => ↑(V1 X) / ↑(V X)) Filter.atTop < 1 / 10 ^ 5057
  • Two forced squares bound the lower limit of V₁(X)/V(X)

    Let a₁, a₂ ≥ 2. If every counterexample is a multiple of a₁² or of a₂², then the lower limit of V₁(X)/V(X) as X grows is at most 2/min(a₁, a₂).

    theorem CarmichaelChallenge.liminf_V1_div_V_le_two_div_min {a₁ : ℕ} {a₂ : ℕ} (ha₁ : 2 ≤ a₁) (ha₂ : 2 ≤ a₂) (hcov : ∀ (x : ℕ), IsCarmichaelCounterexample x → a₁ ^ 2 ∣ x ∨ a₂ ^ 2 ∣ x) :
      Filter.liminf (fun X => ↑(V1 X) / ↑(V X)) Filter.atTop ≤ 2 / ↑(min a₁ a₂)
  • Values whose preimages are all multiples of a² number at most V(X/a) (Ford's Lemmas 7.4 and 7.5)

    For every a ≥ 2 and every X, V(X; a²) ≤ V(⌊X/a⌋).

    theorem CarmichaelChallenge.ford_lemma_7_4_7_5 {X : ℕ} {a : ℕ} (ha : 2 ≤ a) :
      VDiv X a ≤ V (X / a)
  • Forced squares with small reciprocal sum bound φ(x)

    Let x ≥ 1, b be 36 or 108, and S a set of primes at least 5 with b·∏ p² over S dividing x. If 6·10ᴰ ≤ b·∏ p² and the sum of 1/p over S is below 1/2, then 10ᴰ < φ(x).

    theorem CarmichaelChallenge.totient_value_gt_of_forced_primes {D : ℕ} {b : ℕ} {x : ℕ} {S : Finset ℕ} (hx : 0 < x) (hb : b = 36 ∨ b = 108) (hS : ∀ p ∈ S, Nat.Prime p ∧ 5 ≤ p) (hdvd : b * ∏ p ∈ S, p ^ 2 ∣ x) (hbig : 6 * 10 ^ D ≤ b * ∏ p ∈ S, p ^ 2) (hrec : ∑ p ∈ S, 1 / ↑p < 1 / 2) :
      10 ^ D < x.totient
  • Values whose preimages are all multiples of a² number at most V(X/a) (Ford's Lemmas 7.4 and 7.5), in the library

    The same statement as in the statement file.

  • Forced squares with small reciprocal sum bound φ(x), in the library

    The same statement as in the statement file.

  • Forced primes with small reciprocal sums bound φ(x) and the lower limit

    Let S₁ be forced primes of Case I and S₂ forced primes of Case II, with 6·10²ᵏ < 36·∏ p² over S₁, 12·10²ᵏ < 108·∏ p² over S₂, and the sums of 1/p over S₁ and over S₂ each below 1/2. Then every counterexample x has 10²ᵏ < φ(x), and the lower limit of V₁(X)/V(X) is below 1/10ᵏ.

  • Large forced squares give a small lower limit

    If 2k + 1 ≤ m, 2k + 3 ≤ n, 10ᵐ < a₁², 10ⁿ < 3a₂², and every counterexample is a multiple of a₁² or of a₂², then the lower limit of V₁(X)/V(X) is below 1/10ᵏ.

  • V₁(X)/V(X) is small for arbitrarily large X

    If a₁, a₂ ≥ 2, every counterexample is a multiple of a₁² or of a₂², and c > 2/min(a₁, a₂), then V₁(X)/V(X) < c for arbitrarily large X.

  • V₁(X) ≤ 2·V(X/min(a₁, a₂))

    If a₁, a₂ ≥ 2 and every counterexample is a multiple of a₁² or of a₂², then V₁(X) ≤ 2·V(⌊X/min(a₁, a₂)⌋) for every X.

Klee, Pomerance and Erdős

Lean proves Klee's 1947 results for the smallest counterexample: 4 divides it, 8 does not, and none of the primes 5, 17, 257 and 65537 divides it. It proves Pomerance's 1974 condition: a number x ≥ 1 is a counterexample whenever p² divides x for every prime p with p − 1 dividing φ(x). It also proves Erdős's 1958 step that builds a larger counterexample from one and a suitable prime, and his conclusion of infinitely many counterexamples with the supply of such primes taken as a hypothesis.

  • The smallest counterexample is a multiple of 4 but not of 8, and not of 5, 17, 257 or 65537

    If x₀ is the smallest counterexample, then 4 divides x₀, while none of 8, 5, 17, 257 and 65537 divides x₀.

    theorem CarmichaelChallenge.minimal_counterexample_structure {x₀ : ℕ} (hx₀ : IsMinimalCounterexample x₀) :
      4 ∣ x₀ ∧ ¬8 ∣ x₀ ∧ ¬5 ∣ x₀ ∧ ¬17 ∣ x₀ ∧ ¬257 ∣ x₀ ∧ ¬65537 ∣ x₀
  • Pomerance's condition gives a counterexample

    If x ≥ 1 and p² divides x for every prime p with p − 1 dividing φ(x), then x is a counterexample.

    theorem CarmichaelChallenge.pomerance_sufficient_condition {x : ℕ} (hx : 0 < x) (hpom : ∀ (p : ℕ), Nat.Prime p → p - 1 ∣ x.totient → p ^ 2 ∣ x) :
      IsCarmichaelCounterexample x
  • φ(y) = 10 exactly for y = 11 and y = 22

    For every whole number y, φ(y) = 10 holds exactly when y is 11 or 22.

    theorem CarmichaelChallenge.totient_eq_ten_iff (y : ℕ) :
      y.totient = 10 ↔ y = 11 ∨ y = 22
  • Pomerance's condition, in the library

    The same statement as in the statement file.

  • 8 does not divide a reduced counterexample

    If x is a reduced counterexample, 8 does not divide x.

  • No prime 2ᵐ + 1 with m ≥ 2 divides a reduced counterexample

    If x is a reduced counterexample, m ≥ 2 and 2ᵐ + 1 is prime, then 2ᵐ + 1 does not divide x.

  • Erdős's fiber rule

    Let m, k ≥ 1, q a prime above k·m + 1 with P = 1 + k·q prime, and 1 + j·q not prime for every divisor j ≠ k of k·m. Then φ(y) = k·q·m exactly when y = P·z for some z with φ(z) = m.

  • Erdős's step to a larger counterexample

    Let x be a counterexample, k ≥ 1, q a prime above k·φ(x) + 1 with P = 1 + k·q prime, and 1 + j·q not prime for every divisor j ≠ k of k·φ(x). Then P·x is a counterexample, it is larger than x, and P² does not divide it.

Values whose preimages are all multiples of 10

Ford asked about values m of φ all of whose preimages are multiples of a fixed k. Lean proves his reduction: if no value has all its preimages divisible by 6, Carmichael's conjecture holds. For k = 10 it proves that every preimage is a multiple of 100 and that m ≥ 32,000, and it shows that m = 110 works for k = 11. It also proves that any rung certificate for 10ᴷ, of the kind the paper's outside forest provides, gives 10ᴷ ≤ m.

  • A value whose preimages are all multiples of 10 is at least 32,000

    If m is a value of φ and every y ≥ 1 with φ(y) = m is a multiple of 10, then m ≥ 32,000.

    theorem CarmichaelChallenge.k10_witness_ge_32000 {m : ℕ} (hm : IsDivisibleTotientWitness 10 m) :
      32000 ≤ m
  • If no value has all its preimages divisible by 6, there is no counterexample

    Suppose no m is a value of φ all of whose preimages y ≥ 1 are multiples of 6. Then no whole number is a counterexample.

    theorem CarmichaelChallenge.no_k6_witness_implies_carmichael (h6 : ¬∃ m, IsDivisibleTotientWitness 6 m) (x : ℕ) :
      ¬IsCarmichaelCounterexample x
  • Every preimage of 110 is a multiple of 11

    110 = φ(121), and every y ≥ 1 with φ(y) = 110 is a multiple of 11.

    theorem CarmichaelChallenge.k11_witness_110 :
      IsDivisibleTotientWitness 11 110
  • Every preimage of 110 is a multiple of 11, in the library

    The same statement as in the statement file.

  • Every preimage is a multiple of 100, and 40 divides m

    If every preimage of m is a multiple of 10 and φ(x) = m with x ≥ 1, then 4, 25 and 100 divide x, and 40 divides m.

  • The switching rule for keeping 5

    Let every preimage of m be a multiple of 10, φ(x) = m with x ≥ 1, d a divisor of x with 5 | d and no common factor with x/d, e a divisor of (x/d)/rad(x/d), and 2 ∤ d or t = 0. If S is a set of primes other than 5 with ∏ (P − 1)·2ᵗ = e·φ(d), some P in S divides x.

  • The switching rule for keeping 2

    The same with the roles of 2 and 5 swapped: 2 | d, 5 ∤ d or t = 0, S a set of primes other than 2, and ∏ (P − 1)·5ᵗ = e·φ(d).

  • A rung certificate for 10ᴷ gives 10ᴷ ≤ m

    If there is a rung certificate for 10ᴷ, every value whose preimages are all multiples of 10 is at least 10ᴷ.

  • A closed descent tree bounds m

    If every preimage of m is a multiple of 10, φ(x) = m with x ≥ 1, and x meets the starting conditions of a closed descent tree for 10ᴷ, then 10ᴷ ≤ m.

  • The switching rule with several primes

    Let x be a counterexample, d a divisor of x with no common factor with x/d, and e a divisor of (x/d)/rad(x/d). If S is a nonempty set of primes with ∏ (P − 1) over S equal to e·φ(d), some P in S divides x.

  • A closed case tree bounds every counterexample that meets its conditions

    If x is a counterexample meeting the starting conditions of a closed case tree with bound B, then B ≤ x.