Library Fbound

Require Export Fop.
Section Fbounded_Def.
Variable radix : Z.
Hypothesis radixMoreThanOne : (1 < radix)%Z.

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

Coercion Local FtoRradix := FtoR radix.

Coercion Z_of_N: N >-> Z.

Record Fbound : Set := Bound {vNum : positive; dExp : N}.

Definition Fbounded (b : Fbound) (d : float) :=
  (Zabs (Fnum d) < Zpos (vNum b))%Z /\ (- dExp b <= Fexp d)%Z.

Theorem FboundedNum :
 forall (b : Fbound) (p : float),
 Fbounded b p -> (Zabs (Fnum p) < Zpos (vNum b))%Z.

Theorem FboundedExp :
 forall (b : Fbound) (p : float), Fbounded b p -> (- dExp b <= Fexp p)%Z.
Hint Resolve FboundedNum FboundedExp: float.

Theorem isBounded :
 forall (b : Fbound) (p : float), {Fbounded b p} + {~ Fbounded b p}.

Theorem FzeroisZero : forall b : Fbound, Fzero (- dExp b) = 0%R :>R.

Theorem FboundedFzero : forall b : Fbound, Fbounded b (Fzero (- dExp b)).
Hint Unfold Fbounded.

Theorem FboundedZeroSameExp :
 forall (b : Fbound) (p : float), Fbounded b p -> Fbounded b (Fzero (Fexp p)).

Theorem FBoundedScale :
 forall (b : Fbound) (p : float) (n : nat),
 Fbounded b p -> Fbounded b (Float (Fnum p) (Fexp p + n)).

Theorem FvalScale :
 forall (b : Fbound) (p : float) (n : nat),
 Float (Fnum p) (Fexp p + n) = (powerRZ radix n * p)%R :>R.

Theorem oppBounded :
 forall (b : Fbound) (x : float), Fbounded b x -> Fbounded b (Fopp x).

Theorem oppBoundedInv :
 forall (b : Fbound) (x : float), Fbounded b (Fopp x) -> Fbounded b x.

Theorem FopRepAux :
 forall (b : Fbound) (z : Z) (p : R),
 ex (fun r : float => r = (- p)%R :>R /\ Fbounded b r /\ Fexp r = z) ->
 ex (fun r : float => r = p :>R /\ Fbounded b r /\ Fexp r = z).

Theorem absFBounded :
 forall (b : Fbound) (f : float), Fbounded b f -> Fbounded b (Fabs f).

Theorem FboundedEqExpPos :
 forall (b : Fbound) (p q : float),
 Fbounded b p ->
 p = q :>R -> (Fexp p <= Fexp q)%R -> (0 <= q)%R -> Fbounded b q.

Theorem FboundedEqExp :
 forall (b : Fbound) (p q : float),
 Fbounded b p -> p = q :>R -> (Fexp p <= Fexp q)%R -> Fbounded b q.

Theorem eqExpLess :
 forall (b : Fbound) (p q : float),
 Fbounded b p ->
 p = q :>R ->
 exists r : float, Fbounded b r /\ r = q :>R /\ (Fexp q <= Fexp r)%R.

Theorem FboundedShiftLess :
 forall (b : Fbound) (f : float) (n m : nat),
 m <= n -> Fbounded b (Fshift radix n f) -> Fbounded b (Fshift radix m f).

Theorem eqExpMax :
 forall (b : Fbound) (p q : float),
 Fbounded b p ->
 Fbounded b q ->
 (Fabs p <= q)%R ->
 exists r : float, Fbounded b r /\ r = p :>R /\ (Fexp r <= Fexp q)%Z.

Theorem Zle_monotony_contra_abs_pow :
 forall x y z n : Z,
 (0 < z)%Z ->
 (Rabs (x * powerRZ z n) <= Rabs (y * powerRZ z n))%R -> (Zabs x <= Zabs y)%Z.

Theorem LessExpBound :
 forall (b : Fbound) (p q : float),
 Fbounded b p ->
 Fbounded b q ->
 (Fexp q <= Fexp p)%Z ->
 (0 <= p)%R ->
 (p <= q)%R ->
 exists m : Z,
   Float m (Fexp q) = p :>R /\ Fbounded b (Float m (Fexp q)).

Theorem maxFbounded :
 forall (b : Fbound) (z : Z),
 (- dExp b <= z)%Z -> Fbounded b (Float (Zpred (Zpos (vNum b))) z).

Theorem maxMax :
 forall (b : Fbound) (p : float) (z : Z),
 Fbounded b p ->
 (Fexp p <= z)%Z -> (Fabs p < Float (Zpos (vNum b)) z)%R.
End Fbounded_Def.
Hint Resolve FboundedFzero oppBounded absFBounded maxFbounded FboundedNum
  FboundedExp: float.