Library Flocq.Prop.Fprop_plus_error
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
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.
Copyright (C) 2010-2013 Guillaume Melquiond
Error of the rounded-to-nearest addition is representable.
Require Import Fcore_Raux.
Require Import Fcore_defs.
Require Import Fcore_float_prop.
Require Import Fcore_generic_fmt.
Require Import Fcore_FIX.
Require Import Fcore_FLX.
Require Import Fcore_FLT.
Require Import Fcalc_ops.
Section Fprop_plus_error.
Variable beta : radix.
Notation bpow e := (bpow beta e).
Variable fexp : Z → Z.
Context { valid_exp : Valid_exp fexp }.
Section round_repr_same_exp.
Variable rnd : R → Z.
Context { valid_rnd : Valid_rnd rnd }.
Theorem round_repr_same_exp :
∀ m e,
∃ m',
round beta fexp rnd (F2R (Float beta m e)) = F2R (Float beta m' e).
End round_repr_same_exp.
Context { monotone_exp : Monotone_exp fexp }.
Notation format := (generic_format beta fexp).
Variable choice : Z → bool.
Lemma plus_error_aux :
∀ x y,
(canonic_exp beta fexp x ≤ canonic_exp beta fexp y)%Z →
format x → format y →
format (round beta fexp (Znearest choice) (x + y) - (x + y))%R.
Error of the addition
Theorem plus_error :
∀ x y,
format x → format y →
format (round beta fexp (Znearest choice) (x + y) - (x + y))%R.
End Fprop_plus_error.
Section Fprop_plus_zero.
Variable beta : radix.
Notation bpow e := (bpow beta e).
Variable fexp : Z → Z.
Context { valid_exp : Valid_exp fexp }.
Context { exp_not_FTZ : Exp_not_FTZ fexp }.
Notation format := (generic_format beta fexp).
Section round_plus_eq_zero_aux.
Variable rnd : R → Z.
Context { valid_rnd : Valid_rnd rnd }.
Lemma round_plus_eq_zero_aux :
∀ x y,
(canonic_exp beta fexp x ≤ canonic_exp beta fexp y)%Z →
format x → format y →
(0 ≤ x + y)%R →
round beta fexp rnd (x + y) = R0 →
(x + y = 0)%R.
End round_plus_eq_zero_aux.
Variable rnd : R → Z.
Context { valid_rnd : Valid_rnd rnd }.
∀ x y,
format x → format y →
format (round beta fexp (Znearest choice) (x + y) - (x + y))%R.
End Fprop_plus_error.
Section Fprop_plus_zero.
Variable beta : radix.
Notation bpow e := (bpow beta e).
Variable fexp : Z → Z.
Context { valid_exp : Valid_exp fexp }.
Context { exp_not_FTZ : Exp_not_FTZ fexp }.
Notation format := (generic_format beta fexp).
Section round_plus_eq_zero_aux.
Variable rnd : R → Z.
Context { valid_rnd : Valid_rnd rnd }.
Lemma round_plus_eq_zero_aux :
∀ x y,
(canonic_exp beta fexp x ≤ canonic_exp beta fexp y)%Z →
format x → format y →
(0 ≤ x + y)%R →
round beta fexp rnd (x + y) = R0 →
(x + y = 0)%R.
End round_plus_eq_zero_aux.
Variable rnd : R → Z.
Context { valid_rnd : Valid_rnd rnd }.
rnd(x+y)=0 -> x+y = 0 provided this is not a FTZ format
Theorem round_plus_eq_zero :
∀ x y,
format x → format y →
round beta fexp rnd (x + y) = R0 →
(x + y = 0)%R.
End Fprop_plus_zero.
Section Fprop_plus_FLT.
Variable beta : radix.
Notation bpow e := (bpow beta e).
Variable emin prec : Z.
Context { prec_gt_0_ : Prec_gt_0 prec }.
Theorem FLT_format_plus_small: ∀ x y,
generic_format beta (FLT_exp emin prec) x →
generic_format beta (FLT_exp emin prec) y →
(Rabs (x+y) ≤ bpow (prec+emin))%R →
generic_format beta (FLT_exp emin prec) (x+y).
End Fprop_plus_FLT.
∀ x y,
format x → format y →
round beta fexp rnd (x + y) = R0 →
(x + y = 0)%R.
End Fprop_plus_zero.
Section Fprop_plus_FLT.
Variable beta : radix.
Notation bpow e := (bpow beta e).
Variable emin prec : Z.
Context { prec_gt_0_ : Prec_gt_0 prec }.
Theorem FLT_format_plus_small: ∀ x y,
generic_format beta (FLT_exp emin prec) x →
generic_format beta (FLT_exp emin prec) y →
(Rabs (x+y) ≤ bpow (prec+emin))%R →
generic_format beta (FLT_exp emin prec) (x+y).
End Fprop_plus_FLT.