
theorem Th3:
for D be set, Y be FinSequenceSet of D, F be FinSequence of Y,
    n be Nat st 1 <= n & n <= Sum Length F holds
     ex k,m be Nat
      st 1 <= m & m <= len(F.(k+1)) & k < len F & m + Sum Length(F|k) = n
       & n <= Sum Length(F|(k+1))
proof
   let D be set, Y be FinSequenceSet of D, F be FinSequence of Y, n be Nat;
   assume A1: 1<= n & n <= Sum Length F;
   now assume
A2: for k be Nat holds n <= Sum Length(F|k) or n > Sum Length(F|(k+1));
    defpred P[Nat] means n > Sum Length(F|($1+1));
    dom Length(F|0) = dom {} by Def1; then
    Length(F|0) = {}; then
A3: P[0] by A2,A1,RVSUM_1:72;
A4: for k be Nat st P[k] holds P[k+1] by A2;
    for k be Nat holds P[k] from NAT_1:sch 2(A3,A4); then
    n > Sum Length(F|(len F + 1));
    hence contradiction by A1,FINSEQ_1:58,NAT_1:11;
   end; then
   consider k be Nat such that
A6: Sum Length(F|k) < n & n <= Sum Length(F|(k+1));
   consider m be Nat such that
A7: n = Sum Length(F|k) + m by A6,NAT_1:10;
   take k,m;
A8:now assume A9: len F <= k;
    k <= k+1 by NAT_1:11; then
    (F|(k+1)) = F & F|k = F by A9,XXREAL_0:2,FINSEQ_1:58;
    hence contradiction by A6;
   end; then
   Length(F|(k+1)) = Length(F|k) ^ <*len(F.(k+1))*> by Th2; then
   m + Sum Length(F|k) <= Sum Length(F|k) + len(F.(k+1)) by A6,A7,RVSUM_1:74;
   hence thesis by A6,A7,NAT_1:19,A8,XREAL_1:6;
end;
