(** ** Order *)
Definition Rbar_lt (x y : Rbar) : Prop :=
match x,y with
| p_infty, _ | _, m_infty => False
| m_infty, _ | _, p_infty => True
| Finite x, Finite y => Rlt x y
end.
Definition Rbar_le (x y : Rbar) : Prop :=
match x,y with
| m_infty, _ | _, p_infty => True
| p_infty, _ | _, m_infty => False
| Finite x, Finite y => Rle x y
end.
(** ** Operations *)
(** *** Additive operators *)
Definition Rbar_opp (x : Rbar) :=
match x with
| Finite x => Finite (-x)
| p_infty => m_infty
| m_infty => p_infty
end.
Definition Rbar_plus' (x y : Rbar) :=
match x,y with
| p_infty, m_infty | m_infty, p_infty => None
| p_infty, _ | _, p_infty => Some p_infty
| m_infty, _ | _, m_infty => Some m_infty
| Finite x', Finite y' => Some (Finite (x' + y'))
end.
Definition Rbar_plus (x y : Rbar) :=
match Rbar_plus' x y with Some z => z | None => Finite 0 end.
Arguments Rbar_plus !x !y /.
Definition is_Rbar_plus (x y z : Rbar) : Prop :=
Rbar_plus' x y = Some z.
Definition ex_Rbar_plus (x y : Rbar) : Prop :=
match Rbar_plus' x y with Some _ => True | None => False end.
Arguments ex_Rbar_plus !x !y /.

Lemma Rbar_plus_correct (x y : Rbar) :
ex_Rbar_plus x y -> is_Rbar_plus x y (Rbar_plus x y).