@@ -32,7 +32,7 @@ much more developed, but many lemmas in that file should be eligible to copy ove
3232function with finite support, semimodule, linear algebra
3333-/
3434
35- variables {ι : Type *} {R : Type *} {M : ι → Type *} {N : Type *}
35+ variables {ι : Type *} {R : Type *} {S : Type *} { M : ι → Type *} {N : Type *}
3636
3737variables [dec_ι : decidable_eq ι]
3838variables [semiring R] [Π i, add_comm_monoid (M i)] [Π i, semimodule R (M i)]
@@ -83,11 +83,34 @@ omit dec_ι
8383
8484@[simp] lemma lapply_apply (i : ι) (f : Π₀ i, M i) : (lapply i : _ →ₗ[R] _) f = f i := rfl
8585
86+ section lsum
87+
88+ /-- Typeclass inference can't find `dfinsupp.add_comm_monoid` without help for this case.
89+ This instance allows it to be found where it is needed on the LHS of the colon in
90+ `dfinsupp.semimodule_of_linear_map`. -/
91+ instance add_comm_monoid_of_linear_map : add_comm_monoid (Π₀ (i : ι), M i →ₗ[R] N) :=
92+ @dfinsupp.add_comm_monoid _ (λ i, M i →ₗ[R] N) _
93+
94+ /-- Typeclass inference can't find `dfinsupp.semimodule` without help for this case.
95+ This is needed to define `dfinsupp.lsum` below.
96+
97+ The cause seems to be an inability to unify the `Π i, add_comm_monoid (M i →ₗ[R] N)` instance that
98+ we have with the `Π i, has_zero (M i →ₗ[R] N)` instance which appears as a parameter to the
99+ `dfinsupp` type. -/
100+ instance semimodule_of_linear_map [semiring S] [semimodule S N] [smul_comm_class R S N] :
101+ semimodule S (Π₀ (i : ι), M i →ₗ[R] N) :=
102+ @dfinsupp.semimodule _ (λ i, M i →ₗ[R] N) _ _ _ _
103+
104+ variables (S)
105+
86106include dec_ι
87107
88- /-- The `dfinsupp` version of `finsupp.lsum`. -/
108+ /-- The `dfinsupp` version of `finsupp.lsum`.
109+
110+ See note [bundled maps over different rings] for why separate `R` and `S` semirings are used. -/
89111@[simps apply symm_apply]
90- def lsum : (Π i, M i →ₗ[R] N) ≃+ ((Π₀ i, M i) →ₗ[R] N) :=
112+ def lsum [semiring S] [semimodule S N] [smul_comm_class R S N] :
113+ (Π i, M i →ₗ[R] N) ≃ₗ[S] ((Π₀ i, M i) →ₗ[R] N) :=
91114{ to_fun := λ F, {
92115 to_fun := sum_add_hom (λ i, (F i).to_add_monoid_hom),
93116 map_add' := (lift_add_hom (λ i, (F i).to_add_monoid_hom)).map_add,
@@ -101,6 +124,9 @@ def lsum : (Π i, M i →ₗ[R] N) ≃+ ((Π₀ i, M i) →ₗ[R] N) :=
101124 inv_fun := λ F i, F.comp (lsingle i),
102125 left_inv := λ F, by { ext x y, simp },
103126 right_inv := λ F, by { ext x y, simp },
104- map_add' := λ F G, by { ext x y, simp } }
127+ map_add' := λ F G, by { ext x y, simp },
128+ map_smul' := λ c F, by { ext, simp } }
129+
130+ end lsum
105131
106132end dfinsupp
0 commit comments