reserve a, b, r, s for Real;

theorem Th30:
  for X being non empty interval Subset of REAL st not r in X
  holds r <= lower_bound X or upper_bound X <= r
proof
  let X be non empty interval Subset of REAL such that
A1: not r in X;
  per cases by Th29;
  suppose
    X = REAL;
    hence thesis by A1,XREAL_0:def 1;
  end;
  suppose
    ex a st X = left_closed_halfline(a);
    then consider a such that
A2: X = left_closed_halfline(a);
    upper_bound X = a by A2,Th9;
    hence thesis by A1,A2,XXREAL_1:234;
  end;
  suppose
    ex a st X = left_open_halfline(a);
    then consider a such that
A3: X = left_open_halfline(a);
    upper_bound X = a by A3,Th10;
    hence thesis by A1,A3,XXREAL_1:233;
  end;
  suppose
    ex a st X = right_closed_halfline(a);
    then consider a such that
A4: X = right_closed_halfline(a);
    lower_bound X = a by A4,Th11;
    hence thesis by A1,A4,XXREAL_1:236;
  end;
  suppose
    ex a st X = right_open_halfline(a);
    then consider a such that
A5: X = right_open_halfline(a);
    lower_bound X = a by A5,Th12;
    hence thesis by A1,A5,XXREAL_1:235;
  end;
  suppose
    ex a, b st a <= b & X = [.a,b.];
    then consider a, b such that
A6: a <= b and
A7: X = [.a,b.];
    lower_bound X = a & upper_bound X = b by A6,A7,JORDAN5A:19;
    hence thesis by A1,A7,XXREAL_1:1;
  end;
  suppose
    ex a, b st a < b & X = [.a,b.[;
    then consider a, b such that
A8: a < b and
A9: X = [.a,b.[;
    lower_bound X = a & upper_bound X = b by A8,A9,Th4,Th5;
    hence thesis by A1,A9,XXREAL_1:3;
  end;
  suppose
    ex a, b st a < b & X = ].a,b.];
    then consider a, b such that
A10: a < b and
A11: X = ].a,b.];
    lower_bound X = a & upper_bound X = b by A10,A11,Th6,Th7;
    hence thesis by A1,A11,XXREAL_1:2;
  end;
  suppose
    ex a, b st a < b & X = ].a,b.[;
    then consider a, b such that
A12: a < b and
A13: X = ].a,b.[;
    lower_bound X = a & upper_bound X = b by A12,A13,TOPREAL6:17;
    hence thesis by A1,A13,XXREAL_1:4;
  end;
end;
