Stafford38/Geometry/PaperUnitPowerFactorization.lean

This project (Stafford38) · 1029fdb382eee06e7b59bcf32801f40931e2079a

1 module
2 public import Mathlib.RingTheory.Localization.AtPrime.Basic
3 public import Mathlib.RingTheory.Localization.Away.Basic
4 
5 @[expose] public section
6 
7 set_option autoImplicit false
8 
9 noncomputable section
10 
11 namespace Stafford38.Geometry.PaperUnitPowerFactorization
12 
13 private theorem exists_unit_factorization_atPrime
14     {B : Type*} [CommRing B] [IsDomain B]
15     (P : Ideal B) [P.IsPrime] (s q : B) (e : ℕ)
16     (u : Localization.AtPrime P) (hu : IsUnit u)
17     (hq : algebraMap B (Localization.AtPrime P) q =
18       (algebraMap B (Localization.AtPrime P) s) ^ e * u) :
19     ∃ d n : B, d ∉ P ∧ n ∉ P ∧ q * d = s ^ e * n := by
20   let V := Localization.AtPrime P
21   obtain ⟨⟨n, d⟩, hd⟩ := IsLocalization.surj (M := P.primeCompl) u
22   have hrepr : u * algebraMap B V (d : B) = algebraMap B V n := hd
23   have hdunit : IsUnit (algebraMap B V (d : B)) := IsLocalization.map_units V d
24   have hnunit : IsUnit (algebraMap B V n) := by
25     rw [← hrepr]
26     exact hu.mul hdunit
27   have hdnot : (d : B) ∉ P := d.2
28   have hnnot : n ∉ P := by
29     have hnmem : n ∈ P.primeCompl :=
30       (IsLocalization.AtPrime.isUnit_to_map_iff V P n).mp hnunit
31     exact hnmem
32   have hloc : algebraMap B V (q * d) = algebraMap B V (s ^ e * n) := by
33     calc
34       algebraMap B V (q * (d : B)) = algebraMap B V q * algebraMap B V (d : B) := map_mul _ _ _
35       _ = ((algebraMap B V s) ^ e * u) * algebraMap B V (d : B) := by rw [hq]
36       _ = (algebraMap B V s) ^ e * algebraMap B V n := by rw [mul_assoc, hrepr]
37       _ = algebraMap B V (s ^ e * n) := by simp [map_mul, map_pow]
38   have hinj : Function.Injective (algebraMap B V) :=
39     IsLocalization.injective V P.primeCompl_le_nonZeroDivisors
40   refine ⟨d, n, hdnot, hnnot, ?_⟩
41   exact hinj hloc
42 
43 /-- A unit-power factorization at `B_P` can be cleared to elements outside `P`.
44 After multiplying the four numerator/denominator elements, one principal open
45 simultaneously makes both residual factors units while preserving the original
46 `B`-coordinates. -/
47 theorem exists_common_away_unit_power_factorizations
48     {B : Type*} [CommRing B] [IsDomain B]
49     (P : Ideal B) [hp : P.IsPrime] (s q₀ q₁ : B) (a b : ℕ)
50     (u₀ u₁ : Localization.AtPrime P)
51     (hu₀ : IsUnit u₀) (hu₁ : IsUnit u₁)
52     (h₀ : algebraMap B (Localization.AtPrime P) q₀ =
53       (algebraMap B (Localization.AtPrime P) s) ^ a * u₀)
54     (h₁ : algebraMap B (Localization.AtPrime P) q₁ =
55       (algebraMap B (Localization.AtPrime P) s) ^ b * u₁) :
56     ∃ d₀ n₀ d₁ n₁ f : B,
57       d₀ ∉ P ∧ n₀ ∉ P ∧ d₁ ∉ P ∧ n₁ ∉ P ∧ f ∉ P ∧
58       q₀ * d₀ = s ^ a * n₀ ∧ q₁ * d₁ = s ^ b * n₁ ∧
59       ∃ v₀ v₁ : Localization.Away f,
60         IsUnit v₀ ∧ IsUnit v₁ ∧
61         algebraMap B (Localization.Away f) q₀ =
62           (algebraMap B (Localization.Away f) s) ^ a * v₀ ∧
63         algebraMap B (Localization.Away f) q₁ =
64           (algebraMap B (Localization.Away f) s) ^ b * v₁ := by
65   obtain ⟨d₀, n₀, hd₀, hn₀, hq₀⟩ :=
66     exists_unit_factorization_atPrime P s q₀ a u₀ hu₀ h₀
67   obtain ⟨d₁, n₁, hd₁, hn₁, hq₁⟩ :=
68     exists_unit_factorization_atPrime P s q₁ b u₁ hu₁ h₁
69   let f : B := (d₀ * n₀) * (d₁ * n₁)
70   have hf : f ∉ P := by
71     dsimp [f]
72     exact hp.mul_notMem (hp.mul_notMem hd₀ hn₀)
73       (hp.mul_notMem hd₁ hn₁)
74   let W := Localization.Away f
75   have hfunit : IsUnit (algebraMap B W f) :=
76     IsLocalization.Away.algebraMap_isUnit f
77   have hd₀dvd : d₀ ∣ f := ⟨n₀ * (d₁ * n₁), by dsimp [f]; ac_rfl⟩
78   have hn₀dvd : n₀ ∣ f := ⟨d₀ * (d₁ * n₁), by dsimp [f]; ac_rfl⟩
79   have hd₁dvd : d₁ ∣ f := ⟨d₀ * n₀ * n₁, by dsimp [f]; ac_rfl⟩
80   have hn₁dvd : n₁ ∣ f := ⟨d₀ * n₀ * d₁, by dsimp [f]; ac_rfl⟩
81   have hd₀unit : IsUnit (algebraMap B W d₀) :=
82     isUnit_of_dvd_unit (map_dvd (algebraMap B W) hd₀dvd) hfunit
83   have hn₀unit : IsUnit (algebraMap B W n₀) :=
84     isUnit_of_dvd_unit (map_dvd (algebraMap B W) hn₀dvd) hfunit
85   have hd₁unit : IsUnit (algebraMap B W d₁) :=
86     isUnit_of_dvd_unit (map_dvd (algebraMap B W) hd₁dvd) hfunit
87   have hn₁unit : IsUnit (algebraMap B W n₁) :=
88     isUnit_of_dvd_unit (map_dvd (algebraMap B W) hn₁dvd) hfunit
89   let v₀ : W := ↑(hn₀unit.unit * hd₀unit.unit⁻¹)
90   let v₁ : W := ↑(hn₁unit.unit * hd₁unit.unit⁻¹)
91   have hv₀ : IsUnit v₀ := by
92     exact (hn₀unit.unit * hd₀unit.unit⁻¹).isUnit
93   have hv₁ : IsUnit v₁ := by
94     exact (hn₁unit.unit * hd₁unit.unit⁻¹).isUnit
95   have hq₀W : algebraMap B W q₀ * algebraMap B W d₀ =
96       (algebraMap B W s) ^ a * algebraMap B W n₀ := by
97     simpa [map_mul, map_pow] using congrArg (algebraMap B W) hq₀
98   have hq₁W : algebraMap B W q₁ * algebraMap B W d₁ =
99       (algebraMap B W s) ^ b * algebraMap B W n₁ := by
100     simpa [map_mul, map_pow] using congrArg (algebraMap B W) hq₁
101   have hunitratio₀ : algebraMap B W n₀ * ↑(hd₀unit.unit⁻¹) =
102       ↑(hn₀unit.unit * hd₀unit.unit⁻¹) := by
103     calc
104       algebraMap B W n₀ * ↑(hd₀unit.unit⁻¹) =
105           ↑hn₀unit.unit * ↑(hd₀unit.unit⁻¹) :=
106         congrArg (fun z : W => z * ↑(hd₀unit.unit⁻¹)) hn₀unit.unit_spec.symm
107       _ = ↑(hn₀unit.unit * hd₀unit.unit⁻¹) := by rw [Units.val_mul]
108   have hunitratio₁ : algebraMap B W n₁ * ↑(hd₁unit.unit⁻¹) =
109       ↑(hn₁unit.unit * hd₁unit.unit⁻¹) := by
110     calc
111       algebraMap B W n₁ * ↑(hd₁unit.unit⁻¹) =
112           ↑hn₁unit.unit * ↑(hd₁unit.unit⁻¹) :=
113         congrArg (fun z : W => z * ↑(hd₁unit.unit⁻¹)) hn₁unit.unit_spec.symm
114       _ = ↑(hn₁unit.unit * hd₁unit.unit⁻¹) := by rw [Units.val_mul]
115   have hfactor₀ : algebraMap B W q₀ = (algebraMap B W s) ^ a * v₀ := by
116     dsimp [v₀]
117     calc
118       algebraMap B W q₀ = algebraMap B W q₀ *
119           (algebraMap B W d₀ * ↑(hd₀unit.unit⁻¹)) := by
120         rw [hd₀unit.mul_val_inv, mul_one]
121       _ = (algebraMap B W q₀ * algebraMap B W d₀) *
122           ↑(hd₀unit.unit⁻¹) := by rw [← mul_assoc]
123       _ = ((algebraMap B W s) ^ a * algebraMap B W n₀) *
124           ↑(hd₀unit.unit⁻¹) := by rw [hq₀W]
125       _ = (algebraMap B W s) ^ a *
126           (algebraMap B W n₀ * ↑(hd₀unit.unit⁻¹)) := by rw [mul_assoc]
127       _ = (algebraMap B W s) ^ a * ↑(hn₀unit.unit * hd₀unit.unit⁻¹) := by
128           rw [hunitratio₀]
129   have hfactor₁ : algebraMap B W q₁ = (algebraMap B W s) ^ b * v₁ := by
130     dsimp [v₁]
131     calc
132       algebraMap B W q₁ = algebraMap B W q₁ *
133           (algebraMap B W d₁ * ↑(hd₁unit.unit⁻¹)) := by
134         rw [hd₁unit.mul_val_inv, mul_one]
135       _ = (algebraMap B W q₁ * algebraMap B W d₁) *
136           ↑(hd₁unit.unit⁻¹) := by rw [← mul_assoc]
137       _ = ((algebraMap B W s) ^ b * algebraMap B W n₁) *
138           ↑(hd₁unit.unit⁻¹) := by rw [hq₁W]
139       _ = (algebraMap B W s) ^ b *
140           (algebraMap B W n₁ * ↑(hd₁unit.unit⁻¹)) := by rw [mul_assoc]
141       _ = (algebraMap B W s) ^ b * ↑(hn₁unit.unit * hd₁unit.unit⁻¹) := by
142           rw [hunitratio₁]
143   exact ⟨d₀, n₀, d₁, n₁, f, hd₀, hn₀, hd₁, hn₁, hf, hq₀, hq₁,
144     v₀, v₁, hv₀, hv₁, hfactor₀, hfactor₁⟩
145 
146 
147 end Stafford38.Geometry.PaperUnitPowerFactorization
148