name stringclasses 4
values | kind stringclasses 1
value | type stringclasses 4
values | docstring stringclasses 4
values | proof stringclasses 4
values | has_sorry bool 2
classes |
|---|---|---|---|---|---|
even_of_even_sqr | theorem | {m : β} (h : 2 β£ m ^ 2) : 2 β£ m | Helper lemma: If $2 \mid m^2$, then $2 \mid m$. | rw [pow_two, Nat.prime_two.dvd_mul] at h
cases h <;> assumption | false |
sqrt_two_irrational | theorem | {m n : β} (coprime_mn : m.Coprime n) : m ^ 2 β 2 * n ^ 2 | Main Theorem: For any coprime natural numbers $m, n$, $m^2 \neq 2n^2$. | intro sqr_eq
have : 2 β£ m := by
apply even_of_even_sqr
rw [sqr_eq]
apply dvd_mul_right
obtain β¨k, meqβ© := dvd_iff_exists_eq_mul_left.mp this
have : 2 * (2 * k ^ 2) = 2 * n ^ 2 := by
rw [β sqr_eq, meq]
ring
have : 2 * k ^ 2 = n ^ 2 :=
(mul_right_inj' (by norm_num)).mp this
have : 2 β£ n := by
apply even_of_... | false |
sqrt_prime_irrational | theorem | {m n p : β} (coprime_mn : m.Coprime n) (prime_p : p.Prime) : m ^ 2 β p * n ^ 2 | Generalization to any prime $p$: $m^2 \neq p n^2$ for coprime $m, n$. | intro sqr_eq
have : p β£ m := by
apply prime_p.dvd_of_dvd_pow
rw [sqr_eq]
apply dvd_mul_right
obtain β¨k, meqβ© := dvd_iff_exists_eq_mul_left.mp this
have : p * (p * k ^ 2) = p * n ^ 2 := by
rw [β sqr_eq, meq]
ring
have : p * k ^ 2 = n ^ 2 := by
apply (mul_right_inj' _).mp this
exact prime_p.ne_zero
have : p... | false |
sqrt_two_irrational_real | theorem | Β¬ β (q : β), (q : β) ^ 2 = 2 | Challenge / Open Milestone: Prove irrationality directly over $\mathbb{R}$ using the algebraic definition (demonstrates the red `sorry` badge in Statements view). | sorry | true |
The Irrationality of $\sqrt{2}$ in Lean 4
Formal verification of the irrationality of $\sqrt{2}$, showcasing the Hugging Face Hub Lean 4 Interactive Viewer.
Quick Links
- π Interactive Proof Viewer (
SqrtTwoIrrational.lean) β Explore the proof statements, KaTeX formulas, and folded tactic steps. - π Hugging Face Formal Proofs Documentation β Learn how the Hub natively renders Lean 4
.leanfiles. - π Freek Wiedijk's 100 Greatest Theorems β Theorem #1 in formal mathematics.
Overview
This repository formalizes the classical proof that $\sqrt{2}$ is irrational, commonly known as Theorem #1 on Freek Wiedijk's landmark 100 Greatest Theorems formalization benchmark.
Mathematical Argument
Suppose for contradiction that $\sqrt{2} = \frac{m}{n}$ is rational with $\gcd(m, n) = 1$. Squaring both sides yields: Because 2 is prime, $2 \mid m^2 \implies 2 \mid m$. Substituting $m = 2k$: Thus $2 \mid n^2 \implies 2 \mid n$. Consequently $2 \mid \gcd(m, n) = 1$, which is impossible.
Features Showcased in the Hub Lean Viewer
When viewing SqrtTwoIrrational.lean on the Hugging Face Hub (under Files and versions):
- Statements View: Read mathematical definitions and theorem statements with rich KaTeX math formatting ($a^2 = 2b^2$) without having to scroll through tactical execution steps.
- Foldable Proofs: Click the toggle beside any theorem (e.g.
sqrt_two_irrationalorsqrt_prime_irrational) to unfold and inspect the underlying tactic proof. - Outline Sidebar: Jump directly to lemmas, main theorems, and open challenges.
- Open Challenges / Unfinished Proofs: Uses
sorryinsqrt_two_irrational_realto demonstrate the red badge indicator for open milestones. - Full Code Switcher: Click
Fullin the header or append?code=trueto view the full annotated source with syntax highlighting.
Code Preview
/-- Main Theorem: For any coprime natural numbers $m, n$, $m^2 \neq 2n^2$. -/
theorem sqrt_two_irrational {m n : β} (coprime_mn : m.Coprime n) : m ^ 2 β 2 * n ^ 2 := by
intro sqr_eq
have : 2 β£ m := by
apply even_of_even_sqr
rw [sqr_eq]
apply dvd_mul_right
obtain β¨k, meqβ© := dvd_iff_exists_eq_mul_left.mp this
have : 2 * (2 * k ^ 2) = 2 * n ^ 2 := by
rw [β sqr_eq, meq]
ring
have : 2 * k ^ 2 = n ^ 2 :=
(mul_right_inj' (by norm_num)).mp this
have : 2 β£ n := by
apply even_of_even_sqr
rw [β this]
apply dvd_mul_right
have : 2 β£ m.gcd n := by
apply Nat.dvd_gcd <;> assumption
have : 2 β£ 1 := by
convert this
symm
exact coprime_mn
norm_num at this
Attribution & Citations
Formalization Sources
Mathematics in Lean: The formalization in this repository is adapted from Chapter 5, Section 5.1 (Irrational Roots) of Mathematics in Lean:
Jeremy Avigad, Kevin Buzzard, Robert Y. Lewis, and Patrick Massot.
Mathematics in Lean, Lean Community, 2024.
https://leanprover-community.github.io/mathematics_in_lean/Freek Wiedijk's "Formalizing 100 Theorems":
Freek Wiedijk. Formalizing 100 Theorems. Theorem #1: The Irrationality of $\sqrt{2}$.
https://www.cs.ru.nl/~freek/100/Mathlib 4:
The Lean Community. Mathlib: The Lean mathematical library.
Theoremirrational_sqrt_twoinMathlib.NumberTheory.Real.Irrational.
https://github.com/leanprover-community/mathlib4
Historical References
- Hippasus of Metapontum (~5th c. BCE): Historically credited with the Pythagorean discovery of incommensurable magnitudes (irrational numbers) via geometric reciprocal subtraction (anthyphairesis).
- Aristotle (Prior Analytics, Book I, 23, 41a26β27): Earliest surviving written record of the algebraic even/odd parity proof by contradiction as the classical example of reductio ad absurdum.
- Euclid (Elements, Book X, Proposition 117): Classical Greek codification of the arithmetical proof of incommensurability of the diagonal and side.
Hugging Face Hub Formal Proofs Support
For full details on authoring, formatting KaTeX docstrings, and hosting Lean 4 projects on Hugging Face, see the official documentation at: https://huggingface.co/docs/hub/main/en/formal-proofs.
- Downloads last month
- 30