diff options
author | Guillaume Melquiond <guillaume.melquiond@inria.fr> | 2019-02-13 18:53:17 +0100 |
---|---|---|
committer | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2019-03-27 11:38:25 +0100 |
commit | 0f919eb26c68d3882e612a1b3a9df45bee6d3624 (patch) | |
tree | b8bcf57e06d761be09b8d2cf2f80741acb1e4949 /flocq/Core/Defs.v | |
parent | d5c0b4054c8490bda3b3d191724c58d5d4002e58 (diff) | |
download | compcert-0f919eb26c68d3882e612a1b3a9df45bee6d3624.tar.gz compcert-0f919eb26c68d3882e612a1b3a9df45bee6d3624.zip |
Upgrade embedded version of Flocq to 3.1.
Main changes to CompCert outside of Flocq are as follows:
- Minimal supported version of Coq is now 8.7, due to Flocq requirements.
- Most modifications are due to Z2R being dropped in favor of IZR and to
the way Flocq now handles NaNs.
- CompCert now correctly handles NaNs for the Risc-V architecture
(hopefully).
Diffstat (limited to 'flocq/Core/Defs.v')
-rw-r--r-- | flocq/Core/Defs.v | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/flocq/Core/Defs.v b/flocq/Core/Defs.v new file mode 100644 index 00000000..f5c6f33b --- /dev/null +++ b/flocq/Core/Defs.v @@ -0,0 +1,83 @@ +(** +This file is part of the Flocq formalization of floating-point +arithmetic in Coq: http://flocq.gforge.inria.fr/ + +Copyright (C) 2009-2018 Sylvie Boldo +#<br /># +Copyright (C) 2009-2018 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. +*) + +(** * Basic definitions: float and rounding property *) +Require Import Raux. + +Section Def. + +(** Definition of a floating-point number *) +Record float (beta : radix) := Float { Fnum : Z ; Fexp : Z }. + +Arguments Fnum {beta}. +Arguments Fexp {beta}. + +Variable beta : radix. + +Definition F2R (f : float beta) := + (IZR (Fnum f) * bpow beta (Fexp f))%R. + +(** Requirements on a rounding mode *) +Definition round_pred_total (P : R -> R -> Prop) := + forall x, exists f, P x f. + +Definition round_pred_monotone (P : R -> R -> Prop) := + forall x y f g, P x f -> P y g -> (x <= y)%R -> (f <= g)%R. + +Definition round_pred (P : R -> R -> Prop) := + round_pred_total P /\ + round_pred_monotone P. + +End Def. + +Arguments Fnum {beta}. +Arguments Fexp {beta}. +Arguments F2R {beta}. + +Section RND. + +(** property of being a round toward -inf *) +Definition Rnd_DN_pt (F : R -> Prop) (x f : R) := + F f /\ (f <= x)%R /\ + forall g : R, F g -> (g <= x)%R -> (g <= f)%R. + +(** property of being a round toward +inf *) +Definition Rnd_UP_pt (F : R -> Prop) (x f : R) := + F f /\ (x <= f)%R /\ + forall g : R, F g -> (x <= g)%R -> (f <= g)%R. + +(** property of being a round toward zero *) +Definition Rnd_ZR_pt (F : R -> Prop) (x f : R) := + ( (0 <= x)%R -> Rnd_DN_pt F x f ) /\ + ( (x <= 0)%R -> Rnd_UP_pt F x f ). + +(** property of being a round to nearest *) +Definition Rnd_N_pt (F : R -> Prop) (x f : R) := + F f /\ + forall g : R, F g -> (Rabs (f - x) <= Rabs (g - x))%R. + +Definition Rnd_NG_pt (F : R -> Prop) (P : R -> R -> Prop) (x f : R) := + Rnd_N_pt F x f /\ + ( P x f \/ forall f2 : R, Rnd_N_pt F x f2 -> f2 = f ). + +Definition Rnd_NA_pt (F : R -> Prop) (x f : R) := + Rnd_N_pt F x f /\ + forall f2 : R, Rnd_N_pt F x f2 -> (Rabs f2 <= Rabs f)%R. + +End RND. |