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;

theorem Th58:
  Sum(L1 + L2) = Sum(L1) + Sum(L2)
proof
  set A = Carrier(L1 + L2) \/ Carrier(L1) \/ Carrier(L2);
  set C1 = A \ Carrier(L1);
  consider p such that
A1: rng p = C1 and
A2: p is one-to-one by FINSEQ_4:58;
  reconsider p as FinSequence of V by A1,FINSEQ_1:def 4;
A3: A = Carrier(L1) \/ (Carrier(L1 + L2) \/ Carrier(L2)) by XBOOLE_1:4;
  set C3 = A \ Carrier(L1 + L2);
  consider r such that
A4: rng r = C3 and
A5: r is one-to-one by FINSEQ_4:58;
  reconsider r as FinSequence of V by A4,FINSEQ_1:def 4;
A6: A = Carrier(L1 + L2) \/ (Carrier(L1) \/ Carrier(L2)) by XBOOLE_1:4;
  set C2 = A \ Carrier(L2);
  consider q such that
A7: rng q = C2 and
A8: q is one-to-one by FINSEQ_4:58;
  reconsider q as FinSequence of V by A7,FINSEQ_1:def 4;
  consider F such that
A9: F is one-to-one and
A10: rng F = Carrier(L1 + L2) and
A11: Sum((L1 + L2) (#) F) = Sum(L1 + L2) by Def7;
  set FF = F ^ r;
  consider G such that
A12: G is one-to-one and
A13: rng G = Carrier(L1) and
A14: Sum(L1 (#) G) = Sum(L1) by Def7;
  rng FF = rng F \/ rng r by FINSEQ_1:31;
  then rng FF = Carrier(L1 + L2) \/ A by A10,A4,XBOOLE_1:39;
  then
A15: rng FF = A by A6,XBOOLE_1:7,12;
  set GG = G ^ p;
  rng GG = rng G \/ rng p by FINSEQ_1:31;
  then rng GG = Carrier(L1) \/ A by A13,A1,XBOOLE_1:39;
  then
A16: rng GG = A by A3,XBOOLE_1:7,12;
  rng F misses rng r
  proof
    set x = the Element of rng F /\ rng r;
    assume not thesis;
    then rng F /\ rng r <> {};
    then x in Carrier(L1 + L2) & x in C3 by A10,A4,XBOOLE_0:def 4;
    hence thesis by XBOOLE_0:def 5;
  end;
  then
A17: FF is one-to-one by A9,A5,FINSEQ_3:91;
  rng G misses rng p
  proof
    set x = the Element of rng G /\ rng p;
    assume not thesis;
    then rng G /\ rng p <> {};
    then x in Carrier(L1) & x in C1 by A13,A1,XBOOLE_0:def 4;
    hence thesis by XBOOLE_0:def 5;
  end;
  then
A18: GG is one-to-one by A12,A2,FINSEQ_3:91;
  then
A19: len GG = len FF by A17,A16,A15,FINSEQ_1:48;
  deffunc Q(Nat)=FF <- (GG.$1);
  consider P being FinSequence such that
A20: len P = len FF and
A21: for k be Nat st k in dom P holds P.k = Q(k) from FINSEQ_1:sch 2;
A22: dom P = Seg len FF by A20,FINSEQ_1:def 3;
A23: now
    let x be object;
    assume
A24: x in dom GG;
    then reconsider n = x as Nat by FINSEQ_3:23;
    GG.n in rng FF by A16,A15,A24,FUNCT_1:def 3;
    then
A25: FF just_once_values GG.n by A17,FINSEQ_4:8;
    n in Seg(len FF) by A19,A24,FINSEQ_1:def 3;
    then FF.(P.n) = FF.(FF <- (GG.n)) by A21,A22
      .= GG.n by A25,FINSEQ_4:def 3;
    hence GG.x = FF.(P.x);
  end;
A26: dom GG = dom FF by A19,FINSEQ_3:29;
A27: rng P c= dom FF
  proof
    let x be object;
    assume x in rng P;
    then consider y being object such that
A28: y in dom P and
A29: P.y = x by FUNCT_1:def 3;
    reconsider y as Nat by A28,FINSEQ_3:23;
    y in dom FF by A20,A28,FINSEQ_3:29;
    then GG.y in rng FF by A16,A15,A26,FUNCT_1:def 3;
    then
A30: FF just_once_values GG.y by A17,FINSEQ_4:8;
    P.y = FF <- (GG.y) by A21,A28;
    hence thesis by A29,A30,FINSEQ_4:def 3;
  end;
  now
    let x be object;
    thus x in dom GG implies x in dom P & P.x in dom FF
    proof
      assume x in dom GG;
      hence x in dom P by A19,A20,FINSEQ_3:29;
      then P.x in rng P by FUNCT_1:def 3;
      hence thesis by A27;
    end;
    assume that
A31: x in dom P and
    P.x in dom FF;
    x in Seg(len P) by A31,FINSEQ_1:def 3;
    hence x in dom GG by A19,A20,FINSEQ_1:def 3;
  end;
  then
A32: GG = FF * P by A23,FUNCT_1:10;
  dom FF c= rng P
  proof
    set f = FF" * GG;
    let x be object;
    assume
A33: x in dom FF;
    dom(FF") = rng GG by A17,A16,A15,FUNCT_1:33;
    then
A34: rng f = rng(FF") by RELAT_1:28
      .= dom FF by A17,FUNCT_1:33;
    f = FF " * FF * P by A32,RELAT_1:36
      .= id(dom FF) * P by A17,FUNCT_1:39
      .= P by A27,RELAT_1:53;
    hence thesis by A33,A34;
  end;
  then
A35: dom FF = rng P by A27;
A36: len r = len((L1 + L2) (#) r) by Def6;
  now
    let k;
    assume
A37: k in dom r;
    then r/.k = r.k by PARTFUN1:def 6;
    then r/.k in C3 by A4,A37,FUNCT_1:def 3;
    then
A38: not r/.k in Carrier((L1 + L2)) by XBOOLE_0:def 5;
    k in dom((L1 + L2) (#) r) by A36,A37,FINSEQ_3:29;
    then ((L1 + L2) (#) r).k = (r/.k) * (L1 + L2).(r/.k) by Def6;
    hence ((L1 + L2) (#) r).k = (r/.k) * 0.R by A38;
  end;
  then
A39: Sum((L1 + L2) (#) r) = Sum(r) * 0.R by A36,Lm2
    .= 0.V by VECTSP_2:32;
A40: len p = len(L1 (#) p) by Def6;
  now
    let k;
    assume
A41: k in dom p;
    then p/.k = p.k by PARTFUN1:def 6;
    then p/.k in C1 by A1,A41,FUNCT_1:def 3;
    then
A42: not p/.k in Carrier(L1) by XBOOLE_0:def 5;
    k in dom(L1 (#) p) by A40,A41,FINSEQ_3:29;
    then (L1 (#) p).k = (p/.k) * L1.(p/.k) by Def6;
    hence (L1 (#) p).k = (p/.k) * 0.R by A42;
  end;
  then
A43: Sum(L1 (#) p) = Sum(p) * 0.R by A40,Lm2
    .= 0.V by VECTSP_2:32;
  set f = (L1 + L2) (#) FF;
  consider H such that
A44: H is one-to-one and
A45: rng H = Carrier(L2) and
A46: Sum(L2 (#) H) = Sum(L2) by Def7;
  set HH = H ^ q;
  rng H misses rng q
  proof
    set x = the Element of rng H /\ rng q;
    assume not thesis;
    then rng H /\ rng q <> {};
    then x in Carrier(L2) & x in C2 by A45,A7,XBOOLE_0:def 4;
    hence thesis by XBOOLE_0:def 5;
  end;
  then
A47: HH is one-to-one by A44,A8,FINSEQ_3:91;
A48: len q = len(L2 (#) q) by Def6;
  now
    let k;
    assume
A49: k in dom q;
    then q/.k = q.k by PARTFUN1:def 6;
    then q/.k in C2 by A7,A49,FUNCT_1:def 3;
    then
A50: not q/.k in Carrier(L2) by XBOOLE_0:def 5;
    k in dom(L2 (#) q) by A48,A49,FINSEQ_3:29;
    then (L2 (#) q).k = (q/.k) * L2.(q/.k) by Def6;
    hence (L2 (#) q).k = (q/.k) * 0.R by A50;
  end;
  then
A51: Sum(L2 (#) q) = Sum(q) * 0.R by A48,Lm2
    .= 0.V by VECTSP_2:32;
  set g = L1 (#) GG;
A52: len g = len GG by Def6;
  then
A53: Seg len GG = dom g by FINSEQ_1:def 3;
  rng HH = rng H \/ rng q by FINSEQ_1:31;
  then rng HH = Carrier(L2) \/ A by A45,A7,XBOOLE_1:39;
  then
A54: rng HH = A by XBOOLE_1:7,12;
  then
A55: len GG = len HH by A47,A18,A16,FINSEQ_1:48;
  deffunc Q(Nat)=HH <- (GG.$1);
  consider R being FinSequence such that
A56: len R = len HH and
A57: for k be Nat st k in dom R holds R.k = Q(k) from FINSEQ_1:sch 2;
A58: dom R = Seg len HH by A56,FINSEQ_1:def 3;
A59: now
    let x be object;
    assume
A60: x in dom GG;
    then reconsider n = x as Nat by FINSEQ_3:23;
    GG.n in rng HH by A16,A54,A60,FUNCT_1:def 3;
    then
A61: HH just_once_values GG.n by A47,FINSEQ_4:8;
    n in Seg(len HH) by A55,A60,FINSEQ_1:def 3;
    then HH.(R.n) = HH.(HH <- (GG.n)) by A57,A58
      .= GG.n by A61,FINSEQ_4:def 3;
    hence GG.x = HH.(R.x);
  end;
A62: dom GG = dom HH by A55,FINSEQ_3:29;
A63: rng R c= dom HH
  proof
    let x be object;
    assume x in rng R;
    then consider y being object such that
A64: y in dom R and
A65: R.y = x by FUNCT_1:def 3;
    reconsider y as Nat by A64,FINSEQ_3:23;
    y in dom HH by A56,A64,FINSEQ_3:29;
    then GG.y in rng HH by A16,A54,A62,FUNCT_1:def 3;
    then
A66: HH just_once_values GG.y by A47,FINSEQ_4:8;
    R.y = HH <- (GG.y) by A57,A64;
    hence thesis by A65,A66,FINSEQ_4:def 3;
  end;
  now
    let x be object;
    thus x in dom GG implies x in dom R & R.x in dom HH
    proof
      assume x in dom GG;
      then x in Seg(len R) by A55,A56,FINSEQ_1:def 3;
      hence x in dom R by FINSEQ_1:def 3;
      then R.x in rng R by FUNCT_1:def 3;
      hence thesis by A63;
    end;
    assume that
A67: x in dom R and
    R.x in dom HH;
    x in Seg(len R) by A67,FINSEQ_1:def 3;
    hence x in dom GG by A55,A56,FINSEQ_1:def 3;
  end;
  then
A68: GG = HH * R by A59,FUNCT_1:10;
  dom HH c= rng R
  proof
    set f = HH" * GG;
    let x be object;
    assume
A69: x in dom HH;
    dom(HH") = rng GG by A47,A16,A54,FUNCT_1:33;
    then
A70: rng f = rng(HH") by RELAT_1:28
      .= dom HH by A47,FUNCT_1:33;
    f = HH " * HH * R by A68,RELAT_1:36
      .= id(dom HH) * R by A47,FUNCT_1:39
      .= R by A63,RELAT_1:53;
    hence thesis by A69,A70;
  end;
  then
A71: dom HH = rng R by A63;
A72: Sum(g) = Sum((L1 (#) G) ^ (L1 (#) p)) by Th28
    .= Sum(L1 (#) G) + 0.V by A43,RLVECT_1:41
    .= Sum(L1 (#) G) by RLVECT_1:def 4;
  set h = L2 (#) HH;
A73: Sum(h) = Sum((L2 (#) H) ^ (L2 (#) q)) by Th28
    .= Sum(L2 (#) H) + 0.V by A51,RLVECT_1:41
    .= Sum(L2 (#) H) by RLVECT_1:def 4;
A74: Sum(f) = Sum(((L1 + L2) (#) F) ^ ((L1 + L2) (#) r)) by Th28
    .= Sum((L1 + L2) (#) F) + 0.V by A39,RLVECT_1:41
    .= Sum((L1 + L2) (#) F) by RLVECT_1:def 4;
A75: dom P = dom FF by A20,FINSEQ_3:29;
  then
A76: P is one-to-one by A35,FINSEQ_4:60;
A77: dom R = dom HH by A56,FINSEQ_3:29;
  then
A78: R is one-to-one by A71,FINSEQ_4:60;
  reconsider R as Function of dom HH, dom HH by A63,A77,FUNCT_2:2;
A79: len h = len HH by Def6;
  then
A80: dom h = dom HH by FINSEQ_3:29;
  then reconsider R as Function of dom h, dom h;
  reconsider Hp = h * R as FinSequence of V by FINSEQ_2:47;
  reconsider R as Permutation of dom h by A71,A78,A80,FUNCT_2:57;
A81: Hp = h * R;
  then
A82: len Hp = len GG by A55,A79,FINSEQ_2:44;
  reconsider P as Function of dom FF, dom FF by A27,A75,FUNCT_2:2;
A83: len f = len FF by Def6;
  then
A84: dom f = dom FF 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 A35,A76,A84,FUNCT_2:57;
A85: Fp = f * P;
  then
A86: Sum(Fp) = Sum(f) by RLVECT_2:7;
  deffunc Q(Nat) = (g/.$1) + (Hp/.$1);
  consider I being FinSequence such that
A87: len I = len GG and
A88: for k be Nat st k in dom I holds I.k = Q(k) from FINSEQ_1:sch 2;
A89: dom I = Seg len GG by A87,FINSEQ_1:def 3;
  then
A90: for k be Nat st k in Seg(len GG) holds I.k = Q(k) by A88;
  rng I c= the carrier of V
  proof
    let x be object;
    assume x in rng I;
    then consider y being object such that
A91: y in dom I and
A92: I.y = x by FUNCT_1:def 3;
    reconsider y as Nat by A91,FINSEQ_3:23;
    I.y = (g/.y) + (Hp/.y) by A88,A91;
    hence thesis by A92;
  end;
  then reconsider I as FinSequence of V by FINSEQ_1:def 4;
A93: len Fp = len I by A19,A83,A85,A87,FINSEQ_2:44;
A94: now
    let x be object;
    assume
A95: x in Seg(len I);
    then reconsider k = x as Element of NAT;
A96: x in dom HH by A55,A87,A95,FINSEQ_1:def 3;
    then R.k in dom R by A71,A77,FUNCT_1:def 3;
    then reconsider j = R.k as Nat by FINSEQ_3:23;
A97: x in dom GG by A87,A95,FINSEQ_1:def 3;
    then
A98: HH.j = GG.k by A59
      .= GG/.k by A97,PARTFUN1:def 6;
    P.k in dom P by A26,A62,A35,A75,A96,FUNCT_1:def 3;
    then reconsider l = P.k as Nat by FINSEQ_3:23;
    set v = GG/.k;
A99: x in dom Fp by A93,A95,FINSEQ_1:def 3;
A100: FF.l = GG.k by A23,A97
      .= GG/.k by A97,PARTFUN1:def 6;
    P.k in dom FF by A26,A62,A35,A75,A96,FUNCT_1:def 3;
    then
A101: f.l = v * (L1 + L2).v by A100,Th23
      .= v * (L1.v + L2.v) by Def9
      .= v * L1.v + v * L2.v by VECTSP_2:def 9;
A102: x in dom Hp by A87,A82,A95,FINSEQ_1:def 3;
    then
A103: Hp/.k = (h * R).k by PARTFUN1:def 6
      .= h.(R.k) by A102,FUNCT_1:12;
    R.k in dom HH by A71,A77,A96,FUNCT_1:def 3;
    then
A104: h.j = v * L2.v by A98,Th23;
A105: x in dom g by A87,A52,A95,FINSEQ_1:def 3;
    then g/.k = g.k by PARTFUN1:def 6
      .= v * L1.v by A105,Def6;
    hence I.x = v * L1.v + v * L2.v by A87,A88,A89,A95,A103,A104
      .= Fp.x by A99,A101,FUNCT_1:12;
  end;
  dom I = Seg(len I) & dom Fp = Seg(len I) by A93,FINSEQ_1:def 3;
  then
A106: I = Fp by A94;
  Sum(Hp) = Sum(h) by A81,RLVECT_2:7;
  hence thesis by A11,A14,A46,A72,A73,A74,A86,A87,A90,A82,A52,A106,A53,
RLVECT_2:2;
end;
