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