discriminant2

# Library discriminant2

``
This proof file has been written by Sylvie Boldo(1), following a proof presented by Pr William Kahan (2), and adapted to Coq proof checker with the help of Guillaume Melquiond(1) and Marc Daumas(1). This work has been partially supported by the CNRS grant PICS 2533.
(1) LIP Computer science laboratory UMR 5668 CNRS - ENS de Lyon - INRIA Lyon, France
(2) University of California at Berkeley Berkeley, California
`
Require Export AllFloat.
Section Discriminant1.
Variable bo : Fbound.
Variable precision : nat.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Theorem TwoMoreThanOne : (1 < radix)%Z.
Hint Resolve TwoMoreThanOne.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ TwoMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix precision.
Variables a b b' c p q d:float.
Let delta := (Rabs (d-(b*b'-a*c)))%R.
Hypothesis Fa : (Fbounded bo a).
Hypothesis Fb : (Fbounded bo b).
Hypothesis Fb': (Fbounded bo b').
Hypothesis Fc : (Fbounded bo c).
Hypothesis Fp : (Fbounded bo p).
Hypothesis Fq : (Fbounded bo q).
Hypothesis Fd : (Fbounded bo d).
`
There is no underflow
`Hypothesis U1:(- dExp bo <= Fexp d - 1)%Z.
Hypothesis Nd:(Fnormal radix bo d).
Hypothesis Nq:(Fnormal radix bo q).
Hypothesis Np:(Fnormal radix bo p).
Hypothesis Square:(0 <=b*b')%R.
Hypothesis Roundp : (EvenClosest bo radix precision (b*b')%R p).
Hypothesis Roundq : (EvenClosest bo radix precision (a*c)%R q).
Hypothesis Firstcase : (p+q <= 3*(Rabs (p-q)))%R.
Hypothesis Roundd : (EvenClosest bo radix precision (p-q)%R d).
Theorem delta_inf: (delta <= (/2)*(Fulp bo radix precision d)+
((/2)*(Fulp bo radix precision p)+(/2)*(Fulp bo radix precision q)))%R.
Theorem P_positive: (Rle 0 p)%R.
Theorem Fulp_le_twice_l: forall x y:float, (0 <= x)%R ->
(Fnormal radix bo x) -> (Fbounded bo y) -> (2*x<=y)%R ->
(2*(Fulp bo radix precision x) <= (Fulp bo radix precision y))%R.
Theorem Fulp_le_twice_r: forall x y:float, (0 <= x)%R ->
(Fnormal radix bo y) -> (Fbounded bo x) -> (x<=2*y)%R ->
((Fulp bo radix precision x) <= 2*(Fulp bo radix precision y))%R.
Theorem Half_Closest_Round: forall (x:float) (r:R),
(- dExp bo <= Zpred (Fexp x))%Z -> (Closest bo radix r x)
-> (Closest bo radix (r/2)%R (Float (Fnum x) (Zpred (Fexp x)))).
Theorem Twice_EvenClosest_Round: forall (x:float) (r:R),
(-(dExp bo) <= (Fexp x)-1)%Z -> (Fnormal radix bo x)
-> (EvenClosest bo radix precision r x)
-> (EvenClosest bo radix precision (2*r)%R (Float (Fnum x) (Zsucc (Fexp x)))).
Theorem EvenClosestMonotone2: forall (p q : R) (p' q' : float),
(p <= q)%R -> (EvenClosest bo radix precision p p') ->
(EvenClosest bo radix precision q q') -> (p' <= q')%R.
Theorem Fulp_le_twice_r_round: forall (x y:float) (r:R), (0 <= x)%R ->
(Fbounded bo x) -> (Fnormal radix bo y) -> (- dExp bo <= Fexp y - 1)%Z
-> (x<=2*r)%R ->
(EvenClosest bo radix precision r y) ->
((Fulp bo radix precision x) <= 2*(Fulp bo radix precision y))%R.
Theorem discri1: (delta <= 2*(Fulp bo radix precision d))%R.
End Discriminant1.
Section Discriminant2.
Variable bo : Fbound.
Variable precision : nat.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ TwoMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix precision.
Variables a b b' c p q t dp dq s d:float.
Let delta := (Rabs (d-(b*b'-a*c)))%R.
Hypothesis Fa : (Fbounded bo a).
Hypothesis Fb : (Fbounded bo b).
Hypothesis Fb': (Fbounded bo b').
Hypothesis Fc : (Fbounded bo c).
Hypothesis Fp : (Fbounded bo p).
Hypothesis Fq : (Fbounded bo q).
Hypothesis Fd : (Fbounded bo d).
Hypothesis Ft : (Fbounded bo t).
Hypothesis Fs : (Fbounded bo s).
Hypothesis Fdp: (Fbounded bo dp).
Hypothesis Fdq: (Fbounded bo dq).
Hypothesis Cs:(Fcanonic radix bo s).
`
There is no underflow
`Hypothesis U1: (- dExp bo <= (Fexp t)-1)%Z.
Hypothesis U2: (powerRZ radix (-dExp bo+2*precision-1) <= Rabs (b*b'))%R.
Hypothesis U3: (powerRZ radix (-dExp bo+2*precision-1) <= Rabs (a*c))%R.
Hypothesis Np:(Fnormal radix bo p).
Hypothesis Nq:(Fnormal radix bo q).
Hypothesis Nd:(Fnormal radix bo d).
Hypothesis Square:(0 <=b*b')%R.
Hypothesis Roundp : (EvenClosest bo radix precision (b*b')%R p).
Hypothesis Roundq : (EvenClosest bo radix precision (a*c)%R q).
Hypothesis Secondcase : (3*(Rabs (p-q)) < p+q)%R.
Hypothesis Roundt : (EvenClosest bo radix precision (p-q)%R t).
Hypothesis dpEq : (FtoRradix dp=b*b'-p)%R.
Hypothesis dqEq : (FtoRradix dq=a*c-q)%R.
Hypothesis Rounds : (EvenClosest bo radix precision (dp-dq)%R s).
Hypothesis Roundd : (EvenClosest bo radix precision (t+s)%R d).
Hypothesis p_differ_q:~(p=q)%R.
Theorem Q_positive:(0 < q)%R.
Theorem Q_le_two_P:(q <= 2*p)%R.
Theorem P_le_two_Q:(p <= 2*q)%R.
Theorem t_exact: (FtoRradix t=p-q)%R.
Theorem dp_dq_le:(Rabs (dp-dq) <= (3/2)*(Rmin
(Fulp bo radix precision p) (Fulp bo radix precision q)))%R.
Theorem EvenClosestFabs :
forall (f : float) (r : R), (Fcanonic radix bo f)
-> EvenClosest bo radix precision r f ->
EvenClosest bo radix precision (Rabs r) (Fabs f).
Theorem discri2: (3*(Rmin (Fulp bo radix precision p) (Fulp bo radix precision q))
<= (Rabs (p-q)))%R -> (delta <= 2*(Fulp bo radix precision d))%R.
Theorem discri3: (exists f:float, (Fbounded bo f) /\ (FtoRradix f)=(dp-dq)%R)
-> (delta <= 2*(Fulp bo radix precision d))%R.
Theorem errorBoundedMultClosest_Can:
forall f1 f2 g : float,
Fbounded bo f1 ->
Fbounded bo f2 ->
Closest bo radix (f1* f2) g ->
(powerRZ radix (-dExp bo+2*precision-1) <= Rabs (f1*f2))%R ->
Fcanonic radix bo g ->
(exists s : float,
Fbounded bo s /\
(FtoRradix s = f1*f2 - g)%R /\
Fexp s = (Fexp g - precision)%Z /\
(Rabs (Fnum s) <= powerRZ radix (Zpred precision))%R).
Theorem discri4: (Fexp p)=(Fexp q) -> (delta <= 2*(Fulp bo radix precision d))%R.
End Discriminant2.
Section Discriminant3.
Variable bo : Fbound.
Variable precision : nat.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ TwoMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix precision.
Variables a b b' c p q t dp dq s d:float.
Let delta := (Rabs (d-(b*b'-a*c)))%R.
Hypothesis Fa : (Fbounded bo a).
Hypothesis Fb : (Fbounded bo b).
Hypothesis Fb': (Fbounded bo b').
Hypothesis Fc : (Fbounded bo c).
Hypothesis Fp : (Fbounded bo p).
Hypothesis Fq : (Fbounded bo q).
Hypothesis Fd : (Fbounded bo d).
Hypothesis Ft : (Fbounded bo t).
Hypothesis Fs : (Fbounded bo s).
Hypothesis Fdp: (Fbounded bo dp).
Hypothesis Fdq: (Fbounded bo dq).
Hypothesis Cs:(Fcanonic radix bo s).
`
There is no underflow
`Hypothesis U1: (- dExp bo <= (Fexp d)-1)%Z.
Hypothesis U2: (powerRZ radix (-dExp bo+2*precision-1) <= Rabs (b*b'))%R.
Hypothesis U3: (powerRZ radix (-dExp bo+2*precision-1) <= Rabs (a*c))%R.
Hypothesis Np:(Fnormal radix bo p).
Hypothesis Nq:(Fnormal radix bo q).
Hypothesis Nd:(Fnormal radix bo d).
Hypothesis Square:(0 <=b*b')%R.
Hypothesis Roundp : (EvenClosest bo radix precision (b*b')%R p).
Hypothesis Roundq : (EvenClosest bo radix precision (a*c)%R q).
Hypothesis p_pos:(0 <= p)%R.
Hypothesis q_pos:(0 <= q)%R.
Hypothesis Secondcase : (3*(Rabs (p-q)) < p+q)%R.
Hypothesis Roundt : (EvenClosest bo radix precision (p-q)%R t).
Hypothesis dpEq : (FtoRradix dp=b*b'-p)%R.
Hypothesis dqEq : (FtoRradix dq=a*c-q)%R.
Hypothesis Rounds : (EvenClosest bo radix precision (dp-dq)%R s).
Hypothesis Roundd : (EvenClosest bo radix precision (t+s)%R d).
Hypothesis p_differ_q:~(p=q)%R.
Variable e:Z.
Hypothesis p_eqF : p=(Float (Zpower_nat radix (pred precision)) (Zsucc e)).
Hypothesis p_eqR : (FtoRradix p)=(powerRZ radix (precision+e)%Z).
Hypothesis q_eqExp : (Fexp q)=e.
Theorem discri5: (0 < dp*dq)%R -> (delta <= 2*(Fulp bo radix precision d))%R.
Theorem discri6: (0< dp)%R -> (dq < 0)%R
-> (delta <= 2*(Fulp bo radix precision d))%R.
Theorem discri7: (dp < 0)%R -> (0 < dq)%R
-> (delta <= 2*(Fulp bo radix precision d))%R.
Theorem discri8: (delta <= 2*(Fulp bo radix precision d))%R.
End Discriminant3.
Section Discriminant4.
Variable bo : Fbound.
Variable precision : nat.
Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ TwoMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum bo) = Zpower_nat radix precision.
Variables a b c p q t dp dq s d:float.
Let delta := (Rabs (d-(b*b-a*c)))%R.
Hypothesis Fa : (Fbounded bo a).
Hypothesis Fb : (Fbounded bo b).
Hypothesis Fc : (Fbounded bo c).
Hypothesis Fp : (Fbounded bo p).
Hypothesis Fq : (Fbounded bo q).
Hypothesis Fd : (Fbounded bo d).
Hypothesis Ft : (Fbounded bo t).
Hypothesis Fs : (3*(Rabs (p-q)) < p+q)%R -> (Fbounded bo s).
Hypothesis Fdp: (3*(Rabs (p-q)) < p+q)%R -> (Fbounded bo dp).
Hypothesis Fdq: (3*(Rabs (p-q)) < p+q)%R -> (Fbounded bo dq).
Hypothesis Cs:(3*(Rabs (p-q)) < p+q)%R -> (Fcanonic radix bo s).
`
There is no underflow
`Hypothesis U0: (- dExp bo <= (Fexp d)-1)%Z.
Hypothesis U1: (- dExp bo <= (Fexp t)-1)%Z.
Hypothesis U2: (powerRZ radix (-dExp bo+2*precision-1) <= Rabs (b*b))%R.
Hypothesis U3: (powerRZ radix (-dExp bo+2*precision-1) <= Rabs (a*c))%R.
Hypothesis Np:(Fnormal radix bo p).
Hypothesis Nq:(Fnormal radix bo q).
Hypothesis Nd:(Fnormal radix bo d).
Hypothesis Roundp : (EvenClosest bo radix precision (b*b)%R p).
Hypothesis Roundq : (EvenClosest bo radix precision (a*c)%R q).
Hypothesis Firstcase : (p+q <= 3*(Rabs (p-q)))%R ->
(EvenClosest bo radix precision (p-q)%R d).
Hypothesis SRoundt : (3*(Rabs (p-q)) < p+q)%R -> (EvenClosest bo radix precision (p-q)%R t).
Hypothesis SdpEq : (3*(Rabs (p-q)) < p+q)%R -> (FtoRradix dp=b*b-p)%R.
Hypothesis SdqEq : (3*(Rabs (p-q)) < p+q)%R -> (FtoRradix dq=a*c-q)%R.
Hypothesis SRounds : (3*(Rabs (p-q)) < p+q)%R -> (EvenClosest bo radix precision (dp-dq)%R s).
Hypothesis SRoundd : (3*(Rabs (p-q)) < p+q)%R -> (EvenClosest bo radix precision (t+s)%R d).
Theorem discri9: (delta <= 2*(Fulp bo radix precision d))%R.
End Discriminant4.
`