Fop

# Library Fop

`Require Export Fcomp.
Section operations.
Variable radix : Z.
Coercion Local FtoRradix := FtoR radix.
Hypothesis radixNotZero : (0 < radix)%Z.
Definition Fplus (x y : float) :=
Float
(Fnum x * Zpower_nat radix (Zabs_nat (Fexp x - Zmin (Fexp x) (Fexp y))) +
Fnum y * Zpower_nat radix (Zabs_nat (Fexp y - Zmin (Fexp x) (Fexp y))))
(Zmin (Fexp x) (Fexp y)).
Theorem Fplus_correct : forall x y : float, Fplus x y = (x + y)%R :>R.
Definition Fopp (x : float) := Float (- Fnum x) (Fexp x).
Theorem Fopp_correct : forall x : float, Fopp x = (- x)%R :>R.
Theorem Fopp_Fopp : forall p : float, Fopp (Fopp p) = p.
Theorem Fzero_opp : forall f : float, ~ is_Fzero f -> ~ is_Fzero (Fopp f).
Theorem Fdigit_opp : forall x : float, Fdigit radix (Fopp x) = Fdigit radix x.
Definition Fabs (x : float) := Float (Zabs (Fnum x)) (Fexp x).
Theorem Fabs_correct1 :
forall x : float, (0 <= FtoR radix x)%R -> Fabs x = x :>R.
Theorem Fabs_correct2 :
forall x : float, (FtoR radix x <= 0)%R -> Fabs x = (- x)%R :>R.
Theorem Fabs_correct : forall x : float, Fabs x = Rabs x :>R.
Theorem RleFexpFabs :
forall p : float, p <> 0%R :>R -> (Float 1%nat (Fexp p) <= Fabs p)%R.
Theorem Fabs_Fzero : forall x : float, ~ is_Fzero x -> ~ is_Fzero (Fabs x).
Hint Resolve Fabs_Fzero: float.
Theorem Fdigit_abs : forall x : float, Fdigit radix (Fabs x) = Fdigit radix x.
Definition Fminus (x y : float) := Fplus x (Fopp y).
Theorem Fminus_correct : forall x y : float, Fminus x y = (x - y)%R :>R.
Theorem Fopp_Fminus : forall p q : float, Fopp (Fminus p q) = Fminus q p.
Theorem Fopp_Fminus_dist :
forall p q : float, Fopp (Fminus p q) = Fminus (Fopp p) (Fopp q).
Theorem minusSameExp :
forall x y : float,
Fexp x = Fexp y -> Fminus x y = Float (Fnum x - Fnum y) (Fexp x).
Definition Fmult (x y : float) := Float (Fnum x * Fnum y) (Fexp x + Fexp y).
Definition Fmult_correct : forall x y : float, Fmult x y = (x * y)%R :>R.
Theorem oneZplus :
forall x y : Z,
Float 1%nat (x + y) = Fmult (Float 1%nat x) (Float 1%nat y).
End operations.
Hint Resolve Fabs_Fzero: float.
Hint Resolve Fzero_opp: float.
`