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

theorem Th9:
  for A be FinSequence of n-tuples_on BOOLEAN,
  B be finite Subset of n-BinaryVectSp,
  l being Linear_Combination of B,
  Suml be Element of n-tuples_on BOOLEAN
  st rng A = B & m <= n & len A = m & Suml = Sum l & A is one-to-one &
  (for i,j be Nat st i in Seg n & j in Seg m holds
  (i = j implies (A.i).j = TRUE) & (i <> j implies (A.i).j = FALSE))
  holds for j be Nat st j in Seg m holds (Suml).j = l.(A.j)
proof
  let A be FinSequence of n-tuples_on BOOLEAN,
  B be finite Subset of n-BinaryVectSp,
  l be Linear_Combination of B,
  Suml be Element of n-tuples_on BOOLEAN;
  assume that
A1: rng A = B and
A2: m <= n and
A3: len A = m and
A4: Suml = Sum l and
A5: A is one-to-one and
A6: for i,j be Nat st i in Seg n & j in Seg m holds
  (i = j implies (A.i).j = TRUE) & (i <> j implies (A.i).j = FALSE);
  set V = n-BinaryVectSp;
  let j be Nat;
  assume
A7: j in Seg m;
    reconsider FA = A as FinSequence of V;
A8: j in Seg n by A7,A2,FINSEQ_1:5,TARSKI:def 3;
A9: Carrier l c= rng FA by A1,VECTSP_6:def 4;
A10: len (l (#) FA) = m by A3,VECTSP_6:def 5;
    Suml = Sum (l (#) FA) by VECTSP_9:3,A5,A9,A4;
    then consider x be FinSequence of Z_2 such that
A11: 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 (#) FA).i &
    x.i = K.j by Th7,A2,A8,A10;
A12: for i be Nat st i in Seg m holds (i = j implies x.i = l.(A.j)) &
    (i <> j implies x.i = 0.Z_2)
    proof
      let i be Nat;
      assume
A13:  i in Seg m;
      then consider K be Element of n-tuples_on BOOLEAN such that
A14:  K = (l (#) FA).i & x.i = K.j by A11;
A15:  i in Seg n by A13,A2,FINSEQ_1:5,TARSKI:def 3;
A16:  i in dom (l (#) FA) by FINSEQ_1:def 3,A13,A10;
A17:  K = (l.(FA/.i)) * (FA/.i) by A14,A16,VECTSP_6:def 5;
      reconsider FAi = (FA/.i) as Element of n-tuples_on BOOLEAN;
      set lFAi = l.(FA/.i);
A18:  K.j = lFAi '&' (FAi.j) by Def4,A8,A17,BSPACE:3;
A19: i in dom A by A3,FINSEQ_1:def 3,A13;
      then
A20:  FAi.j = (A.i).j by PARTFUN1:def 6;
      thus i = j implies x.i = l.(A.j)
      proof
        assume
A21:     i = j;
        then K.j = lFAi '&' TRUE by A6,A8,A13,A18,A20;
        hence x.i = l.(A.j) by A21,A14,A19,PARTFUN1:def 6;
      end;
      assume i <> j;
      then K.j = lFAi '&' FALSE by A6,A7,A15,A18,A20;
      hence x.i = 0.Z_2 by A14,BSPACE:5;
    end;
    j in dom A by A3,A7,FINSEQ_1:def 3;
    then l.(A.j) is Element of Z_2 by PARTFUN1:4,FUNCT_2:5;
    hence thesis by Th5,A7,A11,A12;
end;
