reserve n,m for Nat;

theorem Th18:
  for R be non-decreasing real-valued FinSequence, n be Nat
  holds R|n is non-decreasing FinSequence of REAL
proof
  let f be non-decreasing real-valued FinSequence, n;
  reconsider f as non-decreasing FinSequence of REAL by RVSUM_1:145;
  set fn = f|n;
  now
    per cases;
    case
      n = 0;
      then len fn = 0;
      hence thesis by Th16;
    end;
    case
      n <> 0;
      then
A1:   0+1<=n by NAT_1:13;
      now
        per cases;
        case
          len f<=n;
          hence thesis by FINSEQ_1:58;
        end;
        case
          n<len f;
          then
A2:       n in dom f & len fn = n by A1,FINSEQ_1:59,FINSEQ_3:25;
          now
            let m;
A3:         dom fn = Seg len fn by FINSEQ_1:def 3;
            assume
A4:         m in dom fn & m+1 in dom fn;
            then
A5:         m in dom f & m+1 in dom f by A2,A3,RFINSEQ:6;
            f.m = fn.m & f.(m+1) = fn.(m+1) by A2,A4,A3,RFINSEQ:6;
            hence fn.m<=fn.(m+1) by A5,INTEGRA2:def 1;
          end;
          hence thesis by INTEGRA2:def 1;
        end;
      end;
      hence thesis;
    end;
  end;
  hence thesis;
end;
