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 open real-bounded & (for g1,g2 st g1 in X & g2 in X holds [.g1,g2.] c=
  X) implies ex p,g st X = ].p,g.[
proof
  assume that
A1: X is open and
A2: X is real-bounded and
A3: for g1,g2 st g1 in X & g2 in X holds [.g1,g2.] c= X;
  per cases;
  suppose
A4: X={};
    take 1;
    take 0;
    thus thesis by A4,XXREAL_1:28;
  end;
  suppose
A5: X<>{};
    take p=lower_bound X, g=upper_bound X;
    now
      let r be Element of REAL;
      thus r in X implies r in ].p,g.[
      proof
        assume
A6:     r in X;
        then p<>r & p<=r by A1,A2,Th22,SEQ_4:def 2;
        then
A7:     p<r by XXREAL_0:1;
        g<>r & r<=g by A1,A2,A6,Th21,SEQ_4:def 1;
        then r<g by XXREAL_0:1;
        hence thesis by A7;
      end;
      assume r in ].p,g.[;
      then
A8:   ex s st s=r & p<s & s<g;
      then g-r>0 by XREAL_1:50;
      then consider g2 such that
A9:   g2 in X & g-(g-r)<g2 by A2,A5,SEQ_4:def 1;
      r-p>0 by A8,XREAL_1:50;
      then consider g1 such that
A10:  g1 in X & g1<p+(r-p) by A2,A5,SEQ_4:def 2;
      reconsider g1, g2 as Real;
      r in {s: g1<=s & s<=g2} & [.g1,g2.] c= X by A3,A9,A10;
      hence r in X;
    end;
    hence thesis by SUBSET_1:3;
  end;
end;
