Dataset Viewer
Auto-converted to Parquet Duplicate
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


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: m2=2n2m^2 = 2n^2 Because 2 is prime, $2 \mid m^2 \implies 2 \mid m$. Substituting $m = 2k$: 4k2=2n2β€…β€ŠβŸΉβ€…β€Šn2=2k24k^2 = 2n^2 \implies n^2 = 2k^2 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):

  1. 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.
  2. Foldable Proofs: Click the toggle beside any theorem (e.g. sqrt_two_irrational or sqrt_prime_irrational) to unfold and inspect the underlying tactic proof.
  3. Outline Sidebar: Jump directly to lemmas, main theorems, and open challenges.
  4. Open Challenges / Unfinished Proofs: Uses sorry in sqrt_two_irrational_real to demonstrate the red badge indicator for open milestones.
  5. Full Code Switcher: Click Full in the header or append ?code=true to 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

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