Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: port Algebra.Module.GradedModule (#4228)
- In `Algebra.DirectSum.Decomposition`, a simps was commented because it was causing a recurrence loop. However, one of the lemma that it generates is needed in this file, so I put the simps back (and fixed the loop) - At the end of the file, the local instance `GradedModule.isModule` was causing a lot of troubles. (It was in fact marked as a dangerous instance in Mathlib3). I removed it and declared it directly in the only result using it, see [this](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/!4.234228.20cannot.20find.20synthesization.20order.20for.20instance/near/360591542) Zulip thread
- Loading branch information
Showing
3 changed files
with
260 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,250 @@ | ||
/- | ||
Copyright (c) 2022 Jujian Zhang. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Jujian Zhang | ||
! This file was ported from Lean 3 source module algebra.module.graded_module | ||
! leanprover-community/mathlib commit 59cdeb0da2480abbc235b7e611ccd9a7e5603d7c | ||
! Please do not edit these lines, except to modify the commit id | ||
! if you have ported upstream changes. | ||
-/ | ||
import Mathlib.RingTheory.GradedAlgebra.Basic | ||
import Mathlib.Algebra.GradedMulAction | ||
import Mathlib.Algebra.DirectSum.Decomposition | ||
import Mathlib.Algebra.Module.BigOperators | ||
|
||
/-! | ||
# Graded Module | ||
Given an `R`-algebra `A` graded by `π`, a graded `A`-module `M` is expressed as | ||
`DirectSum.Decomposition π` and `SetLike.GradedSmul π π`. | ||
Then `β¨ i, π i` is an `A`-module and is isomorphic to `M`. | ||
## Tags | ||
graded module | ||
-/ | ||
|
||
|
||
section | ||
|
||
open DirectSum | ||
|
||
variable {ΞΉ : Type _} (A : ΞΉ β Type _) (M : ΞΉ β Type _) | ||
|
||
namespace DirectSum | ||
|
||
open GradedMonoid | ||
|
||
/-- A graded version of `DistribMulAction`. -/ | ||
class GdistribMulAction [AddMonoid ΞΉ] [GMonoid A] [β i, AddMonoid (M i)] extends | ||
GMulAction A M where | ||
smul_add {i j} (a : A i) (b c : M j) : smul a (b + c) = smul a b + smul a c | ||
smul_zero {i j} (a : A i) : smul a (0 : M j) = 0 | ||
#align direct_sum.gdistrib_mul_action DirectSum.GdistribMulAction | ||
|
||
/-- A graded version of `Module`. -/ | ||
class Gmodule [AddMonoid ΞΉ] [β i, AddMonoid (A i)] [β i, AddMonoid (M i)] [GMonoid A] extends | ||
GdistribMulAction A M where | ||
add_smul {i j} (a a' : A i) (b : M j) : smul (a + a') b = smul a b + smul a' b | ||
zero_smul {i j} (b : M j) : smul (0 : A i) b = 0 | ||
#align direct_sum.gmodule DirectSum.Gmodule | ||
|
||
/-- A graded version of `Semiring.toModule`. -/ | ||
instance GSemiring.toGmodule [AddMonoid ΞΉ] [β i : ΞΉ, AddCommMonoid (A i)] | ||
[h : GSemiring A] : Gmodule A A := | ||
{ GMonoid.toGMulAction A with | ||
smul_add := fun _ _ _ => h.mul_add _ _ _ | ||
smul_zero := fun _ => h.mul_zero _ | ||
add_smul := fun _ _ => h.add_mul _ _ | ||
zero_smul := fun _ => h.zero_mul _ } | ||
#align direct_sum.gsemiring.to_gmodule DirectSum.GSemiring.toGmodule | ||
|
||
variable [AddMonoid ΞΉ] [β i : ΞΉ, AddCommMonoid (A i)] [β i, AddCommMonoid (M i)] | ||
|
||
/-- The piecewise multiplication from the `Mul` instance, as a bundled homomorphism. -/ | ||
@[simps] | ||
def gsmulHom [GMonoid A] [Gmodule A M] {i j} : A i β+ M j β+ M (i + j) where | ||
toFun a := | ||
{ toFun := fun b => GSmul.smul a b | ||
map_zero' := GdistribMulAction.smul_zero _ | ||
map_add' := GdistribMulAction.smul_add _ } | ||
map_zero' := AddMonoidHom.ext fun a => Gmodule.zero_smul a | ||
map_add' _aβ _aβ := AddMonoidHom.ext fun _b => Gmodule.add_smul _ _ _ | ||
#align direct_sum.gsmul_hom DirectSum.gsmulHom | ||
|
||
namespace Gmodule | ||
|
||
/-- For graded monoid `A` and a graded module `M` over `A`. `gmodule.smul_add_monoid_hom` is the | ||
`β¨α΅’ Aα΅’`-scalar multiplication on `β¨α΅’ Mα΅’` induced by `gsmul_hom`. -/ | ||
def smulAddMonoidHom [DecidableEq ΞΉ] [GMonoid A] [Gmodule A M] : | ||
(β¨ i, A i) β+ (β¨ i, M i) β+ β¨ i, M i := | ||
toAddMonoid fun _i => | ||
AddMonoidHom.flip <| | ||
toAddMonoid fun _j => AddMonoidHom.flip <| (of M _).compHom.comp <| gsmulHom A M | ||
#align direct_sum.gmodule.smul_add_monoid_hom DirectSum.Gmodule.smulAddMonoidHom | ||
|
||
section | ||
|
||
open GradedMonoid DirectSum Gmodule | ||
|
||
instance [DecidableEq ΞΉ] [GMonoid A] [Gmodule A M] : SMul (β¨ i, A i) (β¨ i, M i) | ||
where smul x y := smulAddMonoidHom A M x y | ||
|
||
@[simp] | ||
theorem smul_def [DecidableEq ΞΉ] [GMonoid A] [Gmodule A M] (x : β¨ i, A i) (y : β¨ i, M i) : | ||
x β’ y = smulAddMonoidHom _ _ x y := rfl | ||
#align direct_sum.gmodule.smul_def DirectSum.Gmodule.smul_def | ||
|
||
@[simp] | ||
theorem smulAddMonoidHom_apply_of_of [DecidableEq ΞΉ] [GMonoid A] [Gmodule A M] {i j} (x : A i) | ||
(y : M j) : | ||
smulAddMonoidHom A M (DirectSum.of A i x) (of M j y) = of M (i + j) (GSmul.smul x y) := by | ||
simp [smulAddMonoidHom] | ||
#align direct_sum.gmodule.smul_add_monoid_hom_apply_of_of DirectSum.Gmodule.smulAddMonoidHom_apply_of_of | ||
|
||
-- @[simp] -- Porting note: simpNF lint | ||
theorem of_smul_of [DecidableEq ΞΉ] [GMonoid A] [Gmodule A M] {i j} (x : A i) (y : M j) : | ||
DirectSum.of A i x β’ of M j y = of M (i + j) (GSmul.smul x y) := | ||
smulAddMonoidHom_apply_of_of _ _ _ _ | ||
#align direct_sum.gmodule.of_smul_of DirectSum.Gmodule.of_smul_of | ||
|
||
open AddMonoidHom | ||
|
||
-- Porting note: renamed to one_smul' since DirectSum.Gmodule.one_smul already exists | ||
-- Almost identical to the proof of `direct_sum.one_mul` | ||
private theorem one_smul' [DecidableEq ΞΉ] [GMonoid A] [Gmodule A M] (x : β¨ i, M i) : | ||
(1 : β¨ i, A i) β’ x = x := by | ||
suffices smulAddMonoidHom A M 1 = AddMonoidHom.id (β¨ i, M i) from FunLike.congr_fun this x | ||
apply DirectSum.addHom_ext; intro i xi | ||
rw [show (1 : DirectSum ΞΉ fun i => A i) = (of A 0) GOne.one by rfl] | ||
rw [smulAddMonoidHom_apply_of_of] | ||
exact DirectSum.of_eq_of_gradedMonoid_eq (one_smul (GradedMonoid A) <| GradedMonoid.mk i xi) | ||
|
||
-- Porting note: renamed to mul_smul' since DirectSum.Gmodule.mul_smul already exists | ||
-- Almost identical to the proof of `direct_sum.mul_assoc` | ||
private theorem mul_smul' [DecidableEq ΞΉ] [GSemiring A] [Gmodule A M] (a b : β¨ i, A i) | ||
(c : β¨ i, M i) : (a * b) β’ c = a β’ b β’ c := by | ||
suffices | ||
(-- `Ξ» a b c, (a * b) β’ c` as a bundled hom | ||
smulAddMonoidHom | ||
A M).compHom.comp | ||
(DirectSum.mulHom A) = | ||
(AddMonoidHom.compHom AddMonoidHom.flipHom <| | ||
(smulAddMonoidHom A M).flip.compHom.comp <| smulAddMonoidHom A M).flip | ||
from-- `Ξ» a b c, a β’ (b β’ c)` as a bundled hom | ||
FunLike.congr_fun (FunLike.congr_fun (FunLike.congr_fun this a) b) c | ||
ext (ai ax bi bx ci cx) : 6 | ||
dsimp only [coe_comp, Function.comp_apply, compHom_apply_apply, flip_apply, flipHom_apply] | ||
rw [smulAddMonoidHom_apply_of_of, smulAddMonoidHom_apply_of_of, DirectSum.mulHom_of_of, | ||
smulAddMonoidHom_apply_of_of] | ||
exact | ||
DirectSum.of_eq_of_gradedMonoid_eq | ||
(mul_smul (GradedMonoid.mk ai ax) (GradedMonoid.mk bi bx) (GradedMonoid.mk ci cx)) | ||
|
||
/-- The `Module` derived from `gmodule A M`. -/ | ||
instance module [DecidableEq ΞΉ] [GSemiring A] [Gmodule A M] : Module (β¨ i, A i) (β¨ i, M i) where | ||
smul := (Β· β’ Β·) | ||
one_smul := one_smul' _ _ | ||
mul_smul := mul_smul' _ _ | ||
smul_add r := (smulAddMonoidHom A M r).map_add | ||
smul_zero r := (smulAddMonoidHom A M r).map_zero | ||
add_smul r s x := by simp only [smul_def, map_add, AddMonoidHom.add_apply] | ||
zero_smul x := by simp only [smul_def, map_zero, AddMonoidHom.zero_apply] | ||
#align direct_sum.gmodule.module DirectSum.Gmodule.module | ||
|
||
end | ||
|
||
end Gmodule | ||
|
||
end DirectSum | ||
|
||
end | ||
|
||
open DirectSum BigOperators | ||
|
||
variable {ΞΉ R A M Ο Ο' : Type _} | ||
|
||
variable [AddMonoid ΞΉ] [CommSemiring R] [Semiring A] [Algebra R A] | ||
|
||
variable (π : ΞΉ β Ο') [SetLike Ο' A] | ||
|
||
variable (π : ΞΉ β Ο) | ||
|
||
namespace SetLike | ||
|
||
instance gmulAction [AddMonoid M] [DistribMulAction A M] [SetLike Ο M] [SetLike.GradedMonoid π] | ||
[SetLike.GradedSmul π π] : GradedMonoid.GMulAction (fun i => π i) fun i => π i := | ||
{ SetLike.toGSmul π | ||
π with | ||
one_smul := fun β¨_i, _mβ© => Sigma.subtype_ext (zero_add _) (one_smul _ _) | ||
mul_smul := fun β¨_i, _aβ© β¨_j, _a'β© β¨_k, _bβ© => | ||
Sigma.subtype_ext (add_assoc _ _ _) (mul_smul _ _ _) } | ||
#align set_like.gmul_action SetLike.gmulAction | ||
|
||
instance gdistribMulAction [AddMonoid M] [DistribMulAction A M] [SetLike Ο M] | ||
[AddSubmonoidClass Ο M] [SetLike.GradedMonoid π] [SetLike.GradedSmul π π] : | ||
DirectSum.GdistribMulAction (fun i => π i) fun i => π i := | ||
{ SetLike.gmulAction π | ||
π with | ||
smul_add := fun _a _b _c => Subtype.ext <| smul_add _ _ _ | ||
smul_zero := fun _a => Subtype.ext <| smul_zero _ } | ||
#align set_like.gdistrib_mul_action SetLike.gdistribMulAction | ||
|
||
variable [AddCommMonoid M] [Module A M] [SetLike Ο M] [AddSubmonoidClass Ο' A] | ||
[AddSubmonoidClass Ο M] [SetLike.GradedMonoid π] [SetLike.GradedSmul π π] | ||
|
||
/-- `[SetLike.GradedMonoid π] [SetLike.GradedSmul π π]` is the internal version of graded | ||
module, the internal version can be translated into the external version `gmodule`. -/ | ||
instance gmodule : DirectSum.Gmodule (fun i => π i) fun i => π i := | ||
{ SetLike.gdistribMulAction π | ||
π with | ||
smul := fun x y => β¨(x : A) β’ (y : M), SetLike.GradedSmul.smul_mem x.2 y.2β© | ||
add_smul := fun _a _a' _b => Subtype.ext <| add_smul _ _ _ | ||
zero_smul := fun _b => Subtype.ext <| zero_smul _ _ } | ||
#align set_like.gmodule SetLike.gmodule | ||
|
||
end SetLike | ||
|
||
namespace GradedModule | ||
|
||
variable [AddCommMonoid M] [Module A M] [SetLike Ο M] [AddSubmonoidClass Ο' A] | ||
[AddSubmonoidClass Ο M] [SetLike.GradedMonoid π] [SetLike.GradedSmul π π] | ||
|
||
set_option maxHeartbeats 300000 in -- Porting note: needs more Hearbeats to elaborate | ||
/-- The smul multiplication of `A` on `β¨ i, π i` from `(β¨ i, π i) β+ (β¨ i, π i) β+ β¨ i, π i` | ||
turns `β¨ i, π i` into an `A`-module | ||
-/ | ||
def isModule [DecidableEq ΞΉ] [GradedRing π] : Module A (β¨ i, π i) := | ||
{ Module.compHom _ (DirectSum.decomposeRingEquiv π : A β+* β¨ i, π i).toRingHom with | ||
smul := fun a b => DirectSum.decompose π a β’ b } | ||
#align graded_module.is_module GradedModule.isModule | ||
|
||
/-- `β¨ i, π i` and `M` are isomorphic as `A`-modules. | ||
"The internal version" and "the external version" are isomorphism as `A`-modules. | ||
-/ | ||
def linearEquiv [DecidableEq ΞΉ] [GradedRing π] [DirectSum.Decomposition π] : | ||
@LinearEquiv A A _ _ (RingHom.id A) (RingHom.id A) _ _ M (β¨ i, π i) _ | ||
_ _ (by letI := isModule π π ; infer_instance) := by | ||
letI h := isModule π π | ||
refine β¨β¨(DirectSum.decomposeAddEquiv π).toAddHom, ?_β©, | ||
(DirectSum.decomposeAddEquiv π).symm.toFun, (DirectSum.decomposeAddEquiv π).left_inv, | ||
(DirectSum.decomposeAddEquiv π).right_invβ© | ||
intro x y | ||
classical | ||
rw [AddHom.toFun_eq_coe, β DirectSum.sum_support_decompose π x, map_sum, Finset.sum_smul, | ||
AddEquiv.coe_toAddHom, map_sum, Finset.sum_smul] | ||
refine Finset.sum_congr rfl (fun i _hi => ?_) | ||
rw [RingHom.id_apply, β DirectSum.sum_support_decompose π y, map_sum, Finset.smul_sum, map_sum, | ||
Finset.smul_sum] | ||
refine Finset.sum_congr rfl (fun j _hj => ?_) | ||
rw [show (decompose π x i : A) β’ (decomposeAddEquiv π β(decompose π y j) : (β¨ i, π i)) = | ||
DirectSum.Gmodule.smulAddMonoidHom _ _ (decompose π β(decompose π x i)) | ||
(decomposeAddEquiv π β(decompose π y j)) from DirectSum.Gmodule.smul_def _ _ _ _] | ||
simp only [decomposeAddEquiv_apply, Equiv.invFun_as_coe, Equiv.symm_symm, decompose_coe, | ||
Gmodule.smulAddMonoidHom_apply_of_of] | ||
convert DirectSum.decompose_coe π _ | ||
rfl | ||
#align graded_module.linear_equiv GradedModule.linearEquiv | ||
|
||
end GradedModule |