Commit b28441ba authored by Heiko Becker's avatar Heiko Becker
Browse files

Prove IEEE connection in Coq

parent afdfc31e
...@@ -86,3 +86,19 @@ Fixpoint liveVars V (f:cmd V) :NatSet.t := ...@@ -86,3 +86,19 @@ Fixpoint liveVars V (f:cmd V) :NatSet.t :=
| Let _ _ e g => NatSet.union (usedVars e) (liveVars g) | Let _ _ e g => NatSet.union (usedVars e) (liveVars g)
| Ret e => usedVars e | Ret e => usedVars e
end. end.
Lemma bstep_eq_env f:
forall E1 E2 Gamma v m,
(forall x, E1 x = E2 x) ->
bstep f E1 Gamma v m ->
bstep f E2 Gamma v m.
Proof.
induction f; intros * eq_envs bstep_E1;
inversion bstep_E1; subst; simpl in *.
- eapply eval_eq_env in H7; eauto. eapply let_b; eauto.
eapply IHf. instantiate (1:=(updEnv n v0 E1)).
+ intros; unfold updEnv.
destruct (x=? n); auto.
+ auto.
- apply ret_b. eapply eval_eq_env; eauto.
Qed.
\ No newline at end of file
...@@ -432,6 +432,19 @@ Proof. ...@@ -432,6 +432,19 @@ Proof.
econstructor; try auto. econstructor; try auto.
Qed. Qed.
Lemma eval_eq_env e:
forall E1 E2 Gamma v m,
(forall x, E1 x = E2 x) ->
eval_exp E1 Gamma e v m ->
eval_exp E2 Gamma e v m.
Proof.
induction e; intros;
(match_pat (eval_exp _ _ _ _ _) (fun H => inversion H; subst; simpl in *));
try eauto.
eapply Var_load; auto.
rewrite <- (H n); auto.
Qed.
(* (*
(** (**
Analogous lemma for unary expressions. Analogous lemma for unary expressions.
......
This diff is collapsed.
...@@ -146,17 +146,17 @@ Definition join (m1:mType) (m2:mType) := ...@@ -146,17 +146,17 @@ Definition join (m1:mType) (m2:mType) :=
(* destruct m1, m2; simpl in *; cbv in *; try congruence; try auto. *) (* destruct m1, m2; simpl in *; cbv in *; try congruence; try auto. *)
(* Qed. *) (* Qed. *)
Definition maxExponent (m:mType) :Z := Definition maxExponent (m:mType) :positive :=
match m with match m with
| M0 => 0 | M0 => 1
| M16 => 15 | M16 => 15
| M32 => 127 | M32 => 127
| M64 => 1023 | M64 => 1023
end. end.
Definition minExponentPos (m:mType) :Z := Definition minExponentPos (m:mType) :positive :=
match m with match m with
| M0 => 0 | M0 => 1
| M16 => 14 | M16 => 14
| M32 => 126 | M32 => 126
| M64 => 1022 | M64 => 1022
...@@ -169,16 +169,16 @@ Goldberg - Handbook of Floating-Point Arithmetic: (p.183) ...@@ -169,16 +169,16 @@ Goldberg - Handbook of Floating-Point Arithmetic: (p.183)
which simplifies to 2^(e_max) for base 2 which simplifies to 2^(e_max) for base 2
**) **)
Definition maxValue (m:mType) := Definition maxValue (m:mType) :=
Qpower (2#1) (maxExponent m). (Z.pow_pos 2 (maxExponent m)) # 1.
Definition minValue (m:mType) := Definition minValue (m:mType) :=
Qinv (Qpower (2#1) (minExponentPos m)). Qinv ((Z.pow_pos 2 (minExponentPos m)) # 1).
(** Goldberg - Handbook of Floating-Point Arithmetic: (p.183) (** Goldberg - Handbook of Floating-Point Arithmetic: (p.183)
𝛃^(e_min -p + 1) = 𝛃^(e_min -1) for base 2 𝛃^(e_min -p + 1) = 𝛃^(e_min -1) for base 2
**) **)
Definition minDenormalValue (m:mType) := Definition minDenormalValue (m:mType) :=
Qinv (Qpower (2#1) (minExponentPos m - 1)). Qinv (Z.pow_pos 2 (minExponentPos m - 1) # 1).
Definition normal (v:Q) (m:mType) := Definition normal (v:Q) (m:mType) :=
Qle_bool (minValue m) (Qabs v) && Qle_bool (Qabs v) (maxValue m). Qle_bool (minValue m) (Qabs v) && Qle_bool (Qabs v) (maxValue m).
...@@ -190,7 +190,7 @@ Definition Normal (v:R) (m:mType) := ...@@ -190,7 +190,7 @@ Definition Normal (v:R) (m:mType) :=
(Q2R (minValue m) <= (Rabs v) /\ (Rabs v) <= Q2R (maxValue m))%R. (Q2R (minValue m) <= (Rabs v) /\ (Rabs v) <= Q2R (maxValue m))%R.
Definition Denormal (v:R) (m:mType) := Definition Denormal (v:R) (m:mType) :=
((Rabs v) <= Q2R (minValue m) /\ ~ (v = 0))%R. ((Rabs v) < Q2R (minValue m) /\ ~ (v = 0))%R.
(** (**
Predicate that is true if and only if the given value v is a valid Predicate that is true if and only if the given value v is a valid
floating-point value according to the the type m. floating-point value according to the the type m.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment