|
| 1 | +/- |
| 2 | +Copyright (c) 2025 Kenny Lau. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Kenny Lau |
| 5 | +-/ |
| 6 | +module |
| 7 | + |
| 8 | +public import Mathlib.Data.FunLike.Graded |
| 9 | +public import Mathlib.RingTheory.GradedAlgebra.Basic |
| 10 | + |
| 11 | +/-! |
| 12 | +# Homomorphisms of graded (semi)rings |
| 13 | +
|
| 14 | +This file defines bundled homomorphisms of graded (semi)rings. We use the same structure |
| 15 | +`GradedRingHom π β¬`, a.k.a. `π β+*α΅ β¬`, for both types of homomorphisms. |
| 16 | +
|
| 17 | +We do **not** define a separate class of graded ring homomorphisms; instead, we use |
| 18 | +`[FunLike F A B] [GradedFunLike F π β¬] [RingHomClass F A B]`. |
| 19 | +
|
| 20 | +## Main definitions |
| 21 | +
|
| 22 | +* `GradedRingHom`: Graded (semi)ring homomorphisms. Ring homomorphism which preserves the grading. |
| 23 | +
|
| 24 | +## Notation |
| 25 | +
|
| 26 | +* `β+*α΅`: Graded (semi)ring hom. |
| 27 | +
|
| 28 | +## Implementation notes |
| 29 | +
|
| 30 | +* We don't really need the fact that they are graded rings until the theorem |
| 31 | +`DirectSum.decompose_map` which describes how the decomposition interacts with the map. |
| 32 | +-/ |
| 33 | + |
| 34 | +@[expose] public section |
| 35 | + |
| 36 | +variable {ΞΉ A B C D Ο Ο Ο Ο : Type*} |
| 37 | + [Semiring A] [Semiring B] [Semiring C] [Semiring D] |
| 38 | + [SetLike Ο A] [SetLike Ο B] [SetLike Ο C] [SetLike Ο D] |
| 39 | + |
| 40 | +section SetLike |
| 41 | + |
| 42 | +/-- Bundled graded (semi)ring homomorphisms. Use `GradedRingHom` for the namespace and other |
| 43 | +identifiers, and `π β+*α΅ β¬` for the notation. -/ |
| 44 | +structure GradedRingHom (π : ΞΉ β Ο) (β¬ : ΞΉ β Ο) extends A β+* B where |
| 45 | + protected map_mem {i : ΞΉ} {x : A} : x β π i β toRingHom x β β¬ i |
| 46 | + |
| 47 | +variable {π : ΞΉ β Ο} {β¬ : ΞΉ β Ο} {π : ΞΉ β Ο} {π : ΞΉ β Ο} |
| 48 | + |
| 49 | +@[inherit_doc] |
| 50 | +notation:25 π " β+*α΅ " β¬ => GradedRingHom π β¬ |
| 51 | + |
| 52 | +namespace GradedRingHom |
| 53 | + |
| 54 | +section ofClass |
| 55 | +variable {F : Type*} [FunLike F A B] [GradedFunLike F π β¬] [RingHomClass F A B] |
| 56 | + |
| 57 | +/-- Turn an element of a type `F` satisfying |
| 58 | +`[FunLike F A B] [GradedFunLike F π β¬] [RingHomClass F A B]` into an actual `GradedRingHom`. |
| 59 | +
|
| 60 | +This should not be used directly. In the future, Mathlib will prefer structural projections over |
| 61 | +these general constructions from hom classes. -/ |
| 62 | +@[coe] |
| 63 | +def ofClass (f : F) : π β+*α΅ β¬ where |
| 64 | + __ := (f : A β+* B) |
| 65 | + map_mem := map_mem f |
| 66 | + |
| 67 | +end ofClass |
| 68 | + |
| 69 | +section coe |
| 70 | + |
| 71 | +instance : FunLike (π β+*α΅ β¬) A B where |
| 72 | + coe f := f.toFun |
| 73 | + coe_injective' f g h := by |
| 74 | + cases f |
| 75 | + cases g |
| 76 | + congr |
| 77 | + apply DFunLike.coe_injective' |
| 78 | + exact h |
| 79 | + |
| 80 | +instance : GradedFunLike (π β+*α΅ β¬) π β¬ where |
| 81 | + map_mem f := f.map_mem |
| 82 | + |
| 83 | +instance : RingHomClass (π β+*α΅ β¬) A B where |
| 84 | + map_add f := f.map_add' |
| 85 | + map_zero f := f.map_zero' |
| 86 | + map_mul f := f.map_mul' |
| 87 | + map_one f := f.map_one' |
| 88 | + |
| 89 | +initialize_simps_projections GradedRingHom (toFun β apply) |
| 90 | + |
| 91 | +attribute [coe] GradedRingHom.toRingHom |
| 92 | + |
| 93 | +@[simp] |
| 94 | +theorem toRingHom_eq_toRingHom (f : π β+*α΅ β¬) : RingHomClass.toRingHom f = f.toRingHom := rfl |
| 95 | + |
| 96 | +@[simp] |
| 97 | +theorem coe_toRingHom (f : π β+*α΅ β¬) : βf.toRingHom = f := rfl |
| 98 | + |
| 99 | +@[simp] |
| 100 | +theorem coe_mk (f : A β+* B) (h) : ((β¨f, hβ© : π β+*α΅ β¬) : A β B) = f := rfl |
| 101 | + |
| 102 | +@[simp] |
| 103 | +theorem coe_ofClass {F : Type*} [FunLike F A B] [GradedFunLike F π β¬] [RingHomClass F A B] |
| 104 | + (f : F) : ((.ofClass f : π β+*α΅ β¬) : A β B) = f := rfl |
| 105 | + |
| 106 | +instance coeToRingHom : CoeOut (π β+*α΅ β¬) (A β+* B) := |
| 107 | + β¨GradedRingHom.toRingHomβ© |
| 108 | + |
| 109 | +/-- Copy of a `GradedRingHom` with a new `toFun` equal to the old one. Useful to fix definitional |
| 110 | +equalities. -/ |
| 111 | +def copy (f : π β+*α΅ β¬) (f' : A β B) (h : f' = f) : π β+*α΅ β¬ where |
| 112 | + __ := f.toRingHom.copy f' h |
| 113 | + map_mem hx := congr($h _ β β¬ _).to_iff.mpr <| map_mem f hx |
| 114 | + |
| 115 | +@[simp] |
| 116 | +theorem coe_copy (f : π β+*α΅ β¬) (f' : A β B) (h : f' = f) : β(f.copy f' h) = f' := |
| 117 | + rfl |
| 118 | + |
| 119 | +theorem copy_eq (f : π β+*α΅ β¬) (f' : A β B) (h : f' = f) : f.copy f' h = f := |
| 120 | + DFunLike.ext' h |
| 121 | + |
| 122 | +end coe |
| 123 | + |
| 124 | +section |
| 125 | + |
| 126 | +variable (f : π β+*α΅ β¬) |
| 127 | + |
| 128 | +protected theorem congr_fun {f g : π β+*α΅ β¬} (h : f = g) (x : A) : f x = g x := |
| 129 | + DFunLike.congr_fun h x |
| 130 | + |
| 131 | +protected theorem congr_arg (f : π β+*α΅ β¬) {x y : A} (h : x = y) : f x = f y := |
| 132 | + DFunLike.congr_arg f h |
| 133 | + |
| 134 | +theorem coe_inj β¦f g : π β+*α΅ β¬β¦ (h : (f : A β B) = g) : f = g := |
| 135 | + DFunLike.coe_injective h |
| 136 | + |
| 137 | +@[ext] |
| 138 | +theorem ext β¦f g : π β+*α΅ β¬β¦ : (β x, f x = g x) β f = g := |
| 139 | + DFunLike.ext _ _ |
| 140 | + |
| 141 | +@[simp] |
| 142 | +theorem mk_coe (f : π β+*α΅ β¬) (hβ hβ hβ hβ hβ
) : .mk β¨β¨β¨f, hββ©, hββ©, hβ, hββ© hβ
= f := |
| 143 | + ext fun _ => rfl |
| 144 | + |
| 145 | +theorem coe_ringHom_injective : (fun f : π β+*α΅ β¬ => (f : A β+* B)).Injective := fun _ _ h => |
| 146 | + ext <| DFunLike.congr_fun (F := A β+* B) h |
| 147 | + |
| 148 | +/-- Graded ring homomorphisms map zero to zero. -/ |
| 149 | +protected theorem map_zero (f : π β+*α΅ β¬) : f 0 = 0 := |
| 150 | + map_zero f |
| 151 | + |
| 152 | +/-- Graded ring homomorphisms map one to one. -/ |
| 153 | +protected theorem map_one (f : π β+*α΅ β¬) : f 1 = 1 := |
| 154 | + map_one f |
| 155 | + |
| 156 | +/-- Graded ring homomorphisms preserve addition. -/ |
| 157 | +protected theorem map_add (f : π β+*α΅ β¬) (a b : A) : f (a + b) = f a + f b := |
| 158 | + map_add .. |
| 159 | + |
| 160 | +/-- Graded ring homomorphisms preserve multiplication. -/ |
| 161 | +protected theorem map_mul (f : π β+*α΅ β¬) (a b : A) : f (a * b) = f a * f b := |
| 162 | + map_mul .. |
| 163 | + |
| 164 | +end |
| 165 | + |
| 166 | +section Ring |
| 167 | +variable {A B Ο Ο : Type*} |
| 168 | +variable [Ring A] [Ring B] [SetLike Ο A] [SetLike Ο B] |
| 169 | +variable (π : ΞΉ β Ο) (β¬ : ΞΉ β Ο) |
| 170 | + |
| 171 | +/-- Graded ring homomorphisms preserve additive inverse. -/ |
| 172 | +protected theorem map_neg (f : π β+*α΅ β¬) (x : A) : f (-x) = -f x := |
| 173 | + map_neg f x |
| 174 | + |
| 175 | +/-- Graded ring homomorphisms preserve subtraction. -/ |
| 176 | +protected theorem map_sub (f : π β+*α΅ β¬) (x y : A) : |
| 177 | + f (x - y) = f x - f y := |
| 178 | + map_sub f x y |
| 179 | + |
| 180 | +end Ring |
| 181 | + |
| 182 | +variable (π) in |
| 183 | +/-- The identity graded ring homomorphism from a graded ring to itself. -/ |
| 184 | +def id : π β+*α΅ π where |
| 185 | + __ := RingHom.id _ |
| 186 | + map_mem h := h |
| 187 | + |
| 188 | +@[simp, norm_cast] |
| 189 | +theorem coe_id : β(GradedRingHom.id π) = _root_.id := rfl |
| 190 | + |
| 191 | +@[simp] |
| 192 | +theorem id_apply (x : A) : GradedRingHom.id π x = x := |
| 193 | + rfl |
| 194 | + |
| 195 | +@[simp] |
| 196 | +theorem toRingHom_id : (id π).toRingHom = RingHom.id A := |
| 197 | + rfl |
| 198 | + |
| 199 | +/-- Composition of graded ring homomorphisms is a graded ring homomorphism. -/ |
| 200 | +def comp (g : β¬ β+*α΅ π) (f : π β+*α΅ β¬) : π β+*α΅ π where |
| 201 | + __ := g.toRingHom.comp f |
| 202 | + map_mem := g.map_mem β f.map_mem |
| 203 | + |
| 204 | +/-- Composition of graded ring homomorphisms is associative. -/ |
| 205 | +theorem comp_assoc (h : π β+*α΅ π) (g : β¬ β+*α΅ π) (f : π β+*α΅ β¬) : |
| 206 | + (h.comp g).comp f = h.comp (g.comp f) := |
| 207 | + rfl |
| 208 | + |
| 209 | +@[simp] |
| 210 | +theorem coe_comp (hnp : β¬ β+*α΅ π) (hmn : π β+*α΅ β¬) : (hnp.comp hmn : A β C) = hnp β hmn := |
| 211 | + rfl |
| 212 | + |
| 213 | +theorem comp_apply (hnp : β¬ β+*α΅ π) (hmn : π β+*α΅ β¬) (x : A) : |
| 214 | + (hnp.comp hmn : A β C) x = hnp (hmn x) := |
| 215 | + rfl |
| 216 | + |
| 217 | +@[simp] |
| 218 | +theorem comp_id (f : π β+*α΅ β¬) : f.comp (id π) = f := |
| 219 | + ext fun _ => rfl |
| 220 | + |
| 221 | +@[simp] |
| 222 | +theorem id_comp (f : π β+*α΅ β¬) : (id β¬).comp f = f := |
| 223 | + ext fun _ => rfl |
| 224 | + |
| 225 | +instance instOne : One (π β+*α΅ π) where one := id _ |
| 226 | +instance instMul : Mul (π β+*α΅ π) where mul := comp |
| 227 | + |
| 228 | +lemma one_def : (1 : π β+*α΅ π) = id π := rfl |
| 229 | + |
| 230 | +lemma mul_def (f g : π β+*α΅ π) : f * g = f.comp g := rfl |
| 231 | + |
| 232 | +@[simp, norm_cast] lemma coe_one : β(1 : π β+*α΅ π) = _root_.id := rfl |
| 233 | + |
| 234 | +@[simp, norm_cast] lemma coe_mul (f g : π β+*α΅ π) : β(f * g) = f β g := rfl |
| 235 | + |
| 236 | +instance instMonoid : Monoid (π β+*α΅ π) where |
| 237 | + mul_one := comp_id |
| 238 | + one_mul := id_comp |
| 239 | + mul_assoc _ _ _ := comp_assoc _ _ _ |
| 240 | + npow n f := (npowRec n f).copy f^[n] <| by induction n <;> simp [npowRec, *] |
| 241 | + npow_succ _ _ := DFunLike.coe_injective <| Function.iterate_succ _ _ |
| 242 | + |
| 243 | +@[simp, norm_cast] lemma coe_pow (f : π β+*α΅ π) (n : β) : β(f ^ n) = f^[n] := rfl |
| 244 | + |
| 245 | +@[simp] |
| 246 | +theorem cancel_right {gβ gβ : β¬ β+*α΅ π} {f : π β+*α΅ β¬} (hf : Function.Surjective f) : |
| 247 | + gβ.comp f = gβ.comp f β gβ = gβ := |
| 248 | + β¨fun h => ext <| hf.forall.2 (GradedRingHom.ext_iff.1 h), fun h => h βΈ rflβ© |
| 249 | + |
| 250 | +@[simp] |
| 251 | +theorem cancel_left {g : β¬ β+*α΅ π} {fβ fβ : π β+*α΅ β¬} (hg : Function.Injective g) : |
| 252 | + g.comp fβ = g.comp fβ β fβ = fβ := |
| 253 | + β¨fun h => ext fun x => hg <| by rw [β comp_apply, h, comp_apply], fun h => h βΈ rflβ© |
| 254 | + |
| 255 | +-- Note: if `GradedAddHom` is added later, then the assumptions can be relaxed. |
| 256 | +/-- A graded ring homomorphism descends to an additive homomorphism on each indexed component. -/ |
| 257 | +@[simps!] def gradedAddHom [AddSubmonoidClass Ο A] [AddSubmonoidClass Ο B] |
| 258 | + (f : π β+*α΅ β¬) (i : ΞΉ) : π i β+ β¬ i where |
| 259 | + toFun x := β¨f x, map_mem f x.2β© |
| 260 | + map_zero' := by ext; simp |
| 261 | + map_add' x y := by ext; simp |
| 262 | + |
| 263 | +/-- A graded ring homomorphism descends to a ring homomorphism on the zeroth component. -/ |
| 264 | +@[simps!] def gradedZeroRingHom [AddSubmonoidClass Ο A] [AddSubmonoidClass Ο B] [AddMonoid ΞΉ] |
| 265 | + [SetLike.GradedMonoid π] [SetLike.GradedMonoid β¬] (f : π β+*α΅ β¬) : π 0 β+* β¬ 0 where |
| 266 | + __ := f.gradedAddHom 0 |
| 267 | + map_one' := Subtype.ext <| map_one _ |
| 268 | + map_mul' _ _ := Subtype.ext <| map_mul .. |
| 269 | + |
| 270 | +end GradedRingHom |
| 271 | + |
| 272 | +end SetLike |
| 273 | + |
| 274 | +section GradedRing |
| 275 | +variable [DecidableEq ΞΉ] [AddMonoid ΞΉ] [AddSubmonoidClass Ο A] [AddSubmonoidClass Ο B] |
| 276 | +variable (π : ΞΉ β Ο) (β¬ : ΞΉ β Ο) [GradedRing π] [GradedRing β¬] |
| 277 | +variable {F : Type*} [FunLike F A B] [GradedFunLike F π β¬] [RingHomClass F A B] |
| 278 | + |
| 279 | +-- not simp because `π` cannot be inferred |
| 280 | +lemma DirectSum.decompose_map (f : F) {x : A} : |
| 281 | + DirectSum.decompose β¬ (f x) = |
| 282 | + .map (GradedRingHom.gradedAddHom <| .ofClass f) (.decompose π x) := by |
| 283 | + classical |
| 284 | + rw [β DirectSum.sum_support_decompose π x, map_sum, DirectSum.decompose_sum, |
| 285 | + DirectSum.decompose_sum, map_sum] |
| 286 | + congr 1 |
| 287 | + simp [DirectSum.decompose_of_mem _ (map_mem f (Subtype.prop _)), |
| 288 | + DirectSum.decompose_of_mem _ (Subtype.prop _), DirectSum.map_of, GradedRingHom.gradedAddHom] |
| 289 | + |
| 290 | +-- not simp because `β¬` cannot be inferred |
| 291 | +-- for every concrete instance of GradedFunLike, we need one simp lemma |
| 292 | +lemma map_directSumDecompose (f : F) {x : A} {i : ΞΉ} : |
| 293 | + f (DirectSum.decompose π x i) = DirectSum.decompose β¬ (f x) i := by |
| 294 | + simp [DirectSum.decompose_map π] |
| 295 | + |
| 296 | +@[simp] lemma GradedRingHom.map_directSumDecompose (f : π β+*α΅ β¬) {x : A} {i : ΞΉ} : |
| 297 | + f (DirectSum.decompose π x i) = DirectSum.decompose β¬ (f x) i := |
| 298 | + _root_.map_directSumDecompose .. |
| 299 | + |
| 300 | +end GradedRing |
0 commit comments