reserve R for Ring,
  V for RightMod of R,
  a,b for Scalar of R,
  x,y for set,
  p,q ,r for FinSequence,
  i,k for Nat,
  u,v,v1,v2,v3,w for Vector of V,
  F,G,H for FinSequence of V,
  A,B for Subset of V,
  f for Function of V, R,
  S,T for finite Subset of V;
reserve L,L1,L2,L3 for Linear_Combination of V;
reserve l for Linear_Combination of A;
reserve RR for domRing;
reserve VV for RightMod of RR;
reserve LL for Linear_Combination of VV;
reserve aa for Scalar of RR;
reserve uu, vv for Vector of VV;
reserve R for domRing;
reserve V for RightMod of R;
reserve L,L1,L2 for Linear_Combination of V;
reserve a for Scalar of R;

theorem Th59:
  Sum(L * a) = Sum(L) * a
proof
  per cases;
  suppose
A1: a <> 0.R;
    set l = L * a;
A2: Carrier(l) = Carrier(L) by A1,Th43;
    consider G being FinSequence of V such that
A3: G is one-to-one and
A4: rng G = Carrier(L) and
A5: Sum(L) = Sum(L (#) G) by Def7;
    set g = L (#) G;
    consider F being FinSequence of V such that
A6: F is one-to-one and
A7: rng F = Carrier(L * a) and
A8: Sum(L * a) = Sum((L * a) (#) F) by Def7;
A9: len G = len F by A1,A6,A7,A3,A4,Th43,FINSEQ_1:48;
    set f = (L * a) (#) F;
    deffunc Q(Nat)= F <- (G.$1);
    consider P being FinSequence such that
A10: len P = len F and
A11: for k be Nat st k in dom P holds P.k = Q(k) from FINSEQ_1:sch 2;
A12: dom P = Seg len F by A10,FINSEQ_1:def 3;
A13: now
      let x be object;
      assume
A14:  x in dom G;
      then reconsider n = x as Nat by FINSEQ_3:23;
      G.n in rng F by A7,A4,A2,A14,FUNCT_1:def 3;
      then
A15:  F just_once_values G.n by A6,FINSEQ_4:8;
      n in Seg len F by A9,A14,FINSEQ_1:def 3;
      then F.(P.n) = F.(F <- (G.n)) by A11,A12
        .= G.n by A15,FINSEQ_4:def 3;
      hence G.x = F.(P.x);
    end;
A16: rng P c= dom F
    proof
      let x be object;
      assume x in rng P;
      then consider y being object such that
A17:  y in dom P and
A18:  P.y = x by FUNCT_1:def 3;
      reconsider y as Nat by A17,FINSEQ_3:23;
      y in dom G by A10,A9,A17,FINSEQ_3:29;
      then G.y in rng F by A7,A4,A2,FUNCT_1:def 3;
      then
A19:  F just_once_values G.y by A6,FINSEQ_4:8;
      P.y = F <- (G.y) by A11,A17;
      hence thesis by A18,A19,FINSEQ_4:def 3;
    end;
    now
      let x be object;
      thus x in dom G implies x in dom P & P.x in dom F
      proof
        assume x in dom G;
        then x in Seg(len P) by A10,A9,FINSEQ_1:def 3;
        hence x in dom P by FINSEQ_1:def 3;
        then P.x in rng P by FUNCT_1:def 3;
        hence thesis by A16;
      end;
      assume that
A20:  x in dom P and
      P.x in dom F;
      x in Seg(len P) by A20,FINSEQ_1:def 3;
      hence x in dom G by A10,A9,FINSEQ_1:def 3;
    end;
    then
A21: G = F * P by A13,FUNCT_1:10;
    dom F c= rng P
    proof
      set f = F" * G;
      let x be object;
      assume
A22:  x in dom F;
      dom(F") = rng G by A6,A7,A4,A2,FUNCT_1:33;
      then
A23:  rng f = rng(F") by RELAT_1:28
        .= dom F by A6,FUNCT_1:33;
      f = F " * F * P by A21,RELAT_1:36
        .= id(dom F) * P by A6,FUNCT_1:39
        .= P by A16,RELAT_1:53;
      hence thesis by A22,A23;
    end;
    then
A24: dom F = rng P by A16;
A25: dom P = dom F by A10,FINSEQ_3:29;
    then
A26: P is one-to-one by A24,FINSEQ_4:60;
    reconsider P as Function of dom F, dom F by A16,A25,FUNCT_2:2;
A27: len f = len F by Def6;
    then
A28: dom f = dom F by FINSEQ_3:29;
    then reconsider P as Function of dom f, dom f;
    reconsider Fp = f * P as FinSequence of V by FINSEQ_2:47;
    reconsider P as Permutation of dom f by A24,A26,A28,FUNCT_2:57;
A29: Fp = f * P;
    then
A30: len Fp = len f by FINSEQ_2:44;
    then
A31: len Fp = len g by A9,A27,Def6;
A32: now
      let k;
      let v be Vector of V;
      assume that
A33:  k in dom Fp and
A34:  v = g.k;
A35:  k in Seg(len g) by A31,A33,FINSEQ_1:def 3;
      then
A36:  k in dom P by A10,A27,A30,A31,FINSEQ_1:def 3;
A37:  k in dom G by A9,A27,A30,A31,A35,FINSEQ_1:def 3;
      then G.k in rng G by FUNCT_1:def 3;
      then F just_once_values G.k by A6,A7,A4,A2,FINSEQ_4:8;
      then
A38:  (F <- (G.k)) in dom F by FINSEQ_4:def 3;
      then reconsider i = F <- (G.k) as Nat by FINSEQ_3:23;
A39:  G/.k = G.k by A37,PARTFUN1:def 6
        .= F.(P.k) by A21,A36,FUNCT_1:13
        .= F.i by A11,A12,A27,A30,A31,A35
        .= F/.i by A38,PARTFUN1:def 6;
A40:  k in dom g by A35,FINSEQ_1:def 3;
      i in Seg(len f) by A27,A38,FINSEQ_1:def 3;
      then
A41:  i in dom f by FINSEQ_1:def 3;
      thus Fp.k = f.(P.k) by A36,FUNCT_1:13
        .= f.(F <- (G.k)) by A11,A12,A27,A30,A31,A35
        .= (F/.i) * l.(F/.i) by A41,Def6
        .= (F/.i) * (L.(F/.i) * a) by Def10
        .= (F/.i) * L.(F/.i) * a by VECTSP_2:def 9
        .= v * a by A34,A40,A39,Def6;
    end;
    Sum(Fp) = Sum(f) by A29,RLVECT_2:7;
    hence thesis by A8,A5,A31,A32,Th1;
  end;
  suppose
A42: a = 0.R;
    hence Sum(L * a) = Sum(ZeroLC(V)) by Th44
      .= 0.V by Lm3
      .= Sum(L) * a by A42,VECTSP_2:32;
  end;
end;
