Axpy

# Library Axpy

`Require Export MinOrMax.
Section AxpyMisc.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Variable b : Fbound.
Variable precision : nat.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Theorem TwoMoreThanOne : (1 < radix)%Z.
Hint Resolve TwoMoreThanOne.
Theorem TwoMoreThanOneR : (1 < radix)%R.
Hint Resolve TwoMoreThanOneR.
Theorem FulpLeGeneral :
forall p : float,
Fbounded b p ->
(Fulp b radix precision p <=
Rabs (FtoRradix p) * powerRZ radix (Zsucc (- precision)) +
powerRZ radix (- dExp b))%R.
Theorem RoundLeGeneral :
forall (p : float) (z : R),
Fbounded b p ->
Closest b radix z p ->
(Rabs p <=
Rabs z * / (1 - powerRZ radix (- precision)) +
powerRZ radix (Zpred (- dExp b)) * / (1 - powerRZ radix (- precision)))%R.
Theorem RoundGeGeneral :
forall (p : float) (z : R),
Fbounded b p ->
Closest b radix z p ->
(Rabs z * / (1 + powerRZ radix (- precision)) -
powerRZ radix (Zpred (- dExp b)) * / (1 + powerRZ radix (- precision)) <=
Rabs p)%R.
Theorem ExactSum_Near :
forall p q f : float,
Fbounded b p ->
Fbounded b q ->
Fbounded b f ->
Closest b radix (p + q) f ->
Fexp p = (- dExp b)%Z ->
(Rabs (p + q - f) < powerRZ radix (- dExp b))%R -> (p + q)%R = f.
End AxpyMisc.
Section AxpyAux.
Add Field RField : Rfield (completeness Zeq_bool_complete).
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Variable b : Fbound.
Variable precision : nat.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Variables a1 x1 y1 : R.
Variables a x y t u r : float.
Hypothesis Fa : Fbounded b a.
Hypothesis Fx : Fbounded b x.
Hypothesis Fy : Fbounded b y.
Hypothesis Ft : Fbounded b t.
Hypothesis Fu : Fbounded b u.
Hypothesis tDef : Closest b radix (a * x) t.
Hypothesis uDef : Closest b radix (t + y) u.
Hypothesis rDef : isMin b radix (a1 * x1 + y1) r.
Theorem Axpy_aux1 :
Fcanonic radix b u ->
(Rabs (FtoRradix a * FtoRradix x - FtoRradix t) <=
/ 4%nat * Fulp b radix precision (FPred b radix precision u))%R ->
(0 < u)%R ->
(4%nat * Rabs t <= Rabs u)%R ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <
/ 4%nat * Fulp b radix precision (FPred b radix precision u))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
Theorem Axpy_aux1_aux1 :
Fnormal radix b t ->
Fcanonic radix b u ->
(0 < u)%R ->
(4%nat * Rabs t <= Rabs u)%R ->
(Rabs (FtoRradix a * FtoRradix x - FtoRradix t) <=
/ 4%nat * Fulp b radix precision (FPred b radix precision u))%R.
Theorem Axpy_aux2 :
Fcanonic radix b u ->
Fsubnormal radix b t ->
(0 < u)%R ->
FtoRradix u = (t + y)%R ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <
/ 4%nat * Fulp b radix precision (FPred b radix precision u))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
Theorem Axpy_aux1_aux2 :
Fsubnormal radix b t ->
Fcanonic radix b u ->
(0 < u)%R ->
(Zsucc (- dExp b) <= Fexp (FPred b radix precision u))%Z ->
(Rabs (FtoRradix a * FtoRradix x - FtoRradix t) <=
/ 4%nat * Fulp b radix precision (FPred b radix precision u))%R.
Theorem Axpy_aux1_aux3 :
Fsubnormal radix b t ->
Fcanonic radix b u ->
(0 < u)%R ->
(Zsucc (- dExp b) <= Fexp (FPred b radix precision u))%Z ->
(Rabs (FtoRradix a * FtoRradix x - FtoRradix t) <=
/ 4%nat * Fulp b radix precision (FPred b radix precision u))%R.
Theorem Axpy_aux3 :
Fcanonic radix b u ->
Fsubnormal radix b t ->
(0 < u)%R ->
Fexp (FPred b radix precision u) = (- dExp b)%Z ->
(Zsucc (- dExp b) <= Fexp u)%Z ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <
/ 4%nat * Fulp b radix precision (FPred b radix precision u))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
Theorem AxpyPos :
Fcanonic radix b u ->
Fcanonic radix b t ->
(0 < u)%R ->
(4%nat * Rabs t <= Rabs u)%R ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <
/ 4%nat * Fulp b radix precision (FPred b radix precision u))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
Definition FLess (p : float) :=
match Rcase_abs p with
| left _ => FSucc b radix precision p
| right _ => FPred b radix precision p
end.
Theorem UlpFlessuGe_aux :
forall p : float,
Fbounded b p ->
Fcanonic radix b p ->
(Rabs p - Fulp b radix precision p <= Rabs (FLess p))%R.
Theorem UlpFlessuGe :
Fcanonic radix b u ->
(/
(4%nat * (powerRZ radix precision - 1) * (1 + powerRZ radix (- precision))) *
((1 - powerRZ radix (Zsucc (- precision))) * Rabs y) +
-
(/
(4%nat * (powerRZ radix precision - 1) * (1 + powerRZ radix (- precision)) *
(1 - powerRZ radix (- precision))) *
((1 - powerRZ radix (Zsucc (- precision))) * Rabs (a * x))) +
-
(powerRZ radix (Zpred (- dExp b)) *
(/ (2%nat * (powerRZ radix precision - 1)) +
/
(4%nat * (powerRZ radix precision - 1) *
(1 + powerRZ radix (- precision)) * (1 - powerRZ radix (- precision))) *
(1 - powerRZ radix (Zsucc (- precision))))) <=
/ 4%nat * Fulp b radix precision (FLess u))%R.
Theorem UlpFlessuGe2 :
Fcanonic radix b u ->
(powerRZ radix (Zpred (Zpred (- precision))) *
(1 - powerRZ radix (Zsucc (- precision))) * Rabs y +
- (powerRZ radix (Zpred (Zpred (- precision))) * Rabs (a * x)) +
- powerRZ radix (Zpred (Zpred (- dExp b))) <
/ 4%nat * Fulp b radix precision (FLess u))%R.
End AxpyAux.
Section Axpy.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Variable b : Fbound.
Variable precision : nat.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Theorem Axpy_tFlessu :
forall (a1 x1 y1 : R) (a x y t u : float),
Fbounded b a ->
Fbounded b x ->
Fbounded b y ->
Fbounded b t ->
Fbounded b u ->
Closest b radix (a * x) t ->
Closest b radix (t + y) u ->
Fcanonic radix b u ->
Fcanonic radix b t ->
(4%nat * Rabs t <= Rabs u)%R ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <
/ 4%nat * Fulp b radix precision (FLess b precision u))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
Theorem Axpy_opt :
forall (a1 x1 y1 : R) (a x y t u : float),
(Fbounded b a) -> (Fbounded b x) -> (Fbounded b y) ->
(Fbounded b t) -> (Fbounded b u) ->
(Closest b radix (a * x) t) ->
(Closest b radix (t + y) u) ->
(Fcanonic radix b u) -> (Fcanonic radix b t) ->
((5%nat + 4%nat * (powerRZ radix (- precision))) *
/ (1 - powerRZ radix (- precision)) *
(Rabs (a * x) + (powerRZ radix (Zpred (- dExp b))))
<= Rabs y)%R ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <=
(powerRZ radix (Zpred (Zpred (- precision)))) *
(1 - powerRZ radix (Zsucc (- precision))) * Rabs y +
- (powerRZ radix (Zpred (Zpred (- precision))) * Rabs (a * x)) +
- powerRZ radix (Zpred (Zpred (- dExp b))))%R ->
(MinOrMax radix b (a1 * x1 + y1) u).
Theorem Axpy_Simpl1 :
forall (a1 x1 y1 : R) (a x y t u : float),
4 <= precision ->
Fbounded b a ->
Fbounded b x ->
Fbounded b y ->
Fbounded b t ->
Fbounded b u ->
Closest b radix (a * x) t ->
Closest b radix (t + y) u ->
Fcanonic radix b u ->
Fcanonic radix b t ->
(6%nat * (Rabs (a * x) + powerRZ radix (Zpred (- dExp b))) <= Rabs y)%R ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <=
powerRZ radix (Zpred (Zpred (- precision))) *
(1 - powerRZ radix (Zsucc (- precision))) * Rabs y +
- (powerRZ radix (Zpred (Zpred (- precision))) * Rabs (a * x)) +
- powerRZ radix (Zpred (Zpred (- dExp b))))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
Theorem Axpy_Simpl1bis :
forall (a1 x1 y1 : R) (a x y t u : float),
4 <= precision ->
Fbounded b a ->
Fbounded b x ->
Fbounded b y ->
Fbounded b t ->
Fbounded b u ->
Closest b radix (a * x) t ->
Closest b radix (t + y) u ->
Fcanonic radix b u ->
Fcanonic radix b t ->
(6%nat * (Rabs (a * x) + powerRZ radix (Zpred (- dExp b))) <= Rabs y)%R ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <=
powerRZ radix (Zpred (Zpred (- precision))) *
(5%nat * / 6%nat - powerRZ radix (Zsucc (- precision))) *
Rabs y + - powerRZ radix (Zpred (Zpred (- dExp b))))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
Theorem Axpy_Simpl2 :
forall (a1 x1 y1 : R) (a x y t u : float),
4 <= precision ->
Fbounded b a ->
Fbounded b x ->
Fbounded b y ->
Fbounded b t ->
Fbounded b u ->
Closest b radix (a * x) t ->
Closest b radix (t + y) u ->
Fcanonic radix b u ->
Fcanonic radix b t ->
(6%nat * (Rabs (a * x) + powerRZ radix (Zpred (- dExp b))) <= Rabs y)%R ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <=
powerRZ radix (Zpred (Zpred (- precision))) * (2%nat * / 3%nat) * Rabs y +
- powerRZ radix (Zpred (Zpred (- dExp b))))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
End Axpy.
Section AxpyFmac.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Variable b : Fbound.
Variable precision : nat.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Theorem AxpyPos_Fmac :
forall (a1 x1 y1 : R) (a x y u : float),
Fbounded b a ->
Fbounded b x ->
Fbounded b y ->
Fbounded b u ->
Closest b radix (a * x + y) u ->
Fcanonic radix b u ->
(0 < u)%R ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <
/ 2%nat * Fulp b radix precision (FPred b radix precision u))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
Theorem AxpyFLessu_Fmac :
forall (a1 x1 y1 : R) (a x y u : float),
Fbounded b a ->
Fbounded b x ->
Fbounded b y ->
Fbounded b u ->
Closest b radix (a * x + y) u ->
Fcanonic radix b u ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <
/ 2%nat * Fulp b radix precision (FLess b precision u))%R ->
MinOrMax radix b (a1 * x1 + y1) u.
Theorem Axpy_opt_Fmac :
forall (a1 x1 y1 : R) (a x y u : float),
(Fbounded b a) -> (Fbounded b x) -> (Fbounded b y) -> (Fbounded b u) ->
(Closest b radix (a * x + y) u) ->
(Fcanonic radix b u) ->
(Rabs (y1 - y) + Rabs (a1 * x1 - a * x) <
(Rabs (a * x + y)) * (powerRZ radix (Zpred (- precision)) *
(1 - powerRZ radix (Zsucc (- precision)))) -
powerRZ radix (Zpred (Zpred (- dExp b))) *
(3 * / (powerRZ radix precision - powerRZ radix (- precision))))%R ->
(MinOrMax radix b (a1 * x1 + y1) u).
End AxpyFmac.
`