reserve a, b, r, s for Real;

theorem Th29:
  for X being interval Subset of REAL holds X is empty or X =
  REAL or (ex a st X = left_closed_halfline(a)) or (ex a st X =
left_open_halfline(a)) or (ex a st X = right_closed_halfline(a)) or (ex a st X
= right_open_halfline(a)) or (ex a, b st a <= b & X = [.a,b.]) or (ex a, b st a
< b & X = [.a,b.[) or (ex a, b st a < b & X = ].a,b.]) or ex a, b st a < b & X
  = ].a,b.[
proof
  let X be interval Subset of REAL;
  assume X is non empty;
  then reconsider X as non empty interval Subset of REAL;
  per cases;
  suppose
    X is real-bounded;
    then reconsider X as non empty real-bounded interval Subset of REAL;
    per cases;
    suppose
      X is trivial;
      then consider x being object such that
A1:   X = {x} by ZFMISC_1:131;
      x in X by A1,TARSKI:def 1;
      then reconsider x as Real;
      X = [.x,x.] by A1,XXREAL_1:17;
      hence thesis;
    end;
    suppose
      X is non trivial;
      then ex p, q being object st p in X & q in X & p <> q;
      then
A2:   lower_bound X < upper_bound X by SEQ_4:12;
      per cases;
      suppose
        upper_bound X in X & lower_bound X in X;
        then X = [.lower_bound X,upper_bound X.] by Th13;
        hence thesis by A2;
      end;
      suppose
        upper_bound X in X & not lower_bound X in X;
        then X = ].lower_bound X,upper_bound X.] by Th15;
        hence thesis by A2;
      end;
      suppose
        not upper_bound X in X & lower_bound X in X;
        then X = [.lower_bound X,upper_bound X.[ by Th17;
        hence thesis by A2;
      end;
      suppose
        not upper_bound X in X & not lower_bound X in X;
        then X = ].lower_bound X,upper_bound X.[ by Th19;
        hence thesis by A2;
      end;
    end;
  end;
  suppose
A3: X is not real-bounded;
    per cases by A3;
    suppose
A4:   X is not bounded_below & X is bounded_above;
      per cases;
      suppose
        upper_bound X in X;
        then X = left_closed_halfline(upper_bound X) by A4,Th21;
        hence thesis;
      end;
      suppose
        not upper_bound X in X;
        then X = left_open_halfline(upper_bound X) by A4,Th23;
        hence thesis;
      end;
    end;
    suppose
A5:   X is not bounded_above & X is bounded_below;
      per cases;
      suppose
        lower_bound X in X;
        then X = right_closed_halfline(lower_bound X) by A5,Th25;
        hence thesis;
      end;
      suppose
        not lower_bound X in X;
        then X = right_open_halfline(lower_bound X) by A5,Th27;
        hence thesis;
      end;
    end;
    suppose
      X is not bounded_above & X is not bounded_below;
      hence thesis by Th28;
    end;
  end;
end;
