let complement i =
if i.dom <> Dom.Real then
raise (Invalid_argument "interval not complementable")
else
match i.lo, i.hi with
| None, None -> mk_empty
| None, Some(p, beta) ->
{ dom = Dom.Real; lo = Some(not beta, p); hi = None }
| Some(alpha, q), None ->
{ dom = Dom.Real; lo = None; hi = Some(q, not alpha) }
| _ ->
raise (Invalid_argument "interval not complementable")