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 Th7:
  ].p,q.[ is open
proof
  defpred P[Real] means $1<=p or q<=$1;
  consider X such that
A1: for r be Element of REAL holds r in X iff P[r] from SUBSET_1:sch 3;
  now
    let s1 such that
A2: (rng s1) c= X and
A3: s1 is convergent;
A4: lim s1 in REAL by XREAL_0:def 1;
    lim s1<=p or q<=lim s1
    proof
      assume
A5:   not thesis;
      then 0<lim s1 - p by XREAL_1:50;
      then consider n1 such that
A6:   for m st n1<=m holds |.s1.m-lim s1.|<lim s1-p by A3,SEQ_2:def 7;
      0<q - lim s1 by A5,XREAL_1:50;
      then consider n such that
A7:   for m st n<=m holds |.s1.m-lim s1.|<q-lim s1 by A3,SEQ_2:def 7;
      consider k such that
A8:   max(n,n1)<k by SEQ_4:3;
      n1<=max(n,n1) by XXREAL_0:25;
      then n1<=k by A8,XXREAL_0:2;
      then
A9:   |.s1.k-lim s1.|<lim s1 - p by A6;
      -|.s1.k-lim s1.| <= s1.k-lim s1 by ABSVALUE:4;
      then -(s1.k-lim s1) <= -(-|.s1.k-lim s1.|) by XREAL_1:24;
      then -(s1.k-lim s1)<lim s1 - p by A9,XXREAL_0:2;
      then -(lim s1 - p)< -(-(s1.k-lim s1)) by XREAL_1:24;
      then p - lim s1 < s1.k-lim s1;
      then
A10:   p < s1.k by XREAL_1:9;
      n<=max(n,n1) by XXREAL_0:25;
      then n<=k by A8,XXREAL_0:2;
      then
      s1.k-lim s1 <= |.s1.k-lim s1.| & |.s1.k-lim s1.|<q-lim s1 by A7,
ABSVALUE:4;
      then s1.k-lim s1 < q-lim s1 by XXREAL_0:2;
      then
A11:  s1.k < q by XREAL_1:9;
A12:   k in NAT by ORDINAL1:def 12;
A13:   s1.k in REAL by XREAL_0:def 1;
      dom s1 = NAT by FUNCT_2:def 1;
      then s1.k in rng s1 by FUNCT_1:def 3,A12;
      hence contradiction by A1,A2,A11,A10,A13;
    end;
    hence lim s1 in X by A1,A4;
  end;
  then
A14: X is closed;
  now
    let r;
A15: r in REAL by XREAL_0:def 1;
    assume r in ].p,q.[`;
    then not r in ].p,q.[ by XBOOLE_0:def 5;
    then r<=p or q<=r;
    hence r in X by A1,A15;
  end;
  then
A16: ].p,q.[` c= X;
  now
    let r;
    assume r in X;
    then not ex s st s=r & p<s & s<q by A1;
    then r in REAL & not r in ].p,q.[ by XREAL_0:def 1;
    hence r in ].p,q.[` by XBOOLE_0:def 5;
  end;
  then X c= ].p,q.[`;
  then ].p,q.[` = X by A16;
  hence thesis by A14;
end;
