Commit 43ce2820 authored by Raphaël Monat's avatar Raphaël Monat

Proofs done until validErrorbound_sound included

parent bd0ba831
......@@ -58,29 +58,28 @@ Lemma add_abs_err_bounded (e1:exp Q) (e1R:R) (e1F:R) (e2:exp Q) (e2R:R) (e2F:R)
Proof.
intros e1_real e1_float e2_real e2_float plus_real plus_float bound_e1 bound_e2.
(* Prove that e1R and e2R are the correct values and that vR is e1R + e2R *)
inversion plus_real; subst;
assert (m3 = M0) by (apply (ifM0isJoin_l M0 m3 m4); auto);
assert (m4 = M0) by (apply (ifM0isJoin_r M0 m3 m4); auto); subst;
simpl (meps M0) in H3; rewrite Q2R0_is_0 in H3; auto.
inversion plus_real; subst.
destruct m0; destruct m3; inversion H2;
simpl in H4; rewrite Q2R0_is_0 in H4; auto.
rewrite delta_0_deterministic in plus_real; auto.
rewrite (delta_0_deterministic (evalBinop Plus v1 v2) delta); auto.
unfold evalBinop in *; simpl in *.
clear delta H3.
rewrite (meps_0_deterministic (toRExp e1) H6 e1_real);
rewrite (meps_0_deterministic (toRExp e2) H7 e2_real).
rewrite (meps_0_deterministic (toRExp e1) H6 e1_real) in plus_real.
rewrite (meps_0_deterministic (toRExp e2) H7 e2_real) in plus_real.
clear H6 H7 v1 v2.
clear delta H4.
rewrite (meps_0_deterministic (toRExp e1) H5 e1_real);
rewrite (meps_0_deterministic (toRExp e2) H6 e2_real).
rewrite (meps_0_deterministic (toRExp e1) H5 e1_real) in plus_real.
rewrite (meps_0_deterministic (toRExp e2) H6 e2_real) in plus_real.
clear H5 H6 v1 v2.
(* Now unfold the float valued evaluation to get the deltas we need for the inequality *)
inversion plus_float; subst.
unfold perturb; simpl.
inversion H7; subst; inversion H8; subst.
inversion H6; subst; inversion H7; subst.
unfold updEnv; simpl.
unfold updEnv in H6,H9; simpl in *.
symmetry in H6,H9.
inversion H6; inversion H9; subst.
unfold updEnv in H5,H8; simpl in *.
symmetry in H5,H8.
inversion H5; inversion H8; subst.
(* We have now obtained all necessary values from the evaluations --> remove them for readability *)
clear plus_float H7 H8 plus_real e1_real e1_float e2_real e2_float H9 H6.
clear plus_float H7 H8 plus_real e1_real e1_float e2_real e2_float H5 H8.
repeat rewrite Rmult_plus_distr_l.
rewrite Rmult_1_r.
rewrite Rsub_eq_Ropp_Rplus.
......@@ -103,7 +102,7 @@ Proof.
eapply Rle_trans.
eapply Rmult_le_compat_l.
apply Rabs_pos.
apply H4.
apply H3.
apply Req_le; auto.
Qed.
......@@ -125,28 +124,27 @@ Proof.
intros e1_real e1_float e2_real e2_float sub_real sub_float bound_e1 bound_e2.
(* Prove that e1R and e2R are the correct values and that vR is e1R + e2R *)
inversion sub_real; subst;
assert (m3 = M0) by (apply (ifM0isJoin_l M0 m3 m4); auto);
assert (m4 = M0) by (apply (ifM0isJoin_r M0 m3 m4); auto); subst;
simpl (meps M0) in H3; rewrite Q2R0_is_0 in H3; auto.
destruct m0; destruct m3; inversion H2;
simpl in H4; rewrite Q2R0_is_0 in H4; auto.
rewrite delta_0_deterministic in sub_real; auto.
rewrite delta_0_deterministic; auto.
unfold evalBinop in *; simpl in *.
clear delta H3.
rewrite (meps_0_deterministic (toRExp e1) H6 e1_real);
rewrite (meps_0_deterministic (toRExp e2) H7 e2_real).
rewrite (meps_0_deterministic (toRExp e1) H6 e1_real) in sub_real.
rewrite (meps_0_deterministic (toRExp e2) H7 e2_real) in sub_real.
clear H6 H7 v1 v2.
clear delta H4.
rewrite (meps_0_deterministic (toRExp e1) H5 e1_real);
rewrite (meps_0_deterministic (toRExp e2) H6 e2_real).
rewrite (meps_0_deterministic (toRExp e1) H5 e1_real) in sub_real.
rewrite (meps_0_deterministic (toRExp e2) H6 e2_real) in sub_real.
clear H5 H6 v1 v2.
(* Now unfold the float valued evaluation to get the deltas we need for the inequality *)
inversion sub_float; subst.
unfold perturb; simpl.
inversion H7; subst; inversion H8; subst.
inversion H6; subst; inversion H7; subst.
unfold updEnv; simpl.
symmetry in H6, H9.
unfold updEnv in H6, H9; simpl in H6, H9.
inversion H6; inversion H9; subst.
symmetry in H5, H8.
unfold updEnv in H5, H8; simpl in H5, H8.
inversion H5; inversion H8; subst.
(* We have now obtained all necessary values from the evaluations --> remove them for readability *)
clear sub_float H7 H8 sub_real e1_real e1_float e2_real e2_float H6 H9.
clear sub_float H7 H8 sub_real e1_real e1_float e2_real e2_float H5 H8.
repeat rewrite Rmult_plus_distr_l.
rewrite Rmult_1_r.
repeat rewrite Rsub_eq_Ropp_Rplus.
......@@ -182,27 +180,26 @@ Proof.
intros e1_real e1_float e2_real e2_float mult_real mult_float.
(* Prove that e1R and e2R are the correct values and that vR is e1R * e2R *)
inversion mult_real; subst;
assert (m3 = M0) by (apply (ifM0isJoin_l M0 m3 m4); auto);
assert (m4 = M0) by (apply (ifM0isJoin_r M0 m3 m4); auto); subst;
simpl (meps M0) in H3; rewrite Q2R0_is_0 in H3; auto.
destruct m0; destruct m3; inversion H2;
simpl in H4; rewrite Q2R0_is_0 in H4; auto.
rewrite delta_0_deterministic in mult_real; auto.
rewrite delta_0_deterministic; auto.
unfold evalBinop in *; simpl in *.
clear delta H3.
rewrite (meps_0_deterministic (toRExp e1) H6 e1_real);
rewrite (meps_0_deterministic (toRExp e2) H7 e2_real).
rewrite (meps_0_deterministic (toRExp e1) H6 e1_real) in mult_real.
rewrite (meps_0_deterministic (toRExp e2) H7 e2_real) in mult_real.
clear H6 H7 v1 v2.
clear delta H4.
rewrite (meps_0_deterministic (toRExp e1) H5 e1_real);
rewrite (meps_0_deterministic (toRExp e2) H6 e2_real).
rewrite (meps_0_deterministic (toRExp e1) H5 e1_real) in mult_real.
rewrite (meps_0_deterministic (toRExp e2) H6 e2_real) in mult_real.
clear H5 H6 v1 v2.
(* Now unfold the float valued evaluation to get the deltas we need for the inequality *)
inversion mult_float; subst.
unfold perturb; simpl.
inversion H7; subst; inversion H8; subst.
symmetry in H6, H9;
inversion H6; subst; inversion H7; subst.
symmetry in H5, H8;
unfold updEnv in *; simpl in *.
inversion H6; inversion H9; subst.
inversion H5; inversion H8; subst.
(* We have now obtained all necessary values from the evaluations --> remove them for readability *)
clear mult_float H7 H8 mult_real e1_real e1_float e2_real e2_float H6 H9.
clear mult_float H7 H8 mult_real e1_real e1_float e2_real e2_float H5 H8.
repeat rewrite Rmult_plus_distr_l.
rewrite Rmult_1_r.
rewrite Rsub_eq_Ropp_Rplus.
......@@ -232,27 +229,26 @@ Proof.
intros e1_real e1_float e2_real e2_float div_real div_float.
(* Prove that e1R and e2R are the correct values and that vR is e1R * e2R *)
inversion div_real; subst;
assert (m3 = M0) by (apply (ifM0isJoin_l M0 m3 m4); auto);
assert (m4 = M0) by (apply (ifM0isJoin_r M0 m3 m4); auto); subst;
simpl (meps M0) in H3; rewrite Q2R0_is_0 in H3; auto.
destruct m0; destruct m3; inversion H2;
simpl in H4; rewrite Q2R0_is_0 in H4; auto.
rewrite delta_0_deterministic in div_real; auto.
rewrite delta_0_deterministic; auto.
unfold evalBinop in *; simpl in *.
clear delta H3.
rewrite (meps_0_deterministic (toRExp e1) H6 e1_real);
rewrite (meps_0_deterministic (toRExp e2) H7 e2_real).
rewrite (meps_0_deterministic (toRExp e1) H6 e1_real) in div_real.
rewrite (meps_0_deterministic (toRExp e2) H7 e2_real) in div_real.
clear H6 H7 v1 v2.
clear delta H4.
rewrite (meps_0_deterministic (toRExp e1) H5 e1_real);
rewrite (meps_0_deterministic (toRExp e2) H6 e2_real).
rewrite (meps_0_deterministic (toRExp e1) H5 e1_real) in div_real.
rewrite (meps_0_deterministic (toRExp e2) H6 e2_real) in div_real.
clear H5 H6 v1 v2.
(* Now unfold the float valued evaluation to get the deltas we need for the inequality *)
inversion div_float; subst.
unfold perturb; simpl.
inversion H7; subst; inversion H8; subst.
symmetry in H6, H9;
inversion H6; subst; inversion H7; subst.
symmetry in H5, H8;
unfold updEnv in *; simpl in *.
inversion H6; inversion H9; subst.
inversion H5; inversion H8; subst.
(* We have now obtained all necessary values from the evaluations --> remove them for readability *)
clear div_float H7 H8 div_real e1_real e1_float e2_real e2_float H6 H9.
clear div_float H7 H8 div_real e1_real e1_float e2_real e2_float H5 H8.
repeat rewrite Rmult_plus_distr_l.
rewrite Rmult_1_r.
rewrite Rsub_eq_Ropp_Rplus.
......@@ -447,10 +443,10 @@ Proof.
rewrite Q2R0_is_0; auto.
Qed.
Lemma round_abs_err_bounded (e:exp R) (nR nF1 nF:R) (E: env) (err:R) (machineEpsilon m:mType):
eval_exp E (toREval e) nR M0 ->
eval_exp E e nF1 m ->
eval_exp (updEnv 1 m nF1 E) (toRExp (Downcast machineEpsilon (Var Q m 1))) nF machineEpsilon->
Lemma round_abs_err_bounded (e:exp R) (nR nF1 nF:R) (E1 E2: env) (err:R) (machineEpsilon m:mType):
eval_exp E1 (toREval e) nR M0 ->
eval_exp E2 e nF1 m ->
eval_exp (updEnv 1 m nF1 emptyEnv) (toRExp (Downcast machineEpsilon (Var Q m 1))) nF machineEpsilon->
(Rabs (nR - nF1) <= err)%R ->
(Rabs (nR - nF) <= err + (Rabs nF1) * Q2R (meps machineEpsilon))%R.
Proof.
......
This diff is collapsed.
......@@ -235,12 +235,12 @@ Inductive eval_exp (E:env) :(exp R) -> R -> mType -> Prop :=
Rle (Rabs delta) (Q2R (meps m)) ->
eval_exp E f1 v1 m ->
eval_exp E (Unop Inv f1) (perturb (evalUnop Inv v1) delta) m
| Binop_dist m m1 m2 op f1 f2 v1 v2 delta:
isJoinOf m m1 m2 = true ->
Rle (Rabs delta) (Q2R (meps m)) ->
| Binop_dist m1 m2 op f1 f2 v1 v2 delta:
(*isJoinOf m m1 m2 = true ->*)
Rle (Rabs delta) (Q2R (meps (computeJoin m1 m2))) ->
eval_exp E f1 v1 m1 ->
eval_exp E f2 v2 m2 ->
eval_exp E (Binop op f1 f2) (perturb (evalBinop op v1 v2) delta) m
eval_exp E (Binop op f1 f2) (perturb (evalBinop op v1 v2) delta) (computeJoin m1 m2)
| Downcast_dist m m1 f1 v1 delta:
(* Downcast expression f1 (evaluating to machine type m1), to a machine type m, less precise than m1.*)
isMorePrecise m1 m = true ->
......@@ -296,18 +296,27 @@ Proof.
- inversion eval_v1; inversion eval_v2; subst; auto;
try repeat (repeat rewrite delta_0_deterministic; simpl in *; rewrite Q2R0_is_0 in *; subst; auto); simpl.
assert (M0 = M0) as M00 by auto.
pose proof (ifM0isJoin_l M0 m0 m2 M00 H2); auto.
pose proof (ifM0isJoin_r M0 m0 m2 M00 H2); auto.
pose proof (ifM0isJoin_l M0 m4 m5 M00 H11); auto.
pose proof (ifM0isJoin_r M0 m4 m5 M00 H11); auto.
subst.
destruct m0; destruct m2; inversion H4.
destruct m3; destruct m4; inversion H10.
simpl in *.
rewrite (IHf1 v0 v4 M0); auto.
rewrite (IHf2 v5 v3 M0); auto.
rewrite Q2R0_is_0 in H2,H12.
rewrite delta_0_deterministic; auto.
rewrite delta_0_deterministic; auto.
- simpl toREval in eval_v1.
simpl toREval in eval_v2.
apply (IHf v1 v2 m1); auto.
Qed.
(* Lemma rnd_0_deterministic f E m v: *)
(* eval_exp E (toREval (Downcast m f)) v M0 <-> *)
(* eval_exp E (toREval f) v M0. *)
(* Proof. *)
(* split; intros. *)
(* - simpl in H. auto. *)
(* - simpl; auto. *)
(* Qed. *)
(**
......@@ -334,10 +343,11 @@ variables in the Environment.
Lemma binary_unfolding b f1 f2 m E vF:
eval_exp E (Binop b f1 f2) vF m ->
exists vF1 vF2 m1 m2,
eval_exp E f1 vF1 m1 /\
eval_exp E f2 vF2 m2 /\
eval_exp (updEnv 2 m2 vF2 (updEnv 1 m1 vF1 emptyEnv))
(Binop b (Var R m1 1) (Var R m2 2)) vF m.
m = computeJoin m1 m2 /\
eval_exp E f1 vF1 m1 /\
eval_exp E f2 vF2 m2 /\
eval_exp (updEnv 2 m2 vF2 (updEnv 1 m1 vF1 emptyEnv))
(Binop b (Var R m1 1) (Var R m2 2)) vF m.
Proof.
intros eval_float.
inversion eval_float; subst.
......
......@@ -272,6 +272,15 @@ Proof.
- apply EquivEqBoolEq in H; auto.
Qed.
Lemma ifM0isJoin (m1:mType) (m2:mType):
isJoinOf M0 m1 m2 = true -> m1 = M0 /\ m2 = M0.
Proof.
assert (M0 = M0) by auto.
intros; split.
- apply (ifM0isJoin_l M0 m1 m2); auto.
- apply (ifM0isJoin_r M0 m1 m2); auto.
Qed.
Lemma computeJoinIsJoin (m1:mType) (m2:mType) :
isJoinOf (computeJoin m1 m2) m1 m2 = true.
Proof.
......
......@@ -476,7 +476,7 @@ Proof.
rewrite NatSet.diff_spec in in_diff_e1.
destruct in_diff_e1 as [ in_usedVars not_dVar].
split; try auto.
assert (m1 = M0) by (apply (ifM0isJoin_l M0 m1 m2); auto); subst; auto.
destruct m1; destruct m2; inversion H2; subst; auto.
+ assert (Q2R (fst (fst (iv2, err2))) <= v2 <= Q2R (snd (fst (iv2, err2))))%R as valid_bounds_e2.
* apply IHf2; try auto.
intros v in_diff_e2.
......@@ -484,7 +484,7 @@ Proof.
simpl. rewrite NatSet.diff_spec, NatSet.union_spec.
rewrite NatSet.diff_spec in in_diff_e2.
destruct in_diff_e2; split; auto.
assert (m2 = M0) by (apply (ifM0isJoin_r M0 m1 m2); auto); subst; auto.
destruct m1; destruct m2; inversion H2; auto.
* destruct b; simpl in *.
{ pose proof (interval_addition_valid (iv1 :=(Q2R (fst iv1),Q2R (snd iv1))) (iv2 :=(Q2R (fst iv2), Q2R (snd iv2)))) as valid_add.
unfold validIntervalAdd in valid_add.
......@@ -614,8 +614,10 @@ Proof.
rewrite <- Q2R_inv in valid_div_hi; [ | auto].
repeat rewrite <- Q2R_mult in valid_div_hi.
rewrite <- Q2R_max4 in valid_div_hi; auto. } }
+ simpl in H3; rewrite Q2R0_is_0 in H3; auto.
+ simpl in H3; rewrite Q2R0_is_0 in H3; auto.
+ destruct m1; destruct m2; inversion H2.
simpl in H4; rewrite Q2R0_is_0 in H4; auto.
+ destruct m1; destruct m2; inversion H2.
simpl in H4; rewrite Q2R0_is_0 in H4; auto.
- unfold validIntervalbounds in valid_bounds.
(*simpl erasure in valid_bounds.*)
simpl in *; destruct (absenv (Downcast m f)); destruct (absenv f); simpl in *.
......
This diff is collapsed.
......@@ -78,9 +78,10 @@ Proof.
apply NatSet.union_spec; auto. }
* destruct eval_e1_def as [vR1 eval_e1_def];
destruct eval_e2_def as [vR2 eval_e2_def].
exists (perturb (evalBinop b vR1 vR2) 0); econstructor; eauto.
auto.
simpl. rewrite Q2R0_is_0. rewrite Rabs_R0; lra.
exists (perturb (evalBinop b vR1 vR2) 0).
replace M0 with (computeJoin M0 M0) by auto.
constructor; auto.
simpl meps; rewrite Q2R0_is_0. rewrite Rabs_R0; lra.
- assert (exists vR, eval_exp (toREvalEnv E) (toREval (toRExp e)) vR M0) as eval_r_def by (eapply IHe; eauto).
destruct eval_r_def as [vr eval_r_def].
exists vr.
......@@ -220,13 +221,10 @@ Proof.
+ erewrite <- IHe; eauto.
+ erewrite <- IHe; eauto.
- split; intros eval_Binop; inversion eval_Binop; subst; econstructor; eauto;
assert (M0 = M0) as M00 by auto;
pose proof (ifM0isJoin_l M0 m1 m2 M00 H2);
pose proof (ifM0isJoin_r M0 m1 m2 M00 H2);
subst;
destruct m1; destruct m2; inversion H2;
try (erewrite IHe1; eauto);
try (erewrite IHe2; eauto); auto.
- split; intros eval_Downcast; inversion eval_Downcast; subst; try auto; erewrite IHe; eauto.
- split; intros eval_Downcast; simpl; simpl in eval_Downcast; erewrite IHe; eauto.
Qed.
Lemma shadowing_free_rewriting_cmd f E1 E2 vR:
......@@ -285,9 +283,7 @@ Proof.
- inversion eval_e; subst; econstructor; eauto.
- simpl in valid_vars.
inversion eval_e; subst; econstructor; eauto;
assert (M0 = M0) as M00 by auto;
pose proof (ifM0isJoin_l M0 m1 m2 M00 H2);
pose proof (ifM0isJoin_r M0 m1 m2 M00 H2);
destruct m1; destruct m2; inversion H2;
subst.
+ eapply IHe1; eauto.
hnf; intros a in_e1.
......@@ -347,15 +343,11 @@ Proof.
rewrite IHe; auto.
- intros v_res; split; [intros eval_upd | intros eval_subst].
+ inversion eval_upd; econstructor; auto;
assert (M0 = M0) as M00 by auto; pose proof (ifM0isJoin_l M0 m1 m2 M00 H2);
pose proof (ifM0isJoin_r M0 m1 m2 M00 H2); subst.
* apply H2.
destruct m1; destruct m2; inversion H2.
* rewrite <- IHe1; auto.
* rewrite <- IHe2; auto.
+ inversion eval_subst; econstructor; auto;
assert (M0 = M0) as M00 by auto; pose proof (ifM0isJoin_l M0 m1 m2 M00 H2);
pose proof (ifM0isJoin_r M0 m1 m2 M00 H2); subst.
* apply H2.
destruct m1; destruct m2; inversion H2.
* rewrite IHe1; auto.
* rewrite IHe2; auto.
- split; [intros eval_upd | intros eval_subst].
......
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