/-- The `DFinsupp` version of `Finsupp.lsum`.

See note [bundled maps over different rings] for why separate `R` and `S` semirings are used. -/
@[simps]
def lsum [Semiring S] [Module S N] [SMulCommClass R S N] :
    (∀ i, M i →ₗ[R] N) ≃ₗ[S] (Π₀ i, M i) →ₗ[R] N where
  toFun F :=
    { toFun := sumAddHom fun i => (F i).toAddMonoidHom
      -- Porting note: needed to (β := M) hint below
      map_add' := (DFinsupp.liftAddHom (β := M) (fun (i : ι) => (F i).toAddMonoidHom)).map_add
      map_smul' := fun c f => by
        dsimp
        apply DFinsupp.induction f
        · rw [smul_zero, AddMonoidHom.map_zero, smul_zero]
        · intro a b f _ _ hf
          rw [smul_add, AddMonoidHom.map_add, AddMonoidHom.map_add, smul_add, hf, ← single_smul,
            sumAddHom_single, sumAddHom_single, LinearMap.toAddMonoidHom_coe,
            LinearMap.map_smul] }
  invFun F i := F.comp (lsingle i)
  left_inv F := by
    ext
    simp
  right_inv F := by
    refine DFinsupp.lhom_ext' (fun i ↦ ?_)
    ext
    simp
  map_add' F G := by
    refine DFinsupp.lhom_ext' (fun i ↦ ?_)
    ext
    

Proof state:
case h
ι : Type u_1
R : Type u_2
S : Type u_3
M : ι → Type u_4
N : Type u_5
dec_ι : DecidableEq ι
inst✝⁷ : Semiring R
inst✝⁶ : (i : ι) → AddCommMonoid (M i)
inst✝⁵ : (i : ι) → Module R (M i)
inst✝⁴ : AddCommMonoid N
inst✝³ : Module R N
inst✝² : Semiring S
inst✝¹ : Module S N
inst✝ : SMulCommClass R S N
F G : (i : ι) → M i →ₗ[R] N
i : ι
x✝ : M i
⊢ ((fun F =>
            {
              toAddHom :=
                { toFun := ⇑(sumAddHom fun i => LinearMap.toAddMonoidHom (F i)),
                  map_add' :=
                    (_ :
                      ∀ (a b : Π₀ (i : ι), M i),
                        (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) (a + b) =
                          (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) a +
                            (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) b) },
              map_smul' :=
                (_ :
                  ∀ (c : R) (f : Π₀ (i : ι), M i),
                    AddHom.toFun
                        { toFun := ⇑(sumAddHom fun i => LinearMap.toAddMonoidHom (F i)),
                          map_add' :=
                            (_ :
                              ∀ (a b : Π₀ (i : ι), M i),
                                (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) (a + b) =
                                  (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) a +
                                    (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) b) }
                        (c • f) =
                      (RingHom.id R) c •
                        AddHom.toFun
                          { toFun := ⇑(sumAddHom fun i => LinearMap.toAddMonoidHom (F i)),
                            map_add' :=
                              (_ :
                                ∀ (a b : Π₀ (i : ι), M i),
                                  (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) (a + b) =
                                    (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) a +
                                      (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) b) }
                          f) })
          (F + G) ∘ₗ
        lsingle i)
      x✝ =
    (((fun F =>
              {
                toAddHom :=
                  { toFun := ⇑(sumAddHom fun i => LinearMap.toAddMonoidHom (F i)),
                    map_add' :=
                      (_ :
                        ∀ (a b : Π₀ (i : ι), M i),
                          (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) (a + b) =
                            (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) a +
                              (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) b) },
                map_smul' :=
                  (_ :
                    ∀ (c : R) (f : Π₀ (i : ι), M i),
                      AddHom.toFun
                          { toFun := ⇑(sumAddHom fun i => LinearMap.toAddMonoidHom (F i)),
                            map_add' :=
                              (_ :
                                ∀ (a b : Π₀ (i : ι), M i),
                                  (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) (a + b) =
                                    (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) a +
                                      (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) b) }
                          (c • f) =
                        (RingHom.id R) c •
                          AddHom.toFun
                            { toFun := ⇑(sumAddHom fun i => LinearMap.toAddMonoidHom (F i)),
                              map_add' :=
                                (_ :
                                  ∀ (a b : Π₀ (i : ι), M i),
                                    (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) (a + b) =
                                      (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) a +
                                        (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) b) }
                            f) })
            F +
          (fun F =>
              {
                toAddHom :=
                  { toFun := ⇑(sumAddHom fun i => LinearMap.toAddMonoidHom (F i)),
                    map_add' :=
                      (_ :
                        ∀ (a b : Π₀ (i : ι), M i),
                          (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) (a + b) =
                            (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) a +
                              (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) b) },
                map_smul' :=
                  (_ :
                    ∀ (c : R) (f : Π₀ (i : ι), M i),
                      AddHom.toFun
                          { toFun := ⇑(sumAddHom fun i => LinearMap.toAddMonoidHom (F i)),
                            map_add' :=
                              (_ :
                                ∀ (a b : Π₀ (i : ι), M i),
                                  (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) (a + b) =
                                    (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) a +
                                      (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) b) }
                          (c • f) =
                        (RingHom.id R) c •
                          AddHom.toFun
                            { toFun := ⇑(sumAddHom fun i => LinearMap.toAddMonoidHom (F i)),
                              map_add' :=
                                (_ :
                                  ∀ (a b : Π₀ (i : ι), M i),
                                    (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) (a + b) =
                                      (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) a +
                                        (liftAddHom fun i => LinearMap.toAddMonoidHom (F i)) b) }
                            f) })
            G) ∘ₗ
        lsingle i)
      x✝

Next tactic:
simp