Stafford38/Geometry/FiniteBirationalAway.lean

This project (Stafford38) · 1029fdb382eee06e7b59bcf32801f40931e2079a

1 module
2 public import Mathlib.RingTheory.Localization.Integer
3 public import Mathlib.RingTheory.Localization.Away.Basic
4 public import Mathlib.RingTheory.Localization.FractionRing
5 public import Mathlib.RingTheory.Finiteness.Cardinality
6 
7 @[expose] public section
8 
9 set_option autoImplicit false
10 set_option maxHeartbeats 500000
11 
12 noncomputable section
13 
14 namespace Stafford38.Geometry.FiniteBirationalAway
15 
16 universe u v w
17 
18 /-- A finite birational algebra becomes the original domain after inverting
19 one nonzero element.  The common denominator is chosen for a finite module
20 generating family, then linearity gives the localization map's surjectivity. -/
21 theorem exists_nonzero_away_equiv_of_finite
22     {Q : Type u} [CommRing Q] [IsDomain Q]
23     {F : Type v} [Field F] [Algebra Q F] [IsFractionRing Q F]
24     {B : Type w} [CommRing B] [Algebra Q B] [Algebra B F]
25     [IsScalarTower Q B F] [Module.Finite Q B]
26     (hinj : Function.Injective (algebraMap B F)) :
27     ∃ f : Q, f ≠ 0 ∧
28       Nonempty (Localization.Away f ≃ₐ[Q]
29         Localization.Away (algebraMap Q B f)) := by
30   obtain ⟨n, gen, hgen⟩ := Module.Finite.exists_fin (R := Q) (M := B)
31   obtain ⟨f₀, hf₀⟩ :=
32     IsLocalization.exist_integer_multiples_of_finite
33       (M := nonZeroDivisors Q) (fun i : Fin n => algebraMap B F (gen i))
34   let f : Q := f₀
35   have hf : f ≠ 0 := by
36     exact nonZeroDivisors.ne_zero f₀.property
37   let p : Submodule Q B :=
38     { carrier := {x | ∃ q : Q, algebraMap Q B q = algebraMap Q B f * x}
39       zero_mem' := ⟨0, by simp⟩
40       add_mem' := by
41         intro x y hx hy
42         rcases hx with ⟨q, hq⟩
43         rcases hy with ⟨r, hr⟩
44         refine ⟨q + r, ?_⟩
45         rw [map_add, hq, hr, mul_add]
46       smul_mem' := by
47         intro a x hx
48         rcases hx with ⟨q, hq⟩
49         refine ⟨a * q, ?_⟩
50         rw [map_mul, hq, Algebra.smul_def]
51         ring }
52   have hgen_mem : ∀ i : Fin n, gen i ∈ p := by
53     intro i
54     obtain ⟨q, hq⟩ := hf₀ i
55     have hqF : algebraMap Q F q =
56         algebraMap Q F f * algebraMap B F (gen i) := by
57       simpa [f, Algebra.smul_def] using hq
58     have hqB : algebraMap B F (algebraMap Q B q) =
59         algebraMap B F (algebraMap Q B f * gen i) := by
60       calc
61         algebraMap B F (algebraMap Q B q) = algebraMap Q F q :=
62           (IsScalarTower.algebraMap_apply Q B F q).symm
63         _ = algebraMap Q F f * algebraMap B F (gen i) := hqF
64         _ = algebraMap B F (algebraMap Q B f * gen i) := by
65           rw [map_mul, IsScalarTower.algebraMap_apply Q B F f]
66     exact ⟨q, hinj hqB⟩
67   have hp : (⊤ : Submodule Q B) ≤ p := by
68     rw [← hgen]
69     apply Submodule.span_le.2
70     rintro x ⟨i, rfl⟩
71     exact hgen_mem i
72   have hclear : ∀ x : B, ∃ q : Q,
73       algebraMap Q B q = algebraMap Q B f * x := by
74     intro x
75     have hx : x ∈ p := hp (Submodule.mem_top)
76     exact hx
77   have hQB : Function.Injective (algebraMap Q B) := by
78     intro x y hxy
79     exact IsFractionRing.injective Q F <| by
80       calc
81         algebraMap Q F x = algebraMap B F (algebraMap Q B x) :=
82           IsScalarTower.algebraMap_apply Q B F x
83         _ = algebraMap B F (algebraMap Q B y) := congrArg (algebraMap B F) hxy
84         _ = algebraMap Q F y := (IsScalarTower.algebraMap_apply Q B F y).symm
85   have hmap_injective :
86       Function.Injective (Localization.awayMap (algebraMap Q B) f) := by
87     rw [Localization.awayMap_injective_iff]
88     intro x hx
89     have hx0 : x = 0 := hQB (by simpa using hx)
90     exact ⟨0, by simp [hx0]⟩
91   have hmap_surjective :
92       Function.Surjective (Localization.awayMap (algebraMap Q B) f) := by
93     rw [Localization.awayMap_surjective_iff]
94     intro x
95     obtain ⟨q, hq⟩ := hclear x
96     exact ⟨q, 1, by simpa using hq⟩
97   refine ⟨f, hf, ?_⟩
98   exact ⟨AlgEquiv.ofBijective
99     (Localization.awayMapₐ (Algebra.ofId Q B) f)
100     ⟨hmap_injective, hmap_surjective⟩⟩
101 
102 end Stafford38.Geometry.FiniteBirationalAway
103