Section IntervalLattice.
Variable (disp : unit) (T : latticeType disp).
Implicit Types (x y z : T) (b bl br : itv_bound T) (i : interval T).
Definition bound_meet bl br : itv_bound T :=
match bl, br with
| -oo, _ | _, -oo => -oo
| +oo, b | b, +oo => b
| BSide xb x, BSide yb y =>
BSide (((x <= y) && xb) || ((y <= x) && yb)) (x `&` y)
end.
Definition bound_join bl br : itv_bound T :=
match bl, br with
| -oo, b | b, -oo => b
| +oo, _ | _, +oo => +oo
| BSide xb x, BSide yb y =>
BSide ((~~ (x <= y) || yb) && (~~ (y <= x) || xb)) (x `|` y)
end.
Definition itv_bound_latticeMixin :=
LatticeMixin bound_meetC bound_joinC bound_meetA bound_joinA
bound_joinKI bound_meetKU bound_leEmeet.
Canonical itv_bound_latticeType :=
LatticeType (itv_bound T) itv_bound_latticeMixin.
Canonical itv_bound_bLatticeType :=
BLatticeType (itv_bound T) (BottomMixin bound_le0x).
Canonical itv_bound_tbLatticeType :=
TBLatticeType (itv_bound T) (TopMixin bound_lex1).
Definition itv_meet i1 i2 : interval T :=
let: Interval b1l b1r := i1 in
let: Interval b2l b2r := i2 in Interval (b1l `|` b2l) (b1r `&` b2r).
Definition itv_join i1 i2 : interval T :=
let: Interval b1l b1r := i1 in
let: Interval b2l b2r := i2 in Interval (b1l `&` b2l) (b1r `|` b2r).

Lemma itv_meetC : commutative itv_meet.