Skip to content

Commit 988f6f4

Browse files
committed
feat(Algebra): expand Subalgebra.restrictScalars API
1 parent 00dbc4e commit 988f6f4

File tree

4 files changed

+61
-14
lines changed

4 files changed

+61
-14
lines changed

Mathlib/Algebra/Algebra/Subalgebra/Tower.lean

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,58 @@ This is a special case of `AlgHom.restrictScalars` that can be helpful in elabor
116116
def ofRestrictScalars (U : Subalgebra S A) (f : U →ₐ[S] B) : U.restrictScalars R →ₐ[R] B :=
117117
f.restrictScalars R
118118

119+
instance restrictScalars.SMul {U : Subalgebra S A} : SMul S (U.restrictScalars R) where
120+
smul s := fun ⟨u, hu⟩ ↦
121+
⟨s • u, by simp only [mem_restrictScalars] at hu ⊢; apply smul_mem _ hu⟩
122+
123+
instance restrictScalars.origAlgebra {U : Subalgebra S A} : Algebra S (U.restrictScalars R) where
124+
algebraMap := {
125+
toFun s :=
126+
let ⟨u, hu⟩ := algebraMap S U s
127+
⟨u, by rwa [mem_restrictScalars]⟩
128+
map_zero' := by ext; simp
129+
map_one' := by ext; simp
130+
map_add' x y := by ext; simp
131+
map_mul' x y := by ext; simp
132+
}
133+
commutes' s x := by
134+
ext
135+
exact Algebra.commutes s x.val
136+
smul_def' s x := by
137+
ext
138+
exact Algebra.smul_def s x.val
139+
140+
@[simp, norm_cast]
141+
lemma restrictScalars.coe_smul {U : Subalgebra S A} (s : S) (u : U.restrictScalars R) :
142+
(↑(s • u) : A) = s • (u : A) := by
143+
rfl
144+
145+
@[simp, norm_cast]
146+
lemma restrictScalars.coe_algebraMap {U : Subalgebra S A} (s : S) :
147+
(algebraMap S (U.restrictScalars R) s : A) = algebraMap S A s := by
148+
rfl
149+
150+
instance restrictScalars.isScalarTower {U : Subalgebra S A} :
151+
IsScalarTower R S (U.restrictScalars R) :=
152+
fun _ _ _ ↦ by ext; simp⟩
153+
154+
instance restrictScalars.isScalarTower' {U : Subalgebra S A} :
155+
IsScalarTower S (U.restrictScalars R) A :=
156+
by simp [smul_def]⟩
157+
158+
/-- Turning `p : Subalgebra S A` into an `R`-subalgebra gives the same algebra structure. -/
159+
def restrictScalarsEquiv (p : Subalgebra S A) : p.restrictScalars R ≃ₐ[S] p :=
160+
{ RingEquiv.refl p with
161+
commutes' := fun _ => rfl }
162+
163+
@[simp]
164+
theorem restrictScalarsEquiv_apply (p : Subalgebra S A) (a : p.restrictScalars R) :
165+
((restrictScalarsEquiv R p) a : A) = a := rfl
166+
167+
@[simp]
168+
theorem restrictScalarsEquiv_symm_apply (p : Subalgebra S A) (a : p) :
169+
((restrictScalarsEquiv R p).symm a : A) = a := rfl
170+
119171
end Semiring
120172

121173
section CommSemiring

Mathlib/RingTheory/AlgebraicIndependent/TranscendenceBasis.lean

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,15 @@ theorem matroid_closure_eq [IsDomain A] {s : Set A} :
340340
forall_mem_insert]
341341
exact fun _ ↦ and_iff_left fun x hx ↦ isAlgebraic_algebraMap (⟨x, subset_adjoin hx⟩ : adjoin R B)
342342

343-
set_option backward.isDefEq.respectTransparency false in
344343
theorem matroid_isFlat_iff [IsDomain A] {s : Set A} :
345344
(matroid R A).IsFlat s ↔ ∃ S : Subalgebra R A, S = s ∧ ∀ a : A, IsAlgebraic S a → a ∈ s := by
346345
rw [Matroid.isFlat_iff_closure_eq, matroid_closure_eq]
347346
set S := algebraicClosure (adjoin R s) A
348-
refine ⟨fun eq ↦ ⟨S.restrictScalars R, eq, fun a (h : IsAlgebraic S _) ↦ ?_⟩, ?_⟩
349-
· rw [← eq]; exact h.restrictScalars (adjoin R s)
347+
refine ⟨fun eq ↦ ⟨S.restrictScalars R, eq, fun a h ↦ ?_⟩, ?_⟩
348+
· rw [← eq, ← coe_restrictScalars R]
349+
have : Algebra.IsAlgebraic (adjoin R s) (Subalgebra.restrictScalars R S) :=
350+
(Subalgebra.restrictScalarsEquiv R S).symm.isAlgebraic
351+
exact h.restrictScalars (adjoin R s)
350352
rintro ⟨s, rfl, hs⟩
351353
refine Set.ext fun a ↦ ⟨(hs _ <| adjoin_eq s ▸ ·), fun h ↦ ?_⟩
352354
exact isAlgebraic_algebraMap (A := A) (by exact (⟨a, subset_adjoin h⟩ : adjoin R s))

Mathlib/RingTheory/Finiteness/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,10 @@ variable {M : Type*} [AddCommMonoid M] [Module R M]
411411
variable {A : Type*} [Semiring A] [Module R A] [Module A M] [IsScalarTower R A M]
412412
variable {S : Submodule A M}
413413

414-
set_option backward.isDefEq.respectTransparency false in
415414
theorem FG.restrictScalars [Module.Finite R A] (hS : S.FG) : (S.restrictScalars R).FG := by
416415
rw [← Module.Finite.iff_fg] at *
417-
exact Module.Finite.trans A S
416+
have : Module.Finite R S := Module.Finite.trans A S
417+
exact Module.Finite.equiv ((restrictScalarsEquiv R A M S).restrictScalars R).symm
418418

419419
@[simp]
420420
theorem FG.restrictScalars_iff [Module.Finite R A] : (S.restrictScalars R).FG ↔ S.FG :=

Mathlib/RingTheory/IntegralClosure/IsIntegralClosure/Basic.lean

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public import Mathlib.RingTheory.Polynomial.ScaleRoots
1414
public import Mathlib.RingTheory.TensorProduct.MvPolynomial
1515

1616
import Mathlib.RingTheory.Polynomial.Subring
17+
import Mathlib.RingTheory.Finiteness.Subalgebra
1718

1819
/-!
1920
# # Integral closure as a characteristic predicate
@@ -472,7 +473,6 @@ variable [CommRing R] [CommRing A] [Ring B] [CommRing S] [CommRing T]
472473
variable [Algebra A B] [Algebra R B] (f : R →+* S) (g : S →+* T)
473474
variable [Algebra R A] [IsScalarTower R A B]
474475

475-
set_option backward.isDefEq.respectTransparency false in
476476
/-- If A is an R-algebra all of whose elements are integral over R,
477477
and x is an element of an A-algebra that is integral over A, then x is integral over R. -/
478478
theorem isIntegral_trans [Algebra.IsIntegral R A] (x : B) (hx : IsIntegral A x) :
@@ -485,16 +485,9 @@ theorem isIntegral_trans [Algebra.IsIntegral R A] (x : B) (hx : IsIntegral A x)
485485
have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by
486486
rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map]
487487
convert hp; apply p.map_toSubring S.toSubring⟩
488-
let Sx := Subalgebra.toSubmodule (S[x])
489-
let MSx : Module S Sx := SMulMemClass.toModule _ -- the next line times out without this
490-
have : Module.Finite S Sx := .of_fg hSx.fg_adjoin_singleton
491488
refine .of_mem_of_fg ((S[x]).restrictScalars R) ?_ _
492489
((Subalgebra.mem_restrictScalars R).mpr <| subset_adjoin rfl)
493-
rw [← Module.Finite.iff_fg]
494-
letI : SMul S Sx := { MSx with } -- need this even though MSx is there
495-
have : IsScalarTower R S Sx :=
496-
Submodule.isScalarTower Sx -- Lean looks for `Module A Sx` without this
497-
exact Module.Finite.trans S Sx
490+
simpa using hSx.fg_adjoin_singleton
498491

499492
variable (A) in
500493
/-- If A is an R-algebra all of whose elements are integral over R,

0 commit comments

Comments
 (0)