reserve x,y for set;
reserve a,b for Real;
reserve i,j for Integer;
reserve V for RealLinearSpace;
reserve W1,W2,W3 for Subspace of V;
reserve v,v1,v2,v3,u,w,w1,w2,w3 for VECTOR of V;
reserve A,B,C for Subset of V;
reserve L,L1,L2 for Linear_Combination of V;
reserve l,l1,l2 for Linear_Combination of A;

theorem Th35:
  for x be set, g1,h1 be FinSequence of V,
      a1 be INT-valued FinSequence st x=Sum(h1) &
    rng g1 c= Z_Lin(A) & len g1 =len h1 & len g1 = len a1 &
    for i be Nat st i in Seg (len g1) holds
        h1/.i=(a1.i)*(g1/.i) holds x in Z_Lin(A)
proof
  reconsider z0=0 as Element of INT by NUMBERS:17;
  reconsider z1=1 as Element of INT by NUMBERS:17;
  defpred P[Nat] means for x be set, g1,h1 be FinSequence of V,
  a1 be INT-valued FinSequence st x = Sum(h1) &
  rng g1 c= Z_Lin(A) & len g1 = $1 & len g1 =len h1 & len g1 = len a1 &
  for i be Nat st i in Seg (len g1) holds
  h1/.i=(a1.i)*(g1/.i) holds x in Z_Lin(A);
  A1: P[0]
  proof
    let x be set, g1,h1 be FinSequence of V,
    a1 be INT-valued FinSequence;
    assume A2: x = Sum(h1) &
    rng g1 c= Z_Lin(A) & len g1 = 0 & len g1 =len h1 & len g1 = len a1 &
    for i be Nat st i in Seg (len g1) holds h1/.i=(a1.i)*(g1/.i);
    Sum(h1) = Sum(<*> the carrier of V) by A2,FINSEQ_1:20
    .= 0.V by RLVECT_1:43;
    hence x in Z_Lin(A) by A2,Th11;
  end;
A3: now let n be Nat;
    assume A4: P[n];
    now let x be set, g1,h1 be FinSequence of V,
      a1 be INT-valued FinSequence;
      assume A5: x = Sum(h1) &
      rng g1 c= Z_Lin(A) & len g1 = n+1 & len g1 =len h1 & len g1 = len a1 &
      for i be Nat st i in Seg (len g1) holds h1/.i=(a1.i)*(g1/.i);
      reconsider gn = g1|n as FinSequence of V;
      reconsider hn = h1|n as FinSequence of V;
      reconsider an = a1|n as INT-valued FinSequence;
      A6:rng gn c= Z_Lin(A) &
            len gn = n & len gn = len an & len gn = len hn &
            for i be Nat st i in Seg (len gn) holds
              hn/.i=(an.i)*(gn/.i)
      proof
        A7: rng gn c= rng g1 by RELAT_1:70;
        A8: n <= len g1 by A5,NAT_1:11;
        A9: n <= len h1 by A5,NAT_1:11;
        A10: len hn = n by A5,FINSEQ_1:59,NAT_1:11;
        A11: len an = n by A5,FINSEQ_1:59,NAT_1:11;
        for i be Nat st i in Seg (len gn) holds
        hn/.i=(an.i)*(gn/.i)
        proof
          per cases;
          suppose n = 0;
            hence thesis;
          end;
          suppose n <> 0;
            then A12: n >= 1 by NAT_1:14;
            let i be Nat;
            assume i in Seg (len gn);
            then A13: i in Seg (n) by A5,FINSEQ_1:59,NAT_1:11;
            n in Seg (len g1) by A8,A12;
            then n in dom g1 by FINSEQ_1:def 3;
            then A14: gn/.i = g1/.i by A13,FINSEQ_4:71;
            n in Seg (len h1) by A9,A12;
            then n in dom h1 by FINSEQ_1:def 3;
            then A15: hn/.i = h1/.i by A13,FINSEQ_4:71;
            i <= n by A13,FINSEQ_1:1;
            then an.i = a1.i by FINSEQ_3:112;
            hence thesis by A5,A13,A14,A15,FINSEQ_2:8;
          end;
        end;
        hence thesis by A5,A7,A8,A10,A11,FINSEQ_1:59;
      end;
      A16: n+1 in Seg (len g1) by A5,FINSEQ_1:4;
      A17: h1/.(n+1) = a1.(n+1)*g1/.(n+1) by A5,FINSEQ_1:4;
      A18: h1 = hn ^ <* a1.(n+1)*g1/.(n+1) *> by A5,A17,FINSEQ_5:21;
      A19: n+1 in dom g1 by A16,FINSEQ_1:def 3; then
      g1/.(n+1) = g1.(n+1) by PARTFUN1:def 6; then
      g1/.(n+1) in rng g1 by A19,FUNCT_1:3; then
      z1*a1.(n+1)*(g1/.(n+1)) in Z_Lin(A) &
      z0*(g1/.(n+1)) in Z_Lin(A) by A5,Th10; then
      z1*a1.(n+1)*(g1/.(n+1)) + z0*(g1/.(n+1)) in Z_Lin(A) by Th9; then
      z1*a1.(n+1)*(g1/.(n+1)) + 0.V in Z_Lin(A) by RLVECT_1:10; then
      A20: z1*(a1.(n+1))*(g1/.(n+1)) in Z_Lin(A) by RLVECT_1:4;
      z1*Sum(hn) in Z_Lin(A) by A4,A6,Th10;
      then A21: z1*Sum(hn)+z1*(a1.(n+1))*(g1/.(n+1)) in Z_Lin(A) by A20,Th9;
      Sum(h1) =Sum(hn)+Sum(<* a1.(n+1)*(g1/.(n+1)) *>) by A18,RLVECT_1:41
      .=Sum(hn)+ a1.(n+1)*(g1/.(n+1)) by RLVECT_1:44;
      hence Sum(h1)in Z_Lin(A) by A21,RLVECT_1:def 8;
    end;
    hence P[n+1];
  end;
  for n be Nat holds P[n] from NAT_1:sch 2(A1,A3);
  hence thesis;
end;
