Skip to content

Commit a807326

Browse files
committed
refactor: use Algebra.FiniteType as a class (#27030)
Assumptions are currently being passed explicitly, which is quite odd. Also generalise the ~lemmas~ instances about `Polynomial`, `MvPolynomial`, etc... to be about two rings instead of one. From Toric
1 parent 9067089 commit a807326

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed

Mathlib/RingTheory/AdjoinRoot.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ theorem algebraMap_eq' [CommSemiring S] [Algebra S R] :
150150
rfl
151151

152152
theorem finiteType : Algebra.FiniteType R (AdjoinRoot f) :=
153-
(Algebra.FiniteType.polynomial R).of_surjective _ (Ideal.Quotient.mkₐ_surjective R _)
153+
.of_surjective _ (Ideal.Quotient.mkₐ_surjective R _)
154154

155155
theorem finitePresentation : Algebra.FinitePresentation R (AdjoinRoot f) :=
156156
(Algebra.FinitePresentation.polynomial R).quotient (Submodule.fg_span_singleton f)

Mathlib/RingTheory/Extension/Cotangent/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ open KaehlerDifferential in
438438
attribute [local instance] Module.finitePresentation_of_projective in
439439
instance [Algebra.FinitePresentation R S] : Module.FinitePresentation S Ω[S⁄R] := by
440440
let P := Algebra.Presentation.ofFinitePresentation R S
441-
have : Algebra.FiniteType R P.toExtension.Ring := .mvPolynomial _ _
441+
have : Algebra.FiniteType R P.toExtension.Ring := by simp [P]; infer_instance
442442
refine Module.finitePresentation_of_surjective _ P.toExtension.toKaehler_surjective ?_
443443
rw [LinearMap.exact_iff.mp P.toExtension.exact_cotangentComplex_toKaehler, ← Submodule.map_top]
444444
exact (Extension.Cotangent.finite P.fg_ker).1.map P.toExtension.cotangentComplex
@@ -504,7 +504,7 @@ attribute [local instance] Module.finitePresentation_of_projective in
504504
instance [FinitePresentation R S] [Module.Projective S Ω[S⁄R]] :
505505
Module.Finite S (H1Cotangent R S) := by
506506
let P := Algebra.Presentation.ofFinitePresentation R S
507-
have : Algebra.FiniteType R P.toExtension.Ring := FiniteType.mvPolynomial R _
507+
have : Algebra.FiniteType R P.toExtension.Ring := by simp [P]; infer_instance
508508
suffices Module.Finite S P.toExtension.H1Cotangent from
509509
.of_surjective P.equivH1Cotangent.toLinearMap P.equivH1Cotangent.surjective
510510
rw [Module.finite_def, Submodule.fg_top, ← LinearMap.ker_rangeRestrict]

Mathlib/RingTheory/FiniteType.lean

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,8 @@ variable [AddCommMonoid N] [Module R N]
6767

6868
namespace FiniteType
6969

70-
theorem self : FiniteType R R :=
71-
⟨⟨{1}, Subsingleton.elim _ _⟩⟩
72-
73-
protected theorem polynomial : FiniteType R R[X] :=
74-
⟨⟨{Polynomial.X}, by
75-
rw [Finset.coe_singleton]
76-
exact Polynomial.adjoin_X⟩⟩
77-
78-
79-
protected theorem freeAlgebra (ι : Type*) [Finite ι] : FiniteType R (FreeAlgebra R ι) := by
80-
cases nonempty_fintype ι
81-
classical
82-
exact
83-
⟨⟨Finset.univ.image (FreeAlgebra.ι R), by
84-
rw [Finset.coe_image, Finset.coe_univ, Set.image_univ]
85-
exact FreeAlgebra.adjoin_range_ι R ι⟩⟩
86-
87-
protected theorem mvPolynomial (ι : Type*) [Finite ι] : FiniteType R (MvPolynomial ι R) := by
88-
cases nonempty_fintype ι
89-
classical
90-
exact
91-
⟨⟨Finset.univ.image MvPolynomial.X, by
92-
rw [Finset.coe_image, Finset.coe_univ, Set.image_univ]
93-
exact MvPolynomial.adjoin_range_X⟩⟩
70+
@[deprecated inferInstance (since := "2025-07-12")]
71+
theorem self : FiniteType R R := inferInstance
9472

9573
theorem of_restrictScalars_finiteType [Algebra S A] [IsScalarTower R S A] [hA : FiniteType R A] :
9674
FiniteType S A := by
@@ -104,9 +82,9 @@ theorem of_restrictScalars_finiteType [Algebra S A] [IsScalarTower R S A] [hA :
10482

10583
variable {R S A B}
10684

107-
theorem of_surjective (hRA : FiniteType R A) (f : A →ₐ[R] B) (hf : Surjective f) : FiniteType R B :=
85+
theorem of_surjective [FiniteType R A] (f : A →ₐ[R] B) (hf : Surjective f) : FiniteType R B :=
10886
by
109-
convert hRA.1.map f
87+
convert ‹FiniteType R A›.1.map f
11088
simpa only [map_top f, @eq_comm _ ⊤, eq_top_iff, AlgHom.mem_range] using hf⟩
11189

11290
theorem equiv (hRA : FiniteType R A) (e : A ≃ₐ[R] B) : FiniteType R B :=
@@ -120,6 +98,36 @@ instance quotient (R : Type*) {S : Type*} [CommSemiring R] [CommRing S] [Algebra
12098
[h : Algebra.FiniteType R S] : Algebra.FiniteType R (S ⧸ I) :=
12199
Algebra.FiniteType.trans h inferInstance
122100

101+
instance [FiniteType R S] : FiniteType R S[X] := by
102+
refine .trans ‹_› ⟨{Polynomial.X}, ?_⟩
103+
rw [Finset.coe_singleton]
104+
exact Polynomial.adjoin_X
105+
106+
@[deprecated inferInstance (since := "2025-07-12")]
107+
protected theorem polynomial : FiniteType R R[X] := inferInstance
108+
109+
instance {ι : Type*} [Finite ι] [FiniteType R S] : FiniteType R (MvPolynomial ι S) := by
110+
classical
111+
cases nonempty_fintype ι
112+
refine .trans ‹_› ⟨Finset.univ.image MvPolynomial.X, ?_⟩
113+
rw [Finset.coe_image, Finset.coe_univ, Set.image_univ]
114+
exact MvPolynomial.adjoin_range_X
115+
116+
@[deprecated inferInstance (since := "2025-07-12")]
117+
protected theorem mvPolynomial (ι : Type*) [Finite ι] : FiniteType R (MvPolynomial ι R) :=
118+
inferInstance
119+
120+
instance {ι : Type*} [Finite ι] [FiniteType R S] : FiniteType R (FreeAlgebra S ι) := by
121+
classical
122+
cases nonempty_fintype ι
123+
refine .trans ‹_› ⟨Finset.univ.image (FreeAlgebra.ι _), ?_⟩
124+
rw [Finset.coe_image, Finset.coe_univ, Set.image_univ]
125+
exact FreeAlgebra.adjoin_range_ι ..
126+
127+
@[deprecated inferInstance (since := "2025-07-12")]
128+
protected theorem freeAlgebra (ι : Type*) [Finite ι] : FiniteType R (FreeAlgebra R ι) :=
129+
inferInstance
130+
123131
/-- An algebra is finitely generated if and only if it is a quotient
124132
of a free algebra whose variables are indexed by a finset. -/
125133
theorem iff_quotient_freeAlgebra :
@@ -130,8 +138,8 @@ theorem iff_quotient_freeAlgebra :
130138
refine ⟨s, FreeAlgebra.lift _ (↑), ?_⟩
131139
rw [← Set.range_eq_univ, ← AlgHom.coe_range, ← adjoin_range_eq_range_freeAlgebra_lift,
132140
Subtype.range_coe_subtype, Finset.setOf_mem, hs, coe_top]
133-
· rintro ⟨s, f, hsur
134-
exact FiniteType.of_surjective (FiniteType.freeAlgebra R s) f hsur
141+
· rintro ⟨s, f, hsur⟩
142+
exact .of_surjective f hsur
135143

136144
/-- A commutative algebra is finitely generated if and only if it is a quotient
137145
of a polynomial ring whose variables are indexed by a finset. -/
@@ -146,44 +154,44 @@ theorem iff_quotient_mvPolynomial :
146154
rw [← Set.mem_range, ← AlgHom.coe_range, ← adjoin_eq_range]
147155
simp_rw [← hrw, hs]
148156
exact Set.mem_univ x
149-
· rintro ⟨s, f, hsur
150-
exact FiniteType.of_surjective (FiniteType.mvPolynomial R { x // x ∈ s }) f hsur
157+
· rintro ⟨s, f, hsur⟩
158+
exact .of_surjective f hsur
151159

152160
/-- An algebra is finitely generated if and only if it is a quotient
153161
of a polynomial ring whose variables are indexed by a fintype. -/
154162
theorem iff_quotient_freeAlgebra' : FiniteType R A ↔
155163
∃ (ι : Type uA) (_ : Fintype ι) (f : FreeAlgebra R ι →ₐ[R] A), Surjective f := by
156164
constructor
157165
· rw [iff_quotient_freeAlgebra]
158-
rintro ⟨s, f, hsur
166+
rintro ⟨s, f, hsur⟩
159167
use { x : A // x ∈ s }, inferInstance, f
160-
· rintro ⟨ι, hfintype, f, hsur⟩⟩
168+
· rintro ⟨ι, hfintype, f, hsur⟩
161169
letI : Fintype ι := hfintype
162-
exact FiniteType.of_surjective (FiniteType.freeAlgebra R ι) f hsur
170+
exact .of_surjective f hsur
163171

164172
/-- A commutative algebra is finitely generated if and only if it is a quotient
165173
of a polynomial ring whose variables are indexed by a fintype. -/
166174
theorem iff_quotient_mvPolynomial' : FiniteType R S ↔
167175
∃ (ι : Type uS) (_ : Fintype ι) (f : MvPolynomial ι R →ₐ[R] S), Surjective f := by
168176
constructor
169177
· rw [iff_quotient_mvPolynomial]
170-
rintro ⟨s, f, hsur
178+
rintro ⟨s, f, hsur⟩
171179
use { x : S // x ∈ s }, inferInstance, f
172-
· rintro ⟨ι, hfintype, f, hsur⟩⟩
180+
· rintro ⟨ι, hfintype, f, hsur⟩
173181
letI : Fintype ι := hfintype
174-
exact FiniteType.of_surjective (FiniteType.mvPolynomial R ι) f hsur
182+
exact .of_surjective f hsur
175183

176184
/-- A commutative algebra is finitely generated if and only if it is a quotient of a polynomial ring
177185
in `n` variables. -/
178186
theorem iff_quotient_mvPolynomial'' :
179187
FiniteType R S ↔ ∃ (n : ℕ) (f : MvPolynomial (Fin n) R →ₐ[R] S), Surjective f := by
180188
constructor
181189
· rw [iff_quotient_mvPolynomial']
182-
rintro ⟨ι, hfintype, f, hsur
190+
rintro ⟨ι, hfintype, f, hsur⟩
183191
have equiv := MvPolynomial.renameEquiv R (Fintype.equivFin ι)
184192
exact ⟨Fintype.card ι, AlgHom.comp f equiv.symm.toAlgHom, by simpa using hsur⟩
185-
· rintro ⟨n, f, hsur
186-
exact FiniteType.of_surjective (FiniteType.mvPolynomial R (Fin n)) f hsur
193+
· rintro ⟨n, f, hsur⟩
194+
exact .of_surjective f hsur
187195

188196
instance prod [hA : FiniteType R A] [hB : FiniteType R B] : FiniteType R (A × B) :=
189197
by rw [← Subalgebra.prod_top]; exact hA.1.prod hB.1
@@ -232,13 +240,12 @@ end Finite
232240
namespace FiniteType
233241

234242
variable (A) in
235-
theorem id : FiniteType (RingHom.id A) :=
236-
Algebra.FiniteType.self A
243+
theorem id : FiniteType (RingHom.id A) := by simp [FiniteType]; infer_instance
237244

238245
theorem comp_surjective {f : A →+* B} {g : B →+* C} (hf : f.FiniteType) (hg : Surjective g) :
239246
(g.comp f).FiniteType := by
240247
algebraize_only [f, g.comp f]
241-
exact Algebra.FiniteType.of_surjective hf
248+
exact Algebra.FiniteType _ _›.of_surjective
242249
{ g with
243250
toFun := g
244251
commutes' := fun a => rfl }
@@ -469,7 +476,7 @@ type. -/
469476
instance finiteType_of_fg [CommRing R] [h : AddMonoid.FG M] :
470477
FiniteType R R[M] := by
471478
obtain ⟨S, hS⟩ := h.fg_top
472-
exact (FiniteType.freeAlgebra R (S : Set M)).of_surjective
479+
exact .of_surjective
473480
(FreeAlgebra.lift R fun s : (S : Set M) => of' R M ↑s)
474481
(freeAlgebra_lift_of_surjective_of_closure hS)
475482

0 commit comments

Comments
 (0)