reserve x,y for object, X,Y,Z for set;
reserve a,b for Real;
reserve k for Element of NAT;
reserve V for RealLinearSpace;
reserve W1,W2,W3 for Subspace of V;
reserve v,v1,v2,u for VECTOR of V;
reserve A,B,C for Subset of V;
reserve T for finite Subset of V;
reserve L,L1,L2 for Linear_Combination of V;
reserve l for Linear_Combination of A;
reserve F,G,H for FinSequence of the carrier of V;
reserve f,g for Function of the carrier of V, REAL;
reserve p,q,r for FinSequence;
reserve M for non empty set;
reserve CF for Choice_Function of M;

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