reserve a, r, s for Real;

theorem Th1:
  r <= s implies for p being Point of Closed-Interval-MSpace(r,s)
holds Ball(p,a) = [.r,s.] or Ball(p,a) = [.r,p+a.[ or Ball(p,a) = ].p-a,s.] or
  Ball(p,a) = ].p-a,p+a.[
proof
  set M = Closed-Interval-MSpace(r,s);
  assume r <= s;
  then
A1: the carrier of M = [.r,s.] by TOPMETR:10;
  let p be Point of M;
  set B = Ball(p,a);
  reconsider p1 = p as Point of RealSpace by TOPMETR:8;
  set B1 = Ball(p1,a);
A2: B = B1 /\ the carrier of M by TOPMETR:9;
A3: B1 = ].p1-a, p1+a.[ by FRECHET:7;
  per cases;
  suppose that
A4: p1+a <= s and
A5: p1-a < r;
    B = [.r,p1+a.[
    proof
      thus B c= [.r,p1+a.[
      proof
        let b be object;
        assume
A6:     b in B;
        then reconsider b as Element of B;
        b in B1 by A2,A6,XBOOLE_0:def 4;
        then
A7:     b < p1+a by A3,XXREAL_1:4;
        r <= b by A1,A6,XXREAL_1:1;
        hence thesis by A7,XXREAL_1:3;
      end;
      let b be object;
      assume
A8:   b in [.r,p1+a.[;
      then reconsider b as Real;
A9:   r <= b by A8,XXREAL_1:3;
A10:  b < p1+a by A8,XXREAL_1:3;
      then b <= s by A4,XXREAL_0:2;
      then
A11:  b in [.r,s.] by A9,XXREAL_1:1;
      p1-a < b by A5,A9,XXREAL_0:2;
      then b in B1 by A3,A10,XXREAL_1:4;
      hence thesis by A1,A2,A11,XBOOLE_0:def 4;
    end;
    hence thesis;
  end;
  suppose that
A12: p1+a <= s and
A13: p1-a >= r;
    B = ].p1-a,p1+a.[
    proof
      thus B c= ].p1-a,p1+a.[ by A2,A3,XBOOLE_1:17;
      let b be object;
      assume
A14:  b in ].p1-a,p1+a.[;
      then reconsider b as Real;
      b < p1+a by A14,XXREAL_1:4;
      then
A15:  b <= s by A12,XXREAL_0:2;
      p1-a <= b by A14,XXREAL_1:4;
      then r <= b by A13,XXREAL_0:2;
      then b in [.r,s.] by A15,XXREAL_1:1;
      hence thesis by A1,A2,A3,A14,XBOOLE_0:def 4;
    end;
    hence thesis;
  end;
  suppose that
A16: p1+a > s and
A17: p1-a < r;
    B = [.r,s.]
    proof
      thus B c= [.r,s.] by A1;
      let b be object;
      assume
A18:  b in [.r,s.];
      then reconsider b as Real;
      b <= s by A18,XXREAL_1:1;
      then
A19:  b < p1+a by A16,XXREAL_0:2;
      r <= b by A18,XXREAL_1:1;
      then p1-a < b by A17,XXREAL_0:2;
      then b in B1 by A3,A19,XXREAL_1:4;
      hence thesis by A1,A2,A18,XBOOLE_0:def 4;
    end;
    hence thesis;
  end;
  suppose that
A20: p1+a > s and
A21: p1-a >= r;
    B = ].p1-a,s.]
    proof
      thus B c= ].p1-a,s.]
      proof
        let b be object;
        assume
A22:    b in B;
        then reconsider b as Element of B;
        b in B1 by A2,A22,XBOOLE_0:def 4;
        then
A23:    p1-a < b by A3,XXREAL_1:4;
        b <= s by A1,A22,XXREAL_1:1;
        hence thesis by A23,XXREAL_1:2;
      end;
      let b be object;
      assume
A24:  b in ].p1-a,s.];
      then reconsider b as Real;
A25:  b <= s by A24,XXREAL_1:2;
A26:  p1-a < b by A24,XXREAL_1:2;
      then r <= b by A21,XXREAL_0:2;
      then
A27:  b in [.r,s.] by A25,XXREAL_1:1;
      b < p1+a by A20,A25,XXREAL_0:2;
      then b in B1 by A3,A26,XXREAL_1:4;
      hence thesis by A1,A2,A27,XBOOLE_0:def 4;
    end;
    hence thesis;
  end;
end;
