reserve n,m,k,k1,k2 for Nat;
reserve r,r1,r2,s,t,p for Real;
reserve seq,seq1,seq2 for Real_Sequence;
reserve x,y for set;

theorem Th41:
  seq is bounded_above implies (r = (superior_realsequence seq).n
  iff (for k holds seq.(n+k) <= r) & for s st 0<s ex k st r-s<seq.(n+k))
proof
  reconsider Y1 = {seq.k : n <= k} as Subset of REAL by Th29;
  assume seq is bounded_above;
  then
A1: Y1 is non empty bounded_above by Th31,SETLIM_1:1;
  thus r = (superior_realsequence seq).n implies (for k holds seq.(n+k) <= r)
  & for s st 0<s ex k st r-s<seq.(n+k)
  proof
    assume r = (superior_realsequence seq).n;
    then
A2: r = upper_bound Y1 by Def5;
A3: for s st 0<s ex k st r-s<seq.(n+k)
    proof
      let s;
      assume 0<s;
      then consider r1 such that
A4:   r1 in Y1 and
A5:   r-s<r1 by A1,A2,SEQ_4:def 1;
      consider k1 such that
A6:   r1=seq.k1 and
A7:   n <= k1 by A4;
      consider k2 being Nat such that
A8:   k1 = n + k2 by A7,NAT_1:10;
      thus thesis by A5,A6,A8;
    end;
    for k holds seq.(n+k) <= r
    proof
      let k;
      seq.(n+k) in Y1 by SETLIM_1:1;
      hence thesis by A1,A2,SEQ_4:def 1;
    end;
    hence thesis by A3;
  end;
  assume that
A9: for k holds seq.(n+k) <= r and
A10: for s st 0<s ex k st r-s<seq.(n+k);
A11: for s st 0<s ex r1 st r1 in Y1 & r-s<r1
  proof
    let s;
    assume 0<s;
    then consider k such that
A12: r-s<seq.(n+k) by A10;
    n + k >= n by NAT_1:11;
    then seq.(n+k) in Y1;
    hence thesis by A12;
  end;
  for r1 st r1 in Y1 holds r1 <= r
  proof
    let r1;
    assume r1 in Y1;
    then consider k1 such that
A13: r1=seq.k1 and
A14: n <= k1;
    consider k2 being Nat such that
A15: k1 = n + k2 by A14,NAT_1:10;
    thus thesis by A9,A13,A15;
  end;
  then r=upper_bound Y1 by A1,A11,SEQ_4:def 1;
  hence thesis by Def5;
end;
