For a prime one has , so divides . The converse equality is also classical: if and only if is prime, a characterisation already available in Mathlib as Nat.totient_eq_iff_prime. Lehmer's totient problem, posed in 1932, asks whether the same conclusion holds when equality is relaxed to divisibility. In other words, if divides , must be prime?
The question is a test of how much of the prime-detecting character of survives under a weaker arithmetic condition. It is also close to the theory of Carmichael numbers: if a composite satisfied , then the Carmichael function would divide as well, and would be a Fermat pseudoprime to every base coprime to . Lehmer already recorded this implication in the 1932 note. The problem remains open: no composite solution is known, and no proof that none exists is known.
Timeline. Lehmer proved that a composite solution , if one exists, must be odd and square-free, and must have at least seven distinct prime factors. Cohen and Hagis improved the factor-count to in 1980. A 2004 computational report of Renze raises the bound to ; that determination is widely cited, but it is a computational archive note rather than a journal article, and the milestone formalized here is the peer-reviewed Cohen–Hagis bound. In the special case , much larger lower bounds are known; Burcsi, Czirbusz, and Farkas showed that any such solution would satisfy and . Luca and Pomerance proved that the number of composite solutions up to , if any, is . Burek and Żmija later gave an upper bound on a hypothetical solution in terms of . None of these results has produced a composite example or a full contradiction, and the problem is still generally regarded as open.
As in the companion mission on Carmichael's conjecture, denotes Euler's totient, implemented in Mathlib by Nat.totient n: the number of natural numbers coprime to . For an integer , write for the predecessor of in . The hypothesis of the problem is that divides in , written Nat.totient n ∣ n - 1.
The restriction is part of the statement, not an informal convention. For , Mathlib evaluates as by truncated subtraction, and holds, while is not prime. For , one has and , while is not prime. A formalization that omits is therefore false in Lean, even though those two inputs are excluded from the usual informal phrasing “there is no composite with ” (since and are not composite). The goal below is exactly that informal statement, rendered for with .
If is prime, the divisibility holds because . The open direction is the converse: divisibility implies primality.
If is a prime power and divides , then is prime. This is a known elementary special case, included as a first milestone. It already goes beyond the equality , but it excludes the square-free products of several primes that any hypothetical counterexample would have to be.
If is composite and divides , then is odd and square-free, and . This is a known theorem of Lehmer, Theorems 1 and the analysis. In Lean, is the cardinality of Nat.primeFactors n.
If is composite and divides , then
This is a known theorem of Cohen and Hagis. It strictly improves Lehmer's lower bound of seven prime factors and is the last of the three milestones that is already proved in the literature.
If and divides , then is prime:
This is the open goal.
A proof would give a divisibility criterion for primality in terms of , strictly stronger than the known characterisation by the equality . It would also imply that no Carmichael number satisfies the more rigid condition , which is stronger than the defining condition . A composite example would be a Carmichael number of a very special kind, necessarily odd, square-free, and (by the results above) a product of at least fourteen distinct primes; no such example is known.
On the formal side, Mathlib already contains Nat.totient_eq_iff_prime, which is the equality case, together with the usual formulae for at prime powers and on coprime factors. It does not contain Lehmer's constraints, the Cohen–Hagis bound, or the conjecture. Formalizing the two known structural theorems would give reusable lemmas about integers satisfying , independently of whether the goal is later proved or refuted. As of 2026 the goal itself is open, and no machine-checked proof is claimed.
The equality forces to have no room for a proper prime-power factorisation, and the argument is short. Divisibility only requires that the integer be a positive integer, possibly larger than . For a product of distinct odd primes this ratio can in principle be an integer when many primes are present. Checking small composite is not a proof: the known constraints already push any counterexample beyond a range that is easy to exhaust, and in the branch the published lower bounds are enormous. The remaining difficulty is to turn those constraints — odd, square-free, many prime factors, and the implicit Carmichael condition — into a contradiction, or to exhibit an example that meets all of them at once. No such contradiction or example is known.
The formalization uses Lean 4 and Mathlib. The totient is Nat.totient, primality is Nat.Prime, and divisibility is Nat-divisibility ∣. The predecessor is Mathlib's truncated subtraction on Nat; it is used only under the hypothesis , so it agrees with the integer predecessor. The goal is not the unguarded statement Nat.totient n ∣ n - 1 → Nat.Prime n for all , which fails at and as explained above.
A composite solution is expressed as 1 < n, ¬ Nat.Prime n, and Nat.totient n ∣ n - 1. Square-freeness is Mathlib's Squarefree, and the number of distinct prime factors is (Nat.primeFactors n).card. The prime-power milestone uses Mathlib's IsPrimePow; no local definition of these notions is needed or wanted.
The mission does not treat the companion equation , which Lehmer also studied and which has known composite solutions. A formalization of that companion equation is a different theorem.
Welcome contributions include formal proofs of the prime-power case and of Lehmer's odd square-free constraints, a formalization of the Cohen–Hagis bound (or of Renze's later computational strengthening), special cases such as the branch , and a proof or counterexample to the goal.
namespace LehmerTotient
theorem lehmer_totient {n : Nat} (hn : 1 < n)
(h : Nat.totient n ∣ n - 1) : Nat.Prime n := by sorry
end LehmerTotient
Let be a natural number such that divides . Then is prime. Equivalently, there is no composite natural number for which divides . This is Lehmer's totient problem, which remains open. The hypothesis is essential in Lean: the unguarded implication fails at (where truncated subtraction gives ) and at (where divides ).