
theorem Th54:
  for L be ExtREAL_sequence st (for n,m be Nat st n <=m holds L.n
  <= L.m) holds L is convergent & lim L = sup rng L
proof
  let L be ExtREAL_sequence;
  assume
A1: for n,m be Nat st n <=m holds L.n <= L.m;
A2: now
    let n be Nat;
    reconsider n1=n as Element of NAT by ORDINAL1:def 12;
    dom L = NAT by FUNCT_2:def 1;
    then
A3: L.n1 in rng L by FUNCT_1:def 3;
    sup rng L is UpperBound of rng L by XXREAL_2:def 3;
    hence L.n <= sup rng L by A3,XXREAL_2:def 1;
  end;
  per cases;
  suppose
A4: not ex k0 be Nat st -infty < L.k0;
    now
      let x be ExtReal;
      assume x in rng L;
      then ex n be object st n in dom L & x=L.n by FUNCT_1:def 3;
      hence x <= -infty by A4;
    end;
    then
A5: -infty is UpperBound of rng L by XXREAL_2:def 1;
    for y being UpperBound of rng L holds -infty <= y by XXREAL_0:5;
    then
A6: -infty =sup rng L by A5,XXREAL_2:def 3;
    now
      reconsider N0=0 as Nat;
      let K be Real such that
      K < 0;
      take N0;
      let n be Nat such that
      N0 <= n;
      L.n=-infty by A4,XXREAL_0:6;
      hence L.n <= K by XXREAL_0:5;
    end;
    then
A7: L is convergent_to_-infty;
    then L is convergent;
    hence thesis by A7,A6,Def12;
  end;
  suppose
    ex k0 be Nat st -infty < L.k0;
    then consider k0 be Nat such that
A8: -infty < L.k0;
    reconsider k0 as Element of NAT by ORDINAL1:def 12;
    per cases;
    suppose
      ex K be Real st for n be Nat holds L.n < K;
      then consider K be Real such that
A9:   for n be Nat holds L.n < K;
      now
        let x be ExtReal;
        assume x in rng L;
        then ex z be object st z in dom L & x=L.z by FUNCT_1:def 3;
        hence x <= K by A9;
      end;
      then K is UpperBound of rng L by XXREAL_2:def 1;
      then
A10:  sup rng L <= K by XXREAL_2:def 3;
      K in REAL by XREAL_0:def 1;
      then
A11:  sup rng L <>+infty by A10,XXREAL_0:9;
A12:  sup rng L <> -infty by A2,A8;
      then reconsider h=sup rng L as Element of REAL by A11,XXREAL_0:14;
A13:  for p be Real st 0<p ex N0 be Nat st for m be Nat st N0<=m
      holds |. L.m - sup rng L .| < p
      proof
        let p be Real;
        assume
A14:    0 < p;
        reconsider e=p as R_eal by XXREAL_0:def 1;
        sup rng L in REAL by A12,A11,XXREAL_0:14;
        then consider y being ExtReal such that
A15:    y in rng L and
A16:    sup rng L - e < y by A14,MEASURE6:6;
        consider x be object such that
A17:    x in dom L and
A18:    y=L.x by A15,FUNCT_1:def 3;
        reconsider N1=x as Element of NAT by A17;
        set N0=max(N1,k0);
        take N0;
        hereby
          let n be Nat;
A19:      N1<=N0 by XXREAL_0:25;
          assume N0 <= n;
          then N1 <=n by A19,XXREAL_0:2;
          then L.N1 <= L.n by A1;
          then sup rng L - e < L.n by A16,A18,XXREAL_0:2;
          then sup rng L < L.n + e by XXREAL_3:54;
          then sup rng L - L.n < e by XXREAL_3:55;
          then -e < - (sup rng L - L.n) by XXREAL_3:38;
          then
A20:      -e < L.n -sup rng L by XXREAL_3:26;
A21:      L.n <= sup rng L by A2;
A22:      now
            assume
A23:        sup rng L = sup rng L + e;
             e + sup rng L + -sup rng L = e + (sup rng L + -sup
            rng L) by A12,A11,XXREAL_3:29
              .= e + 0 by XXREAL_3:7
              .= e by XXREAL_3:4;
            hence contradiction by A14,A23,XXREAL_3:7;
          end;
          sup rng L + (0 qua ExtReal)
             <= sup rng L + e by A14,XXREAL_3:36;
          then sup rng L <= sup rng L + e by XXREAL_3:4;
          then sup rng L < sup rng L + e by A22,XXREAL_0:1;
          then L.n < sup rng L + e by A21,XXREAL_0:2;
          then L.n -sup rng L < e by XXREAL_3:55;
          hence |.L.n-sup rng L .| < p by A20,EXTREAL1:22;
        end;
      end;
A24:  h = sup rng L;
      then
A25:  L is convergent_to_finite_number by A13;
      hence L is convergent;
      hence thesis by A13,A24,A25,Def12;
    end;
    suppose
A26:  not (ex K be Real st 0 < K & for n be Nat holds L.n < K);
      now
        let K be Real;
        assume 0 < K;
        then consider N0 be Nat such that
A27:    K <= L.N0 by A26;
        now
          let n be Nat;
          assume N0 <=n;
          then L.N0 <= L.n by A1;
          hence K <= L.n by A27,XXREAL_0:2;
        end;
        hence ex N0 be Nat st for n be Nat st N0<=n holds K <= L.n;
      end;
      then
A28:  L is convergent_to_+infty;
      hence
A29:  L is convergent;
      now
        assume
A30:    sup rng L <> +infty;
        L.k0 <= sup(rng L) by A2;
        then reconsider h=sup rng L as Element of REAL
               by A8,A30,XXREAL_0:14;
        set K=max(0,h);
        0 <=K by XXREAL_0:25;
        then consider N0 be Nat such that
A31:     K+1 <= L.N0 by A26;
        h+0 < K+1 by XREAL_1:8,XXREAL_0:25;
        then sup rng L < L.N0 by A31,XXREAL_0:2;
        hence contradiction by A2;
      end;
      hence thesis by A28,A29,Def12;
    end;
  end;
end;
