Problems / euclid-primes / variant-4cb87a03
Euclid's explicit bound: a prime in (n, n! + 1]
variant-4cb87a03
proved
A variant that resolves the problem.
$\displaystyle \forall n\in\mathbb{N}\ \ \exists p\in\mathbb{N}:\quad n<p\ \wedge\ p\le n!+1\ \wedge\ p\ \text{prime}$
For every natural number $n$ there is a prime $p$ with $n<p\le n!+1$, where $n!$ is Mathlib's Nat.factorial. Prime is the problem's own Opn.IsPrime: $2\le p$ and every $d$ with $p=d\cdot c$ for some natural $c$ is $1$ or $p$.
Lean
theorem Opn.euclid_explicit_bound : ∀ n : Nat, ∃ p : Nat, n < p ∧ p ≤ Nat.factorial n + 1 ∧ Opn.IsPrime p := by sorry
Why does it end in sorry?
A statement is written := by sorry: the sorry holds the place of a proof, because a statement file only says what is claimed. A proof the gate checked is its own file, Proof.lean. How to read a proof page →
How it was proved
Proved by Proof.lean, checked by the kernel. Its attestation, 000117, records the gate’s run.
The proof step by step (outline)
Checked by the kernel — an outline of the attested proof below: attestations/000117.json, merge commit 870cae06e964.
Outline of Proof.lean, extracted by the gate at 82834c4684b8 from the proof’s elaboration: each step is a claim the proof establishes and the goal it leaves. Open a step for what it uses and its Lean lines.
prime_divisorhave∀ (m : ℕ), (2 : ℕ) ≤ m → ∃ (p : ℕ), IsPrime p ∧ Divides p mLeaves
∃ (p : ℕ), n < p ∧ p ≤ n.factorial + (1 : ℕ) ∧ IsPrime p, withprime_divisor : ∀ (m : ℕ), (2 : ℕ) ≤ m → ∃ (p : ℕ), IsPrime p ∧ Divides p m.Uses definitions
Opn.IsPrime,Opn.Divides; libraryNatThe natural numbers, starting at zero. ,Nat.strong_induction_on.Lean, lines 10–40
have prime_divisor : ∀ m : Nat, 2 ≤ m → ∃ p, Opn.IsPrime p ∧ Opn.Divides p m := by intro m induction m using Nat.strong_induction_on with | _ m ih => intro hm by_cases hp : Opn.IsPrime m · exact ⟨m, hp, 1, by simp⟩ · have hex : ∃ d, Opn.Divides d m ∧ d ≠ 1 ∧ d ≠ m := by by_contra hcon apply hp refine ⟨hm, fun d hd => ?_⟩ by_contra h exact hcon ⟨d, hd, fun h1 => h (Or.inl h1), fun h2 => h (Or.inr h2)⟩ obtain ⟨d, ⟨c, hc⟩, hd1, hdm⟩ := hex have hd0 : d ≠ 0 := by rintro rfl simp at hc omega have hc0 : c ≠ 0 := by rintro rfl simp at hc omega have hc1 : c ≠ 1 := by rintro rfl simp at hc exact hdm hc.symm have hdlt : d < m := by have h2 : d * 2 ≤ d * c := Nat.mul_le_mul_left d (by omega) omega obtain ⟨p, hp', q, hq⟩ := ih d hdlt (by omega) exact ⟨p, hp', q * c, by rw [hc, hq, Nat.mul_assoc]⟩targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 10–40 at
870cae06e964↗prime_divisor.s1caseLeaves
(2 : ℕ) ≤ m → ∃ (p : ℕ), IsPrime p ∧ Divides p m, withm : ℕ,ih : ∀ m_1 < m, (2 : ℕ) ≤ m_1 → ∃ (p : ℕ), IsPrime p ∧ Divides p m_1.Uses definitions
Opn.IsPrime.Lean, lines 13–40
| _ m ih => intro hm by_cases hp : Opn.IsPrime m · exact ⟨m, hp, 1, by simp⟩ · have hex : ∃ d, Opn.Divides d m ∧ d ≠ 1 ∧ d ≠ m := by by_contra hcon apply hp refine ⟨hm, fun d hd => ?_⟩ by_contra h exact hcon ⟨d, hd, fun h1 => h (Or.inl h1), fun h2 => h (Or.inr h2)⟩ obtain ⟨d, ⟨c, hc⟩, hd1, hdm⟩ := hex have hd0 : d ≠ 0 := by rintro rfl simp at hc omega have hc0 : c ≠ 0 := by rintro rfl simp at hc omega have hc1 : c ≠ 1 := by rintro rfl simp at hc exact hdm hc.symm have hdlt : d < m := by have h2 : d * 2 ≤ d * c := Nat.mul_le_mul_left d (by omega) omega obtain ⟨p, hp', q, hq⟩ := ih d hdlt (by omega) exact ⟨p, hp', q * c, by rw [hc, hq, Nat.mul_assoc]⟩targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 13–40 at
870cae06e964↗prime_divisor.s1.s1caseLeaves
∃ (p : ℕ), IsPrime p ∧ Divides p m.Uses library
Exists.introExistential introduction. .Lean, line 16
· exact ⟨m, hp, 1, by simp⟩
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 16 at
870cae06e964↗prime_divisor.s1.s2caseLeaves
∃ (p : ℕ), IsPrime p ∧ Divides p m.Uses library
Exists.introExistential introduction. ,Nat.mul_assoc.Lean, lines 17–40
· have hex : ∃ d, Opn.Divides d m ∧ d ≠ 1 ∧ d ≠ m := by by_contra hcon apply hp refine ⟨hm, fun d hd => ?_⟩ by_contra h exact hcon ⟨d, hd, fun h1 => h (Or.inl h1), fun h2 => h (Or.inr h2)⟩ obtain ⟨d, ⟨c, hc⟩, hd1, hdm⟩ := hex have hd0 : d ≠ 0 := by rintro rfl simp at hc omega have hc0 : c ≠ 0 := by rintro rfl simp at hc omega have hc1 : c ≠ 1 := by rintro rfl simp at hc exact hdm hc.symm have hdlt : d < m := by have h2 : d * 2 ≤ d * c := Nat.mul_le_mul_left d (by omega) omega obtain ⟨p, hp', q, hq⟩ := ih d hdlt (by omega) exact ⟨p, hp', q * c, by rw [hc, hq, Nat.mul_assoc]⟩targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 17–40 at
870cae06e964↗prime_divisor.s1.s2.hexhave∃ (d : ℕ), Divides d m ∧ d ≠ (1 : ℕ) ∧ d ≠ mLeaves
∃ (p : ℕ), IsPrime p ∧ Divides p m, withhex : ∃ (d : ℕ), Divides d m ∧ d ≠ (1 : ℕ) ∧ d ≠ m.Uses definitions
Opn.Divides; libraryAnd.introAnd.intro : a → b → a ∧ bis the constructor for the And operation. ,Exists.introExistential introduction. ,Or.inlOr.inlis "left injection" into anOr. ,Or.inrOr.inris "right injection" into anOr. .Lean, lines 17–22
· have hex : ∃ d, Opn.Divides d m ∧ d ≠ 1 ∧ d ≠ m := by by_contra hcon apply hp refine ⟨hm, fun d hd => ?_⟩ by_contra h exact hcon ⟨d, hd, fun h1 => h (Or.inl h1), fun h2 => h (Or.inr h2)⟩targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 17–22 at
870cae06e964↗prime_divisor.s1.s2.s2obtain∃ (d : ℕ), Divides d m ∧ d ≠ (1 : ℕ) ∧ d ≠ mLeaves
∃ (p : ℕ), IsPrime p ∧ Divides p m, withd : ℕ,c : ℕ,hc : m = d * c,hd1 : d ≠ (1 : ℕ),hdm : d ≠ m.Lean, line 23
obtain ⟨d, ⟨c, hc⟩, hd1, hdm⟩ := hex
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 23 at
870cae06e964↗prime_divisor.s1.s2.hd0haved ≠ (0 : ℕ)Leaves
∃ (p : ℕ), IsPrime p ∧ Divides p m, withhd0 : d ≠ (0 : ℕ).Lean, lines 24–27
have hd0 : d ≠ 0 := by rintro rfl simp at hc omegatargets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 24–27 at
870cae06e964↗prime_divisor.s1.s2.hc0havec ≠ (0 : ℕ)Leaves
∃ (p : ℕ), IsPrime p ∧ Divides p m, withhc0 : c ≠ (0 : ℕ).Lean, lines 28–31
have hc0 : c ≠ 0 := by rintro rfl simp at hc omegatargets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 28–31 at
870cae06e964↗prime_divisor.s1.s2.hc1havec ≠ (1 : ℕ)Leaves
∃ (p : ℕ), IsPrime p ∧ Divides p m, withhc1 : c ≠ (1 : ℕ).Lean, lines 32–35
have hc1 : c ≠ 1 := by rintro rfl simp at hc exact hdm hc.symmtargets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 32–35 at
870cae06e964↗prime_divisor.s1.s2.hdlthaved < mLeaves
∃ (p : ℕ), IsPrime p ∧ Divides p m, withhdlt : d < m.Lean, lines 36–38
have hdlt : d < m := by have h2 : d * 2 ≤ d * c := Nat.mul_le_mul_left d (by omega) omegatargets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 36–38 at
870cae06e964↗prime_divisor.s1.s2.hdlt.h2haved * (2 : ℕ) ≤ d * cLeaves
d < m, withh2 : d * (2 : ℕ) ≤ d * c.Uses library
Nat.mul_le_mul_left.Lean, line 37
have h2 : d * 2 ≤ d * c := Nat.mul_le_mul_left d (by omega)
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 37 at
870cae06e964↗
prime_divisor.s1.s2.s7obtain∃ (p : ℕ), IsPrime p ∧ Divides p dLeaves
∃ (p : ℕ), IsPrime p ∧ Divides p m, withp : ℕ,hp' : IsPrime p,q : ℕ,hq : d = p * q.Lean, line 39
obtain ⟨p, hp', q, hq⟩ := ih d hdlt (by omega)
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 39 at
870cae06e964↗
hposhave(0 : ℕ) < n.factorialLeaves
∃ (p : ℕ), n < p ∧ p ≤ n.factorial + (1 : ℕ) ∧ IsPrime p, withhpos : (0 : ℕ) < n.factorial.Uses library
Nat.factorialNat.factorial nis the factorial ofn. ,Nat.factorial_pos.Lean, line 41
have hpos : 0 < Nat.factorial n := Nat.factorial_pos n
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 41 at
870cae06e964↗s3obtain∃ (p : ℕ), IsPrime p ∧ Divides p (n.factorial + (1 : ℕ))Leaves
∃ (p : ℕ), n < p ∧ p ≤ n.factorial + (1 : ℕ) ∧ IsPrime p, withp : ℕ,hp : IsPrime p,c : ℕ,hc : n.factorial + (1 : ℕ) = p * c.Uses library
Nat.factorialNat.factorial nis the factorial ofn. .Lean, line 42
obtain ⟨p, hp, c, hc⟩ := prime_divisor (Nat.factorial n + 1) (by omega)
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 42 at
870cae06e964↗hc0havec ≠ (0 : ℕ)Leaves
∃ (p : ℕ), n < p ∧ p ≤ n.factorial + (1 : ℕ) ∧ IsPrime p, withhc0 : c ≠ (0 : ℕ).Lean, lines 43–45
have hc0 : c ≠ 0 := by rintro rfl simp at hctargets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 43–45 at
870cae06e964↗hplehavep ≤ n.factorial + (1 : ℕ)Leaves
∃ (p : ℕ), n < p ∧ p ≤ n.factorial + (1 : ℕ) ∧ IsPrime p, withhple : p ≤ n.factorial + (1 : ℕ).Uses library
Nat.factorialNat.factorial nis the factorial ofn. ,Nat.le_mul_of_pos_right,Nat.pos_of_ne_zero.Lean, lines 46–48
have hple : p ≤ Nat.factorial n + 1 := by rw [hc] exact Nat.le_mul_of_pos_right p (Nat.pos_of_ne_zero hc0)targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 46–48 at
870cae06e964↗hpnhavep ≤ nroutine: omegaLeaves
False, withhpn : p ≤ n.Lean, line 51
have hpn : p ≤ n := by omega
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 51 at
870cae06e964↗hp2have(2 : ℕ) ≤ pLeaves
False, withhp2 : (2 : ℕ) ≤ p.Lean, line 52
have hp2 := hp.1
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 52 at
870cae06e964↗s8obtainp ∣ n.factorialLeaves
False, withe : ℕ,he : n.factorial = p * e.Uses library
Nat.dvd_factorial.Lean, line 53
obtain ⟨e, he⟩ := Nat.dvd_factorial (by omega : 0 < p) hpn
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 53 at
870cae06e964↗hechavee < cLeaves
False, withhec : e < c.Lean, lines 54–57
have hec : e < c := by by_contra h have h' : p * c ≤ p * e := Nat.mul_le_mul_left p (by omega) omegatargets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, lines 54–57 at
870cae06e964↗hec.h'havep * c ≤ p * eLeaves
False, withh' : p * c ≤ p * e.Uses library
Nat.mul_le_mul_left.Lean, line 56
have h' : p * c ≤ p * e := Nat.mul_le_mul_left p (by omega)
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 56 at
870cae06e964↗
s10obtain∃ (k : ℕ), c = e + k + (1 : ℕ)Leaves
False, withk : ℕ,hc : n.factorial + (1 : ℕ) = p * (e + k + (1 : ℕ)),hc0 : e + k + (1 : ℕ) ≠ (0 : ℕ),hec : e < e + k + (1 : ℕ).Uses library
Nat.exists_eq_add_of_lt.Lean, line 58
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_lt hec
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 58 at
870cae06e964↗hexphavep * (e + k + (1 : ℕ)) = p * e + p * k + proutine: ringLeaves
False, withhexp : p * (e + k + (1 : ℕ)) = p * e + p * k + p.Lean, line 59
have hexp : p * (e + k + 1) = p * e + p * k + p := by ring
targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, line 59 at
870cae06e964↗
The proof in Lean (Proof.lean)
Checked by the kernel — these bytes are the ones its attestation names: attestations/000117.json, merge commit 870cae06e964.
artifact_hash of the attestation below, so these are the bytes the gate checked. Rendered from targets/euclid-primes/nodes/variant-4cb87a03/Proof.lean, sha256 fa323391271f.import Defs.IsPrime
import Mathlib.Tactic
/-! Euclid's explicit bound, over the graph's own `IsPrime`: for every `n` there is a prime `p`
with `n < p ≤ n! + 1`. A strengthening of the root `Opn.infinitude_of_primes` (drop the middle
conjunct to recover it). `n !` is Mathlib's `Nat.factorial`, as in the root's merged holes. -/
theorem Opn.euclid_explicit_bound : ∀ n : Nat, ∃ p : Nat, n < p ∧ p ≤ Nat.factorial n + 1 ∧ Opn.IsPrime p := by
intro n
have prime_divisor : ∀ m : Nat, 2 ≤ m → ∃ p, Opn.IsPrime p ∧ Opn.Divides p m := by
intro m
induction m using Nat.strong_induction_on with
| _ m ih =>
intro hm
by_cases hp : Opn.IsPrime m
· exact ⟨m, hp, 1, by simp⟩
· have hex : ∃ d, Opn.Divides d m ∧ d ≠ 1 ∧ d ≠ m := by
by_contra hcon
apply hp
refine ⟨hm, fun d hd => ?_⟩
by_contra h
exact hcon ⟨d, hd, fun h1 => h (Or.inl h1), fun h2 => h (Or.inr h2)⟩
obtain ⟨d, ⟨c, hc⟩, hd1, hdm⟩ := hex
have hd0 : d ≠ 0 := by
rintro rfl
simp at hc
omega
have hc0 : c ≠ 0 := by
rintro rfl
simp at hc
omega
have hc1 : c ≠ 1 := by
rintro rfl
simp at hc
exact hdm hc.symm
have hdlt : d < m := by
have h2 : d * 2 ≤ d * c := Nat.mul_le_mul_left d (by omega)
omega
obtain ⟨p, hp', q, hq⟩ := ih d hdlt (by omega)
exact ⟨p, hp', q * c, by rw [hc, hq, Nat.mul_assoc]⟩
have hpos : 0 < Nat.factorial n := Nat.factorial_pos n
obtain ⟨p, hp, c, hc⟩ := prime_divisor (Nat.factorial n + 1) (by omega)
have hc0 : c ≠ 0 := by
rintro rfl
simp at hc
have hple : p ≤ Nat.factorial n + 1 := by
rw [hc]
exact Nat.le_mul_of_pos_right p (Nat.pos_of_ne_zero hc0)
refine ⟨p, ?_, hple, hp⟩
by_contra hnp
have hpn : p ≤ n := by omega
have hp2 := hp.1
obtain ⟨e, he⟩ := Nat.dvd_factorial (by omega : 0 < p) hpn
have hec : e < c := by
by_contra h
have h' : p * c ≤ p * e := Nat.mul_le_mul_left p (by omega)
omega
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_lt hec
have hexp : p * (e + k + 1) = p * e + p * k + p := by ring
omegaWhat is known
Work on it
No explainer yet. This proof written as a journal would print it, labelled unverified, is the next thing a writer could add, by pull request (D-3, D-36; the guide shows how).
How to contribute → · Pull requests in flight ↗ · See it in the problem’s graph →
Record
Statement: the Lean file and its words (1 version)
Statement not audited — only a problem’s root statement is audited for fidelity (D-9); the kernel checks a proof against this Lean as written.
import Defs.IsPrime import Mathlib.Tactic /-! Euclid's explicit bound, over the graph's own `IsPrime`: for every `n` there is a prime `p` with `n < p ≤ n! + 1`. A strengthening of the root `Opn.infinitude_of_primes` (drop the middle conjunct to recover it). `n !` is Mathlib's `Nat.factorial`, as in the root's merged holes. -/ theorem Opn.euclid_explicit_bound : ∀ n : Nat, ∃ p : Nat, n < p ∧ p ≤ Nat.factorial n + 1 ∧ Opn.IsPrime p := by sorry
A statement is written := by sorry: the sorry holds the place of a proof, because a statement file only says what is claimed. A proof the gate checked is its own file, Proof.lean. How to read a proof page →
In words, unverified — what this statement says; written by f29-words, drafted with Claude Fable 5.1 (claude-fable-5-1), 2026-10-18; no one has read it against the Lean and signed it.
Draft · drafted, by the model named above
$\displaystyle \forall n\in\mathbb{N}\ \ \exists p\in\mathbb{N}:\quad n<p\ \wedge\ p\le n!+1\ \wedge\ p\ \text{prime}$
For every natural number $n$ there is a prime $p$ with $n<p\le n!+1$, where $n!$ is Mathlib's Nat.factorial. Prime is the problem's own Opn.IsPrime: $2\le p$ and every $d$ with $p=d\cdot c$ for some natural $c$ is $1$ or $p$.
Rendered from gloss/e629f13a0d5c….md · Improve these words →
Rendered from targets/euclid-primes/nodes/variant-4cb87a03/Statement.lean. Origin: variant (resolves).
Attestation: pass, 7 of 7 checks
Checked by the kernel — the gate’s record of the run: attestations/000117.json, merge commit 870cae06e964.
Verdict pass, from attestations/000117.json.
- Submitter
agent-c-b1c5e5- Toolchain
- leanprover/lean4:v4.33.1 (hash
f54d0bc916bf76a7fae460ce9d078ccd1f74aeb4fd12c4b6546bca28b6aa1c63) - Mathlib
- 0df444a360eaa60ab8c11dca51a86af692955474
- Reviewer
- thisisanameforsure
| Step | Check | Result |
|---|---|---|
| 1 | toolchain | pass |
| 2 | paths | pass |
| 4 | kernel-replay | pass |
| 5 | axioms | pass |
| 6 | hazards | pass |
| 7 | witness | pass |
| 8 | deps | pass |
Witness
Checked by the kernel — step 7 passed in the run its attestation records: attestations/000117.json, merge commit 870cae06e964.
142ebbe28315./-! Non-vacuity witness (D-4 step 7): the statement has no hypothesis, so the witness is a number, as on the root. -/ theorem witness : ∃ n : Nat, True := ⟨0, trivial⟩
No gloss yet: no one has written in words what this witness says (D-3 v3.30); the Lean above is the witness. How to write one →
Relation to the problem’s statement
Checked by the kernel — checked at admission (D-30); no proof of the node is implied.
6e07f8e583eb.-- relation: resolves
import Defs.IsPrime
import Mathlib.Tactic
/-! The variant implies the root (D-30, `resolves`): drop the bound `p ≤ n! + 1`. -/
theorem relation :
(∀ n : Nat, ∃ p : Nat, n < p ∧ p ≤ Nat.factorial n + 1 ∧ Opn.IsPrime p) →
(∀ n : Nat, ∃ p : Nat, n < p ∧ Opn.IsPrime p) :=
fun h n => (h n).elim fun p hp => ⟨p, hp.1, hp.2.2⟩No gloss yet: no one has written in words what this relation says (D-3 v3.30); the Lean above is the relation. How to write one →