Commit 2a5c4420 authored by Nikita Zyuzin's avatar Nikita Zyuzin

Revert "Start changing expression semantics"

This reverts commit 6ef96566.
parent 579e5d38
...@@ -32,66 +32,50 @@ using a perturbation of the real valued computation by (1 + delta), where ...@@ -32,66 +32,50 @@ using a perturbation of the real valued computation by (1 + delta), where
**) **)
Open Scope R_scope. Open Scope R_scope.
Definition nonDestrUpd (T: Type) M k (v: T) :=
match (M k) with
| Some v1 => M
| None => (fun x => if R_orderedExps.eq_dec x k then Some v else M x)
end.
Inductive eval_expr (E:env) Inductive eval_expr (E:env)
(Gamma: expr R -> option mType) (Gamma: expr R -> option mType)
:(expr R -> option R) -> (expr R) -> R -> mType -> Prop := :(expr R) -> R -> mType -> Prop :=
| Var_load DeltaMap m x v: | Var_load m x v:
Gamma (Var R x) = Some m -> Gamma (Var R x) = Some m ->
E x = Some v -> E x = Some v ->
eval_expr E Gamma DeltaMap (Var R x) v m eval_expr E Gamma (Var R x) v m
| Const_dist DeltaMap m n delta: | Const_dist m n delta:
(forall delta', DeltaMap (Const m n) = Some delta' -> delta = delta') ->
Rabs delta <= mTypeToR m -> Rabs delta <= mTypeToR m ->
eval_expr E Gamma (nonDestrUpd DeltaMap (Const m n) delta) (Const m n) (perturb n m delta) m eval_expr E Gamma (Const m n) (perturb n m delta) m
(* eval_expr E Gamma DeltaMap (Const m n) (perturb n m delta) m *) | Unop_neg m mN f1 v1:
| Unop_neg DeltaMap m mN f1 v1:
Gamma (Unop Neg f1) = Some mN -> Gamma (Unop Neg f1) = Some mN ->
isCompat m mN = true -> isCompat m mN = true ->
eval_expr E Gamma DeltaMap f1 v1 m -> eval_expr E Gamma f1 v1 m ->
eval_expr E Gamma DeltaMap (Unop Neg f1) (evalUnop Neg v1) mN eval_expr E Gamma (Unop Neg f1) (evalUnop Neg v1) mN
| Unop_inv DeltaMap m mN f1 v1 delta: | Unop_inv m mN f1 v1 delta:
(forall delta', DeltaMap (Unop Inv f1) = Some delta' -> delta = delta') ->
Gamma (Unop Inv f1) = Some mN -> Gamma (Unop Inv f1) = Some mN ->
isCompat m mN = true -> isCompat m mN = true ->
Rabs delta <= mTypeToR mN -> Rabs delta <= mTypeToR mN ->
eval_expr E Gamma DeltaMap f1 v1 m -> eval_expr E Gamma f1 v1 m ->
(~ v1 = 0)%R -> (~ v1 = 0)%R ->
eval_expr E Gamma (nonDestrUpd DeltaMap (Unop Inv f1) delta) eval_expr E Gamma (Unop Inv f1) (perturb (evalUnop Inv v1) mN delta) mN
(Unop Inv f1) (perturb (evalUnop Inv v1) mN delta) mN | Downcast_dist m m1 f1 v1 delta:
| Downcast_dist DeltaMap m m1 f1 v1 delta:
(forall delta', DeltaMap (Downcast m f1) = Some delta' -> delta = delta') ->
Gamma (Downcast m f1) = Some m -> Gamma (Downcast m f1) = Some m ->
isMorePrecise m1 m = true -> isMorePrecise m1 m = true ->
Rabs delta <= mTypeToR m -> Rabs delta <= mTypeToR m ->
eval_expr E Gamma DeltaMap f1 v1 m1 -> eval_expr E Gamma f1 v1 m1 ->
eval_expr E Gamma (nonDestrUpd DeltaMap (Downcast m f1) delta) eval_expr E Gamma (Downcast m f1) (perturb v1 m delta) m
(Downcast m f1) (perturb v1 m delta) m | Binop_dist m1 m2 op f1 f2 v1 v2 delta m:
| Binop_dist DeltaMap m1 m2 op f1 f2 v1 v2 delta m:
(forall delta', DeltaMap (Binop op f1 f2) = Some delta' -> delta = delta') ->
Gamma (Binop op f1 f2) = Some m -> Gamma (Binop op f1 f2) = Some m ->
isJoin m1 m2 m = true -> isJoin m1 m2 m = true ->
Rabs delta <= mTypeToR m -> Rabs delta <= mTypeToR m ->
eval_expr E Gamma DeltaMap f1 v1 m1 -> eval_expr E Gamma f1 v1 m1 ->
eval_expr E Gamma DeltaMap f2 v2 m2 -> eval_expr E Gamma f2 v2 m2 ->
((op = Div) -> (~ v2 = 0)%R) -> ((op = Div) -> (~ v2 = 0)%R) ->
eval_expr E Gamma (nonDestrUpd DeltaMap (Binop op f1 f2) delta) eval_expr E Gamma (Binop op f1 f2) (perturb (evalBinop op v1 v2) m delta) m
(Binop op f1 f2) (perturb (evalBinop op v1 v2) m delta) m | Fma_dist m1 m2 m3 m f1 f2 f3 v1 v2 v3 delta:
| Fma_dist DeltaMap m1 m2 m3 m f1 f2 f3 v1 v2 v3 delta:
(forall delta', DeltaMap (Fma f1 f2 f3) = Some delta' -> delta = delta') ->
Gamma (Fma f1 f2 f3) = Some m -> Gamma (Fma f1 f2 f3) = Some m ->
isJoin3 m1 m2 m3 m = true -> isJoin3 m1 m2 m3 m = true ->
Rabs delta <= mTypeToR m -> Rabs delta <= mTypeToR m ->
eval_expr E Gamma DeltaMap f1 v1 m1 -> eval_expr E Gamma f1 v1 m1 ->
eval_expr E Gamma DeltaMap f2 v2 m2 -> eval_expr E Gamma f2 v2 m2 ->
eval_expr E Gamma DeltaMap f3 v3 m3 -> eval_expr E Gamma f3 v3 m3 ->
eval_expr E Gamma (nonDestrUpd DeltaMap (Fma f1 f2 f3) delta) eval_expr E Gamma (Fma f1 f2 f3) (perturb (evalFma v1 v2 v3) m delta) m.
(Fma f1 f2 f3) (perturb (evalFma v1 v2 v3) m delta) m.
Close Scope R_scope. Close Scope R_scope.
...@@ -100,13 +84,11 @@ Hint Constructors eval_expr. ...@@ -100,13 +84,11 @@ Hint Constructors eval_expr.
(** *) (** *)
(* Show some simpler (more general) rule lemmata *) (* Show some simpler (more general) rule lemmata *)
(* **) (* **)
Lemma Const_dist' DeltaMap DeltaMap' m n delta v m' E Gamma: Lemma Const_dist' m n delta v m' E Gamma:
(forall delta', DeltaMap' (Const m n) = Some delta' -> delta = delta') ->
Rle (Rabs delta) (mTypeToR m') -> Rle (Rabs delta) (mTypeToR m') ->
DeltaMap = nonDestrUpd DeltaMap' (Const m n) delta ->
v = perturb n m delta -> v = perturb n m delta ->
m' = m -> m' = m ->
eval_expr E Gamma DeltaMap (Const m n) v m'. eval_expr E Gamma (Const m n) v m'.
Proof. Proof.
intros; subst; auto. intros; subst; auto.
Qed. Qed.
...@@ -421,4 +403,4 @@ Lemma Rmap_updVars_comm Gamma n m: ...@@ -421,4 +403,4 @@ Lemma Rmap_updVars_comm Gamma n m:
Proof. Proof.
unfold updDefVars, toRMap; simpl. unfold updDefVars, toRMap; simpl.
intros x; destruct (R_orderedExps.compare x n); auto. intros x; destruct (R_orderedExps.compare x n); auto.
Qed. Qed.
\ No newline at end of file
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