diff options
author | David Monniaux <David.Monniaux@univ-grenoble-alpes.fr> | 2021-12-06 21:14:46 +0100 |
---|---|---|
committer | David Monniaux <David.Monniaux@univ-grenoble-alpes.fr> | 2021-12-06 23:48:54 +0100 |
commit | c5e74c17f2ab7f40d314417f2b20b18d4d2d057b (patch) | |
tree | 54303a7a2aa3722c33da0510d6d8695a14295fb1 /lib | |
parent | 54e63022f92795ab9ffa5c67023a98b7d30ebc69 (diff) | |
download | compcert-kvx-c5e74c17f2ab7f40d314417f2b20b18d4d2d057b.tar.gz compcert-kvx-c5e74c17f2ab7f40d314417f2b20b18d4d2d057b.zip |
progress on ZofB_ne
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IEEE754_extra.v | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/IEEE754_extra.v b/lib/IEEE754_extra.v index d2372f17..1ee9c2e0 100644 --- a/lib/IEEE754_extra.v +++ b/lib/IEEE754_extra.v @@ -890,6 +890,57 @@ Definition Zdiv_ne (a b : Z) := | Eq => (if Z.even q then q else q1) end. +Definition ZofB_ne (f: binary_float): option Z := + match f with + | B754_finite _ _ s m (Zpos e) _ => Some (cond_Zopp s (Zpos m) * Z.pow_pos radix2 e)%Z + | B754_finite _ _ s m 0 _ => Some (cond_Zopp s (Zpos m)) + | B754_finite _ _ s m (Zneg e) _ => Some (cond_Zopp s (Zdiv_ne (Zpos m) (Z.pow_pos radix2 e)))%Z + | B754_zero _ _ _ => Some 0%Z + | _ => None + end. + +Lemma ZnearestE_IZR: + forall n, (ZnearestE (IZR n)) = n. +Proof. + intro n. + unfold ZnearestE. + case Rcompare_spec ; intro ORDER. + - apply Zfloor_IZR. + - destruct negb. + + apply Zceil_IZR. + + apply Zfloor_IZR. + - apply Zceil_IZR. +Qed. + +Lemma Zfloor_opp : + forall x : R, (Zfloor (- x)) = - (Zceil x). +Proof. + unfold Zceil, Zfloor. + intro x. + rewrite Z.opp_involutive. + reflexivity. +Qed. + +Lemma Zceil_opp : + forall x : R, (Zceil (- x)) = - (Zfloor x). +Proof. + unfold Zceil, Zfloor. + intro x. + rewrite Ropp_involutive. + reflexivity. +Qed. + +Lemma ZnearestE_opp + : forall x : R, ZnearestE (- x) = - ZnearestE x. +Admitted. + + +Theorem ZofB_ne_correct: + forall f, + ZofB_ne f = if is_finite _ _ f then Some (ZnearestE (B2R _ _ f)) else None. +Admitted. + + (** ** Algebraic identities *) (** Commutativity of addition and multiplication *) |