Library ThreeSum2
Require Export AllFloat.
Section F2.
Variable b : Fbound.
Variable precision : nat.
Let radix := 2%Z.
Coercion Local FtoRradix := FtoR radix.
Let TMTO : (1 < radix)%Z := TwoMoreThanOne.
Hint Resolve TMTO: zarith.
Hypothesis precisionNotZero : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Variables p q r u v w p' q' r' : float.
Hypothesis Fp : Fbounded b p.
Hypothesis Fq : Fbounded b q.
Hypothesis Fr : Fbounded b r.
Hypothesis Fu : Fbounded b u.
Hypothesis Fv : Fbounded b v.
Hypothesis Fw : Fbounded b w.
Hypothesis Fp' : Fbounded b p'.
Hypothesis Fq' : Fbounded b q'.
Hypothesis Fr' : Fbounded b r'.
Hypothesis epq : (Fexp q <= Fexp p)%Z.
Hypothesis eqr : (Fexp r <= Fexp q)%Z.
Hypothesis uDef : Closest b radix (q + r) u.
Hypothesis vDef : v = (q + r - u)%R :>R.
Hypothesis p'Def : Closest b radix (p + u) p'.
Hypothesis wDef : w = (p + u - p')%R :>R.
Hypothesis q'Def : Closest b radix (w + v) q'.
Hypothesis r'Def : r' = (w + v - q')%R :>R.
Theorem TwoSumNul :
forall f g x : float,
Closest b radix (f + g) x ->
x = 0%R :>R -> Fbounded b f -> Fbounded b g -> (f + g - x)%R = 0%R.
Theorem bound3Sum :
r' <> 0%R :>R ->
(Rabs (q' + r') < 3%nat * radix * / pPred (vNum b) * Rabs p')%R.
Theorem exp3Sum :
exists p'' : float,
(exists q'' : float,
(exists r'' : float,
(Fbounded b p'' /\ Fbounded b q'' /\ Fbounded b r'') /\
(p'' = p' :>R /\ q'' = q' :>R /\ r'' = r' :>R) /\
(Fexp r <= Fexp r'')%Z /\
((Fexp r'' <= Fexp q'')%Z /\ (Fexp q'' <= Fexp p'')%Z) /\
Fexp r'' = Fexp r)).
Theorem OutSum3 :
r' <> 0%R :>R ->
(Float 1%nat (Fexp r) <
3%nat *
(radix *
(radix * (Rabs p' * / (pPred (vNum b) * (radix * pPred (vNum b) - radix))))))%R.
Theorem TwoSumNonNul :
forall p q r pq : float,
Fbounded b p ->
Fbounded b q ->
Closest b radix (p + q) pq ->
r = (p + q - pq)%R :>R -> r <> 0%R :>R -> pq <> 0%R :>R.
Theorem TwoSumOneNul :
forall p q pq : float,
Fbounded b p ->
Fbounded b q ->
Fbounded b pq -> Closest b radix (p + q) pq -> p = 0%R :>R -> pq = q :>R.
Theorem TwoSumOneNul2 :
forall p q pq r : float,
Fbounded b p ->
Fbounded b q ->
Fbounded b pq ->
Closest b radix (p + q) pq ->
p = 0%R :>R -> r = (p + q - pq)%R :>R -> r = 0%R :>R.
End F2.