reserve n,n1,m,k for Nat;
reserve x,y for set;
reserve s,g,g1,g2,r,p,p2,q,t for Real;
reserve s1,s2,s3 for Real_Sequence;
reserve Nseq for increasing sequence of NAT;
reserve X for Subset of REAL;

theorem Th10:
  X is compact implies X is real-bounded
proof
  assume
A1: X is compact;
  assume
A2: not X is real-bounded;
    per cases by A2;
    suppose
A3:   not X is bounded_above;
      defpred P[Element of NAT,Element of REAL] means ex q st q =$2 & q in X &
      $1<q;
A4:   for n being Element of NAT ex p being Element of REAL st P[n,p]
      proof
        let n be Element of NAT;
        n is not UpperBound of X by A3,XXREAL_2:def 10;
        then consider t being ExtReal such that
A5:     t in X & n<t by XXREAL_2:def 1;
        take t;
        thus thesis by A5;
      end;
      consider f being sequence of REAL such that
A6:   for n being Element of NAT holds P[n,f.n] from FUNCT_2:sch 3(A4);
A7:   now
        let n;
        n in NAT by ORDINAL1:def 12;
        then ex q st q=f.n & q in X & n<q by A6;
        hence f.n in X & n<f.n;
      end;
A8:   for p st p in X ex r,n st 0<r & for m st n<m holds r<|.f.m-p.|
      proof
        let p such that
        p in X;
        consider q such that
A9:     q = 1;
        take r = q;
        consider k such that
A10:    p+1<k by SEQ_4:3;
        take n = k;
        thus 0 < r by A9;
        let m;
        assume n<m;
        then p+1 < m by A10,XXREAL_0:2;
        then p+1 < f.m by A7,XXREAL_0:2;
        then 1 < f.m - p by XREAL_1:20;
        hence thesis by A9,ABSVALUE:def 1;
      end;
      rng f c= X
      proof
        let x be object;
        assume x in rng f;
        then consider y being object such that
A11:    y in dom f and
A12:    x = f.y by FUNCT_1:def 3;
        reconsider y as Element of NAT by A11,FUNCT_2:def 1;
        f.y in X by A7;
        hence thesis by A12;
      end;
      then
      ex s2 st s2 is subsequence of f & s2 is convergent & lim s2 in X by A1;
      hence contradiction by A8,Th9;
    end;
    suppose
A13:  not X is bounded_below;
      defpred P[Element of NAT,Element of REAL] means ex q st q=$2 & q in X &
      q<-$1;
A14:  for n being Element of NAT ex p being Element of REAL st P[n,p]
      proof
        let n be Element of NAT;
        -n is not LowerBound of X by A13,XXREAL_2:def 9;
        then consider t being ExtReal such that
A15:    t in X & t<-n by XXREAL_2:def 2;
        take t;
        thus thesis by A15;
      end;
      consider f being sequence of REAL such that
A16:  for n being Element of NAT holds P[n,f.n] from FUNCT_2:sch 3(
      A14);
A17:  now
        let n;
        n in NAT by ORDINAL1:def 12;
        then ex q st q=f.n & q in X & q<-n by A16;
        hence f.n in X & f.n<-n;
      end;
A18:  for p st p in X ex r,n st 0<r & for m st n<m holds r<|.f.m-p.|
      proof
        let p such that
        p in X;
        consider q such that
A19:    q = 1;
        take r = q;
        consider k such that
A20:    |.p-1.| <k by SEQ_4:3;
        take n = k;
        thus 0 < r by A19;
        let m;
        assume n<m;
        then
A21:    -m<-n by XREAL_1:24;
        -k <p-1 by A20,SEQ_2:1;
        then -m < p-1 by A21,XXREAL_0:2;
        then f.m < p-1 by A17,XXREAL_0:2;
        then f.m +1 < p by XREAL_1:20;
        then 1 < p - f.m by XREAL_1:20;
        then r < |.-(f.m-p).| by A19,ABSVALUE:def 1;
        hence thesis by COMPLEX1:52;
      end;
      rng f c= X
      proof
        let x be object;
        assume x in rng f;
        then consider y being object such that
A22:    y in dom f and
A23:    x = f.y by FUNCT_1:def 3;
        reconsider y as Element of NAT by A22,FUNCT_2:def 1;
        f.y in X by A17;
        hence thesis by A23;
      end;
      then
      ex s2 st s2 is subsequence of f & s2 is convergent & lim s2 in X by A1;
      hence contradiction by A18,Th9;
    end;
end;
