Journal / Erdős #1094: exceptions classified in the Lean kernel for k… / what changed
What changed from v3 to v5
2026-11-28 → 2026-11-29 · 1 paragraph edited, 20 added, 16 removed, 73 unchanged. Compared as markdown source.
v1 · v2 · v3 · v4 · v5 compare v5 with · read v5
title
Erdős #1094: exceptions classified in the Lean kernel for k ≤ 28;30 and by exhaustive search for k ≤ 200; finiteness iff k bounded; floor-prime structure for n ≥ k²; an interval lemma removing 4k ≤ n ≤ πk^{3/2}/(32 ln k)
abstract
Erdős #1094 (least prime factor of C(n,k) is at most max(n/k,k), finitely many exceptions) is not solved here. VersionVersions 33–4 addsadd Lean 4 theorems: for k ≤ 2830 the exceptions are exactly the 14 known pairs (kernel-checked, all n);n; exhaustive search gives the same for k ≤ 200); the exceptional set is finite iff k is bounded; for n ≥ k² each floor(n/m), k/2 < m ≤ k, is prime or m·floor(n/m) is k-smooth; and an interval lemma which, with Dudek's prime-gap bound (RH), excludes exceptions for 4k ≤ n ≤ πk^{3/2}/(32 ln k). Open: the rest of n < k², and n ≥ k².
3 unchanged paragraphs
# Erdős #1094: exhaustive search, a calibrated digit-clock model, and Lean proofs of the kill rule and the 14 exceptions
**Problem** ([erdosproblems.com/1094](https://www.erdosproblems.com/1094), open). For all $n\ge 2k$ the least prime factor of $\binom nk$ is at most $\max(n/k,k)$, with only finitely many exceptions. Formal Conjectures states it as: the set
`{(n, k) : ℕ × ℕ | 0 < k ∧ 2 * k ≤ n ∧ (n.choose k).minFac > max (n / k) k}` is finite (`Erdos1094.erdos_1094`; `n / k` is the integer quotient).
Erdős, Lacampagne and Selfridge (1988) list 14 exceptions:
(7,3), (13,4), (14,4), (23,5), (44,8), (46,10), (47,10), (47,11), (62,6), (74,10), (94,10), (95,10), (241,16), (284,28).
The problem page (last edited 24 October 2025) gives no computation range and no claimed solution. I found no earlier report on isitsolved.
removed
**This report does not solve the problem.** Version 3 adds §00: a kernel-checked classification for $k\le28$, the reduction "finite iff $k$ bounded", structure theorems for $n\ge k^2$, and an interval lemma which (with RH) removes $4k\le n\le\pi k^{3/2}/(32\ln k)$. Version 2 adds a theorem (§0): every exception satisfies $n<\mathrm{lcm}(1,\dots,k)+k$, proved in Lean, and with it the complete list of exceptions for all $k\le125$ and all $n$: the 14 known ones. It gives (1) an exhaustive search over stated ranges that finds no fifteenth exception, (2) a heuristic model, calibrated without fitted parameters, that predicts about 0.11 further exceptions in total in the region $n<k^2$, (3) Lean 4 proofs of the rule the search uses and of the 14 exceptions.
removed
## 00. New in version 3: kernel-checked classification for small $k$, a reduction of finiteness, structure of exceptions with $n\ge k^2$, and an interval lemma that removes $4k\le n\le \pi k^{3/2}/(32\ln k)$
added
**This report does not solve the problem.** Versions 3 and 4 add §00: a kernel-checked classification for $k\le30$, the reduction "finite iff $k$ bounded", structure theorems for $n\ge k^2$, and an interval lemma which (with RH) removes $4k\le n\le\pi k^{3/2}/(32\ln k)$. Version 2 adds a theorem (§0): every exception satisfies $n<\mathrm{lcm}(1,\dots,k)+k$, proved in Lean, and with it the complete list of exceptions for all $k\le125$ and all $n$: the 14 known ones. It gives (1) an exhaustive search over stated ranges that finds no fifteenth exception, (2) a heuristic model, calibrated without fitted parameters, that predicts about 0.11 further exceptions in total in the region $n<k^2$, (3) Lean 4 proofs of the rule the search uses and of the 14 exceptions.
added
**Lean project.** The Lean files of this report are a Lake project at https://github.com/janjarosz05/0kwas (commit `6c4c16e`, Lean v4.34.1, Mathlib v4.34.1; modules `Kwas.Erdos1093`, `Kwas.Erdos1094Classify`, `Kwas.Erdos1094Struct`, `Kwas.Erdos1094Window`, `Kwas.Erdos1094Rule`, `Kwas.Erdos1094Finds`); `lake build` passes with no `sorry` and only the three standard axioms. The project was built from source by the isitsolved checker and accepted (no `sorry`, no extra axioms, no `native_decide`): https://isitsolved.com/lean/receipts/634fcf164b17 .
added
*This version adds Jan Jarosz as co-author and the link to the buildable Lean project; the mathematical content is unchanged.*
added
## 00. New in versions 3 and 4: kernel-checked classification for small $k$, a reduction of finiteness, structure of exceptions with $n\ge k^2$, and an interval lemma that removes $4k\le n\le \pi k^{3/2}/(32\ln k)$
added
*Version 4 changes: the kernel-checked classification now reaches $k\le30$ (was 28); Theorem C has a fifth item (all multiples of any $u$); and the C search behind §0 now covers $k\le200$ (was 125), still with exactly the 14 known exceptions.*
All Lean statements below compile with Mathlib v4.34.1, no `sorry`, axioms `propext`, `Classical.choice`, `Quot.sound` only. `Exc` is the Formal Conjectures set. Files: `Erdos1094Classify.lean`, `Erdos1094Struct.lean`, `Erdos1094Window.lean` (theorem statements are reproduced at the end).
edited
**Theorem A (classification, kernel-checked; `exc_classification`, `exc_iff_of_le_28`).**`exc_iff_of_le_30`).** For $k\le 28$30$ and every $n$: $(n,k)\in\mathrm{Exc}$ if and only if $(n,k)$ is one of the 14 known pairs. This is no longer a C search: by the theorem of §0 every exception has $k\lfloor n/k\rfloor\mid L_k$, so Lean enumerates the divisors of $L_k$ and the kernel evaluates the digit test for each (`decide +kernel`). Consequently any new exception has $k\ge 29$31$ (`new_exception_large_k`). (The C search of §0§0, extended in the #1093 report iis:2611.00207 and its successor, covers $k\le125$;$k\le200$ and all $n$: every exception has a smooth term, hence is among the 185 pairs with deficiency $\ge1$, and testing those leaves the 14 known ones. The kernel proof covers $k\le 28$.)30$; beyond that the kernel evaluation of a single $k$ exceeds the 15 GB of memory I have.)
**Theorem B (reduction; `exc_finite_iff_bounded`).** $\mathrm{Exc}$ is finite if and only if there is $K$ with $k\le K$ for every exception. One direction is trivial; the other is $n<L_k+k\le L_K+K$. So Erdős #1094 is exactly the statement "exceptions have bounded $k$".
removed
**Theorem C (structure; `exc_mod_le`, `exc_term_prime`, `exc_term_one_large`, `exc_floor_prime`).** Let $(n,k)$ be an exception.
1. $k\bmod q\le n\bmod q$ for every prime $q\le\max(n/k,k)$.
2. Every prime dividing a term $n-j$ ($0\le j<k$) is $\le k$ or $>n/k$.
3. If $n\ge k^2$, no term is divisible by two primes $>n/k$ (with multiplicity).
4. **Floor-prime theorem.** If $n\ge k^2$, then for every integer $m$ with $k/2<m\le k$: either $\lfloor n/m\rfloor$ is prime, or $m\lfloor n/m\rfloor$ is $k$-smooth (and then it divides $L_k$).
removed
*Proof of 4.* $T=m\lfloor n/m\rfloor$ is one of the terms. If $T$ is not $k$-smooth, some prime $q>n/k\ge k\ge m$ divides it (by 2), so $q\mid\lfloor n/m\rfloor=qs$. From $mqs\le n<qk$ we get $ms<k<2m$, so $s=1$. $\square$
added
**Theorem C (structure; `exc_mod_le`, `exc_term_prime`, `exc_term_one_large`, `exc_floor_prime`, `exc_floor_struct`).** Let $(n,k)$ be an exception.
1. $k\bmod q\le n\bmod q$ for every prime $q\le\max(n/k,k)$.
2. Every prime dividing a term $n-j$ ($0\le j<k$) is $\le k$ or $>n/k$.
3. If $n\ge k^2$, no term is divisible by two primes $>n/k$ (with multiplicity).
4. **Floor-prime theorem.** If $n\ge k^2$, then for every integer $m$ with $k/2<m\le k$: either $\lfloor n/m\rfloor$ is prime, or $m\lfloor n/m\rfloor$ is $k$-smooth (and then it divides $L_k$).
added
5. **All multiples of $u$.** If $n\ge k^2$, then for every $u\ge1$ and every $0\le s<\lfloor k/u\rfloor$: either $u(\lfloor n/u\rfloor-s)$ is $k$-smooth, or $\lfloor n/u\rfloor-s=bq$ with $q$ a prime $>n/k$ and $ub<k$. (Item 4 is $s=0$, $u=m$, which forces $b=1$. For $k/3<u\le k/2$ it says that of $\lfloor n/u\rfloor$ and $\lfloor n/u\rfloor-1$ one is a prime and the other twice a prime, unless a term is smooth.)
added
*Proof of 4.* $T=m\lfloor n/m\rfloor$ is one of the terms. If $T$ is not $k$-smooth, some prime $q>n/k\ge k\ge m$ divides it (by 2), so $q\mid\lfloor n/m\rfloor=qs$. From $mqs\le n<qk$ we get $ms<k<2m$, so $s=1$. Item 5 is the same argument with $ubq\le n<qk$. $\square$
68 unchanged paragraphs
So an exception with $n\ge k^2$ needs about $k/2$ of the numbers $\lfloor n/m\rfloor$, $k/2<m\le k$, to be prime simultaneously, while $k\lfloor n/k\rfloor$ divides $L_k$. Example: $(62,6)$, the only known exception with $n\ge k^2$: $m=4,5,6$ all give the smooth term $60$. Heuristically the chance is about $(\log n)^{-k/2}$ per candidate against at most $e^{(1+o(1))k}$ candidates $n<L_k+k$, which is summable over $k$; turning this into a proof would need an upper-bound sieve for $\sim k/2$ linear forms of dimension growing with $k$, uniformly for $n$ up to $e^{k}$, which I do not have.
**Theorem D (interval lemma; `dvd_choose_of_window`, `exc_no_window`).** Let $p$ be a prime with $k/2<p\le k$ and $N$ an integer with $Np\le n<Np+k-p$. Then $p\mid\binom nk$. Hence an exception has no prime in any interval $\big((n-k)/(N-1),\,n/N\big]\subset(k/2,k]$.
*Proof.* $k=1\cdot p+(k-p)$ in base $p$ and $n\bmod p=n-Np<k-p$, so the lowest digit of $n$ is below that of $k$; apply the kill rule. $\square$
**Corollary E (uses RH).** For all $k$ and $4k\le n\le \pi k^{3/2}/(32\ln k)$, some prime in $(k/2,k]$ divides $\binom nk$; there is no exception in this range.
*Proof.* Put $\theta=n/k\ge4$ and $N=\lfloor2\theta-1\rfloor$. The interval $I=((n-k)/(N-1),n/N]$ lies in $(k/2,k]$ and has length $(kN-n)/(N(N-1))>k/(8\theta)$. Dudek (arXiv:1402.6417) proved under RH that $(x-\tfrac4\pi\sqrt x\log x,\,x]$ contains a prime for all $x\ge2$. With $x=n/N\le k$ the required length is at most $\tfrac4\pi\sqrt k\ln k\le k/(8\theta)$ by the assumption on $n$. So $I$ contains a prime and Theorem D applies. $\square$
*Status of RH in this corollary.* I use RH as a theorem: Alpöge's 2026 proof is formalized in Lean and has been recompiled independently (https://alpo.ge/remark.pdf, https://github.com/luosiallen/riemann-hypothesis-lean-verify); it has not yet been refereed by humans. Without RH, the same argument with Baker–Harman–Pintz gaps ($x^{0.525}$) gives the range $4k\le n\le ck^{1.475}$ for large $k$ with an ineffective constant. The lemma itself (Theorem D) is unconditional and in Lean; the passage from Dudek's theorem to Corollary E is a pen-and-paper argument, not formalized.
**What is still open after version 3.** (i) $n<k^2$: the range $\pi k^{3/2}/(32\ln k)<n<k^2$, where the windows of Theorem D are shorter than any provable prime gap; numerically the primes in $(k/2,k]$ alone kill every $n<k^2$ for $239\le k\le800$ (see conjecture IIS-N-00002 on this site). (ii) $n\ge k^2$: the simultaneous-primes condition of Theorem C.4.
## 0. New in version 2: every exception has $n<\mathrm{lcm}(1,\dots,k)+k$, and for $k\le125$ the 14 known exceptions are all
Write $L_k=\mathrm{lcm}(1,\dots,k)$.
**Theorem** (Lean: `Erdos1093.exc_multiple_dvd_lcm`, `Erdos1093.exc_lt_lcm_add`; Mathlib v4.34.1, no `sorry`, standard axioms; `Exc` is the Formal Conjectures set). If $(n,k)$ is an exception, then $k\lfloor n/k\rfloor$ divides $L_k$. In particular $n<L_k+k$, so for each $k$ there are only finitely many exceptions and they are found by a finite search.
*Proof.* Let $m=k\lfloor n/k\rfloor$, the multiple of $k$ among $n-k+1,\dots,n$. (i) No prime $p\le k$ divides $\binom nk$. (ii) Every prime $q>k$ dividing $m$ divides $\lfloor n/k\rfloor$, so $q\le n/k$; and $q$ divides the numerator $n(n-1)\cdots(n-k+1)$ but not $k!$, so $q\mid\binom nk$, which is forbidden for $q\le n/k$. Hence $m$ is $k$-smooth. (iii) If $p^e\mid m$ with $p\le k$ and $p^e>k$, then with $i=n-m<k$ the digit rule gives $k=k \bmod p^e\le n \bmod p^e=i \bmod p^e<k$, a contradiction. So every prime power dividing $m$ is $\le k$, i.e. $m\mid L_k$. $\blacksquare$
Step (iii) is Theorem 1 of my report on #1093 (iis:2611.00189), where the full Lean file is printed; the part specific to #1094 is reproduced at the end of this report.
**Consequence: complete answer for $k\le125$.** By the theorem every exception has a $k$-smooth term, so it appears in the complete list of pairs with deficiency $\ge1$ computed in the #1093 report (all $n$, $2\le k\le125$: 176 pairs). Testing these 176 pairs exactly (`exceptions1094.py`) leaves precisely the 14 known exceptions. **So #1094 has no further exception with $k\le125$, for any $n$.** This removes the restriction to $n<k^2$ or to bounded $n$ of version 1 for these $k$, and it covers the region $n\ge k^2$ where the model of §3 does not apply. (Independently, a direct run over multiples $m$ of $k$ dividing $L_k$ gives the same 14 for $k\le55$.)
**What is still missing for finiteness.** The conjecture is now equivalent to: for all large $k$, no $n<L_k+k$ with $k\lfloor n/k\rfloor\mid L_k$ is admissible and free of primes in $(k,n/k]$. For $n<k^2$ this is the avoidance problem of §5. For $n\ge k^2$ every term $n-i$ must be (a $k$-smooth number) times (1 or a prime $>n/k$), with the smooth parts multiplying to $k!$; the step I cannot do is to rule this out for large $k$ uniformly in $n<L_k$.
## 1. The kill rule (proved in Lean)
For a prime $p$, write $n$ and $k$ in base $p$. Then
$$p\nmid\binom nk\iff\text{every base-}p\text{ digit of }k\text{ is at most the corresponding digit of }n.$$
This is Lucas's theorem in digit form (equivalently Kummer: no carries when adding $k$ and $n-k$). So a pair $(n,k)$ is an exception iff it passes this digit test for every prime $p\le\max(\lfloor n/k\rfloor,k)$. For a prime $p>k$ the test is just $n\bmod p\ge k$.
Lean (`Erdos1094Rule.lean`, Mathlib v4.34.1, no `sorry`, axioms `propext`, `Classical.choice`, `Quot.sound`):
- `theorem not_dvd_choose_iff_passes {p : ℕ} (hp : p.Prime) : ∀ k n : ℕ, ¬ p ∣ n.choose k ↔ passes p n k`
- `theorem mem_Exc_iff {n k : ℕ} (hk : 0 < k) (hn : 2 * k ≤ n) : (n, k) ∈ Exc ↔ ∀ p : ℕ, p.Prime → p ≤ max (n / k) k → passes p n k`
Here `passes p n k` is the recursive digit test and `Exc` is the set from Formal Conjectures, copied verbatim.
**Logic net.** Before proving the rule I let a small logic net find it without being told Lucas or Kummer. Hypothesis class: clock $p$ lets $(n,k)$ through iff a gate $g_p(a,b)$ is open at every digit position, where $(a,b)$ is the digit pair of $(n,k)$. Gates start closed; a gate opens only when a training pair that truly survives (exact binomials) shows that digit pair. Trained on all pairs with $n\le120$ for the primes $p\le23$, the learned gates are exactly $g_p(a,b)=[a\ge b]$, and the net makes 0 errors on 1,070,100 test cases ($120<n\le700$, $1\le k\le n/2$, nine primes). With training only up to $n\le60$ the gate table for $p=23$ is incomplete (268 of 276 open gates) and the net makes 3,160 errors: the rule is learned only once every digit pair has been seen.
## 2. Exhaustive search
Program `ex.c` (C, OpenMP) tests each pair with the kill rule, trying the primes just above $k/2$ first, because they reject most $n$.
| range of $k$ | range of $n$ | pairs tested (about) | exceptions found |
|---|---|---|---|
| $1\le k\le300$ | $2k\le n\le 2\cdot10^6$ | $6\times10^8$ | the 14 known pairs |
| $2\le k\le 10\,000$ | $2k\le n\le k^2$ (the whole region where the bound is $k$) | $3.3\times10^{11}$ | the 13 known pairs with $n<k^2$ |
| $301\le k\le 3000$ | $2k\le n\le 2\cdot10^7$ | $5\times10^{10}$ | none |
| $301\le k\le 100\,000$ | $2k\le n\le 20k$ | $9\times10^{10}$ | none |
Of the 14 known exceptions only (62,6) has $n\ge k^2$.
No pair outside the 14 known ones was found in any of these ranges. The search reproduces all 14, and the Lean file proves each of them (§4).
Not covered: $n\ge k^2$ beyond the stated bounds, and $k>10\,000$ with $n>20k$. Guy's *Unsolved Problems in Number Theory* (B31, B33) credits Selfridge with the statement that $\binom nk$ has a prime factor $\le n/k$ whenever $n>17.125k$; I could not check a proof of it, so I do not use it. If it holds, the range $2k\le n\le 20k$ (searched for all $k\le100\,000$) contains every exception with $k\le 100\,000$.
## 3. Predictive model (digit clocks) and its calibration
In the region $2k\le n<k^2$ the bound is $k$, so only the primes $p\le k$ matter. Treat each prime as an independent clock and the digits of $n$ as uniform. A pair passes clock $p$ with probability
$$\delta_p(k)=\prod_i\frac{p-d_i}{p},\qquad d_i=\text{base-}p\text{ digits of }k,$$
and the expected number of exceptions with this $k$ is $E(k)=(k^2-2k)\prod_{p\le k}\delta_p(k)$. There is no fitted parameter.
Calibration against exact counts of pairs with $2k\le n<k^2$ that pass a given set of clocks:
| clocks used | $k$ range | actual | predicted | ratio |
|---|---|---|---|---|
| all $p\le k$ (true exceptions) | 4–29 | 12 | 12.04 | 1.00 |
| all $p\le k$ | 30–99 | 0 | 0.11 | |
| $k/2<p\le k$ | 4–29 | 1203 | 1147.7 | 1.05 |
| $k/2<p\le k$ | 30–99 | 2881 | 3156.1 | 0.91 |
| $k/2<p\le k$ | 100–249 | 251 | 207.7 | 1.21 |
| $k/3<p\le k/2$ | 30–99 | 44275 | 43982.5 | 1.01 |
| $k/3<p\le k/2$ | 100–249 | 48772 | 48323.7 | 1.01 |
| $p\le\sqrt k$ | 30–99 | 321 | 337.0 | 0.95 |
| $p\le\sqrt k$ | 100–249 | 153 | 200.1 | 0.77 |
The model is right to within about 25% on every clock family, and it predicts 12.04 exceptions for $4\le k<30$ where there are 12 (the thirteenth exception with $n<k^2$ is (7,3)).
Predicted number of further exceptions with $n<k^2$:
| $k$ range | $\sum E(k)$ |
|---|---|
| 30–49 | 0.105 |
| 50–99 | $2.6\times10^{-3}$ |
| 100–299 | $3.6\times10^{-7}$ |
| 300–2999 | $1.5\times10^{-21}$ |
The density $\prod_{p\le k}\delta_p(k)$ is about $10^{-28}$ at $k=300$, $10^{-69}$ at $k=1000$, $10^{-460}$ at $k=10^4$ and $10^{-3434}$ at $k=10^5$. The primes in $(k/2,k]$ alone give a factor $\prod(2p-k)/p$, which decays like $\exp(-ck/\log k)$. So the model predicts finitely many exceptions with $n<k^2$, and that the search has already passed all of them. **This is a heuristic, not a proof**: the clocks are not independent, and nothing here bounds the dependence.
The same model fails for $n\ge k^2$ and small $k$, and I do not use it there. For example for $k=3$ independent clocks $p\le n/3$ would predict infinitely many exceptions, while in fact a number $m\le n$ with no prime factor $\le n/k$ other than those cancelled by $k!$ must be a prime times a cofactor below $k$, which is a rigid constraint. In that region the only exception found is (62,6), in line with Selfridge's conjecture quoted on the problem page.
## 4. Lean proofs of the 14 exceptions
`Erdos1094Finds.lean` (Mathlib v4.34.1, no `sorry`, standard axioms only) proves `(n, k) ∈ Exc` for each of the 14 pairs, for example `theorem exc_284_28 : ((284, 28) : ℕ × ℕ) ∈ Exc`. Each proof computes $n!/(k!(n-k)!)$ in the kernel and checks that no $d$ with $2\le d\le\max(\lfloor n/k\rfloor,k)$ divides it (`decide +kernel`).
## 5. Where I got stuck
- **No proof of finiteness.** What is needed is: for every large $k$ and every $n$ with $2k\le n<k^2$, some prime $p\le k$ has a base-$p$ digit of $k$ exceeding that of $n$. For $p\in(k/2,k]$ this says $n\bmod p<k-p$. So the task is to show that $n$ cannot avoid the residue windows $[0,k-p)$ modulo all primes $p\in(k/2,k]$ (and the analogous windows for smaller primes) at once. That is a simultaneous-avoidance problem for about $k/(2\log k)$ moduli of size about $k$ and $n<k^2$; I have no tool that controls it, and the heuristic independence is exactly what is unproved.
- **Region $n\ge k^2$.** Searched only up to the stated bounds; a complete treatment needs either Selfridge's $17.125k$ statement with proof or an argument via the deficiency of $\binom nk$ (problem #1093).
- I did not check the original papers [ELS88], [ELS93], [Se77]; the statements about them are taken from the problem page.
## Lean source: `Erdos1094Rule.lean`
```lean
import Mathlib
/-!
# Erdős Problem 1094: the kill rule of the logic net, proved
The logic net learned, from pairs with `n ≤ 120`, that clock `p` lets `(n, k)` through exactly when every
base-`p` digit of `k` is at most the corresponding digit of `n`. Here this rule is proved for all `n, k`
(it is Lucas's theorem in digit form), and the exceptional set of the problem is rewritten with it.
-/
namespace Erdos1094Rule
/-- The learned gate, applied to all base-`p` digit pairs: every digit of `k` is `≤` that of `n`. -/
def passes (p : ℕ) : ℕ → ℕ → Prop
| n, k => if _h : k = 0 ∨ p < 2 then True else k % p ≤ n % p ∧ passes p (n / p) (k / p)
decreasing_by
have hk : k ≠ 0 := fun h0 ↦ _h (Or.inl h0)
have hp : 2 ≤ p := by omega
exact Nat.div_lt_self (Nat.pos_of_ne_zero hk) hp
theorem passes_zero (p n : ℕ) : passes p n 0 := by
unfold passes; simp
theorem passes_step {p : ℕ} (hp : 2 ≤ p) (n : ℕ) {k : ℕ} (hk : k ≠ 0) :
passes p n k ↔ k % p ≤ n % p ∧ passes p (n / p) (k / p) := by
rw [passes]
have h1 : 1 < p := by omega
simp [hk, h1]
/-- **Kill rule.** For a prime `p`: `p ∤ C(n, k)` iff every base-`p` digit of `k` is at most that of `n`. -/
theorem not_dvd_choose_iff_passes {p : ℕ} (hp : p.Prime) :
∀ k n : ℕ, ¬ p ∣ n.choose k ↔ passes p n k := by
have : Fact p.Prime := ⟨hp⟩
intro k
induction k using Nat.strong_induction_on with
| _ k ih =>
intro n
by_cases hk : k = 0
· subst hk
simp [passes_zero, hp.one_lt.ne', Nat.dvd_one]
· rw [passes_step hp.two_le n hk]
have hlt : k / p < k := Nat.div_lt_self (Nat.pos_of_ne_zero hk) hp.two_le
rw [← ih (k / p) hlt (n / p)]
have hl := Choose.choose_modEq_choose_mod_mul_choose_div_nat (n := n) (k := k) (p := p)
have hdvd : p ∣ n.choose k ↔ p ∣ (n % p).choose (k % p) * (n / p).choose (k / p) := by
rw [Nat.dvd_iff_mod_eq_zero, Nat.dvd_iff_mod_eq_zero]
unfold Nat.ModEq at hl
rw [hl]
rw [hdvd, hp.dvd_mul, not_or]
have hdig : ¬ p ∣ (n % p).choose (k % p) ↔ k % p ≤ n % p := by
constructor
· intro h
by_contra hlt'
exact h (by rw [Nat.choose_eq_zero_of_lt (by omega)]; exact dvd_zero p)
· intro hle hd
have hnp : n % p < p := Nat.mod_lt _ hp.pos
have hpos : 0 < (n % p).choose (k % p) := Nat.choose_pos hle
have : p ∣ (n % p).factorial := by
rw [← Nat.choose_mul_factorial_mul_factorial hle]
exact Dvd.dvd.mul_right (Dvd.dvd.mul_right hd _) _
exact absurd ((hp.dvd_factorial).1 this) (by omega)
rw [hdig]
/-- The exceptional set of Erdős Problem 1094 (verbatim from Formal Conjectures). -/
def Exc : Set (ℕ × ℕ) :=
{(n, k) : ℕ × ℕ | 0 < k ∧ 2 * k ≤ n ∧ (n.choose k).minFac > max (n / k) k}
/-- A pair is exceptional iff it passes every prime clock `p ≤ max (n / k) k`. -/
theorem mem_Exc_iff {n k : ℕ} (hk : 0 < k) (hn : 2 * k ≤ n) :
(n, k) ∈ Exc ↔ ∀ p : ℕ, p.Prime → p ≤ max (n / k) k → passes p n k := by
have hc1 : n.choose k ≠ 1 := by
intro h
have := Nat.choose_eq_one_iff.1 h
omega
constructor
· rintro ⟨-, -, h⟩ p hp hple
rw [← not_dvd_choose_iff_passes hp]
intro hd
have := Nat.minFac_le_of_dvd hp.two_le hd
omega
· intro h
refine ⟨hk, hn, ?_⟩
by_contra hle
push Not at hle
have hp := Nat.minFac_prime hc1
exact (not_dvd_choose_iff_passes hp k n).2 (h _ hp hle) (Nat.minFac_dvd _)
end Erdos1094Rule
#print axioms Erdos1094Rule.not_dvd_choose_iff_passes
#print axioms Erdos1094Rule.mem_Exc_iff
```
## Lean source: `Erdos1094Finds.lean` (first lines and one example; the other 13 theorems have the same form)
```lean
import Mathlib
/-!
# Erdős Problem 1094: the fourteen known exceptions, checked by the kernel
Formal Conjectures (`Erdos1094.erdos_1094`) asks that
`{(n, k) : ℕ × ℕ | 0 < k ∧ 2 * k ≤ n ∧ (n.choose k).minFac > max (n / k) k}` is finite.
Here we prove that the fourteen pairs listed by Erdős, Lacampagne and Selfridge are in this set.
-/
namespace Erdos1094Finds
/-- The exceptional set of Erdős Problem 1094 (verbatim from Formal Conjectures). -/
def Exc : Set (ℕ × ℕ) :=
{(n, k) : ℕ × ℕ | 0 < k ∧ 2 * k ≤ n ∧ (n.choose k).minFac > max (n / k) k}
/-- Computable test: `n.choose k` computed as `n! / (k! (n-k)!)` has no divisor `d` with `2 ≤ d ≤ m`. -/
def noSmallDivisor (N m : ℕ) : Bool :=
(List.range (m + 1)).all fun d ↦ d < 2 || N % d != 0
theorem minFac_gt_of_noSmallDivisor {N m : ℕ} (h : noSmallDivisor N m = true) (hN : N ≠ 1) :
N.minFac > m := by
by_contra hle
push Not at hle
have hp : (N.minFac).Prime := Nat.minFac_prime hN
have hd : N.minFac ∣ N := Nat.minFac_dvd N
simp only [noSmallDivisor, List.all_eq_true, List.mem_range, Bool.or_eq_true, decide_eq_true_eq,
bne_iff_ne, ne_eq] at h
rcases h N.minFac (by omega) with h2 | h2
· exact absurd hp.two_le (by omega)
· exact h2 (Nat.mod_eq_zero_of_dvd hd)
theorem mem_of_check (n k : ℕ) (hk : 0 < k) (hn : 2 * k ≤ n)
(h : noSmallDivisor (n.factorial / (k.factorial * (n - k).factorial)) (max (n / k) k) = true)
(h1 : n.factorial / (k.factorial * (n - k).factorial) ≠ 1) : (n, k) ∈ Exc := by
have hc : n.choose k = n.factorial / (k.factorial * (n - k).factorial) :=
Nat.choose_eq_factorial_div_factorial (by omega)
refine ⟨hk, hn, ?_⟩
rw [hc]
exact minFac_gt_of_noSmallDivisor h h1
theorem exc_284_28 : ((284, 28) : ℕ × ℕ) ∈ Exc :=
mem_of_check 284 28 (by norm_num) (by norm_num) (by decide +kernel) (by decide +kernel)
end Erdos1094Finds
```
## Lean source: the #1094 part of `Erdos1093.lean` (it uses `smooth_term_dvd_lcm` from the same file, printed in iis:2611.00189)
```lean
/-! ## Consequence for Erdős problem 1094 -/
/-- The exceptional set of Erdős Problem 1094 (verbatim from Formal Conjectures). -/
def Exc : Set (ℕ × ℕ) :=
{(n, k) : ℕ × ℕ | 0 < k ∧ 2 * k ≤ n ∧ (n.choose k).minFac > max (n / k) k}
/-- **Theorem (1094).** For every exception `(n, k)` of Erdős problem 1094, the multiple `k * (n / k)` of `k`
in `(n - k, n]` divides `lcm(1, …, k)`. -/
theorem exc_multiple_dvd_lcm {n k : ℕ} (h : (n, k) ∈ Exc) : k * (n / k) ∣ (Finset.Icc 1 k).lcm id := by
obtain ⟨hk, hn, hmin⟩ := h
have hadm : ∀ q : ℕ, q.Prime → q ≤ k → ¬ q ∣ n.choose k := by
intro q hq hqk hd
have := Nat.minFac_le_of_dvd hq.two_le hd
have := le_max_right (n / k) k
omega
have hi : n % k < k := Nat.mod_lt _ hk
have hin : n % k ≤ n := Nat.mod_le _ _
have hm : n - n % k = k * (n / k) := by
have := Nat.div_add_mod n k
omega
rw [← hm]
refine smooth_term_dvd_lcm hadm hi hin ?_
intro q hq hd
by_contra hqk
have hqk' : k < q := by omega
rw [hm] at hd
have hq1 : q ∣ n / k := by
rcases (hq.dvd_mul).1 hd with h1 | h1
· exact absurd (Nat.le_of_dvd hk h1) (by omega)
· exact h1
have hpos : 0 < n / k := Nat.div_pos (by omega) hk
have hqle : q ≤ n / k := Nat.le_of_dvd hpos hq1
-- q divides the term n - n % k of the falling factorial, hence C(n,k)
have hterm : q ∣ n.descFactorial k := by
rw [Nat.descFactorial_eq_prod_range]
exact dvd_trans (hm ▸ hd) (Finset.dvd_prod_of_mem _ (Finset.mem_range.2 hi))
rw [Nat.descFactorial_eq_factorial_mul_choose] at hterm
have hc : q ∣ n.choose k := by
rcases (hq.dvd_mul).1 hterm with h1 | h1
· exact absurd ((hq.dvd_factorial).1 h1) (by omega)
· exact h1
have := Nat.minFac_le_of_dvd hq.two_le hc
have := le_max_left (n / k) k
omega
/-- **Corollary (1094).** Every exception of Erdős problem 1094 satisfies `n < lcm(1, …, k) + k`.
So for each `k` there are finitely many exceptions, found by a finite search. -/
theorem exc_lt_lcm_add {n k : ℕ} (h : (n, k) ∈ Exc) : n < (Finset.Icc 1 k).lcm id + k := by
have hd := exc_multiple_dvd_lcm h
obtain ⟨hk, hn, -⟩ := h
have hpos : 0 < (Finset.Icc 1 k).lcm id := by
apply Nat.pos_of_ne_zero
rw [Ne, Finset.lcm_eq_zero_iff]
simp
have := Nat.le_of_dvd hpos hd
have := Nat.div_add_mod n k
have := Nat.mod_lt n hk
omega
```
removed
## Lean statements added in version 3 (full files in the repository copy of this report; all compile, `#print axioms` gives only the three standard axioms)
removed
```lean
/-- **Classification for `k ≤ 28`.** Every exception `(n, k)` of Erdős problem 1094 with `k ≤ 28`
(and any `n`) is one of the 14 known exceptions. -/
theorem exc_classification {n k : ℕ} (he : (n, k) ∈ Exc) (hk : k ≤ 28) : (n, k) ∈ known14 := by …
removed
/-- **Exact classification for `k ≤ 28`**: for every `n`, `(n, k)` is an exception iff it is one of the 14. -/
theorem exc_iff_of_le_28 {n k : ℕ} (hk : k ≤ 28) : (n, k) ∈ Exc ↔ (n, k) ∈ known14 :=
⟨fun he => exc_classification he hk, known14_subset⟩
removed
theorem lcm_pos' (k : ℕ) : 0 < (Finset.Icc 1 k).lcm id := by …
removed
/-- **Reduction.** The Formal Conjectures statement of Erdős problem 1094 (`Exc` is finite) holds
iff the exceptions have bounded `k`. -/
theorem exc_finite_iff_bounded : Exc.Finite ↔ ∃ K : ℕ, ∀ n k : ℕ, (n, k) ∈ Exc → k ≤ K := by …
removed
/-- Any further exception has `k ≥ 29`. -/
theorem new_exception_large_k {n k : ℕ} (he : (n, k) ∈ Exc) (hnew : (n, k) ∉ known14) : 29 ≤ k := by …
removed
/-- **Residue windows.** For an exception `(n, k)` and every prime `q ≤ max (n / k) k`: `k mod q ≤ n mod q`.
For `k < q ≤ n / k` this reads `k ≤ n mod q`; for `k / 2 < q ≤ k` it reads `k - q ≤ n mod q`. -/
theorem exc_mod_le {n k q : ℕ} (he : (n, k) ∈ Exc) (hq : q.Prime) (hle : q ≤ max (n / k) k) :
k % q ≤ n % q := by …
removed
/-- **Every term is (`k`-smooth) × (primes above `n / k`).** For an exception `(n, k)`, a prime dividing one of
`n, n - 1, …, n - k + 1` is either `≤ k` or `> n / k`. -/
theorem exc_term_prime {n k j q : ℕ} (he : (n, k) ∈ Exc) (hj : j < k) (hq : q.Prime) (hd : q ∣ n - j) :
q ≤ k ∨ n / k < q := by …
removed
/-- For an exception with `n ≥ k^2`, a term has at most one prime factor above `n / k` (two would exceed `n`):
if primes `q₁ q₂ > n / k` satisfy `q₁ * q₂ ∣ n - j`, contradiction. -/
theorem exc_term_one_large {n k j q₁ q₂ : ℕ} (he : (n, k) ∈ Exc) (hn2 : k ^ 2 ≤ n) (hjn : j < n)
(h1 : n / k < q₁) (h2 : n / k < q₂) (hd : q₁ * q₂ ∣ n - j) : False := by …
removed
/-- **Floor-prime theorem.** In an exception of Erdős 1094 with `n ≥ k²`, for every `m` with `k/2 < m ≤ k`
the quotient `n / m` is a prime, unless the term `m * (n / m)` is `k`-smooth. -/
theorem exc_floor_prime {n k m : ℕ} (he : (n, k) ∈ Exc) (hn2 : k * k ≤ n) (hm1 : k < 2 * m)
(hm2 : m ≤ k) : (n / m).Prime ∨ ∀ q : ℕ, q.Prime → q ∣ m * (n / m) → q ≤ k := by …
removed
/-- Interval lemma. `p` prime in `(k/2, k]` and `N * p ≤ n < N * p + k - p` imply `p ∣ C(n, k)`. -/
theorem dvd_choose_of_window {n k N p : ℕ} (hp : p.Prime) (hp2 : k < 2 * p) (hpk : p ≤ k)
(hNp : N * p ≤ n) (hlow : n + p < N * p + k) : p ∣ n.choose k := by …
removed
/-- An exception of Erdős 1094 has no prime in any window `((n - k)/(N - 1), n/N]` inside `(k/2, k]`. -/
theorem exc_no_window {n k N p : ℕ} (he : (n, k) ∈ Exc) (hp : p.Prime) (hp2 : k < 2 * p)
(hpk : p ≤ k) (hNp : N * p ≤ n) (hlow : n + p < N * p + k) : False := by …
```
added
## Lean statements added in versions 3 and 4 (full files in the repository copy; all compile, `#print axioms` gives only the three standard axioms)
added
```lean
/-- **Classification for `k ≤ 30`.** Every exception `(n, k)` of Erdős problem 1094 with `k ≤ 30`
(and any `n`) is one of the 14 known exceptions. -/
theorem exc_classification {n k : ℕ} (he : (n, k) ∈ Exc) (hk : k ≤ 30) : (n, k) ∈ known14 := …
added
/-- **Exact classification for `k ≤ 30`**: for every `n`, `(n, k)` is an exception iff it is one of the 14. -/
theorem exc_iff_of_le_30 {n k : ℕ} (hk : k ≤ 30) : (n, k) ∈ Exc ↔ (n, k) ∈ known14 := …
added
/-- **Reduction.** The Formal Conjectures statement of Erdős problem 1094 (`Exc` is finite) holds
iff the exceptions have bounded `k`. -/
theorem exc_finite_iff_bounded : Exc.Finite ↔ ∃ K : ℕ, ∀ n k : ℕ, (n, k) ∈ Exc → k ≤ K := …
added
/-- Any further exception has `k ≥ 31`. -/
theorem new_exception_large_k {n k : ℕ} (he : (n, k) ∈ Exc) (hnew : (n, k) ∉ known14) : 31 ≤ k := …
added
/-- **Residue windows.** For an exception `(n, k)` and every prime `q ≤ max (n / k) k`: `k mod q ≤ n mod q`.
For `k < q ≤ n / k` this reads `k ≤ n mod q`; for `k / 2 < q ≤ k` it reads `k - q ≤ n mod q`. -/
theorem exc_mod_le {n k q : ℕ} (he : (n, k) ∈ Exc) (hq : q.Prime) (hle : q ≤ max (n / k) k) :
k % q ≤ n % q := …
added
/-- **Every term is (`k`-smooth) × (primes above `n / k`).** For an exception `(n, k)`, a prime dividing one of
`n, n - 1, …, n - k + 1` is either `≤ k` or `> n / k`. -/
theorem exc_term_prime {n k j q : ℕ} (he : (n, k) ∈ Exc) (hj : j < k) (hq : q.Prime) (hd : q ∣ n - j) :
q ≤ k ∨ n / k < q := …
added
/-- For an exception with `n ≥ k^2`, a term has at most one prime factor above `n / k` (two would exceed `n`):
if primes `q₁ q₂ > n / k` satisfy `q₁ * q₂ ∣ n - j`, contradiction. -/
theorem exc_term_one_large {n k j q₁ q₂ : ℕ} (he : (n, k) ∈ Exc) (hn2 : k ^ 2 ≤ n) (hjn : j < n)
(h1 : n / k < q₁) (h2 : n / k < q₂) (hd : q₁ * q₂ ∣ n - j) : False := …
added
/-- **Floor-prime theorem.** In an exception of Erdős 1094 with `n ≥ k²`, for every `m` with `k/2 < m ≤ k`
the quotient `n / m` is a prime, unless the term `m * (n / m)` is `k`-smooth. -/
theorem exc_floor_prime {n k m : ℕ} (he : (n, k) ∈ Exc) (hn2 : k * k ≤ n) (hm1 : k < 2 * m)
(hm2 : m ≤ k) : (n / m).Prime ∨ ∀ q : ℕ, q.Prime → q ∣ m * (n / m) → q ≤ k := …
added
/-- **Structure of the multiples of `u`.** In an exception with `n ≥ k²`, for every `u` and every `s < k / u`,
the term `u * (n / u - s)` is `k`-smooth, or `n / u - s = b * q` with `q` a prime `> n / k` and `u * b < k`. -/
theorem exc_floor_struct {n k u s : ℕ} (he : (n, k) ∈ Exc) (hn2 : k * k ≤ n) (hs : s < k / u) :
(∀ q : ℕ, q.Prime → q ∣ u * (n / u - s) → q ≤ k) ∨
∃ q b : ℕ, q.Prime ∧ n / k < q ∧ n / u - s = b * q ∧ u * b < k := …
added
/-- Interval lemma. `p` prime in `(k/2, k]` and `N * p ≤ n < N * p + k - p` imply `p ∣ C(n, k)`. -/
theorem dvd_choose_of_window {n k N p : ℕ} (hp : p.Prime) (hp2 : k < 2 * p) (hpk : p ≤ k)
(hNp : N * p ≤ n) (hlow : n + p < N * p + k) : p ∣ n.choose k := …
added
/-- An exception of Erdős 1094 has no prime in any window `((n - k)/(N - 1), n/N]` inside `(k/2, k]`. -/
theorem exc_no_window {n k N p : ℕ} (he : (n, k) ∈ Exc) (hp : p.Prime) (hp2 : k < 2 * p)
(hpk : p ≤ k) (hNp : N * p ≤ n) (hlow : n + p < N * p + k) : False := …
```