Skip to content

Commit 95a48b5

Browse files
committed
feat: add scalar tower instances for RingQuot and BilinForm (#6066)
I tidied up some universe and type variables in the RingQuot file while I was here (in the first commit).
1 parent ccbfd85 commit 95a48b5

2 files changed

Lines changed: 44 additions & 20 deletions

File tree

Mathlib/Algebra/RingQuot.lean

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ Since everything runs in parallel for quotients of `R`-algebras, we do that case
2424
-/
2525

2626

27-
universe u₁ u₂ u₃ u₄
27+
universe uR uS uT uA
2828

29-
variable {R : Type u₁} [Semiring R]
29+
variable {R : Type uR} [Semiring R]
3030

31-
variable {S : Type u₂} [CommSemiring S]
31+
variable {S : Type uS} [CommSemiring S]
32+
variable {T : Type uT}
3233

33-
variable {A : Type u₃} [Semiring A] [Algebra S A]
34+
variable {A : Type uA} [Semiring A] [Algebra S A]
3435

3536
namespace RingCon
3637

@@ -66,15 +67,15 @@ theorem Rel.add_right {r : R → R → Prop} ⦃a b c : R⦄ (h : Rel r b c) : R
6667
exact Rel.add_left h
6768
#align ring_quot.rel.add_right RingQuot.Rel.add_right
6869

69-
theorem Rel.neg {R : Type u₁} [Ring R] {r : R → R → Prop} ⦃a b : R⦄ (h : Rel r a b) :
70+
theorem Rel.neg {R : Type uR} [Ring R] {r : R → R → Prop} ⦃a b : R⦄ (h : Rel r a b) :
7071
Rel r (-a) (-b) := by simp only [neg_eq_neg_one_mul a, neg_eq_neg_one_mul b, Rel.mul_right h]
7172
#align ring_quot.rel.neg RingQuot.Rel.neg
7273

73-
theorem Rel.sub_left {R : Type u₁} [Ring R] {r : R → R → Prop} ⦃a b c : R⦄ (h : Rel r a b) :
74+
theorem Rel.sub_left {R : Type uR} [Ring R] {r : R → R → Prop} ⦃a b c : R⦄ (h : Rel r a b) :
7475
Rel r (a - c) (b - c) := by simp only [sub_eq_add_neg, h.add_left]
7576
#align ring_quot.rel.sub_left RingQuot.Rel.sub_left
7677

77-
theorem Rel.sub_right {R : Type u₁} [Ring R] {r : R → R → Prop} ⦃a b c : R⦄ (h : Rel r b c) :
78+
theorem Rel.sub_right {R : Type uR} [Ring R] {r : R → R → Prop} ⦃a b c : R⦄ (h : Rel r b c) :
7879
Rel r (a - b) (a - c) := by simp only [sub_eq_add_neg, h.neg.add_right]
7980
#align ring_quot.rel.sub_right RingQuot.Rel.sub_right
8081

@@ -169,10 +170,10 @@ private irreducible_def add : RingQuot r → RingQuot r → RingQuot r
169170
private irreducible_def mul : RingQuot r → RingQuot r → RingQuot r
170171
| ⟨a⟩, ⟨b⟩ => ⟨Quot.map₂ (· * ·) Rel.mul_right Rel.mul_left a b⟩
171172

172-
private irreducible_def neg {R : Type u₁} [Ring R] (r : R → R → Prop) : RingQuot r → RingQuot r
173+
private irreducible_def neg {R : Type uR} [Ring R] (r : R → R → Prop) : RingQuot r → RingQuot r
173174
| ⟨a⟩ => ⟨Quot.map (fun a ↦ -a) Rel.neg a⟩
174175

175-
private irreducible_def sub {R : Type u₁} [Ring R] (r : R → R → Prop) :
176+
private irreducible_def sub {R : Type uR} [Ring R] (r : R → R → Prop) :
176177
RingQuot r → RingQuot r → RingQuot r
177178
| ⟨a⟩, ⟨b⟩ => ⟨Quot.map₂ Sub.sub Rel.sub_right Rel.sub_left a b⟩
178179

@@ -213,10 +214,10 @@ instance : Mul (RingQuot r) :=
213214
instance : Pow (RingQuot r) ℕ :=
214215
fun x n ↦ npow r n x⟩
215216

216-
instance {R : Type u₁} [Ring R] (r : R → R → Prop) : Neg (RingQuot r) :=
217+
instance {R : Type uR} [Ring R] (r : R → R → Prop) : Neg (RingQuot r) :=
217218
⟨neg r⟩
218219

219-
instance {R : Type u₁} [Ring R] (r : R → R → Prop) : Sub (RingQuot r) :=
220+
instance {R : Type uR} [Ring R] (r : R → R → Prop) : Sub (RingQuot r) :=
220221
⟨sub r⟩
221222

222223
instance [Algebra S R] : SMul S (RingQuot r) :=
@@ -247,14 +248,14 @@ theorem pow_quot {a} {n : ℕ} : (⟨Quot.mk _ a⟩ ^ n : RingQuot r) = ⟨Quot.
247248
rw [npow_def]
248249
#align ring_quot.pow_quot RingQuot.pow_quot
249250

250-
theorem neg_quot {R : Type u₁} [Ring R] (r : R → R → Prop) {a} :
251+
theorem neg_quot {R : Type uR} [Ring R] (r : R → R → Prop) {a} :
251252
(-⟨Quot.mk _ a⟩ : RingQuot r) = ⟨Quot.mk _ (-a)⟩ := by
252253
show neg r _ = _
253254
rw [neg_def]
254255
rfl
255256
#align ring_quot.neg_quot RingQuot.neg_quot
256257

257-
theorem sub_quot {R : Type u₁} [Ring R] (r : R → R → Prop) {a b} :
258+
theorem sub_quot {R : Type uR} [Ring R] (r : R → R → Prop) {a b} :
258259
(⟨Quot.mk _ a⟩ - ⟨Quot.mk _ b⟩ : RingQuot r) = ⟨Quot.mk _ (a - b)⟩ := by
259260
show sub r _ _ = _
260261
rw [sub_def]
@@ -268,6 +269,14 @@ theorem smul_quot [Algebra S R] {n : S} {a : R} :
268269
rfl
269270
#align ring_quot.smul_quot RingQuot.smul_quot
270271

272+
instance [CommSemiring T] [SMul S T] [Algebra S R] [Algebra T R] [IsScalarTower S T R] :
273+
IsScalarTower S T (RingQuot r) :=
274+
fun s t ⟨a⟩ => Quot.inductionOn a <| fun a' => by simp only [RingQuot.smul_quot, smul_assoc]⟩
275+
276+
instance [CommSemiring T] [Algebra S R] [Algebra T R] [SMulCommClass S T R] :
277+
SMulCommClass S T (RingQuot r) :=
278+
fun s t ⟨a⟩ => Quot.inductionOn a <| fun a' => by simp only [RingQuot.smul_quot, smul_comm]⟩
279+
271280
instance instAddCommMonoid (r : R → R → Prop) : AddCommMonoid (RingQuot r) where
272281
add := (· + ·)
273282
zero := 0
@@ -337,7 +346,7 @@ instance instSemiring (r : R → R → Prop) : Semiring (RingQuot r) where
337346
__ := instAddCommMonoid r
338347
__ := instMonoidWithZero r
339348

340-
instance instRing {R : Type u₁} [Ring R] (r : R → R → Prop) : Ring (RingQuot r) :=
349+
instance instRing {R : Type uR} [Ring R] (r : R → R → Prop) : Ring (RingQuot r) :=
341350
{ RingQuot.instSemiring r with
342351
neg := Neg.neg
343352
add_left_neg := by
@@ -358,14 +367,14 @@ instance instRing {R : Type u₁} [Ring R] (r : R → R → Prop) : Ring (RingQu
358367
rintro n ⟨⟨⟩⟩
359368
simp [smul_quot, neg_quot, add_mul] }
360369

361-
instance instCommSemiring {R : Type u₁} [CommSemiring R] (r : R → R → Prop) :
370+
instance instCommSemiring {R : Type uR} [CommSemiring R] (r : R → R → Prop) :
362371
CommSemiring (RingQuot r) :=
363372
{ RingQuot.instSemiring r with
364373
mul_comm := by
365374
rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩
366375
simp [mul_quot, mul_comm] }
367376

368-
instance {R : Type u₁} [CommRing R] (r : R → R → Prop) : CommRing (RingQuot r) :=
377+
instance {R : Type uR} [CommRing R] (r : R → R → Prop) : CommRing (RingQuot r) :=
369378
{ RingQuot.instCommSemiring r, RingQuot.instRing r with }
370379

371380
instance (r : R → R → Prop) : Inhabited (RingQuot r) :=
@@ -406,14 +415,14 @@ theorem mkRingHom_surjective (r : R → R → Prop) : Function.Surjective (mkRin
406415
#align ring_quot.mk_ring_hom_surjective RingQuot.mkRingHom_surjective
407416

408417
@[ext 1100]
409-
theorem ringQuot_ext {T : Type u₄} [Semiring T] {r : R → R → Prop} (f g : RingQuot r →+* T)
418+
theorem ringQuot_ext [Semiring T] {r : R → R → Prop} (f g : RingQuot r →+* T)
410419
(w : f.comp (mkRingHom r) = g.comp (mkRingHom r)) : f = g := by
411420
ext x
412421
rcases mkRingHom_surjective r x with ⟨x, rfl⟩
413422
exact (RingHom.congr_fun w x : _)
414423
#align ring_quot.ring_quot_ext RingQuot.ringQuot_ext
415424

416-
variable {T : Type u₄} [Semiring T]
425+
variable [Semiring T]
417426

418427
irreducible_def preLift {r : R → R → Prop} { f : R →+* T } (h : ∀ ⦃x y⦄, r x y → f x = f y) :
419428
RingQuot r →+* T :=
@@ -482,7 +491,7 @@ agrees with the quotient by the appropriate ideal.
482491
-/
483492

484493

485-
variable {B : Type u₁} [CommRing B]
494+
variable {B : Type uR} [CommRing B]
486495

487496
/-- The universal ring homomorphism from `RingQuot r` to `B ⧸ Ideal.ofRel r`. -/
488497
def ringQuotToIdealQuotient (r : B → B → Prop) : RingQuot r →+* B ⧸ Ideal.ofRel r :=
@@ -564,7 +573,7 @@ theorem star'_quot (hr : ∀ a b, r a b → r (star a) (star b)) {a} :
564573
#align ring_quot.star'_quot RingQuot.star'_quot
565574

566575
/-- Transfer a star_ring instance through a quotient, if the quotient is invariant to `star` -/
567-
def starRing {R : Type u₁} [Semiring R] [StarRing R] (r : R → R → Prop)
576+
def starRing {R : Type uR} [Semiring R] [StarRing R] (r : R → R → Prop)
568577
(hr : ∀ a b, r a b → r (star a) (star b)) : StarRing (RingQuot r) where
569578
star := star' r hr
570579
star_involutive := by

Mathlib/LinearAlgebra/BilinearForm.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@ theorem smul_apply {α} [Monoid α] [DistribMulAction α R] [SMulCommClass α R
223223
rfl
224224
#align bilin_form.smul_apply BilinForm.smul_apply
225225

226+
instance {α β} [Monoid α] [Monoid β] [DistribMulAction α R] [DistribMulAction β R]
227+
[SMulCommClass α R R] [SMulCommClass β R R] [SMulCommClass α β R] :
228+
SMulCommClass α β (BilinForm R M) :=
229+
fun a b B => ext $ fun x y => smul_comm a b (B x y)⟩
230+
231+
instance {α β} [Monoid α] [Monoid β] [SMul α β] [DistribMulAction α R] [DistribMulAction β R]
232+
[SMulCommClass α R R] [SMulCommClass β R R] [IsScalarTower α β R] :
233+
IsScalarTower α β (BilinForm R M) :=
234+
fun a b B => ext $ fun x y => smul_assoc a b (B x y)⟩
235+
236+
instance {α} [Monoid α] [DistribMulAction α R] [DistribMulAction αᵐᵒᵖ R]
237+
[SMulCommClass α R R] [IsCentralScalar α R] :
238+
IsCentralScalar α (BilinForm R M) :=
239+
fun a B => ext $ fun x y => op_smul_eq_smul a (B x y)⟩
240+
226241
instance : AddCommMonoid (BilinForm R M) :=
227242
Function.Injective.addCommMonoid _ coe_injective coe_zero coe_add fun _ _ => coe_smul _ _
228243

0 commit comments

Comments
 (0)