DblRndOdd

# Library DblRndOdd

`Require Export AllFloat.
Section plouf.
Variable bound : Fbound.
Variable radix : Z.
Variable precision : nat.
Coercion Local FtoRradix := FtoR radix.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Hypothesis precisionMoreThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum bound) = Zpower_nat radix precision.
Lemma radixNotZero: (0 < radix)%Z.
Lemma precisionNotZero : ~(precision = (0)).
Lemma ClosestInfPredExp :
forall f : float, forall x : R,
Closest bound radix x f ->
Fnum f = nNormMin radix precision ->
(Fexp f <> -dExp bound)%Z ->
(2%nat*f - powerRZ radix (Fexp f - 1) <= 2%nat*x)%R.
End plouf.
Section RndOdd.
Variable b : Fbound.
Variable radix : Z.
Variable precision : nat.
Coercion Local FtoRradix := FtoR radix.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Definition To_Odd (r : R) (p : float) :=
Fbounded b p /\
((r=p) \/
(((isMin b radix r p) \/ (isMax b radix r p)) /\ (FNodd b radix precision p))).
Theorem To_OddTotal : TotalP To_Odd.
Theorem To_OddCompatible : CompatibleP b radix To_Odd.
Theorem To_OddMinOrMax : MinOrMaxP b radix To_Odd.
Theorem To_OddMonotone : MonotoneP radix To_Odd.
Theorem To_OddRoundedModeP : RoundedModeP b radix To_Odd.
Theorem To_OddUniqueP : UniqueP radix To_Odd.
Theorem To_OddSymmetricP : SymmetricP To_Odd.
End RndOdd.
Section DblRndOddAux.
Variables b be : Fbound.
Variables p k : nat.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Hypotheses pGreaterThanOne : (lt (S O) p).
Hypotheses kGreaterThanOne : (lt (S O) k).
Hypotheses pGivesBound : (Zpos (vNum b)) = (Zpower_nat radix p).
Hypotheses pkGivesBounde : (Zpos (vNum be)) = (Zpower_nat radix (plus p k)).
Theorem ClosestStrictPred: forall (f:float) (z:R),
(Fcanonic radix b f) -> (0 < f)%R ->
(-Fulp b radix p (FNPred b radix p f) < 2%nat *(z - f) < Fulp b radix p f)%R
-> Closest b radix z f /\
(forall q : float, Closest b radix z q -> FtoR radix q = FtoR radix f).
Theorem ClosestStrictPos: forall (f:float) (z:R),
(Fcanonic radix b f) -> (0 < f)%R -> Fnum f <> nNormMin radix p
-> (2%nat * Rabs (z - f) < Fulp b radix p f)%R
-> Closest b radix z f /\
(forall q : float, Closest b radix z q -> FtoR radix q = FtoR radix f).
Theorem ClosestStrict: forall (f:float) (z0:R),
(Fcanonic radix b f) -> Zabs (Fnum f) <> nNormMin radix p
-> (2%nat * Rabs (z0 - f) < Fulp b radix p f)%R
-> Closest b radix z0 f /\
(forall q : float, Closest b radix z0 q -> FtoR radix q = FtoR radix f).
Theorem EvenNormalize:forall (f:float), (Fbounded be f)
-> (Even (Fnum f)) -> (FNeven be radix (p+k) f).
Variables y z v: float.
Variables x : R.
Hypotheses By : (Fbounded be y).
Hypotheses Bz : (Fbounded b z).
Hypotheses Bv : (Fbounded b v).
Hypotheses Cv : (Fcanonic radix b v).
Hypotheses ydef : (To_Odd be radix (plus p k) x y).
Hypotheses zdef : (EvenClosest b radix p y z).
Hypotheses vdef : (EvenClosest b radix p x v).
Hypotheses rangeext: (-(dExp be) <= (Zpred (Zpred (-(dExp b)))))%Z.
Hypotheses H:(Fnum v=(nNormMin radix p))%Z.
Hypotheses H':(x<>y)%R.
Hypotheses H1: (0 <= v)%R.
Theorem To_Odd_Even_is_Even_nNormMin: EvenClosest b radix p y v.
End DblRndOddAux.
Section DblRndOdd.
Variables b be : Fbound.
Variables p k : nat.
Variables y z v: float.
Variables x : R.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Hypotheses pGreaterThanOne : (lt (S O) p).
Hypotheses kGreaterThanOne : (lt (S O) k).
Hypotheses pGivesBound : (Zpos (vNum b)) = (Zpower_nat radix p).
Hypotheses pkGivesBounde : (Zpos (vNum be)) = (Zpower_nat radix (plus p k)).
Hypotheses By : (Fbounded be y).
Hypotheses Bz : (Fbounded b z).
Hypotheses Bv : (Fbounded b v).
Hypotheses Cv : (Fcanonic radix b v).
Hypotheses ydef : (To_Odd be radix (plus p k) x y).
Hypotheses zdef : (EvenClosest b radix p y z).
Hypotheses vdef : (EvenClosest b radix p x v).
Hypotheses rangeext: (-(dExp be) <= (Zpred (Zpred (-(dExp b)))))%Z.
Theorem To_Odd_Even_is_Even: ((FtoRradix v)=(FtoRradix z))%R.
End DblRndOdd.
`