@@ -486,14 +486,13 @@ end Unbundled
486486variable (M : ModuleCat.{v} R)
487487
488488/-- If `M` is an `R`-module, then the set of `R`-linear maps `S →ₗ[R] M` is an `S`-module with
489- scalar multiplication defined by `s • l := x ↦ l (x • s)` -/
489+ scalar multiplication defined by `s • l := x ↦ l (x • s)`.
490+
491+ This is an implementation detail: use `(coextendScalars f).obj` instead.
492+ -/
490493def obj' : ModuleCat S :=
491494 of _ ((restrictScalars f).obj (of _ S) →ₗ[R] M)
492495
493- set_option backward.inferInstanceAs.wrap.data false in
494- instance : CoeFun (obj' f M) fun _ => S → M :=
495- inferInstanceAs <| CoeFun ((restrictScalars f).obj (of _ S) →ₗ[R] M) _
496-
497496/-- If `M, M'` are `R`-modules, then any `R`-linear map `g : M ⟶ M'` induces an `S`-linear map
498497`(S →ₗ[R] M) ⟶ (S →ₗ[R] M')` defined by `h ↦ g ∘ h` -/
499498@[simps!]
@@ -509,6 +508,8 @@ end CoextendScalars
509508For any rings `R, S` and a ring homomorphism `f : R →+* S`, there is a functor from `R`-module to
510509`S`-module defined by `M ↦ (S →ₗ[R] M)` where `S` is considered as an `R`-module via restriction of
511510scalars and `g : M ⟶ M'` is sent to `h ↦ g ∘ h`.
511+
512+ The definition of `(coextendScalars f).obj` is given by `CoextendScalars.equiv`.
512513-/
513514def coextendScalars {R : Type u₁} {S : Type u₂} [Ring R] [Ring S] (f : R →+* S) :
514515 ModuleCat R ⥤ ModuleCat S where
@@ -521,9 +522,22 @@ namespace CoextendScalars
521522
522523variable {R : Type u₁} {S : Type u₂} [Ring R] [Ring S] (f : R →+* S)
523524
524- set_option backward.inferInstanceAs.wrap.data false in
525- instance (M : ModuleCat R) : CoeFun ((coextendScalars f).obj M) fun _ => S → M :=
526- inferInstanceAs <| CoeFun (CoextendScalars.obj' f M) _
525+ /-- The carrier of `(coextendScalars f).obj M` is `S →ₗ[R] M` where `S` is considered as an
526+ `R`-module via restriction of scalars. -/
527+ def equiv (M : ModuleCat R) :
528+ (coextendScalars f).obj M ≃ₗ[S] ((restrictScalars f).obj (of _ S) →ₗ[R] M) where
529+ toFun f := f
530+ invFun f := f
531+ map_add' _ _ := rfl
532+ map_smul' _ _ := rfl
533+
534+ instance (M : ModuleCat R) : CoeFun ((coextendScalars f).obj M) fun _ => S → M where
535+ coe g := equiv f M g
536+
537+ variable {f} in
538+ @[ext] lemma ext {M : ModuleCat R} {g g' : (coextendScalars f).obj M}
539+ (h : CoextendScalars.equiv f M g = CoextendScalars.equiv f M g') :
540+ g = g' := (CoextendScalars.equiv f M).injective h
527541
528542theorem smul_apply (M : ModuleCat R) (g : (coextendScalars f).obj M) (s s' : S) :
529543 (s • g) s' = g (s' * s) :=
@@ -547,20 +561,19 @@ corresponds to `Y ⟶ (coextendScalars f).obj X` by sending `y ↦ (s ↦ g (s
547561def HomEquiv.fromRestriction {X : ModuleCat R} {Y : ModuleCat S}
548562 (g : (restrictScalars f).obj Y ⟶ X) : Y ⟶ (coextendScalars f).obj X :=
549563 ofHom
550- { toFun := fun y : Y =>
564+ { toFun := fun y : Y => (CoextendScalars.equiv _ _).symm
551565 { toFun := fun s : S => g <| (s • y : Y)
552- map_add' := fun s1 s2 : S => by simp only [add_smul]; rw [map_add ]
566+ map_add' := fun s1 s2 : S => by simp [add_smul]
553567 map_smul' := fun r (s : S) => by
554568 -- Porting note: dsimp clears out some rw's but less eager to apply others with Lean 4
555569 dsimp
556570 rw [← g.hom.map_smul]
557- erw [smul_eq_mul, mul_smul]
558- rfl }
559- map_add' := fun y1 y2 : Y =>
560- LinearMap.ext fun s : S => by
561- simp [smul_add, map_add]
562- map_smul' := fun (s : S) (y : Y) => LinearMap.ext fun t : S => by
563- simp [mul_smul] }
571+ erw [smul_eq_mul]
572+ simp [mul_smul] }
573+ map_add' (y1 y2 : Y) := (CoextendScalars.equiv _ _).injective <|
574+ LinearMap.ext fun s : S => by simp
575+ map_smul' (s : S) (y : Y) := (CoextendScalars.equiv _ _).injective <|
576+ LinearMap.ext fun t : S => by simp [mul_smul] }
564577
565578/-- This should be autogenerated by `@[simps]` but we need to give `s` the correct type here. -/
566579@[simp] lemma HomEquiv.fromRestriction_hom_apply_apply {X : ModuleCat R} {Y : ModuleCat S}
@@ -576,13 +589,11 @@ def HomEquiv.toRestriction {X : ModuleCat R} {Y : ModuleCat S} (g : Y ⟶ (coext
576589 -- TODO: after https://github.com/leanprover-community/mathlib4/pull/19511 we need to hint `(X := ...)`.
577590 -- This suggests `restrictScalars` needs to be redesigned.
578591 ofHom (X := (restrictScalars f).obj Y)
579- { toFun := fun y : Y => (g y) (1 : S)
580- map_add' := fun x y => by dsimp; rw [g.hom.map_add, LinearMap.add_apply]
581- map_smul' := fun r (y : Y) => by
582- dsimp
592+ { toFun y := (g y) (1 : S)
593+ map_add' x y := by simp
594+ map_smul' r (y : Y) := by
583595 rw [← map_smul]
584- erw [smul_eq_mul, mul_one, map_smul]
585- rw [CoextendScalars.smul_apply (s := f r) (g := g y) (s' := 1 ), one_mul]
596+ erw [smul_eq_mul]
586597 simp }
587598
588599/-- This should be autogenerated by `@[simps]` but we need to give `1` the correct type here. -/
@@ -594,28 +605,18 @@ set_option backward.defeqAttrib.useBackward true in
594605set_option backward.isDefEq.respectTransparency false in
595606/-- Auxiliary definition for `unit'`, to address timeouts. -/
596607def app' (Y : ModuleCat S) : Y →ₗ[S] (restrictScalars f ⋙ coextendScalars f).obj Y :=
597- { toFun := fun y : Y =>
598- { toFun := fun s : S => (s • y : Y)
599- map_add' := fun _ _ => add_smul _ _ _
600- map_smul' := fun r (s : S) => by
601- dsimp only [AddHom.toFun_eq_coe, AddHom.coe_mk, RingHom.id_apply]
602- erw [smul_eq_mul, mul_smul]
603- simp }
604- map_add' := fun y1 y2 =>
608+ { toFun y := (CoextendScalars.equiv _ _).symm
609+ { toFun (s : S) := s • y
610+ map_add' _ _ := add_smul _ _ _
611+ map_smul' r (s : S) := by
612+ erw [smul_eq_mul]
613+ simp [mul_smul] }
614+ map_add' y1 y2 := (CoextendScalars.equiv _ _).injective <|
605615 LinearMap.ext fun s : S => by
606- -- Porting note: double dsimp seems odd
607- dsimp only [AddHom.toFun_eq_coe, AddHom.coe_mk, RingHom.id_apply,
608- RingHom.toMonoidHom_eq_coe, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
609- MonoidHom.coe_coe, ZeroHom.coe_mk, smul_eq_mul, id_eq, eq_mpr_eq_cast, cast_eq,
610- Functor.comp_obj]
611- rw [LinearMap.add_apply, LinearMap.coe_mk, LinearMap.coe_mk, LinearMap.coe_mk]
612- dsimp
613- rw [smul_add]
614- map_smul' := fun s (y : Y) => LinearMap.ext fun t : S => by
615- -- Porting note: used to be simp [ mul_smul ]
616- rw [RingHom.id_apply, LinearMap.coe_mk, CoextendScalars.smul_apply', LinearMap.coe_mk]
617- dsimp
618- rw [mul_smul] }
616+ simp [smul_add]
617+ map_smul' s (y : Y) := (CoextendScalars.equiv _ _).injective <|
618+ LinearMap.ext fun t : S => by
619+ simp [mul_smul] }
619620
620621/--
621622The natural transformation from identity functor to the composition of restriction and coextension
@@ -625,7 +626,7 @@ of scalars.
625626protected noncomputable def unit' : 𝟭 (ModuleCat S) ⟶ restrictScalars f ⋙ coextendScalars f where
626627 app Y := ofHom (app' f Y)
627628 naturality Y Y' g :=
628- hom_ext <| LinearMap.ext fun y : Y => LinearMap.ext fun s : S => by
629+ hom_ext <| LinearMap.ext fun y : Y => CoextendScalars.ext <| LinearMap.ext fun s : S => by
629630 -- Porting note (https://github.com/leanprover-community/mathlib4/issues/10745): previously simp [ CoextendScalars.map_apply ]
630631 simp only [ModuleCat.hom_comp, Functor.id_map, Functor.id_obj,
631632 Functor.comp_map]
@@ -641,16 +642,14 @@ protected noncomputable def counit' : coextendScalars f ⋙ restrictScalars f
641642 -- TODO: after https://github.com/leanprover-community/mathlib4/pull/19511 we need to hint `(X := ...)`.
642643 -- This suggests `restrictScalars` needs to be redesigned.
643644 app X := ofHom (X := (restrictScalars f).obj ((coextendScalars f).obj X))
644- { toFun := fun g => g.toFun (1 : S)
645- map_add' := fun x1 x2 => by
646- dsimp
647- rw [LinearMap.add_apply]
648- map_smul' := fun r (g : (restrictScalars f).obj ((coextendScalars f).obj X)) => by
645+ { toFun g := CoextendScalars.equiv f X g (1 : S)
646+ map_add' x1 x2 := by simp
647+ map_smul' r g := by
649648 dsimp
650649 rw [CoextendScalars.smul_apply, one_mul, ← map_smul]
651650 congr
652651 change f r = f r • (1 : S)
653- rw [smul_eq_mul (f r) 1 , mul_one] }
652+ simp }
654653
655654end RestrictionCoextensionAdj
656655
@@ -664,16 +663,12 @@ def restrictCoextendScalarsAdj {R : Type u₁} {S : Type u₂} [Ring R] [Ring S]
664663 homEquiv := fun X Y ↦
665664 { toFun := RestrictionCoextensionAdj.HomEquiv.fromRestriction.{u₁, u₂, v} f
666665 invFun := RestrictionCoextensionAdj.HomEquiv.toRestriction.{u₁, u₂, v} f
667- left_inv := fun g => by ext; simp
668- right_inv := fun g => hom_ext <| LinearMap.ext fun x => LinearMap.ext fun s : S => by
669- -- Porting note (https://github.com/leanprover-community/mathlib4/issues/10745): once just simp
670- rw [RestrictionCoextensionAdj.HomEquiv.fromRestriction_hom_apply_apply,
671- RestrictionCoextensionAdj.HomEquiv.toRestriction_hom_apply, map_smulₛₗ,
672- RingHom.id_apply, CoextendScalars.smul_apply', one_mul] }
666+ left_inv g := by ext; simp
667+ right_inv g := by ext; simp }
673668 unit := RestrictionCoextensionAdj.unit'.{u₁, u₂, v} f
674669 counit := RestrictionCoextensionAdj.counit'.{u₁, u₂, v} f
675670 homEquiv_unit := hom_ext <| LinearMap.ext fun _ => rfl
676- homEquiv_counit := fun {X Y g} => by
671+ homEquiv_counit {X Y g} := by
677672 ext
678673 simp [RestrictionCoextensionAdj.counit'] }
679674
@@ -707,8 +702,6 @@ def HomEquiv.toRestrictScalars {X : ModuleCat R} {Y : ModuleCat S}
707702 { toFun := fun x => g <| (1 : S) ⊗ₜ[R,f] x
708703 map_add' := fun _ _ => by dsimp; rw [tmul_add, map_add]
709704 map_smul' := fun r s => by
710- letI : Module R S := Module.compHom S f
711- letI : Module R Y := Module.compHom Y f
712705 dsimp
713706 rw [RestrictScalars.smul_def, ← LinearMap.map_smul]
714707 erw [tmul_smul]
0 commit comments