reserve n,m for Nat;

theorem Th17:
  for R be real-valued FinSequence holds R is non-decreasing iff
  for n,m be Nat st n in dom R & m in dom R & n<m holds R.n<=R.m
proof
  let R be real-valued FinSequence;
  thus R is non-decreasing implies for n,m st n in dom R & m in dom R & n<m
  holds R.n<=R.m
  proof
    defpred P[Nat] means $1 in dom R implies for n st n in dom R &
    n<$1 holds R.n<=R.$1;
    assume
A1: R is non-decreasing;
A2: for m st P[m] holds P[m+1]
    proof
      let m;
      assume
A3:   P[m];
      assume
A4:   m+1 in dom R;
      then m+1<=len R by FINSEQ_3:25;
      then
A5:   m<=len R by NAT_1:13;
      let n;
      assume that
A6:   n in dom R and
A7:   n<m+1;
      set t = R.m, r = R.n, s = R.(m+1);
A8:   n<=m by A7,NAT_1:13;
      1<=n by A6,FINSEQ_3:25;
      then
A9:   1<=m by A8,XXREAL_0:2;
      then
A10:  m in dom R by A5,FINSEQ_3:25;
      now
        per cases;
        case
          n = m;
          hence thesis by A1,A4,A6;
        end;
        case
          n <> m;
          then n<m by A8,XXREAL_0:1;
          then
A11:      r<=t by A3,A6,A9,A5,FINSEQ_3:25;
          t<=s by A1,A4,A10;
          hence thesis by A11,XXREAL_0:2;
        end;
      end;
      hence thesis;
    end;
A12: P[0];
    for m holds P[m] from NAT_1:sch 2(A12,A2);
    hence thesis;
  end;
  assume
A13: for n,m st n in dom R & m in dom R & n<m holds R.n<=R.m;
  let n;
A14: n<n+1 by NAT_1:13;
  assume n in dom R & n+1 in dom R;
  hence thesis by A13,A14;
end;
