reserve n,m,k,k1,k2 for Nat;
reserve X for non empty Subset of ExtREAL;
reserve Y for non empty Subset of REAL;
reserve seq for ExtREAL_sequence;
reserve e1,e2 for ExtReal;
reserve rseq for Real_Sequence;

theorem Th37:
  for seq be ExtREAL_sequence st seq is non-decreasing holds seq
  is convergent & lim seq = sup seq
proof
  let seq be ExtREAL_sequence;
  assume
A1: seq is non-decreasing;
  per cases;
  suppose
A2: for n be Element of NAT holds seq.n <= -infty;
    now
      let y be object;
      assume y in {-infty};
      then
A3:   y = -infty by TARSKI:def 1;
      now
        assume
A4:     not y in rng seq;
        now
          let n be Element of NAT;
          n in NAT;
          then n in dom seq by FUNCT_2:def 1;
          then seq.n <> -infty by A3,A4,FUNCT_1:def 3;
          hence contradiction by A2,XXREAL_0:6;
        end;
        hence contradiction;
      end;
      hence y in rng seq;
    end;
    then
A5: {-infty} c= rng seq;
A6: seq is convergent_to_-infty by A2,Th33;
    hence
A7: seq is convergent by MESFUNC5:def 11;
    now
      let y be object;
      assume y in rng seq;
      then ex x be object st x in dom seq & seq.x=y by FUNCT_1:def 3;
      then y = -infty by A2,XXREAL_0:6;
      hence y in {-infty} by TARSKI:def 1;
    end;
    then rng seq c={-infty};
    then rng seq = {-infty} by A5,XBOOLE_0:def 10;
    then sup seq = -infty by XXREAL_2:11;
    hence thesis by A6,A7,MESFUNC5:def 12;
  end;
  suppose
    not (for n be Element of NAT holds seq.n <= -infty);
    then consider k be Element of NAT such that
A8: -infty < seq.k;
    per cases;
    suppose
A9:   +infty <> sup seq;
      set seq0=seq^\k;
A10:  sup seq = sup seq0 by A1,Th26;
A11:  now
        assume rng seq0 ={+infty};
        then
A12:    +infty in rng seq0 by TARSKI:def 1;
        +infty is UpperBound of rng seq0 by XXREAL_2:41;
        hence contradiction by A9,A10,A12,XXREAL_2:55;
      end;
A13:  inf seq0 <= sup seq0 by Th24;
A14:  sup rng seq0 is UpperBound of rng seq0 by XXREAL_2:def 3;
      seq.k <= sup seq by Th23;
      then seq.k < +infty by A9,XXREAL_0:2,4;
      then
A15:  seq0 is bounded_below by A1,A8,Th31;
      then rng seq0 is bounded_below;
      then -infty < inf rng seq0 by A11,XXREAL_0:12,XXREAL_2:58;
      then sup rng seq0 in REAL by A9,A10,A13,XXREAL_0:14;
      then rng seq0 is bounded_above by A14,XXREAL_2:def 10;
      then seq0 is bounded_above;
      then
A16:  seq0 is bounded by A15;
A17:  seq0 is non-decreasing by A1,Th26;
      then
A18:  lim seq0 = sup seq0 by A16,Lm4;
      seq0 is convergent by A17,A16,Lm4;
      hence thesis by A10,A18,Th17;
    end;
    suppose
A19:  +infty = sup seq;
      then seq is convergent_to_+infty by A1,Th35;
      hence seq is convergent by MESFUNC5:def 11;
      thus thesis by A1,A19,Th35;
    end;
  end;
end;
