Library Divnk

Require Export AllFloat.
Section Divnk.
Variables b1 b2 b3 : Fbound.
Variables n k : nat.
Variables x y z: float.

Let radix := 2%Z.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.

Hypotheses nGreaterThanOne : (lt (S O) n).
Hypotheses kGreaterThanOne : (lt (S O) k).
Hypotheses nGivesBound1 : (Zpos (vNum b1)) = (Zpower_nat radix n).
Hypotheses kGivesBound2 : (Zpos (vNum b2)) = (Zpower_nat radix k).
Hypotheses nkGivesBound3 : (Zpos (vNum b3)) = (Zpower_nat radix (plus n k)).

Hypotheses Normz : (Fnormal radix b1 z).
Hypotheses Normy : (Fnormal radix b2 y).
Hypotheses Normx : (Fnormal radix b3 x).

Hypotheses zNonZero: ~((FtoRradix z)=0)%R.
Hypotheses Roundy : (Closest b2 radix (Rdiv x z) y).

Theorem Divnk_error: (Rabs (x/z-y) <= (powerRZ radix (Zpred (Fexp y))))%R.

Theorem Normal_le: forall (b:Fbound) (u:float) (p:nat),
  (Zpos (vNum b)) = (Zpower_nat radix p) -> (Fnormal radix b u)->
  ((Rabs u) <= (((powerRZ radix p)-1)*(powerRZ radix (Fexp u))))%R.

Theorem Normal_ge: forall (b:Fbound) (u:float) (p:nat),
  (Zpos (vNum b)) = (Zpower_nat radix p) -> (Fnormal radix b u)->
  (Rle (powerRZ radix (Zplus (Zpred p) (Fexp u))) (Rabs u)).

Theorem Divnk_FexpyGe: (Zle (Zminus (Fexp x) (Fexp z)) (Fexp y)).

Theorem Divnk_FexpyLe: (Zle (Fexp y) (Zplus 2%Z (Zminus (Fexp x) (Fexp z)))).

Theorem Divnk_FexpyLe2: (Rle (powerRZ radix (Zplus (Zpred k) (Fexp y))) (Rabs (Rdiv x z)))
  -> (Zle (Fexp y) (Zplus 1%Z (Zminus (Fexp x) (Fexp z)))).

Theorem Rle_err_pow2: forall (b:Fbound) (p:nat) (r:R) (f:float),
  (lt (S O) p) -> (Zpos (vNum b)) = (Zpower_nat radix p) ->
  (Fnormal radix b f) -> ~((Fexp f) = (Zopp (dExp b))) ->
  ((FtoRradix f)=(powerRZ radix (Zplus (Zpred p) (Fexp f))))%R -> (Rlt r f) ->
  (Closest b radix r f) -> (Rle (Rabs (Rminus f r)) (powerRZ radix (Zpred (Zpred (Fexp f))))).

Theorem Divnk: ((Fexp y) <> (-(dExp b2)))%Z ->
  (Rlt (Zabs (Fnum (Fminus radix x (Fmult y z)))) (powerRZ radix n)).
End Divnk.