FexpPlus

# Library FexpPlus

`Require Export Fexp.
Section mf.
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.
Variable b : Fbound.
Variable precision : nat.
Hypothesis precisionGreaterThanOne : 1 < precision.
Hypothesis pGivesBound : Zpos (vNum b) = Zpower_nat radix precision.
Variable TwoSum : float -> float -> float * float.
Hypothesis
TwoSum1 :
forall p q : float,
Fbounded b p ->
Fbounded b q -> Closest b radix (p + q) (fst (TwoSum p q)).
Hypothesis
TwoSum2 :
forall p q : float,
Fbounded b p ->
Fbounded b q -> snd (TwoSum p q) = (p + q - fst (TwoSum p q))%R :>R.
Hypothesis
TwoSum3 :
forall p q : float,
Fbounded b p -> Fbounded b q -> Fbounded b (fst (TwoSum p q)).
Hypothesis
TwoSum4 :
forall p q : float,
Fbounded b p -> Fbounded b q -> Fbounded b (snd (TwoSum p q)).
Hypothesis
TwoSumEq1 :
forall p q r s : float,
Fbounded b p ->
Fbounded b q ->
Fbounded b r ->
Fbounded b s ->
p = q :>R -> r = s :>R -> fst (TwoSum p r) = fst (TwoSum q s) :>R.
Hypothesis
TwoSumEq2 :
forall p q r s : float,
Fbounded b p ->
Fbounded b q ->
Fbounded b r ->
Fbounded b s ->
p = q :>R -> r = s :>R -> snd (TwoSum p r) = snd (TwoSum q s) :>R.
Fixpoint growExp (p : float) (L : list float) {struct L} :
list float :=
match L with
| nil => p :: nil
| x :: L1 => match TwoSum p x with
| (h, c) => c :: growExp h L1
end
end.
Theorem TwoSumExp :
forall p q : float,
Fbounded b p ->
Fbounded b q ->
IsExpansion b radix (snd (TwoSum p q) :: fst (TwoSum p q) :: nil).
Theorem TwoSumOl1 :
forall p q : float,
Fbounded b p -> Fbounded b q -> is_Fzero q -> fst (TwoSum p q) = p :>R.
Theorem TwoSumOl2 :
forall p q : float,
Fbounded b p -> Fbounded b q -> is_Fzero q -> snd (TwoSum p q) = 0%R :>R.
Theorem TwoSumOr1 :
forall p q : float,
Fbounded b p -> Fbounded b q -> is_Fzero p -> fst (TwoSum p q) = q :>R.
Theorem TwoSumOr2 :
forall p q : float,
Fbounded b p -> Fbounded b q -> is_Fzero p -> snd (TwoSum p q) = 0%R :>R.
Theorem growExpIsVal :
forall L : list float,
IsExpansion b radix L ->
forall p : float,
Fbounded b p -> expValue radix (growExp p L) = (p + expValue radix L)%R :>R.
Theorem IsExpansionCons :
forall L : list float,
IsExpansion b radix L ->
forall p : float,
~ is_Fzero p ->
Fbounded b p ->
(forall q : float, In q L -> ~ is_Fzero q -> (MSB radix p < LSB radix q)%Z) ->
IsExpansion b radix (p :: L).
Theorem IsExpansionConsInvAux :
forall L : list float,
IsExpansion b radix L ->
forall (L' : list float) (p q : float),
~ is_Fzero p ->
L = p :: L' -> In q L' -> ~ is_Fzero q -> (MSB radix p < LSB radix q)%Z.
Theorem IsExpansionConsInv :
forall (L : list float) (p q : float),
~ is_Fzero p ->
IsExpansion b radix (p :: L) ->
In q L -> ~ is_Fzero q -> (MSB radix p < LSB radix q)%Z.
Theorem IsExpansionSkip :
forall (L : list float) (p q : float),
IsExpansion b radix (p :: q :: L) -> IsExpansion b radix (p :: L).
Theorem TwoSumLt1 :
forall p q : float,
Fbounded b p ->
Fbounded b q ->
~ is_Fzero p ->
~ is_Fzero q ->
~ is_Fzero (fst (TwoSum p q)) ->
(Zmin (LSB radix p) (LSB radix q) <= LSB radix (fst (TwoSum p q)))%Z.
Theorem TwoSumLt2 :
forall p q : float,
Fbounded b p ->
Fbounded b q ->
~ is_Fzero p ->
~ is_Fzero q ->
~ is_Fzero (snd (TwoSum p q)) ->
(Zmin (LSB radix p) (LSB radix q) <= LSB radix (snd (TwoSum p q)))%Z.
Theorem IsExpansionGrowConsInvAux :
forall L : list float,
IsExpansion b radix L ->
forall (L' : list float) (p q r : float),
Fbounded b r ->
~ is_Fzero p ->
L = p :: L' ->
In q (growExp r L') ->
~ is_Fzero q ->
(is_Fzero r -> (MSB radix p < LSB radix q)%Z) /\
(~ is_Fzero r ->
(MSB radix p < LSB radix q)%Z \/ (LSB radix r <= LSB radix q)%Z).
Theorem growExpIsExp :
forall L : list float,
IsExpansion b radix L ->
forall p : float, Fbounded b p -> IsExpansion b radix (growExp p L).
Fixpoint addExp (L1 L2 : list float) {struct L1} :
list float :=
match L1 with
| nil => L2
| x :: L'1 =>
match growExp x L2 with
| nil => L'1
| y :: L'2 => y :: addExp L'1 L'2
end
end.
Theorem addExpIsVal :
forall L1 L2 : list float,
IsExpansion b radix L1 ->
IsExpansion b radix L2 ->
expValue radix (addExp L1 L2) = (expValue radix L1 + expValue radix L2)%R
:>R.
Theorem IsExpansionAddInv :
forall (L1 L2 : list float) (p q : float),
~ is_Fzero p ->
~ is_Fzero q ->
IsExpansion b radix (p :: L1) ->
IsExpansion b radix (p :: L2) ->
In q (addExp L1 L2) -> (MSB radix p < LSB radix q)%Z.
Theorem addExpIsExp :
forall L1 L2 : list float,
IsExpansion b radix L1 ->
IsExpansion b radix L2 -> IsExpansion b radix (addExp L1 L2).
End mf.
`