reserve
  r,s,r0,s0,t for Real;

theorem
  for e,f being Real, A,B being compact Subset of REAL st A
  misses B & A c= [.e,f.] & B c= [.e,f.] for S being sequence of  bool REAL
st for i being Nat holds S.i is interval & S.i meets A & S.i meets
  B ex r being Real st r in [.e,f.] & not r in A \/ B & for i being
  Nat ex k being Nat st i <= k & r in S.k
proof
  let e,f be Real, A,B be compact Subset of REAL such that
A1: A misses B and
A2: A c= [.e,f.] and
A3: B c= [.e,f.];
  let S be sequence of  bool REAL such that
A4: for i being Nat holds S.i is interval & S.i meets A & S.
  i meets B;
  defpred P[set,Subset of REAL] means $2 is non empty closed_interval
   & $2 meets A & $2
  meets B & $2 c= S.$1;
A5: for i being Element of NAT ex u being Subset of REAL st P[i,u]
  proof
    let i be Element of NAT;
A6: S.i is interval by A4;
    S.i meets B by A4;
    then consider y being object such that
A7: y in S.i and
A8: y in B by XBOOLE_0:3;
    S.i meets A by A4;
    then consider x being object such that
A9: x in S.i and
A10: x in A by XBOOLE_0:3;
    reconsider y as Real by A8;
    reconsider x as Real by A10;
    per cases;
    suppose
A11:  x <= y;
      take [.x,y.];
      thus [.x,y.] is non empty closed_interval by A11,MEASURE5:14;
      x in [.x,y.] by A11;
      hence [.x,y.] meets A by A10,XBOOLE_0:3;
      y in [.x,y.] by A11;
      hence [.x,y.] meets B by A8,XBOOLE_0:3;
      thus [.x,y.] c= S.i by A9,A7,A6;
    end;
    suppose
A12:  y <= x;
      take [.y,x.];
      thus [.y,x.] is non empty closed_interval by A12,MEASURE5:14;
      x in [.y,x.] by A12;
      hence [.y,x.] meets A by A10,XBOOLE_0:3;
      y in [.y,x.] by A12;
      hence [.y,x.] meets B by A8,XBOOLE_0:3;
      thus [.y,x.] c= S.i by A9,A7,A6;
    end;
  end;
  consider T be sequence of  bool REAL such that
A13: for i being Element of NAT holds P[i,T.i] from FUNCT_2:sch 3(A5);
  T.0 meets B by A13;
  then
A14: B is non empty;
  deffunc G(Nat)=T.$1 /\ B;
  deffunc F(Nat)=T.$1 /\ A;
  consider SA being sequence of  bool REAL such that
A15: for i being Element of NAT holds SA.i = F(i) from FUNCT_2:sch 4;
  consider SB being sequence of  bool REAL such that
A16: for i being Element of NAT holds SB.i = G(i) from FUNCT_2:sch 4;
  defpred P[Nat,Real,Real] means $2 in SA.$1 & $3 in SB.$1 & dist(
  SA.$1,SB.$1) = |.$2 - $3.|;
A17: for i being Element of NAT
    ex ai,bi being Element of REAL st P[i,ai,bi]
  proof
    let i be Element of NAT;
    reconsider Si = T.i as non empty closed_interval Subset of REAL by A13;
A18: T.i meets B by A13;
A19: SA.i = Si /\ A by A15;
A20: SB.i = Si /\ B by A16;
    T.i meets A by A13;
    then reconsider
    SAi = SA.i, SBi = SB.i as non empty compact Subset of REAL by A18,A19,A20
,Th5;
    consider ai,bi being Real such that
A21: ai in SAi and
A22: bi in SBi and
A23: dist(SAi,SBi) = |.ai - bi.| by Th9;
    reconsider ai,bi as Element of REAL by XREAL_0:def 1;
    take ai,bi;
    thus thesis by A21,A22,A23;
  end;
  consider sa,sb being Real_Sequence such that
A24: for i being Element of NAT holds P[i,sa.i,sb.i] from DoubleChoice(
  A17);
  rng sa c= [.e,f.]
  proof
    let u be object;
    assume u in rng sa;
    then consider x being object such that
A25: x in dom sa and
A26: u = sa.x by FUNCT_1:def 3;
    reconsider n = x as Element of NAT by A25;
    sa.n in SA.n by A24;
    then u in T.n /\ A by A15,A26;
    then u in A by XBOOLE_0:def 4;
    hence thesis by A2;
  end;
  then consider ga being Real_Sequence such that
A27: ga is subsequence of sa and
A28: ga is convergent and
A29: lim ga in [.e,f.] by RCOMP_1:def 3;
  consider Nseq being increasing sequence of NAT such that
A30: ga = sa*Nseq by A27,VALUED_0:def 17;
  set gb = sb*Nseq;
  rng gb c= [.e,f.]
  proof
    let u be object;
    assume u in rng gb;
    then consider x being object such that
A31: x in dom gb and
A32: u = gb.x by FUNCT_1:def 3;
    reconsider n = x as Element of NAT by A31;
    gb.n = sb.(Nseq.n) by FUNCT_2:15;
    then gb.n in SB.(Nseq.n) by A24;
    then u in T.(Nseq.n) /\ B by A16,A32;
    then u in B by XBOOLE_0:def 4;
    hence thesis by A3;
  end;
  then consider fb being Real_Sequence such that
A33: fb is subsequence of gb and
A34: fb is convergent and
A35: lim fb in [.e,f.] by RCOMP_1:def 3;
  consider Nseq1 being increasing sequence of NAT such that
A36: fb = gb*Nseq1 by A33,VALUED_0:def 17;
  set fa = ga*Nseq1, r = (lim fa + lim fb)/2;
  set d0 = dist(A,B), ff = (1/2)(#)(fa+fb);
A37: fa is convergent by A28,SEQ_4:16;
  then
A38: fa+fb is convergent by A34,SEQ_2:5;
  then
A39: ff is convergent by SEQ_2:7;
  T.0 meets A by A13;
  then A is non empty;
  then d0 > 0 by A1,A14,Th11;
  then
A40: d0/2 > 0 by XREAL_1:139;
  r = (1/2)*(lim fa + lim fb) .= (1/2)*lim(fa+fb) by A34,A37,SEQ_2:6
    .= lim ff by A38,SEQ_2:8;
  then consider k0 being Nat such that
A41: for i being Nat st k0 <= i holds |.ff.i - r.| < d0/2 by A39
,A40,SEQ_2:def 7;
A42: k0 in NAT by ORDINAL1:def 12;
  take r;
  lim fa = lim ga by A28,SEQ_4:17;
  hence r in [.e,f.] by A29,A35,Th1;
  now
    set i = Nseq.(Nseq1.k0), di = dist(SA.i,SB.i);
A43: 2*|.(sa.i+sb.i)/2 - r.| = |.2.|*|.(sa.i+sb.i)/2 - r.| by ABSVALUE:def 1
      .= |.2*((sa.i+sb.i)/2 - r).| by COMPLEX1:65
      .= |.sa.i+sb.i-2*r.|;
A44: fa.k0 = ga.(Nseq1.k0) by FUNCT_2:15,A42
      .= sa.i by A30,FUNCT_2:15;
    T.i meets B by A13;
    then T.i /\ B <> {};
    then
A45: SB.i is non empty by A16;
A46: SB.i = T.i /\ B by A16;
    then
A47: SB.i c= B by XBOOLE_1:17;
A48: SB.i c= T.i by A46,XBOOLE_1:17;
A49: SA.i = T.i /\ A by A15;
    then
A50: SA.i c= A by XBOOLE_1:17;
    T.i meets A by A13;
    then T.i /\ A <> {};
    then
A51: SA.i is non empty by A15;
    then
A52: d0 <= di by A45,A50,A47,Th8;
    d0/2 <= di/2 by A51,A45,A50,A47,Th8,XREAL_1:72;
    then
A53: di/2 + d0/2 <= di/2 + di/2 by XREAL_1:6;
    ff.k0 = (1/2)*((fa+fb).k0) by SEQ_1:9
      .= ((fa+fb).k0)/2
      .= (fa.k0+fb.k0)/2 by SEQ_1:7;
    then
A54: |.(fa.k0+fb.k0)/2 - r.| < d0/2 by A41;
    T.i is non empty closed_interval by A13;
    then
A55: ex a,b being Real st a <= b & T.i = [.a,b.] by MEASURE5:14;
A56: sb.i in SB.i by A24;
A57: SA.i c= T.i by A49,XBOOLE_1:17;
A58: fb.k0 = gb.(Nseq1.k0) by A36,FUNCT_2:15,A42
      .= sb.i by FUNCT_2:15;
    2*(d0/2) = d0;
    then
A59: 2*|.(sa.i+sb.i)/2 - r.| < d0 by A54,A44,A58,XREAL_1:68;
A60: sa.i in SA.i by A24;
    then
A61: di <= |.sb.i-sa.i.| by A56,Th7;
A62: now
      per cases;
      suppose
        sa.i <= sb.i;
        then sb.i - sa.i >= 0 by XREAL_1:48;
        then di <= sb.i-sa.i by A61,ABSVALUE:def 1;
        then d0 <= sb.i-sa.i by A52,XXREAL_0:2;
        then |.sa.i+sb.i-2*r.| <= sb.i-sa.i by A59,A43,XXREAL_0:2;
        then
A63:    r in [.sa.i,sb.i.] by RCOMP_1:2;
        [.sa.i,sb.i.] c= T.i by A55,A60,A56,A57,A48,XXREAL_2:def 12;
        hence r in T.i by A63;
      end;
      suppose
A64:    sb.i <= sa.i;
A65:    |.sb.i-sa.i.| = |.sa.i-sb.i.| by UNIFORM1:11;
        sa.i - sb.i >= 0 by A64,XREAL_1:48;
        then di <= sa.i-sb.i by A61,A65,ABSVALUE:def 1;
        then d0 <= sa.i-sb.i by A52,XXREAL_0:2;
        then |.sb.i+sa.i-2*r.| <= sa.i-sb.i by A59,A43,XXREAL_0:2;
        then
A66:    r in [.sb.i,sa.i.] by RCOMP_1:2;
        [.sb.i,sa.i.] c= T.i by A55,A60,A56,A57,A48,XXREAL_2:def 12;
        hence r in T.i by A66;
      end;
    end;
    assume
A67: r in A \/ B;
    per cases by A67,XBOOLE_0:def 3;
    suppose
A68:  r in B;
      SB.i = T.i /\ B by A16;
      then
A69:  r in SB.i by A62,A68,XBOOLE_0:def 4;
A70:  |.(fa.k0-fb.k0)/2.| = |.(fa.k0-fb.k0).|/|.2.| by COMPLEX1:67
        .= |.(fa.k0-fb.k0).|/2 by ABSVALUE:def 1;
      fa.k0 - r = (fa.k0-fb.k0)/2 + ((fa.k0+fb.k0)/2 - r);
      then
A71:  |.fa.k0 - r.| <= |.(fa.k0-fb.k0)/2.| + |.(fa.k0+fb.k0)/2 - r.|
      by COMPLEX1:56;
      |.(fa.k0-fb.k0)/2.| + |.(fa.k0+fb.k0)/2 - r.| < |.(fa.k0-fb.k0
      )/2.| + d0/2 by A54,XREAL_1:6;
      then |.fa.k0 - r.| < |.(fa.k0-fb.k0).|/2 + d0/2 by A71,A70,XXREAL_0:2;
      then |.fa.k0 - r.| < di/2 + d0/2 by A24,A44,A58;
      then
A72:  |.fa.k0 - r.| < di by A53,XXREAL_0:2;
      fa.k0 in SA.i by A24,A44;
      hence contradiction by A69,A72,Th7;
    end;
    suppose
A73:  r in A;
      SA.i = T.i /\ A by A15;
      then
A74:  r in SA.i by A62,A73,XBOOLE_0:def 4;
A75:  |.(fb.k0-fa.k0)/2.| = |.(fb.k0-fa.k0).|/|.2.| by COMPLEX1:67
        .= |.(fb.k0-fa.k0).|/2 by ABSVALUE:def 1;
      fb.k0 - r = (fb.k0-fa.k0)/2 + ((fb.k0+fa.k0)/2 - r);
      then
A76:  |.fb.k0 - r.| <= |.(fb.k0-fa.k0)/2.| + |.(fb.k0+fa.k0)/2 - r.|
      by COMPLEX1:56;
A77:  |.fb.k0-fa.k0.| = |.fa.k0-fb.k0.| by UNIFORM1:11
        .= di by A24,A44,A58;
      |.(fb.k0-fa.k0)/2.| + |.(fb.k0+fa.k0)/2 - r.| < |.(fb.k0-fa.k0
      )/2.| + d0/2 by A54,XREAL_1:6;
      then |.fb.k0 - r.| < |.(fb.k0-fa.k0).|/2 + d0/2 by A76,A75,XXREAL_0:2;
      then
A78:  |.fb.k0 - r.| < di by A53,A77,XXREAL_0:2;
      fb.k0 in SB.i by A24,A58;
      hence contradiction by A74,A78,Th7;
    end;
  end;
  hence not r in A \/ B;
  let i being Nat;
  set k = max(k0,i);
A79:  k in NAT by ORDINAL1:def 12;
  take j = Nseq.(Nseq1.k);
A80: fb.k = gb.(Nseq1.k) by A36,FUNCT_2:15,A79
    .= sb.j by FUNCT_2:15;
A81: i <= k by XXREAL_0:25;
A82: sb.j in SB.j by A24;
  T.j meets B by A13;
  then T.j /\ B <> {};
  then
A83: SB.j is non empty by A16;
A84: dom Nseq = NAT by FUNCT_2:def 1;
  T.j meets A by A13;
  then T.j /\ A <> {};
  then
A85: SA.j is non empty by A15;
A86: i <= Nseq.i by SEQM_3:14;
A87: SA.j = T.j /\ A by A15;
  then
A88: SA.j c= T.j by XBOOLE_1:17;
  ff.k = (1/2)*((fa+fb).k) by A79,SEQ_1:9
    .= ((fa+fb).k)/2
    .= (fa.k+fb.k)/2 by A79,SEQ_1:7;
  then
A89: |.(fa.k+fb.k)/2 - r.| < d0/2 by A41,A79,XXREAL_0:25;
A90: 2*(d0/2) = d0;
  fa.k = ga.(Nseq1.k) by FUNCT_2:15,A79
    .= sa.j by A30,FUNCT_2:15;
  then
A91: 2*|.(sa.j+sb.j)/2 - r.| < d0 by A89,A80,A90,XREAL_1:68;
  T.j is non empty closed_interval by A13;
  then
A92: ex a,b be Real st a <= b & T.j = [.a,b.] by MEASURE5:14;
A93: SB.j = T.j /\ B by A16;
  then
A94: SB.j c= B by XBOOLE_1:17;
A95: SB.j c= T.j by A93,XBOOLE_1:17;
A96:  i in NAT by ORDINAL1:def 12;
  dom Nseq1 = NAT by FUNCT_2:def 1;
  then Nseq1.i <= Nseq1.k by A81,VALUED_0:def 15,A79,A96;
  then
A97: Nseq.(Nseq1.i) <= j by A84,VALUED_0:def 15;
  i <= Nseq1.i by SEQM_3:14;
  then Nseq.i <= Nseq.(Nseq1.i) by A84,VALUED_0:def 15,A96;
  then i <= Nseq.(Nseq1.i) by A86,XXREAL_0:2;
  hence i <= j by A97,XXREAL_0:2;
  set di = dist(SA.j,SB.j);
A98: 2*|.(sa.j+sb.j)/2 - r.| = |.2.|*|.(sa.j+sb.j)/2 - r.| by ABSVALUE:def 1
    .= |.2*((sa.j+sb.j)/2 - r).| by COMPLEX1:65
    .= |.sa.j+sb.j-2*r.|;
  SA.j c= A by A87,XBOOLE_1:17;
  then
A99: d0 <= di by A85,A83,A94,Th8;
A100: sa.j in SA.j by A24;
  then
A101: di <= |.sb.j-sa.j.| by A82,Th7;
A102: now
    per cases;
    suppose
      sa.j <= sb.j;
      then sb.j - sa.j >= 0 by XREAL_1:48;
      then di <= sb.j-sa.j by A101,ABSVALUE:def 1;
      then d0 <= sb.j-sa.j by A99,XXREAL_0:2;
      then |.sa.j+sb.j-2*r.| <= sb.j-sa.j by A91,A98,XXREAL_0:2;
      then
A103: r in [.sa.j,sb.j.] by RCOMP_1:2;
      [.sa.j,sb.j.] c= T.j by A92,A100,A82,A88,A95,XXREAL_2:def 12;
      hence r in T.j by A103;
    end;
    suppose
A104: sb.j <= sa.j;
A105: |.sb.j-sa.j.| = |.sa.j-sb.j.| by UNIFORM1:11;
      sa.j - sb.j >= 0 by A104,XREAL_1:48;
      then di <= sa.j-sb.j by A101,A105,ABSVALUE:def 1;
      then d0 <= sa.j-sb.j by A99,XXREAL_0:2;
      then |.sb.j+sa.j-2*r.| <= sa.j-sb.j by A91,A98,XXREAL_0:2;
      then
A106: r in [.sb.j,sa.j.] by RCOMP_1:2;
      [.sb.j,sa.j.] c= T.j by A92,A100,A82,A88,A95,XXREAL_2:def 12;
      hence r in T.j by A106;
    end;
  end;
  T.j c= S.j by A13;
  hence thesis by A102;
end;
