Fixpoint closed_eval_expr (j: ident) (e: expr) : bool :=
 match e with
 | Econst_int i ty => true
 | Econst_long i ty => true
 | Econst_float f ty => true
 | Econst_single f ty => true
 | Etempvar id ty => negb (eqb_ident j id)
 | Eaddrof a ty => closed_eval_lvalue j a
 | Eunop op a ty =>  closed_eval_expr j a
 | Ebinop op a1 a2 ty =>  andb (closed_eval_expr j a1) (closed_eval_expr j a2)
 | Ecast a ty => closed_eval_expr j a
 | Evar id ty => true
 | Ederef a ty => closed_eval_expr j a
 | Efield a i ty => closed_eval_lvalue j a
 | Esizeof _ _ => true
 | Ealignof _ _ => true
 end

 with closed_eval_lvalue (j: ident) (e: expr) : bool :=
 match e with
 | Evar id ty => true
 | Ederef a ty => closed_eval_expr j a
 | Efield a i ty => closed_eval_lvalue j a
 | _  => false
 end.

(* Specifications: *)
Lemma closed_eval_expr_e: forall {cs: compspecs} j e, closed_eval_expr j e = true -> closed_wrt_vars (eq j) (eval_expr e) with closed_eval_lvalue_e: forall {cs: compspecs} j e, closed_eval_lvalue j e = true -> closed_wrt_vars (eq j) (eval_lvalue e).
Lemma closed_wrt_eval_expr: forall {cs: compspecs} S e, expr_closed_wrt_vars S e -> closed_wrt_vars S (eval_expr e).
Lemma closed_wrt_lvalue: forall {cs: compspecs} S e, access_mode (typeof e) = By_reference -> closed_wrt_vars S (eval_expr e) -> closed_wrt_vars S (eval_lvalue e).
Lemma closed_wrt_tc_nonzero: forall {cs: compspecs} S e, closed_wrt_vars S (eval_expr e) -> closed_wrt_vars S (denote_tc_assert (tc_nonzero e)).
Lemma closed_wrt_binarithType: forall {cs: compspecs} S t1 t2 t a b, closed_wrt_vars S (denote_tc_assert (binarithType t1 t2 t a b)).
Lemma closed_wrt_tc_samebase : forall {cs: compspecs} S e1 e2, closed_wrt_vars S (eval_expr e1) -> closed_wrt_vars S (eval_expr e2) -> closed_wrt_vars S (denote_tc_assert (tc_samebase e1 e2)).
Lemma closed_wrt_tc_ilt: forall {cs: compspecs} S e n, closed_wrt_vars S (eval_expr e) -> closed_wrt_vars S (denote_tc_assert (tc_ilt e n)).
Lemma closed_wrt_tc_llt: forall {cs: compspecs} S e n, closed_wrt_vars S (eval_expr e) -> closed_wrt_vars S (denote_tc_assert (tc_llt e n)).
Lemma closed_wrt_tc_Zge: forall {cs: compspecs} S e n, closed_wrt_vars S (eval_expr e) -> closed_wrt_vars S (denote_tc_assert (tc_Zge e n)).
Lemma closed_wrt_tc_Zle: forall {cs: compspecs} S e n, closed_wrt_vars S (eval_expr e) -> closed_wrt_vars S (denote_tc_assert (tc_Zle e n)).
Lemma closed_wrt_replace_nth: forall {B} S n R (R1: environ -> B), closed_wrt_vars S R1 -> Forall (closed_wrt_vars S) R -> Forall (closed_wrt_vars S) (replace_nth n R R1).
Lemma closed_wrt_tc_nodivover : forall {cs: compspecs} S e1 e2, closed_wrt_vars S (eval_expr e1) -> closed_wrt_vars S (eval_expr e2) -> closed_wrt_vars S (denote_tc_assert (tc_nodivover e1 e2)).
Lemma closed_wrt_tc_nosignedover: forall op {CS: compspecs} S e1 e2, closed_wrt_vars S (eval_expr e1) -> closed_wrt_vars S (eval_expr e2) -> closed_wrt_vars S (denote_tc_assert (tc_nosignedover op e1 e2)).
Lemma closed_wrt_tc_nobinover: forall op {CS: compspecs} S e1 e2, closed_wrt_vars S (eval_expr e1) -> closed_wrt_vars S (eval_expr e2) -> closed_wrt_vars S (denote_tc_assert (tc_nobinover op e1 e2)).
Lemma closed_wrt_tc_expr: forall {cs: compspecs} Delta j e, closed_eval_expr j e = true -> closed_wrt_vars (eq j) (tc_expr Delta e) with closed_wrt_tc_lvalue: forall {cs: compspecs} Delta j e, closed_eval_lvalue j e = true -> closed_wrt_vars (eq j) (tc_lvalue Delta e).
Lemma closed_wrt_Econst_int: forall {cs: compspecs} S i t, closed_wrt_vars S (eval_expr (Econst_int i t)).
Lemma closed_wrt_PROPx: forall S P Q, closed_wrt_vars S Q -> closed_wrt_vars S (PROPx P Q).
Lemma closed_wrtl_PROPx: forall S P Q, closed_wrt_lvars S Q -> closed_wrt_lvars S (PROPx P Q).
Lemma closed_wrt_LOCALx: forall S Q R, Forall (closed_wrt_vars S) (map locald_denote Q) -> closed_wrt_vars S R -> closed_wrt_vars S (LOCALx Q R).
Lemma closed_wrtl_LOCALx: forall S Q R, Forall (closed_wrt_lvars S) (map locald_denote Q) -> closed_wrt_lvars S R -> closed_wrt_lvars S (LOCALx Q R).
Lemma closed_wrt_SEPx: forall S P, closed_wrt_vars S (SEPx P).
Lemma closed_wrtl_SEPx: forall S P, closed_wrt_lvars S (SEPx P).
Lemma not_not_a_param_i: forall (L: list (ident * type)) i, In i (map (@fst _ _) L) -> ~ not_a_param L i.
Lemma in_map_fst1: forall (i: ident) (t: type) L, In i (map (@fst _ _) ((i,t)::L)).
Lemma in_map_fst2: forall (i: ident) a (L: list (ident*type)), In i (map (@fst _ _) L) -> In i (map (@fst _ _) (a::L)).