(** This file is part of the Flocq formalization of floating-point arithmetic in Coq: http://flocq.gforge.inria.fr/  Copyright (C) 2010-2013 Sylvie Boldo #<br /># Copyright (C) 2010-2013 Guillaume Melquiond  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details. *)
(** * Error of the multiplication is in the FLX/FLT format *)
Section Fprop_mult_error.
Variable beta : radix.
Notation bpow e := (bpow beta e).
Variable prec : Z.
Context { prec_gt_0_ : Prec_gt_0 prec }.
Notation format := (generic_format beta (FLX_exp prec)).
Notation cexp := (canonic_exp beta (FLX_exp prec)).
Variable rnd : R -> Z.
Context { valid_rnd : Valid_rnd rnd }.

(* Specifications: *)
(** Auxiliary result that provides the exponent *)
Lemma mult_error_FLX_aux:
forall x y,
format x -> format y ->
(round beta (FLX_exp prec) rnd (x * y) - (x * y) <> 0)%R ->
exists f:float beta,
(F2R f = round beta (FLX_exp prec) rnd (x * y) - (x * y))%R
/\  (canonic_exp beta (FLX_exp prec) (F2R f) <= Fexp f)%Z
/\ (Fexp f = cexp x + cexp y)%Z.
(** Auxiliary result that provides the exponent *)
Lemma mult_error_FLX_aux:
forall x y,
format x -> format y ->
(round beta (FLX_exp prec) rnd (x * y) - (x * y) <> 0)%R ->
exists f:float beta,
(F2R f = round beta (FLX_exp prec) rnd (x * y) - (x * y))%R
/\  (canonic_exp beta (FLX_exp prec) (F2R f) <= Fexp f)%Z
/\ (Fexp f = cexp x + cexp y)%Z.