(** 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. *)
(** * Floating-point format without underflow *)
Section RND_FLX.
Variable beta : radix.
Notation bpow e := (bpow beta e).
Variable prec : Z.
Class Prec_gt_0 :=
prec_gt_0 : (0 < prec)%Z.
Context { prec_gt_0_ : Prec_gt_0 }.
(* unbounded floating-point format *)
Definition FLX_format (x : R) :=
exists f : float beta,
x = F2R f /\ (Zabs (Fnum f) < Zpower beta prec)%Z.
Definition FLX_exp (e : Z) := (e - prec)%Z.
(** Properties of the FLX format *)
Global Instance FLX_exp_valid : Valid_exp FLX_exp.

(* Specifications: *)
Theorem FIX_format_FLX :
forall x e,
(bpow (e - 1) <= Rabs x <= bpow e)%R ->
FLX_format x ->
FIX_format beta (e - prec) x.
Theorem FLX_format_generic :
forall x, generic_format beta FLX_exp x -> FLX_format x.
Theorem generic_format_FLX :
forall x, FLX_format x -> generic_format beta FLX_exp x.
Theorem FLX_format_satisfies_any :
satisfies_any FLX_format.
Theorem FLX_format_FIX :
forall x e,
(bpow (e - 1) <= Rabs x <= bpow e)%R ->
FIX_format beta (e - prec) x ->
FLX_format x.
Theorem FIX_format_FLX :
forall x e,
(bpow (e - 1) <= Rabs x <= bpow e)%R ->
FLX_format x ->
FIX_format beta (e - prec) x.
Theorem FLX_format_generic :
forall x, generic_format beta FLX_exp x -> FLX_format x.
Theorem generic_format_FLX :
forall x, FLX_format x -> generic_format beta FLX_exp x.
Theorem FLX_format_satisfies_any :
satisfies_any FLX_format.
Theorem FLX_format_FIX :
forall x e,
(bpow (e - 1) <= Rabs x <= bpow e)%R ->
FIX_format beta (e - prec) x ->
FLX_format x.