reserve S for 1-sorted,
  i for Element of NAT,
  p for FinSequence,
  X for set;

theorem Th38:
  for X being finite set, A being Subset of X ex l being
  Linear_Combination of singletons(X) st Sum l = A
proof
  let X be finite set, A be Subset of X;
  set V = bspace(X);
  set S = singletons(X);
  defpred P[set] means $1 is Subset of X implies ex l being Linear_Combination
  of S st Sum l = $1;
A1: P[{}]
  proof
    reconsider l = ZeroLC(V) as Linear_Combination of S by VECTSP_6:5;
    assume {} is Subset of X;
    take l;
    Sum l = 0.V by VECTSP_6:15;
    hence thesis;
  end;
A2: for x,B being set st x in A & B c= A & P[B] holds P[B \/ {x}]
  proof
    let x,B be set such that
    x in A and
    B c= A and
A3: P[B];
    assume
A4: B \/ {x} is Subset of X;
    then reconsider B as Subset of X by XBOOLE_1:11;
    consider l being Linear_Combination of S such that
A5: Sum l = B by A3;
    per cases;
    suppose
A6:   x in B;
      take l;
      thus thesis by A5,A6,ZFMISC_1:40;
    end;
    suppose
      not x in B;
      then
A7:   B misses {x} by ZFMISC_1:50;
      reconsider z = ZeroLC(V) as Linear_Combination of {}V by VECTSP_6:5;
      reconsider f = {x} as Element of V by A4,XBOOLE_1:11;
      reconsider g = f as Subset of X;
      set m = z +* (f,1_Z_2);
      m is Linear_Combination of {}V \/ {f} by RANKNULL:23;
      then reconsider m = z +* (f,1_Z_2) as Linear_Combination of {f};
      dom z = [#]V by FUNCT_2:92;
      then
A8:   m.f = 1_Z_2 by FUNCT_7:31;
      f in S;
      then {f} c= S by ZFMISC_1:31;
      then m is Linear_Combination of S by VECTSP_6:4;
      then reconsider n = l + m as Linear_Combination of S by VECTSP_6:24;
      take n;
      Sum n = (Sum l) + (Sum m) by VECTSP_6:44
        .= (Sum l) + (m.f)*f by VECTSP_6:17
        .= (Sum l) + f by A8
        .= B \+\ g by A5,Def5
        .= (B \/ {x}) \ (B /\ {x}) by XBOOLE_1:101
        .= (B \/ {x}) \ {} by A7
        .= B \/ {x};
      hence thesis;
    end;
  end;
A9: A is finite;
  P[A] from FINSET_1:sch 2(A9,A1,A2);
  hence thesis;
end;
