Fmin

# Library Fmin

`Require Export Zenum.
Require Export FPred.
Section FMinMax.
Variable b : Fbound.
Variable radix : Z.
Variable precision : nat.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ radixMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Hypothesis precisionNotZero : precision <> 0.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Definition boundNat (n : nat) := Float 1%nat (digit radix n).
Theorem boundNatCorrect : forall n : nat, (n < boundNat n)%R.
Theorem boundBoundNat : forall n : nat, Fbounded b (boundNat n).
Definition boundR (r : R) := boundNat (Zabs_nat (up (Rabs r))).
Theorem boundRCorrect1 : forall r : R, (r < boundR r)%R.
Theorem boundRrOpp : forall r : R, boundR r = boundR (- r).
Theorem boundRCorrect2 : forall r : R, (Fopp (boundR r) < r)%R.
Definition mBFloat (p : R) :=
map (fun p : Z * Z => Float (fst p) (snd p))
(mProd Z Z (Z * Z)
(mZlist (- pPred (vNum b)) (pPred (vNum b)))
(mZlist (- dExp b) (Fexp (boundR p)))).
Theorem mBFadic_correct1 :
forall (r : R) (q : float),
~ is_Fzero q ->
(Fopp (boundR r) < q)%R ->
(q < boundR r)%R -> Fbounded b q -> In q (mBFloat r).
Theorem mBFadic_correct2 : forall r : R, In (boundR r) (mBFloat r).
Theorem mBFadic_correct3 : forall r : R, In (Fopp (boundR r)) (mBFloat r).
Theorem mBFadic_correct4 :
forall r : R, In (Float 0%nat (- dExp b)) (mBFloat r).
Theorem mBPadic_Fbounded :
forall (p : float) (r : R), In p (mBFloat r) -> Fbounded b p.
Definition ProjectorP (P : R -> float -> Prop) :=
forall p q : float, Fbounded b p -> P p q -> p = q :>R.
Definition MonotoneP (P : R -> float -> Prop) :=
forall (p q : R) (p' q' : float),
(p < q)%R -> P p p' -> P q q' -> (p' <= q')%R.
Definition isMin (r : R) (min : float) :=
Fbounded b min /\
(min <= r)%R /\
(forall f : float, Fbounded b f -> (f <= r)%R -> (f <= min)%R).
Theorem isMin_inv1 : forall (p : float) (r : R), isMin r p -> (p <= r)%R.
Theorem ProjectMin : ProjectorP isMin.
Theorem MonotoneMin : MonotoneP isMin.
Definition isMax (r : R) (max : float) :=
Fbounded b max /\
(r <= max)%R /\
(forall f : float, Fbounded b f -> (r <= f)%R -> (max <= f)%R).
Theorem isMax_inv1 : forall (p : float) (r : R), isMax r p -> (r <= p)%R.
Theorem ProjectMax : ProjectorP isMax.
Theorem MonotoneMax : MonotoneP isMax.
Theorem MinEq :
forall (p q : float) (r : R), isMin r p -> isMin r q -> p = q :>R.
Theorem MaxEq :
forall (p q : float) (r : R), isMax r p -> isMax r q -> p = q :>R.
Theorem MinOppMax :
forall (p : float) (r : R), isMin r p -> isMax (- r) (Fopp p).
Theorem MaxOppMin :
forall (p : float) (r : R), isMax r p -> isMin (- r) (Fopp p).
Theorem MinMax :
forall (p : float) (r : R),
isMin r p -> r <> p :>R -> isMax r (FNSucc b radix precision p).
Theorem MinExList :
forall (r : R) (L : list float),
(forall f : float, In f L -> (r < f)%R) \/
(exists min : float,
In min L /\
(min <= r)%R /\ (forall f : float, In f L -> (f <= r)%R -> (f <= min)%R)).
Theorem MinEx : forall r : R, exists min : float, isMin r min.
Theorem MaxEx : forall r : R, exists max : float, isMax r max.
Theorem MinBinade :
forall (r : R) (p : float),
Fbounded b p ->
(p <= r)%R -> (r < FNSucc b radix precision p)%R -> isMin r p.
Theorem FminRep :
forall p q : float,
isMin p q -> exists m : Z, q = Float m (Fexp p) :>R.
Theorem MaxBinade :
forall (r : R) (p : float),
Fbounded b p ->
(r <= p)%R -> (FNPred b radix precision p < r)%R -> isMax r p.
Theorem MaxMin :
forall (p : float) (r : R),
isMax r p -> r <> p :>R -> isMin r (FNPred b radix precision p).
Theorem FmaxRep :
forall p q : float,
isMax p q -> exists m : Z, q = Float m (Fexp p) :>R.
End FMinMax.
Hint Resolve ProjectMax MonotoneMax MinOppMax MaxOppMin MinMax MinBinade
MaxBinade MaxMin: float.
`