(** Subtraction *)

Definition Bminus minus_nan m x y := Bplus minus_nan m x (Bopp pair y).

(* Specifications: *)
Theorem Bminus_correct : forall minus_nan m x y, is_finite x = true -> is_finite y = true -> if Rlt_bool (Rabs (round radix2 fexp (round_mode m) (B2R x - B2R y))) (bpow radix2 emax) then B2R (Bminus minus_nan m x y) = round radix2 fexp (round_mode m) (B2R x - B2R y) /\ is_finite (Bminus minus_nan m x y) = true /\ Bsign (Bminus minus_nan m x y) = match Rcompare (B2R x - B2R y) 0 with | Eq => match m with mode_DN => orb (Bsign x) (negb (Bsign y)) | _ => andb (Bsign x) (negb (Bsign y)) end | Lt => true | Gt => false end else (B2FF (Bminus minus_nan m x y) = binary_overflow m (Bsign x) /\ Bsign x = negb (Bsign y)).
Theorem Bminus_correct : forall minus_nan m x y, is_finite x = true -> is_finite y = true -> if Rlt_bool (Rabs (round radix2 fexp (round_mode m) (B2R x - B2R y))) (bpow radix2 emax) then B2R (Bminus minus_nan m x y) = round radix2 fexp (round_mode m) (B2R x - B2R y) /\ is_finite (Bminus minus_nan m x y) = true /\ Bsign (Bminus minus_nan m x y) = match Rcompare (B2R x - B2R y) 0 with | Eq => match m with mode_DN => orb (Bsign x) (negb (Bsign y)) | _ => andb (Bsign x) (negb (Bsign y)) end | Lt => true | Gt => false end else (B2FF (Bminus minus_nan m x y) = binary_overflow m (Bsign x) /\ Bsign x = negb (Bsign y)).