/-
Copyright (c) 2015 Nathaniel Thomas. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro
-/
module
public import Mathlib.Algebra.GroupWithZero.Action.
End
public import Mathlib.Algebra.
Module.Defs
public import Mathlib.Algebra.Ring.Hom.Defs
/-!
# Composing modules with a ring hom
## Main definitions
* `Module.compHom`: compose a `Module` with a `RingHom`, with action `f s • m`.
* `RingHom.toModule`: a `RingHom` defines a module structure by `r • x = f r * x`.
## Tags
semimodule, module, vector space
-/
@[
expose]
public section
assert_not_exists Field Invertible Multiset Pi.single_smul₀
Set.indicator
open Function
universe u v
variable {R S M : Type*}
section AddCommMonoid
variable [Semiring R] [AddCommMonoid M] [
Module R M] (r s : R) (x : M)
variable (R)
/-- Push forward the action of `R` on `M` along a compatible surjective map `f : R →+* S`.
See also `Function.Surjective.mulActionLeft` and `Function.Surjective.distribMulActionLeft`.
-/
abbrev Function.Surjective.moduleLeft {R S M : Type*} [Semiring R] [AddCommMonoid M] [
Module R M]
[Semiring S] [SMul S M] (f : R →+* S) (hf : Function.Surjective f)
(hsmul : ∀ (c) (x : M), f c • x = c • x) :
Module S M :=
{ hf.distribMulActionLeft f.toMonoidHom hsmul with
zero_smul :=
fun x =>
by rw [← f.map_zero, hsmul, zero_smul]
add_smul := hf.forall₂.mpr
fun a b x =>
by simp only [← f.map_add, hsmul, add_smul] }
variable {R} (M)
/-- Compose a `Module` with a `RingHom`, with action `f s • m`.
See note [reducible non-instances]. -/
abbrev Module.compHom [Semiring S] (f : S →+* R) :
Module S M :=
{ MulActionWithZero.compHom M f.toMonoidWithZeroHom, DistribMulAction.compHom M (f : S →* R
) with
-- Porting note: the `show f (r + s) • x = f r • x + f s • x` wasn't needed in mathlib3.
-- Somehow, now that `SMul` is heterogeneous, it can't unfold earlier fields of a definition for
-- use in later fields. See
-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Heterogeneous.20scalar.20multiplication
-- TODO(jmc): there should be a rw-lemma `smul_comp` close to `SMulZeroClass.compFun`
add_smul := fun r s x => show f (r + s) • x = f r • x + f s • x by simp [add_smul] }
end AddCommMonoid
/-- A ring homomorphism `f : R →+* M` defines a module structure by `r • x = f r * x`.
See note [reducible non-instances]. -/
abbrev RingHom.toModule [Semiring R] [Semiring S] (f : R →+* S) : Module R S :=
Module.compHom S f
lemma RingHom.toModule_smul [Semiring R] [Semiring S] (f : R →+* S) (x : R) (y : S) :
letI := f.toModule
x • y = f x * y :=
rfl
/-- If the module action of `R` on `S` is compatible with multiplication on `S`, then
`fun x ↦ x • 1` is a ring homomorphism from `R` to `S`.
This is the `RingHom` version of `MonoidHom.smulOneHom`.
When `R` is commutative, usually `algebraMap` should be preferred. -/
@[simps!] def RingHom.smulOneHom
[Semiring R] [NonAssocSemiring S] [Module R S] [IsScalarTower R S S] : R →+* S where
__ := MonoidHom.smulOneHom
map_zero' := zero_smul R 1
map_add' := (add_smul · · 1)
/-- A homomorphism between semirings R and S can be equivalently specified by an R-module
structure on S such that S/S/R is a scalar tower. -/
def ringHomEquivModuleIsScalarTower [Semiring R] [Semiring S] :
(R →+* S) ≃ {_inst : Module R S // IsScalarTower R S S} where
toFun f := ⟨Module.compHom S f, SMul.comp.isScalarTower _⟩
invFun := fun ⟨_, _⟩ ↦ RingHom.smulOneHom
left_inv f := RingHom.ext fun r ↦ mul_one (f r)
right_inv := fun ⟨_, _⟩ ↦ Subtype.ext <| Module.ext <| funext₂ <| smul_one_smul S