Library EFast2Sum

Require Export Fast2Sum.

Section EFast.
Variable b : Fbound.
Variable precision : nat.

Let radix := 2%Z.

Let radixMoreThanOne : (1 < radix)%Z.

Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ radixMoreThanOne).
Hint Resolve radixMoreThanZERO radixMoreThanOne: zarith.

Coercion Local FtoRradix := FtoR radix.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Variable Iplus : float -> float -> float.
Hypothesis
  IplusCorrect :
    forall p q : float,
    Fbounded b p -> Fbounded b q -> Closest b radix (p + q) (Iplus p q).
Hypothesis
  IplusComp :
    forall p q r s : float,
    Fbounded b p ->
    Fbounded b q ->
    Fbounded b r ->
    Fbounded b s -> p = r :>R -> q = s :>R -> Iplus p q = Iplus r s :>R.
Hypothesis IplusSym : forall p q : float, Iplus p q = Iplus q p.
Hypothesis
  IplusOp : forall p q : float, Fopp (Iplus p q) = Iplus (Fopp p) (Fopp q).
Variable Iminus : float -> float -> float.
Hypothesis IminusPlus : forall p q : float, Iminus p q = Iplus p (Fopp q).

Theorem IminusComp :
 forall p q r s : float,
 Fbounded b p ->
 Fbounded b q ->
 Fbounded b r ->
 Fbounded b s -> p = r :>R -> q = s :>R -> Iminus p q = Iminus r s :>R.

Theorem EvenBound :
 forall (p : float) (m : Z),
 Even m ->
 (Zpred (Zpower_nat radix precision) <= m)%Z ->
 (m <= Zpower_nat radix (S precision) - radix)%Z ->
 Fbounded b p -> exists q : float, Fbounded b q /\ q = Float m (Fexp p) :>R.

Theorem ExtMDekker1 :
 forall p q : float,
 Fbounded b p ->
 Fbounded b q ->
 (Fexp q <= Fexp p)%Z ->
 (0 <= p)%R -> Iminus (Iplus p q) p = (Iplus p q - p)%R :>R.

Theorem ExtMDekker :
 forall p q : float,
 Fbounded b p ->
 Fbounded b q ->
 (Fexp q <= Fexp p)%Z -> Iminus (Iplus p q) p = (Iplus p q - p)%R :>R.

Theorem ExtDekker :
 forall p q : float,
 Fbounded b p ->
 Fbounded b q ->
 (Fexp q <= Fexp p)%Z ->
 Iminus q (Iminus (Iplus p q) p) = (p + q - Iplus p q)%R :>R.
End EFast.