
theorem Th96:
  for f be Function of [:NAT,NAT:],ExtREAL st
    (for n1,m1,n2,m2 be Nat st
      n1<=n2 & m1<=m2 holds f.(n1,m1)<=f.(n2,m2))
  holds f is P-convergent & P-lim f = sup rng f
proof
   let f be Function of [:NAT,NAT:],ExtREAL;
   assume
A1: for n1,m1,n2,m2 be Nat st
      n1<=n2 & m1<=m2 holds f.(n1,m1)<=f.(n2,m2);
A2:now
    let n,m be Nat;
    reconsider n1=n, m1=m as Element of NAT by ORDINAL1:def 12;
    [n1,m1] in [:NAT,NAT:] & dom f = [:NAT,NAT:]
      by ZFMISC_1:def 2,FUNCT_2:def 1; then
A3: f.(n1,m1) in rng f by FUNCT_1:def 3;
    sup rng f is UpperBound of rng f by XXREAL_2:def 3;
    hence f.(n,m) <= sup rng f by A3,XXREAL_2:def 1;
   end;
   per cases;
   suppose
A4: not ex n0,m0 be Nat st -infty < f.(n0,m0);
    now let x be ExtReal;
     assume x in rng f;
     then consider z be object such that
B1:   z in dom f & x=f.z by FUNCT_1:def 3;
     consider n,m be object such that
B2:   n in NAT & m in NAT & z=[n,m] by B1,ZFMISC_1:def 2;
     reconsider n,m as Nat by B2;
     not (-infty < f.(n,m)) by A4;
     hence x <= -infty by B1,B2;
    end;
    then
A5: -infty is UpperBound of rng f by XXREAL_2:def 1;
    for y be UpperBound of rng f holds -infty <= y by XXREAL_0:5;
    then
A6: -infty =sup rng f by A5,XXREAL_2:def 3;
    now
     reconsider N0=0 as Nat;
     let K be Real such that
     K < 0;
     take N0;
     let n,m be Nat such that
     N0 <= n & N0<=m;
     f.(n,m)=-infty by A4,XXREAL_0:6;
     hence f.(n,m) <= K by XXREAL_0:5;
    end;
    then
A7: f is P-convergent_to_-infty;
    then f is P-convergent;
    hence thesis by A7,A6,Def5;
   end;
   suppose
    ex n0,m0 be Nat st -infty < f.(n0,m0);
    then consider n0,m0 be Nat such that
A8: -infty < f.(n0,m0);
    reconsider n0,m0 as Element of NAT by ORDINAL1:def 12;
    per cases;
    suppose
      ex K be Real st for n,m be Nat holds f.(n,m) < K;
      then consider K be Real such that
A9:   for n,m be Nat holds f.(n,m) < K;
      now
        let x be ExtReal;
        assume x in rng f; then
        consider z be object such that
C1:      z in dom f & x=f.z by FUNCT_1:def 3;
        consider n,m be object such that
C2:      n in NAT & m in NAT & z = [n,m] by C1,ZFMISC_1:def 2;
        reconsider n,m as Nat by C2;
        f.(n,m) < K by A9;
        hence x <= K by C1,C2;
      end;
      then K is UpperBound of rng f by XXREAL_2:def 1;
      then sup rng f <= K by XXREAL_2:def 3; then
A11:  sup rng f <>+infty by XXREAL_0:9,XREAL_0:def 1;
A12:  sup rng f <> -infty by A2,A8;
      then reconsider h=sup rng f as Element of REAL by A11,XXREAL_0:14;
A13:  for p be Real st 0<p ex N be Nat st for n,m be Nat st n>=N & m>=N
      holds |. f.(n,m) - sup rng f .| < p
      proof
        let p be Real;
        assume
A14:    0 < p;
        reconsider e=p as R_eal by XXREAL_0:def 1;
        sup rng f in REAL by A12,A11,XXREAL_0:14;
        then consider y be ExtReal such that
A15:    y in rng f and
A16:    sup rng f - e < y by A14,MEASURE6:6;
        consider x be object such that
A17:    x in dom f and
A18:    y=f.x by A15,FUNCT_1:def 3;
        consider i,j be object such that
B1:      i in NAT & j in NAT & x=[i,j] by A17,ZFMISC_1:def 2;
        reconsider i,j as Nat by B1;
        reconsider Ni=i, Nj=j as Element of NAT by B1;
        set N0=max(Ni,n0), M0=max(Nj,m0), N=max(N0,M0);
        take N;
        hereby
          let n,m be Nat;
          Ni<=N0 & n0<=N0 & Nj<=M0 & m0<=M0 & N0<=N & M0<=N
            by XXREAL_0:25; then
B2:       Ni <= N & Nj <= N by XXREAL_0:2;
          assume N <= n & N <= m;
          then Ni <=n & Nj <= m by B2,XXREAL_0:2;
          then f.(Ni,Nj) <= f.(n,m) by A1;
          then sup rng f - e < f.(n,m) by A16,A18,B1,XXREAL_0:2;
          then sup rng f < f.(n,m) + e by XXREAL_3:54;
          then sup rng f - f.(n,m) < e by XXREAL_3:55;
          then -e < - (sup rng f - f.(n,m)) by XXREAL_3:38;
          then
A20:      -e < f.(n,m) -sup rng f by XXREAL_3:26;
A21:      f.(n,m) <= sup rng f by A2;
A22:      now
            assume
A23:        sup rng f = sup rng f + e;
             e + sup rng f + -sup rng f = e + (sup rng f + -sup
            rng f) 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 f + (0 qua ExtReal)
             <= sup rng f + e by A14,XXREAL_3:36;
          then sup rng f <= sup rng f + e by XXREAL_3:4;
          then sup rng f < sup rng f + e by A22,XXREAL_0:1;
          then f.(n,m) < sup rng f + e by A21,XXREAL_0:2;
          then f.(n,m) -sup rng f < e by XXREAL_3:55;
          hence |.f.(n,m)-sup rng f .| < p by A20,EXTREAL1:22;
        end;
      end;
A24:  h = sup rng f;
      then
A25:  f is P-convergent_to_finite_number by A13;
      hence f is P-convergent;
      hence thesis by A13,A24,A25,Def5;
    end;
    suppose
A26:  not (ex K be Real st 0 < K & for n,m be Nat holds f.(n,m) < K);
      now
        let K be Real;
        assume 0 < K;
        then consider N0,N1 be Nat such that
A27:    K <= f.(N0,N1) by A26;
        reconsider n0=N0,n1=N1 as Element of NAT by ORDINAL1:def 12;
        set N = max(n0,n1);
B3:     N >= N0 & N >= N1 by XXREAL_0:25;
        reconsider N as Nat;
        now
          let n,m be Nat;
          assume N <=n & N <= m; then
          N0 <= n & N1 <= m by B3,XXREAL_0:2;
          then f.(N0,N1) <= f.(n,m) by A1;
          hence K <= f.(n,m) by A27,XXREAL_0:2;
        end;
        hence ex N be Nat st for n,m be Nat st N<=n & N<=m
          holds K <= f.(n,m);
      end;
      then
A28:  f is P-convergent_to_+infty;
      hence
A29:  f is P-convergent;
      now
        assume
A30:    sup rng f <> +infty;
        f.(n0,m0) <= sup(rng f) by A2;
        then reconsider h=sup rng f as Element of REAL
               by A8,A30,XXREAL_0:14;
        set K=max(0,h);
        0 <=K by XXREAL_0:25;
        then consider N0,M0 be Nat such that
A31:     K+1 <= f.(N0,M0) by A26;
        h+0 < K+1 by XREAL_1:8,XXREAL_0:25;
        then sup rng f < f.(N0,M0) by A31,XXREAL_0:2;
        hence contradiction by A2;
      end;
      hence thesis by A28,A29,Def5;
    end;
  end;
end;
