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
  X is real-bounded closed implies X is compact
proof
  assume that
A1: X is real-bounded and
A2: X is closed;
  now
    let s1 such that
A3: rng s1 c= X;
A4: s1 is bounded_below
    proof
      consider p such that
A5:    p is LowerBound of X by A1,XXREAL_2:def 9;
A6:   for q st q in X holds p<=q by A5,XXREAL_2:def 2;
      take r = p - 1;
A7:   r + 1 = p - (1-1);
A8:   for t st t in rng s1 holds r < t
      proof
        let t;
        assume t in rng s1;
        then
A9:     p<=t by A3,A6;
        r < p by A7,XREAL_1:29;
        hence thesis by A9,XXREAL_0:2;
      end;
      for n holds r < s1.n
      proof
        let n;
        n in NAT by ORDINAL1:def 12;
        then n in dom s1 by FUNCT_2:def 1;
        then s1.n in rng s1 by FUNCT_1:def 3;
        hence thesis by A8;
      end;
      hence thesis;
    end;
    s1 is bounded_above
    proof
      consider p such that
A10:    p is UpperBound of X by A1,XXREAL_2:def 10;
A11:   for q st q in X holds q<=p by A10,XXREAL_2:def 1;
      take r = p+1;
A12:  for t st t in rng s1 holds t < r
      proof
        let t;
        assume t in rng s1;
        then
A13:    t<=p by A3,A11;
        p < r by XREAL_1:29;
        hence thesis by A13,XXREAL_0:2;
      end;
      for n holds s1.n < r
      proof
        let n;
        n in NAT by ORDINAL1:def 12;
        then n in dom s1 by FUNCT_2:def 1;
        then s1.n in rng s1 by FUNCT_1:def 3;
        hence thesis by A12;
      end;
      hence thesis;
    end;
    then s1 is bounded by A4;
    then consider s2 be Real_Sequence such that
A14: s2 is subsequence of s1 and
A15: s2 is convergent by SEQ_4:40;
    ex Nseq st s2 = s1*Nseq by A14,VALUED_0:def 17;
    then rng s2 c= rng s1 by RELAT_1:26;
    then rng s2 c= X by A3;
    then lim s2 in X by A2,A15;
    hence ex s2 st s2 is subsequence of s1 & s2 is convergent & lim s2 in X by
A14,A15;
  end;
  hence thesis;
end;
