Fnorm

# Library Fnorm

`Require Export Fbound.
Section Fnormalized_Def.
Variable radix : Z.
Hypothesis radixMoreThanOne : (1 < radix)%Z.
Let radixMoreThanZERO := Zlt_1_O _ (Zlt_le_weak _ _ radixMoreThanOne).
Hint Resolve radixMoreThanZERO: zarith.
Let FtoRradix := FtoR radix.
Coercion FtoRradix : float >-> R.
Variable b : Fbound.
Definition Fnormal (p : float) :=
Fbounded b p /\ (Zpos (vNum b) <= Zabs (radix * Fnum p))%Z.
Theorem FnormalBounded : forall p : float, Fnormal p -> Fbounded b p.
Theorem FnormalBound :
forall p : float,
Fnormal p -> (Zpos (vNum b) <= Zabs (radix * Fnum p))%Z.
Hint Resolve FnormalBounded FnormalBound: float.
Theorem FnormalNotZero : forall p : float, Fnormal p -> ~ is_Fzero p.
Theorem FnormalFop : forall p : float, Fnormal p -> Fnormal (Fopp p).
Theorem FnormalFabs : forall p : float, Fnormal p -> Fnormal (Fabs p).
Definition pPred x := Zpred (Zpos x).
Theorem maxMax1 :
forall (p : float) (z : Z),
Fbounded b p -> (Fexp p <= z)%Z -> (Fabs p <= Float (pPred (vNum b)) z)%R.
Theorem FnormalBoundAbs :
forall p : float,
Fnormal p -> (Float (pPred (vNum b)) (Zpred (Fexp p)) < Fabs p)%R.
Definition Fsubnormal (p : float) :=
Fbounded b p /\
Fexp p = (- dExp b)%Z /\ (Zabs (radix * Fnum p) < Zpos (vNum b))%Z.
Theorem FsubnormalFbounded : forall p : float, Fsubnormal p -> Fbounded b p.
Theorem FsubnormalFexp :
forall p : float, Fsubnormal p -> Fexp p = (- dExp b)%Z.
Theorem FsubnormalBound :
forall p : float,
Fsubnormal p -> (Zabs (radix * Fnum p) < Zpos (vNum b))%Z.
Hint Resolve FsubnormalFbounded FsubnormalBound FsubnormalFexp: float.
Theorem FsubnormFopp : forall p : float, Fsubnormal p -> Fsubnormal (Fopp p).
Theorem FsubnormFabs : forall p : float, Fsubnormal p -> Fsubnormal (Fabs p).
Theorem FsubnormalUnique :
forall p q : float, Fsubnormal p -> Fsubnormal q -> p = q :>R -> p = q.
Theorem FsubnormalLt :
forall p q : float,
Fsubnormal p -> Fsubnormal q -> (p < q)%R -> (Fnum p < Fnum q)%Z.
Theorem LtFsubnormal :
forall p q : float,
Fsubnormal p -> Fsubnormal q -> (Fnum p < Fnum q)%Z -> (p < q)%R.
Definition Fcanonic (a : float) := Fnormal a \/ Fsubnormal a.
Theorem FcanonicBound : forall p : float, Fcanonic p -> Fbounded b p.
Hint Resolve FcanonicBound: float.
Theorem pUCanonic_absolu :
forall p : float, Fcanonic p -> (Zabs (Fnum p) < Zpos (vNum b))%Z.
Theorem FcanonicFopp : forall p : float, Fcanonic p -> Fcanonic (Fopp p).
Theorem FcanonicFabs : forall p : float, Fcanonic p -> Fcanonic (Fabs p).
Theorem NormalNotSubNormal : forall p : float, ~ (Fnormal p /\ Fsubnormal p).
Theorem MaxFloat :
forall x : float,
Fbounded b x -> (Rabs x < Float (Zpos (vNum b)) (Fexp x))%R.
Variable precision : nat.
Hypothesis precisionNotZero : precision <> 0.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Theorem FboundNext :
forall p : float,
Fbounded b p ->
exists q : float, Fbounded b q /\ q = Float (Zsucc (Fnum p)) (Fexp p) :>R.
Theorem digitPredVNumiSPrecision :
digit radix (Zpred (Zpos (vNum b))) = precision.
Theorem digitVNumiSPrecision :
digit radix (Zpos (vNum b)) = S precision.
Theorem vNumPrecision :
forall n : Z,
digit radix n <= precision -> (Zabs n < Zpos (vNum b))%Z.
Theorem pGivesDigit :
forall p : float, Fbounded b p -> Fdigit radix p <= precision.
Theorem digitGivesBoundedNum :
forall p : float,
Fdigit radix p <= precision -> (Zabs (Fnum p) < Zpos (vNum b))%Z.
Theorem FboundedOne :
forall z : Z, (- dExp b <= z)%Z -> Fbounded b (Float 1%nat z).
Theorem FboundedMboundPos :
forall z m : Z,
(0 <= m)%Z ->
(m <= Zpower_nat radix precision)%Z ->
(- dExp b <= z)%Z ->
exists c : float, Fbounded b c /\ c = (m * powerRZ radix z)%R :>R.
Theorem FboundedMbound :
forall z m : Z,
(Zabs m <= Zpower_nat radix precision)%Z ->
(- dExp b <= z)%Z ->
exists c : float, Fbounded b c /\ c = (m * powerRZ radix z)%R :>R.
Theorem FnormalPrecision :
forall p : float, Fnormal p -> Fdigit radix p = precision.
Hint Resolve FnormalPrecision: float.
Theorem FnormalUnique :
forall p q : float, Fnormal p -> Fnormal q -> p = q :>R -> p = q.
Theorem FnormalLtPos :
forall p q : float,
Fnormal p ->
Fnormal q ->
(0 <= p)%R ->
(p < q)%R -> (Fexp p < Fexp q)%Z \/ Fexp p = Fexp q /\ (Fnum p < Fnum q)%Z.
Theorem FnormalLtNeg :
forall p q : float,
Fnormal p ->
Fnormal q ->
(q <= 0)%R ->
(p < q)%R -> (Fexp q < Fexp p)%Z \/ Fexp p = Fexp q /\ (Fnum p < Fnum q)%Z.
Definition nNormMin := Zpower_nat radix (pred precision).
Theorem nNormPos : (0 < nNormMin)%Z.
Theorem digitnNormMin : digit radix nNormMin = precision.
Theorem nNrMMimLevNum : (nNormMin <= Zpos (vNum b))%Z.
Hint Resolve nNrMMimLevNum: arith.
Definition firstNormalPos := Float nNormMin (- dExp b).
Theorem firstNormalPosNormal : Fnormal firstNormalPos.
Theorem pNormal_absolu_min :
forall p : float, Fnormal p -> (nNormMin <= Zabs (Fnum p))%Z.
Theorem maxMaxBis :
forall (p : float) (z : Z),
Fbounded b p -> (Fexp p < z)%Z -> (Fabs p < Float nNormMin z)%R.
Theorem FnormalLtFirstNormalPos :
forall p : float, Fnormal p -> (0 <= p)%R -> (firstNormalPos <= p)%R.
Theorem FnormalLtFirstNormalNeg :
forall p : float, Fnormal p -> (p <= 0)%R -> (p <= Fopp firstNormalPos)%R.
Theorem FsubnormalDigit :
forall p : float, Fsubnormal p -> Fdigit radix p < precision.
Hint Resolve FsubnormalDigit: float.
Theorem pSubnormal_absolu_min :
forall p : float, Fsubnormal p -> (Zabs (Fnum p) < nNormMin)%Z.
Theorem FsubnormalLtFirstNormalPos :
forall p : float, Fsubnormal p -> (0 <= p)%R -> (p < firstNormalPos)%R.
Theorem FsubnormalnormalLtPos :
forall p q : float,
Fsubnormal p -> Fnormal q -> (0 <= p)%R -> (0 <= q)%R -> (p < q)%R.
Theorem FsubnormalnormalLtNeg :
forall p q : float,
Fsubnormal p -> Fnormal q -> (p <= 0)%R -> (q <= 0)%R -> (q < p)%R.
Definition Fnormalize (p : float) :=
match Z_zerop (Fnum p) with
| left _ => Float 0 (- dExp b)
| right _ =>
Fshift radix
(min (precision - Fdigit radix p) (Zabs_nat (dExp b + Fexp p))) p
end.
Theorem FnormalizeCorrect : forall p : float, Fnormalize p = p :>R.
Theorem Fnormalize_Fopp :
forall p : float, Fnormalize (Fopp p) = Fopp (Fnormalize p).
Theorem FnormalizeBounded :
forall p : float, Fbounded b p -> Fbounded b (Fnormalize p).
Theorem FnormalizeCanonic :
forall p : float, Fbounded b p -> Fcanonic (Fnormalize p).
Theorem NormalAndSubNormalNotEq :
forall p q : float, Fnormal p -> Fsubnormal q -> p <> q :>R.
Theorem FcanonicUnique :
forall p q : float, Fcanonic p -> Fcanonic q -> p = q :>R -> p = q.
Theorem FcanonicLeastExp :
forall x y : float,
x = y :>R -> Fbounded b x -> Fcanonic y -> (Fexp y <= Fexp x)%Z.
Theorem FcanonicLtPos :
forall p q : float,
Fcanonic p ->
Fcanonic q ->
(0 <= p)%R ->
(p < q)%R -> (Fexp p < Fexp q)%Z \/ Fexp p = Fexp q /\ (Fnum p < Fnum q)%Z.
Theorem FcanonicLePos :
forall p q : float,
Fcanonic p ->
Fcanonic q ->
(0 <= p)%R ->
(p <= q)%R -> (Fexp p < Fexp q)%Z \/ Fexp p = Fexp q /\ (Fnum p <= Fnum q)%Z.
Theorem Fcanonic_Rle_Zle :
forall x y : float,
Fcanonic x -> Fcanonic y -> (Rabs x <= Rabs y)%R -> (Fexp x <= Fexp y)%Z.
Theorem FcanonicLtNeg :
forall p q : float,
Fcanonic p ->
Fcanonic q ->
(q <= 0)%R ->
(p < q)%R -> (Fexp q < Fexp p)%Z \/ Fexp p = Fexp q /\ (Fnum p < Fnum q)%Z.
Theorem FcanonicFnormalizeEq :
forall p : float, Fcanonic p -> Fnormalize p = p.
Theorem FcanonicPosFexpRlt :
forall x y : float,
(0 <= x)%R ->
(0 <= y)%R -> Fcanonic x -> Fcanonic y -> (Fexp x < Fexp y)%Z -> (x < y)%R.
Theorem FcanonicNegFexpRlt :
forall x y : float,
(x <= 0)%R ->
(y <= 0)%R -> Fcanonic x -> Fcanonic y -> (Fexp x < Fexp y)%Z -> (y < x)%R.
Theorem FnormalBoundAbs2 :
forall p : float,
Fnormal p ->
(Zpos (vNum b) * Float 1%nat (Zpred (Fexp p)) <= Fabs p)%R.
Theorem vNumbMoreThanOne : (1 < Zpos (vNum b))%Z.
Theorem PosNormMin : Zpos (vNum b) = (radix * nNormMin)%Z.
Theorem FnormalPpred :
forall x : Z, (- dExp b <= x)%Z -> Fnormal (Float (pPred (vNum b)) x).
Theorem FcanonicPpred :
forall x : Z,
(- dExp b <= x)%Z -> Fcanonic (Float (pPred (vNum b)) x).
Theorem FnormalNnormMin :
forall x : Z, (- dExp b <= x)%Z -> Fnormal (Float nNormMin x).
Theorem FcanonicNnormMin :
forall x : Z, (- dExp b <= x)%Z -> Fcanonic (Float nNormMin x).
Theorem boundedNorMinGivesExp :
forall (x : Z) (p : float),
Fbounded b p ->
(- dExp b <= x)%Z ->
(Float nNormMin x <= p)%R ->
(p <= Float (pPred (vNum b)) x)%R -> Fexp (Fnormalize p) = x.
End Fnormalized_Def.
Hint Resolve FnormalBounded FnormalPrecision: float.
Hint Resolve FnormalNotZero nNrMMimLevNum firstNormalPosNormal FsubnormFopp
FsubnormalLtFirstNormalPos FnormalizeBounded FcanonicFopp FcanonicFabs
FnormalizeCanonic: float.
Hint Resolve nNrMMimLevNum: arith.
Hint Resolve FsubnormalFbounded FsubnormalFexp FsubnormalDigit: float.
Hint Resolve FcanonicBound: float.
`