reserve m,n,s for non zero Element of NAT;

theorem Th7:
  for L be the carrier of (n-BinaryVectSp)-valued FinSequence,
  Suml be Element of n-tuples_on BOOLEAN,
  j be Nat
  st len L = m & m <= n & Suml = Sum(L) & j in Seg n
  ex x be FinSequence of Z_2 st len x = m & (Suml).j = Sum(x) &
  for i be Nat st i in Seg m ex K be Element of n-tuples_on BOOLEAN
  st K = L.i & x.i = K.j
proof
  let L be the carrier of (n-BinaryVectSp)-valued FinSequence,
  Suml be Element of n-tuples_on BOOLEAN,
  j be Nat;
  assume
A1: len L = m & m <= n & Suml = Sum(L) & j in Seg n;
  then consider x be FinSequence of Z_2 such that
A2: len x = m & for i be Nat st i in Seg m
  ex K be Element of n-tuples_on BOOLEAN st K = L.i & x.i = K.j by Th6;
  consider f being Function of NAT, n-BinaryVectSp such that
A3: Sum(L) = f.(len L) & f.0 = 0.(n-BinaryVectSp) &
  (for j being Nat for v being Element of (n-BinaryVectSp)
  st j < len L & v = L.(j + 1) holds f.(j + 1) = (f.j) + v)
  by RLVECT_1:def 12;
  defpred P1[Nat,set] means ex K be Element of n-tuples_on BOOLEAN
  st K = f.$1 & $2 = K.j;
A4: for i be Element of NAT ex y being Element of the carrier of Z_2
  st P1[i,y]
  proof
    let i be Element of NAT;
    reconsider K = f.i as Element of n-tuples_on BOOLEAN;
    reconsider y = K.j as Element of Z_2 by BSPACE:3;
    take y;
    thus P1[i,y];
  end;
  consider g being Function of NAT, Z_2 such that
A5: for i be Element of NAT holds P1[i,g.i] from FUNCT_2:sch 3 (A4);
  set Sumlj = Suml.j;
A6: Sumlj = g.(len x)
  proof
    ex K be Element of n-tuples_on BOOLEAN st K = f.(len L) & g.(len L) = K.j
    by A5;
    hence Sumlj = g.(len x) by A1,A3,A2;
  end;
A7: g.0 = 0.Z_2
  proof
    ex K be Element of n-tuples_on BOOLEAN st K = f.0 & g.0 = K.j by A5;
    hence g.0 = 0.Z_2 by A3,BSPACE:5;
  end;
A8: for k being Nat for vj being Element of Z_2
  st k < len x & vj = x.(k + 1) holds g.(k + 1) = (g.k) + vj
  proof
    let k be Nat, vj be Element of Z_2;
    assume
A9: k < len x & vj = x.(k + 1);
    then 1 <= k + 1 & k + 1 <= len x by NAT_1:11,NAT_1:13;
    then k + 1 in Seg m by A2;
    then consider LVn be Element of n-tuples_on BOOLEAN such that
A10: LVn = L.(k + 1) & x.(k + 1) = LVn.j by A2;
    reconsider Vn = LVn as Element of (n-BinaryVectSp);
    consider K1 be Element of n-tuples_on BOOLEAN such that
A11: K1 = f.(k + 1) & g.(k + 1) = K1.j by A5;
    reconsider VK1 = K1 as Element of (n-BinaryVectSp);
    for i be Nat holds P1[i,g.i]
    proof
      let i be Nat;
      i is Element of NAT by ORDINAL1:def 12;
      hence thesis by A5;
    end; then
    consider K0 be Element of n-tuples_on BOOLEAN such that
A12: K0 = f.k & g.k = K0.j;
    reconsider VK0 = K0 as Element of (n-BinaryVectSp);
    VK0 + Vn = Op-XOR(K0,LVn) by Def1;
    hence g.(k + 1) = (g.k) + vj by A11,A3,A9,A10,A1,A2,A12,DESCIP_1:def 4;
  end;
  (Suml).j = Sum(x) by A6,A7,A8,RLVECT_1:def 12;
  hence thesis by A2;
end;
