Commit 4c69ae3a authored by Heiko Becker's avatar Heiko Becker

Refactor exp type into expr type because of name clash with new coq version,...

Refactor exp type into expr type because of name clash with new coq version, move ExpOrderedType module into separate file
parent b3fc8947
......@@ -12,7 +12,7 @@ Require Export Coq.QArith.QArith.
Require Export Flover.Infra.ExpressionAbbrevs Flover.Commands.
(** Certificate checking function **)
Definition CertificateChecker (e:exp Q) (absenv:analysisResult) (P:precond) (defVars:nat -> option mType) :=
Definition CertificateChecker (e:expr Q) (absenv:analysisResult) (P:precond) (defVars:nat -> option mType) :=
let tMap := (typeMap defVars e (FloverMap.empty mType)) in
if (typeCheck e defVars tMap)
then
......@@ -26,7 +26,7 @@ Definition CertificateChecker (e:exp Q) (absenv:analysisResult) (P:precond) (def
Apart from assuming two executions, one in R and one on floats, we assume that
the real valued execution respects the precondition.
**)
Theorem Certificate_checking_is_sound (e:exp Q) (absenv:analysisResult) P defVars:
Theorem Certificate_checking_is_sound (e:expr Q) (absenv:analysisResult) P defVars:
forall (E1 E2:env),
approxEnv E1 defVars absenv (usedVars e) NatSet.empty E2 ->
(forall v, NatSet.In v (Expressions.usedVars e) ->
......@@ -38,10 +38,10 @@ Theorem Certificate_checking_is_sound (e:exp Q) (absenv:analysisResult) P defVar
CertificateChecker e absenv P defVars = true ->
exists iv err vR vF m,
FloverMap.find e absenv = Some (iv, err) /\
eval_exp E1 (toRMap defVars) (toREval (toRExp e)) vR M0 /\
eval_exp E2 defVars (toRExp e) vF m /\
eval_expr E1 (toRMap defVars) (toREval (toRExp e)) vR M0 /\
eval_expr E2 defVars (toRExp e) vF m /\
(forall vF m,
eval_exp E2 defVars (toRExp e) vF m ->
eval_expr E2 defVars (toRExp e) vF m ->
(Rabs (vR - vF) <= Q2R err))%R.
(**
The proofs is a simple composition of the soundness proofs for the range
......
......@@ -11,8 +11,8 @@ Require Export Flover.Infra.ExpressionAbbrevs Flover.Infra.NatSet.
Only assignments and return statement
**)
Inductive cmd (V:Type) :Type :=
Let: mType -> nat -> exp V -> cmd V -> cmd V
| Ret: exp V -> cmd V.
Let: mType -> nat -> expr V -> cmd V -> cmd V
| Ret: expr V -> cmd V.
Fixpoint getRetExp (V:Type) (f:cmd V) :=
match f with
......@@ -38,10 +38,10 @@ UNUSED!
Small Step semantics for Flover language
Inductive sstep : cmd R -> env -> R -> cmd R -> env -> Prop :=
let_s x e s E v eps:
eval_exp eps E e v ->
eval_expr eps E e v ->
sstep (Let x e s) E eps s (updEnv x v E)
|ret_s e E v eps:
eval_exp eps E e v ->
eval_expr eps E e v ->
sstep (Ret e) E eps (Nop R) (updEnv 0 v E).
*)
......@@ -51,15 +51,15 @@ Inductive sstep : cmd R -> env -> R -> cmd R -> env -> Prop :=
**)
Inductive bstep : cmd R -> env -> (nat -> option mType) -> R -> mType -> Prop :=
let_b m m' x e s E v res defVars:
eval_exp E defVars e v m ->
eval_expr E defVars e v m ->
bstep s (updEnv x v E) (updDefVars x m defVars) res m' ->
bstep (Let m x e s) E defVars res m'
|ret_b m e E v defVars:
eval_exp E defVars e v m ->
eval_expr E defVars e v m ->
bstep (Ret e) E defVars v m.
(**
The free variables of a command are all used variables of expressions
The free variables of a command are all used variables of exprressions
without the let bound variables
**)
Fixpoint freeVars V (f:cmd V) :NatSet.t :=
......
......@@ -9,7 +9,7 @@ Require Import Flover.Infra.ExpressionAbbrevs Flover.Infra.RationalSimps Flover.
Define an approximation relation between two environments.
We use this relation for the soundness proofs.
It is necessary to have this relation, since two evaluations of the very same
expression may yield different values for different machine epsilons
exprression may yield different values for different machine epsilons
(or environments that already only approximate each other)
**)
Inductive approxEnv : env -> (nat -> option mType) -> analysisResult -> NatSet.t -> NatSet.t -> env -> Prop :=
......
(**
Proofs of general bounds on the error of arithmetic expressions.
Proofs of general bounds on the error of arithmetic exprressions.
This shortens soundness proofs later.
Bounds are explained in section 5, Deriving Computable Error Bounds
Bounds are exprlained in section 5, Deriving Computable Error Bounds
**)
Require Import Coq.Reals.Reals Coq.micromega.Psatz Coq.QArith.QArith Coq.QArith.Qreals.
Require Import Flover.Infra.Abbrevs Flover.Infra.RationalSimps Flover.Infra.RealSimps Flover.Infra.RealRationalProps.
......@@ -9,8 +9,8 @@ Require Import Flover.Environments Flover.Infra.ExpressionAbbrevs.
Lemma const_abs_err_bounded (n:R) (nR:R) (nF:R) (E1 E2:env) (m:mType) defVars:
eval_exp E1 (toRMap defVars) (Const M0 n) nR M0 ->
eval_exp E2 defVars (Const m n) nF m ->
eval_expr E1 (toRMap defVars) (Const M0 n) nR M0 ->
eval_expr E2 defVars (Const m n) nF m ->
(Rabs (nR - nF) <= Rabs n * (Q2R (mTypeToQ m)))%R.
Proof.
intros eval_real eval_float.
......@@ -26,14 +26,14 @@ Proof.
Qed.
Lemma add_abs_err_bounded (e1:exp Q) (e1R:R) (e1F:R) (e2:exp Q) (e2R:R) (e2F:R)
Lemma add_abs_err_bounded (e1:expr Q) (e1R:R) (e1F:R) (e2:expr Q) (e2R:R) (e2F:R)
(vR:R) (vF:R) (E1 E2:env) (err1 err2 :Q) (m m1 m2:mType) defVars:
eval_exp E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_exp E2 defVars (toRExp e1) e1F m1->
eval_exp E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_exp E2 defVars (toRExp e2) e2F m2 ->
eval_exp E1 (toRMap defVars) (toREval (Binop Plus (toRExp e1) (toRExp e2))) vR M0 ->
eval_exp (updEnv 2 e2F (updEnv 1 e1F emptyEnv))
eval_expr E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_expr E2 defVars (toRExp e1) e1F m1->
eval_expr E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_expr E2 defVars (toRExp e2) e2F m2 ->
eval_expr E1 (toRMap defVars) (toREval (Binop Plus (toRExp e1) (toRExp e2))) vR M0 ->
eval_expr (updEnv 2 e2F (updEnv 1 e1F emptyEnv))
(updDefVars 2 m2 (updDefVars 1 m1 defVars))
(Binop Plus (Var R 1) (Var R 2)) vF m ->
(Rabs (e1R - e1F) <= Q2R err1)%R ->
......@@ -94,14 +94,14 @@ Qed.
(**
Copy-Paste proof with minor differences, was easier then manipulating the evaluations and then applying the lemma
**)
Lemma subtract_abs_err_bounded (e1:exp Q) (e1R:R) (e1F:R) (e2:exp Q) (e2R:R)
Lemma subtract_abs_err_bounded (e1:expr Q) (e1R:R) (e1F:R) (e2:expr Q) (e2R:R)
(e2F:R) (vR:R) (vF:R) (E1 E2:env) err1 err2 (m m1 m2:mType) defVars:
eval_exp E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_exp E2 defVars (toRExp e1) e1F m1 ->
eval_exp E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_exp E2 defVars (toRExp e2) e2F m2 ->
eval_exp E1 (toRMap defVars) (toREval (Binop Sub (toRExp e1) (toRExp e2))) vR M0 ->
eval_exp (updEnv 2 e2F (updEnv 1 e1F emptyEnv))
eval_expr E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_expr E2 defVars (toRExp e1) e1F m1 ->
eval_expr E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_expr E2 defVars (toRExp e2) e2F m2 ->
eval_expr E1 (toRMap defVars) (toREval (Binop Sub (toRExp e1) (toRExp e2))) vR M0 ->
eval_expr (updEnv 2 e2F (updEnv 1 e1F emptyEnv))
(updDefVars 2 m2 (updDefVars 1 m1 defVars))
(Binop Sub (Var R 1) (Var R 2)) vF m ->
(Rabs (e1R - e1F) <= Q2R err1)%R ->
......@@ -156,14 +156,14 @@ Proof.
eapply Rmult_le_compat_l; [apply Rabs_pos | auto].
Qed.
Lemma mult_abs_err_bounded (e1:exp Q) (e1R:R) (e1F:R) (e2:exp Q) (e2R:R) (e2F:R)
Lemma mult_abs_err_bounded (e1:expr Q) (e1R:R) (e1F:R) (e2:expr Q) (e2R:R) (e2F:R)
(vR:R) (vF:R) (E1 E2:env) (m m1 m2:mType) defVars:
eval_exp E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_exp E2 defVars (toRExp e1) e1F m1 ->
eval_exp E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_exp E2 defVars (toRExp e2) e2F m2 ->
eval_exp E1 (toRMap defVars) (toREval (Binop Mult (toRExp e1) (toRExp e2))) vR M0 ->
eval_exp (updEnv 2 e2F (updEnv 1 e1F emptyEnv))
eval_expr E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_expr E2 defVars (toRExp e1) e1F m1 ->
eval_expr E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_expr E2 defVars (toRExp e2) e2F m2 ->
eval_expr E1 (toRMap defVars) (toREval (Binop Mult (toRExp e1) (toRExp e2))) vR M0 ->
eval_expr (updEnv 2 e2F (updEnv 1 e1F emptyEnv))
(updDefVars 2 m2 (updDefVars 1 m1 defVars))
(Binop Mult (Var R 1) (Var R 2)) vF m ->
(Rabs (vR - vF) <= Rabs (e1R * e2R - e1F * e2F) + Rabs (e1F * e2F) * (Q2R (mTypeToQ m)))%R.
......@@ -208,14 +208,14 @@ Proof.
apply Rabs_pos.
Qed.
Lemma div_abs_err_bounded (e1:exp Q) (e1R:R) (e1F:R) (e2:exp Q) (e2R:R) (e2F:R)
Lemma div_abs_err_bounded (e1:expr Q) (e1R:R) (e1F:R) (e2:expr Q) (e2R:R) (e2F:R)
(vR:R) (vF:R) (E1 E2:env) (m m1 m2:mType) defVars:
eval_exp E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_exp E2 defVars (toRExp e1) e1F m1 ->
eval_exp E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_exp E2 defVars (toRExp e2) e2F m2 ->
eval_exp E1 (toRMap defVars) (toREval (Binop Div (toRExp e1) (toRExp e2))) vR M0 ->
eval_exp (updEnv 2 e2F (updEnv 1 e1F emptyEnv))
eval_expr E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_expr E2 defVars (toRExp e1) e1F m1 ->
eval_expr E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_expr E2 defVars (toRExp e2) e2F m2 ->
eval_expr E1 (toRMap defVars) (toREval (Binop Div (toRExp e1) (toRExp e2))) vR M0 ->
eval_expr (updEnv 2 e2F (updEnv 1 e1F emptyEnv))
(updDefVars 2 m2 (updDefVars 1 m1 defVars))
(Binop Div (Var R 1) (Var R 2)) vF m ->
(Rabs (vR - vF) <= Rabs (e1R / e2R - e1F / e2F) + Rabs (e1F / e2F) * (Q2R (mTypeToQ m)))%R.
......@@ -258,17 +258,17 @@ Proof.
apply Rabs_pos.
Qed.
Lemma fma_abs_err_bounded (e1:exp Q) (e1R:R) (e1F:R) (e2:exp Q) (e2R:R) (e2F:R)
(e3:exp Q) (e3R:R) (e3F:R)
Lemma fma_abs_err_bounded (e1:expr Q) (e1R:R) (e1F:R) (e2:expr Q) (e2R:R) (e2F:R)
(e3:expr Q) (e3R:R) (e3F:R)
(vR:R) (vF:R) (E1 E2:env) (m m1 m2 m3:mType) defVars:
eval_exp E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_exp E2 defVars (toRExp e1) e1F m1->
eval_exp E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_exp E2 defVars (toRExp e2) e2F m2 ->
eval_exp E1 (toRMap defVars) (toREval (toRExp e3)) e3R M0 ->
eval_exp E2 defVars (toRExp e3) e3F m3->
eval_exp E1 (toRMap defVars) (toREval (Fma (toRExp e1) (toRExp e2) (toRExp e3))) vR M0 ->
eval_exp (updEnv 3 e3F (updEnv 2 e2F (updEnv 1 e1F emptyEnv)))
eval_expr E1 (toRMap defVars) (toREval (toRExp e1)) e1R M0 ->
eval_expr E2 defVars (toRExp e1) e1F m1->
eval_expr E1 (toRMap defVars) (toREval (toRExp e2)) e2R M0 ->
eval_expr E2 defVars (toRExp e2) e2F m2 ->
eval_expr E1 (toRMap defVars) (toREval (toRExp e3)) e3R M0 ->
eval_expr E2 defVars (toRExp e3) e3F m3->
eval_expr E1 (toRMap defVars) (toREval (Fma (toRExp e1) (toRExp e2) (toRExp e3))) vR M0 ->
eval_expr (updEnv 3 e3F (updEnv 2 e2F (updEnv 1 e1F emptyEnv)))
(updDefVars 3 m3 (updDefVars 2 m2 (updDefVars 1 m1 defVars)))
(Fma (Var R 1) (Var R 2) (Var R 3)) vF m ->
(Rabs (vR - vF) <= Rabs ((e1R - e1F) + (e2R * e3R - e2F * e3F)) + Rabs (e1F + e2F * e3F) * (Q2R (mTypeToQ m)))%R.
......@@ -505,10 +505,10 @@ Proof.
auto.
Qed.
Lemma round_abs_err_bounded (e:exp R) (nR nF1 nF:R) (E1 E2: env) (err:R) (machineEpsilon m:mType) defVars:
eval_exp E1 (toRMap defVars) (toREval e) nR M0 ->
eval_exp E2 defVars e nF1 m ->
eval_exp (updEnv 1 nF1 emptyEnv)
Lemma round_abs_err_bounded (e:expr R) (nR nF1 nF:R) (E1 E2: env) (err:R) (machineEpsilon m:mType) defVars:
eval_expr E1 (toRMap defVars) (toREval e) nR M0 ->
eval_expr E2 defVars e nF1 m ->
eval_expr (updEnv 1 nF1 emptyEnv)
(updDefVars 1 m defVars)
(toRExp (Downcast machineEpsilon (Var Q 1))) nF machineEpsilon->
(Rabs (nR - nF1) <= err)%R ->
......
This diff is collapsed.
This diff is collapsed.
......@@ -5,7 +5,7 @@ Require Import Coq.QArith.QArith Coq.QArith.Qreals Coq.Reals.Reals Coq.micromega
Require Import Flover.Infra.MachineType Flover.Typing Flover.Infra.RealSimps Flover.IntervalValidation Flover.ErrorValidation Flover.Commands Flover.Environments Flover.ssaPrgs Flover.Infra.Ltacs Flover.Infra.RealRationalProps.
Fixpoint FPRangeValidator (e:exp Q) (A:analysisResult) typeMap dVars {struct e} : bool :=
Fixpoint FPRangeValidator (e:expr Q) (A:analysisResult) typeMap dVars {struct e} : bool :=
match FloverMap.find e typeMap, FloverMap.find e A with
|Some m, Some (iv_e, err_e) =>
let iv_e_float := widenIntv iv_e err_e in
......@@ -72,9 +72,9 @@ Ltac prove_fprangeval m v L1 R:=
destruct (Rle_lt_dec (Rabs v) (Q2R (maxValue m)))%R; lra.
Theorem FPRangeValidator_sound:
forall (e:exp Q) E1 E2 Gamma v m A tMap P fVars dVars,
forall (e:expr Q) E1 E2 Gamma v m A tMap P fVars dVars,
approxEnv E1 Gamma A fVars dVars E2 ->
eval_exp E2 Gamma (toRExp e) v m ->
eval_expr E2 Gamma (toRExp e) v m ->
typeCheck e Gamma tMap = true ->
validIntervalbounds e A P dVars = true ->
validErrorbound e tMap A dVars = true ->
......
This diff is collapsed.
(**
Some abbreviations that require having defined expressions beforehand
Some abbreviations that require having defined exprressions beforehand
If we would put them in the Abbrevs file, this would create a circular dependency which Coq cannot resolve.
**)
Require Import Coq.QArith.QArith Coq.Reals.Reals Coq.QArith.Qreals Coq.QArith.QOrderedType Coq.FSets.FMapAVL Coq.FSets.FMapFacts.
Require Export Flover.Infra.Abbrevs Flover.Expressions.
Require Export Flover.Infra.Abbrevs Flover.Expressions Flover.OrderedExpressions.
Module Q_orderedExps := ExpOrderedType (Q_as_OT).
......@@ -15,7 +15,7 @@ Module FloverMapFacts := OrdProperties (FloverMap).
Definition analysisResult :Type := FloverMap.t (intv * error).
(**
We treat a function mapping an expression arguing on fractions as value type
We treat a function mapping an exprression arguing on fractions as value type
to pairs of intervals on rationals and rational errors as the analysis result
**)
(* Definition analysisResult :Type := exp Q -> intv * error. *)
\ No newline at end of file
(* Definition analysisResult :Type := expr Q -> intv * error. *)
\ No newline at end of file
(**
Interval arithmetic checker and its soundness proof.
The function validIntervalbounds checks wether the given analysis result is
a valid range arithmetic for each sub term of the given expression e.
a valid range arithmetic for each sub term of the given exprression e.
The computation is done using our formalized interval arithmetic.
The function is used in CertificateChecker.v to build the full checker.
**)
......@@ -10,7 +10,7 @@ Require Import Flover.Infra.Abbrevs Flover.Infra.RationalSimps Flover.Infra.Real
Require Import Flover.Infra.Ltacs Flover.Infra.RealSimps Flover.Typing.
Require Export Flover.IntervalArithQ Flover.IntervalArith Flover.ssaPrgs.
Fixpoint validIntervalbounds (e:exp Q) (A:analysisResult) (P:precond) (validVars:NatSet.t) :bool:=
Fixpoint validIntervalbounds (e:expr Q) (A:analysisResult) (P:precond) (validVars:NatSet.t) :bool:=
match FloverMap.find e A with
| None => false
| Some (intv, _) =>
......@@ -154,7 +154,7 @@ Ltac kill_trivial_exists :=
| [ |- exists iv err, Some (?i,?e) = Some (iv, err) /\ _ ] => exists i, e
end.
Theorem validIntervalbounds_sound (f:exp Q) (A:analysisResult) (P:precond)
Theorem validIntervalbounds_sound (f:expr Q) (A:analysisResult) (P:precond)
fVars dVars (E:env) Gamma:
validIntervalbounds f A P dVars = true ->
dVars_range_valid dVars E A ->
......@@ -163,7 +163,7 @@ Theorem validIntervalbounds_sound (f:exp Q) (A:analysisResult) (P:precond)
vars_typed (NatSet.union fVars dVars) Gamma ->
exists iv err vR,
FloverMap.find f A = Some (iv, err) /\
eval_exp E (toRMap Gamma) (toREval (toRExp f)) vR M0 /\
eval_expr E (toRMap Gamma) (toREval (toRExp f)) vR M0 /\
(Q2R (fst iv) <= vR <= Q2R (snd iv))%R.
Proof.
induction f;
......@@ -381,10 +381,10 @@ Proof.
intros x; destruct (x =? n); try auto.
Qed.
Lemma swap_Gamma_eval_exp e E vR m Gamma1 Gamma2:
Lemma swap_Gamma_eval_expr e E vR m Gamma1 Gamma2:
(forall n, Gamma1 n = Gamma2 n) ->
eval_exp E Gamma1 e vR m ->
eval_exp E Gamma2 e vR m.
eval_expr E Gamma1 e vR m ->
eval_expr E Gamma2 e vR m.
Proof.
revert E vR Gamma1 Gamma2 m;
induction e; intros * Gamma_eq eval_e;
......@@ -403,14 +403,14 @@ Proof.
induction f; intros * Gamma_eq eval_f.
- inversion eval_f; subst.
econstructor; try eauto.
+ eapply swap_Gamma_eval_exp; eauto.
+ eapply swap_Gamma_eval_expr; eauto.
+ apply (IHf _ (updDefVars n m0 Gamma1) _); try eauto.
intros n1.
unfold updDefVars.
case (n1 =? n); auto.
- inversion eval_f; subst.
econstructor; try eauto.
eapply swap_Gamma_eval_exp; eauto.
eapply swap_Gamma_eval_expr; eauto.
Qed.
Theorem validIntervalboundsCmd_sound (f:cmd Q) (A:analysisResult):
......
This diff is collapsed.
......@@ -14,14 +14,14 @@ Definition RangeValidator e A P :=
end.
else validAffineBounds e A P NatSet.empty *)
Theorem RangeValidator_sound (f : exp Q) (A : analysisResult) (P : precond)
Theorem RangeValidator_sound (f : expr Q) (A : analysisResult) (P : precond)
(E : env) (Gamma : nat -> option mType) :
RangeValidator f A P = true ->
fVars_P_sound (usedVars f) E P ->
vars_typed (usedVars f) Gamma ->
exists (iv : intv) (err : error) (vR : R),
FloverMap.find (elt:=intv * error) f A = Some (iv, err) /\
eval_exp E (toRMap Gamma) (toREval (toRExp f)) vR M0 /\ (Q2R (fst iv) <= vR <= Q2R (snd iv))%R.
eval_expr E (toRMap Gamma) (toREval (toRExp f)) vR M0 /\ (Q2R (fst iv) <= vR <= Q2R (snd iv))%R.
Proof.
intros.
unfold RangeValidator in *.
......
......@@ -14,7 +14,7 @@ From Flover
Require Export Infra.ExpressionAbbrevs Infra.RealSimps Infra.NatSet
Infra.MachineType.
Fixpoint typeExpression (V:Type) (Gamma:nat -> option mType) (e:exp V) : option mType :=
Fixpoint typeExpression (V:Type) (Gamma:nat -> option mType) (e:expr V) : option mType :=
match e with
| Var _ v => Gamma v
| Const m n => Some m
......@@ -42,7 +42,7 @@ Fixpoint typeExpression (V:Type) (Gamma:nat -> option mType) (e:exp V) : option
end
end.
Fixpoint typeMap (Gamma:nat -> option mType) (e:exp Q) (tMap:FloverMap.t mType)
Fixpoint typeMap (Gamma:nat -> option mType) (e:expr Q) (tMap:FloverMap.t mType)
: FloverMap.t mType :=
if (FloverMap.mem e tMap)
then tMap
......@@ -117,7 +117,7 @@ Fixpoint typeMapCmd (Gamma:nat -> option mType) (f:cmd Q) tMap :=
|Ret e => typeMap Gamma e tMap
end.
Fixpoint typeCheck (e:exp Q) (Gamma:nat -> option mType)
Fixpoint typeCheck (e:expr Q) (Gamma:nat -> option mType)
(tMap: FloverMap.t mType) : bool :=
match e with
| Var _ v => match FloverMap.find e tMap, Gamma v with
......@@ -172,10 +172,10 @@ Fixpoint typeCheckCmd (c:cmd Q) (Gamma:nat -> option mType)
end.
Theorem typingSoundnessExp Gamma E:
forall e v m expTypes,
typeCheck e Gamma expTypes = true ->
eval_exp E Gamma (toRExp e) v m ->
FloverMap.find e expTypes = Some m.
forall e v m exprTypes,
typeCheck e Gamma exprTypes = true ->
eval_expr E Gamma (toRExp e) v m ->
FloverMap.find e exprTypes = Some m.
Proof.
induction e; cbn; intros * typechecks evals; Flover_compute; type_conv;
inversion evals; subst; try auto.
......@@ -191,12 +191,12 @@ Proof.
inversion Heqo0; subst; inversion Heqo1; subst; inversion Heqo2; subst; auto.
Qed.
Theorem typingSoundnessCmd c Gamma E v m expTypes:
typeCheckCmd c Gamma expTypes = true ->
Theorem typingSoundnessCmd c Gamma E v m exprTypes:
typeCheckCmd c Gamma exprTypes = true ->
bstep (toRCmd c) E Gamma v m ->
FloverMap.find (getRetExp c) expTypes = Some m.
FloverMap.find (getRetExp c) exprTypes = Some m.
Proof.
revert Gamma E expTypes; induction c; cbn; intros * tc bc;
revert Gamma E exprTypes; induction c; cbn; intros * tc bc;
Flover_compute; try congruence; type_conv; subst; inversion bc; subst.
- eapply IHc; eauto.
- eapply typingSoundnessExp; eauto.
......
......@@ -174,8 +174,8 @@ Fixpoint pp (tokList:list Token) :=
| [] => ""
end.
(** Prefix form parser for expressions **)
Fixpoint parseExp (tokList:list Token) (fuel:nat):option (exp Q * list Token) :=
(** Prefix form parser for exprressions **)
Fixpoint parseExp (tokList:list Token) (fuel:nat):option (expr Q * list Token) :=
match fuel with
|S fuel' =>
match tokList with
......@@ -249,9 +249,9 @@ Fixpoint parseLet input fuel:option (cmd Q * list Token) :=
|S fuel' =>
match input with
(* We already have a valid let binding *)
| DVAR ::DCONST n :: DTYPE m :: expLetRest =>
(* so we parse an expression *)
match parseExp expLetRest fuel with
| DVAR ::DCONST n :: DTYPE m :: exprLetRest =>
(* so we parse an exprression *)
match parseExp exprLetRest fuel with
| Some (e, letRest) =>
match letRest with
(* If we continue with a let *)
......@@ -272,7 +272,7 @@ Fixpoint parseLet input fuel:option (cmd Q * list Token) :=
end
| _ => None (* fail if there is no continuation for the let *)
end
| None => None (* fail if we do not have an expression to bind *)
| None => None (* fail if we do not have an exprression to bind *)
end
| _ => None (* fail if we cannot find a variable *)
end
......@@ -340,7 +340,7 @@ Definition parsePrecond (input :list Token) fuel :=
Definition defaultAbsenv:analysisResult := FloverMap.empty (intv * error).
Definition updAbsenv (e:exp Q) (iv:intv) (err:Q) (A:analysisResult):=
Definition updAbsenv (e:expr Q) (iv:intv) (err:Q) (A:analysisResult):=
FloverMap.add e (iv, err) A.
(** Abstract environment parser:
......@@ -352,8 +352,8 @@ Fixpoint parseAbsEnvRec (input:list Token) fuel :option (analysisResult * list T
match fuel with
|S fuel' =>
match input with
| DCOND :: expRest =>
match parseExp expRest fuel with
| DCOND :: exprRest =>
match parseExp exprRest fuel with
| Some (e,fracRest) =>
match parseIV fracRest with
| Some (iv, errRest) =>
......
This diff is collapsed.
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