Definition Bconv (conv_nan: bool -> nan_pl prec1 -> bool * nan_pl prec2) (md: mode) (f: binary_float1) : binary_float2 :=
  match f with
    | B754_nan _ _ s pl => let '(s, pl) := conv_nan s pl in B754_nan _ _ s pl
    | B754_infinity _ _ s => B754_infinity _ _ s
    | B754_zero _ _ s => B754_zero _ _ s
    | B754_finite _ _ s m e _ => binary_normalize _ _ _ Hmax2 md (cond_Zopp s (Zpos m)) e s
  end.

(* Specifications: *)
Theorem Bconv_correct: forall conv_nan m f, is_finite _ _ f = true -> if Rlt_bool (Rabs (round radix2 fexp2 (round_mode m) (B2R _ _ f))) (bpow radix2 emax2) then B2R _ _ (Bconv conv_nan m f) = round radix2 fexp2 (round_mode m) (B2R _ _ f) /\ is_finite _ _ (Bconv conv_nan m f) = true /\ Bsign _ _ (Bconv conv_nan m f) = Bsign _ _ f else B2FF _ _ (Bconv conv_nan m f) = binary_overflow prec2 emax2 m (Bsign _ _ f).
Theorem Bconv_widen_exact: (prec2 >= prec1)%Z -> (emax2 >= emax1)%Z -> forall conv_nan m f, is_finite _ _ f = true -> B2R _ _ (Bconv conv_nan m f) = B2R _ _ f /\ is_finite _ _ (Bconv conv_nan m f) = true /\ Bsign _ _ (Bconv conv_nan m f) = Bsign _ _ f.
Theorem Bconv_BofZ: forall conv_nan n, integer_representable prec1 emax1 n -> Bconv conv_nan mode_NE (BofZ prec1 emax1 _ Hmax1 n) = BofZ prec2 emax2 _ Hmax2 n.
Theorem ZofB_Bconv: prec2 >= prec1 -> emax2 >= emax1 -> forall conv_nan m f n, ZofB _ _ f = Some n -> ZofB _ _ (Bconv conv_nan m f) = Some n.
Theorem ZofB_range_Bconv: forall min1 max1 min2 max2, prec2 >= prec1 -> emax2 >= emax1 -> min2 <= min1 -> max1 <= max2 -> forall conv_nan m f n, ZofB_range _ _ f min1 max1 = Some n -> ZofB_range _ _ (Bconv conv_nan m f) min2 max2 = Some n.
Theorem Bcompare_Bconv_widen: prec2 >= prec1 -> emax2 >= emax1 -> forall conv_nan m x y, Bcompare _ _ (Bconv conv_nan m x) (Bconv conv_nan m y) = Bcompare _ _ x y.
Theorem Bconv_narrow_widen: prec2 >= prec1 -> emax2 >= emax1 -> forall narrow_nan widen_nan m f, is_nan _ _ f = false -> Bconv prec2 emax2 prec1 emax1 _ Hmax1 narrow_nan m (Bconv prec1 emax1 prec2 emax2 _ Hmax2 widen_nan m f) = f.
Theorem Bconv_correct: forall conv_nan m f, is_finite _ _ f = true -> if Rlt_bool (Rabs (round radix2 fexp2 (round_mode m) (B2R _ _ f))) (bpow radix2 emax2) then B2R _ _ (Bconv conv_nan m f) = round radix2 fexp2 (round_mode m) (B2R _ _ f) /\ is_finite _ _ (Bconv conv_nan m f) = true /\ Bsign _ _ (Bconv conv_nan m f) = Bsign _ _ f else B2FF _ _ (Bconv conv_nan m f) = binary_overflow prec2 emax2 m (Bsign _ _ f).
Theorem Bconv_widen_exact: (prec2 >= prec1)%Z -> (emax2 >= emax1)%Z -> forall conv_nan m f, is_finite _ _ f = true -> B2R _ _ (Bconv conv_nan m f) = B2R _ _ f /\ is_finite _ _ (Bconv conv_nan m f) = true /\ Bsign _ _ (Bconv conv_nan m f) = Bsign _ _ f.
Theorem Bconv_BofZ: forall conv_nan n, integer_representable prec1 emax1 n -> Bconv conv_nan mode_NE (BofZ prec1 emax1 _ Hmax1 n) = BofZ prec2 emax2 _ Hmax2 n.
Theorem ZofB_Bconv: prec2 >= prec1 -> emax2 >= emax1 -> forall conv_nan m f n, ZofB _ _ f = Some n -> ZofB _ _ (Bconv conv_nan m f) = Some n.
Theorem ZofB_range_Bconv: forall min1 max1 min2 max2, prec2 >= prec1 -> emax2 >= emax1 -> min2 <= min1 -> max1 <= max2 -> forall conv_nan m f n, ZofB_range _ _ f min1 max1 = Some n -> ZofB_range _ _ (Bconv conv_nan m f) min2 max2 = Some n.
Theorem Bcompare_Bconv_widen: prec2 >= prec1 -> emax2 >= emax1 -> forall conv_nan m x y, Bcompare _ _ (Bconv conv_nan m x) (Bconv conv_nan m y) = Bcompare _ _ x y.
Theorem Bconv_narrow_widen: prec2 >= prec1 -> emax2 >= emax1 -> forall narrow_nan widen_nan m f, is_nan _ _ f = false -> Bconv prec2 emax2 prec1 emax1 _ Hmax1 narrow_nan m (Bconv prec1 emax1 prec2 emax2 _ Hmax2 widen_nan m f) = f.