/-- 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
    

Proof state:
ι : 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 : (i : ι) → M i →ₗ[R] N
⊢ (fun F i => F ∘ₗ lsingle i)
      (AddHom.toFun
        {
            toAddHom :=
              {
                toFun := 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) },
                map_add' :=
                  (_ :
                    ∀ (F G : (i : ι) → M i →ₗ[R] N),
                      (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) =
                        (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) },
            map_smul' :=
              (_ :
                ∀ (c : S) (F : (i : ι) → M i →ₗ[R] N),
                  AddHom.toFun
                      {
                        toFun := 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) },
                        map_add' :=
                          (_ :
                            ∀ (F G : (i : ι) → M i →ₗ[R] N),
                              (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) =
                                (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) }
                      (c • F) =
                    (RingHom.id S) c •
                      AddHom.toFun
                        {
                          toFun := 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) },
                          map_add' :=
                            (_ :
                              ∀ (F G : (i : ι) → M i →ₗ[R] N),
                                (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) =
                                  (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) }
                        F) }.toAddHom
        F) =
    F

Next tactic:
ext