1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| (* infinity *)
type 'a with_infinity =
Value of 'a | Neg_inf | Pos_inf
let with_infinity bound =
{ value = Value bound.value;
eq = (fun a b -> match a, b with
| Neg_inf, Neg_inf | Pos_inf, Pos_inf -> true
| Value x, Value y -> bound.eq x y
| _ -> false);
inf = (fun a b -> match a, b with
| Neg_inf, _ | _, Neg_inf -> Neg_inf
| Pos_inf, t | t, Pos_inf -> t
| Value x, Value y -> Value (bound.inf x y));
sup = (fun a b -> match a, b with
| Neg_inf, t | t, Neg_inf -> t
| Pos_inf, _ | _, Pos_inf -> Pos_inf
| Value x, Value y -> Value (bound.sup x y)) }
let interval_with_infinity (a, a') = with_infinity a, with_infinity a' |