Corollary check_rval_wt:
  forall a x, wt_expr ce e a -> check_rval a = OK x -> wt_rvalue ce e a.Corollary check_lval_wt:
  forall a x, wt_expr ce e a -> check_lval a = OK x -> wt_lvalue ce e a.

(* Specifications: *)
Lemma evar_sound: forall x a, evar e x = OK a -> wt_expr ce e a.
Lemma ederef_sound: forall r a, ederef r = OK a -> wt_expr ce e r -> wt_expr ce e a.
Lemma efield_sound: forall r f a, efield ce r f = OK a -> wt_expr ce e r -> wt_expr ce e a.
Lemma econst_int_sound: forall n sg, wt_expr ce e (econst_int n sg).
Lemma econst_ptr_int_sound: forall n ty, wt_expr ce e (econst_ptr_int n ty).
Lemma econst_long_sound: forall n sg, wt_expr ce e (econst_long n sg).
Lemma econst_ptr_long_sound: forall n ty, wt_expr ce e (econst_ptr_long n ty).
Lemma econst_float_sound: forall n, wt_expr ce e (econst_float n).
Lemma econst_single_sound: forall n, wt_expr ce e (econst_single n).
Lemma evalof_sound: forall l a, evalof l = OK a -> wt_expr ce e l -> wt_expr ce e a.
Lemma eaddrof_sound: forall l a, eaddrof l = OK a -> wt_expr ce e l -> wt_expr ce e a.
Lemma eunop_sound: forall op r a, eunop op r = OK a -> wt_expr ce e r -> wt_expr ce e a.
Lemma ebinop_sound: forall op r1 r2 a, ebinop op r1 r2 = OK a -> wt_expr ce e r1 -> wt_expr ce e r2 -> wt_expr ce e a.
Lemma ecast_sound: forall ty r a, ecast ty r = OK a -> wt_expr ce e r -> wt_expr ce e a.
Lemma eseqand_sound: forall r1 r2 a, eseqand r1 r2 = OK a -> wt_expr ce e r1 -> wt_expr ce e r2 -> wt_expr ce e a.
Lemma eseqor_sound: forall r1 r2 a, eseqor r1 r2 = OK a -> wt_expr ce e r1 -> wt_expr ce e r2 -> wt_expr ce e a.
Lemma econdition_sound: forall r1 r2 r3 a, econdition r1 r2 r3 = OK a -> wt_expr ce e r1 -> wt_expr ce e r2 -> wt_expr ce e r3 -> wt_expr ce e a.
Lemma econdition'_sound: forall r1 r2 r3 ty a, econdition' r1 r2 r3 ty = OK a -> wt_expr ce e r1 -> wt_expr ce e r2 -> wt_expr ce e r3 -> wt_expr ce e a.
Lemma esizeof_sound: forall ty, wt_expr ce e (esizeof ty).
Lemma ealignof_sound: forall ty, wt_expr ce e (ealignof ty).
Lemma eassign_sound: forall l r a, eassign l r = OK a -> wt_expr ce e l -> wt_expr ce e r -> wt_expr ce e a.
Lemma eassignop_sound: forall op l r a, eassignop op l r = OK a -> wt_expr ce e l -> wt_expr ce e r -> wt_expr ce e a.
Lemma epostincrdecr_sound: forall id l a, epostincrdecr id l = OK a -> wt_expr ce e l -> wt_expr ce e a.
Lemma ecomma_sound: forall r1 r2 a, ecomma r1 r2 = OK a -> wt_expr ce e r1 -> wt_expr ce e r2 -> wt_expr ce e a.
Lemma ecall_sound: forall fn args a, ecall fn args = OK a -> wt_expr ce e fn -> wt_exprlist ce e args -> wt_expr ce e a.
Lemma ebuiltin_sound: forall ef tyargs args tyres a, ebuiltin ef tyargs args tyres = OK a -> wt_exprlist ce e args -> wt_expr ce e a.
Lemma sdo_sound: forall a s, sdo a = OK s -> wt_expr ce e a -> wt_stmt ce e rt s.
Lemma sifthenelse_sound: forall a s1 s2 s, sifthenelse a s1 s2 = OK s -> wt_expr ce e a -> wt_stmt ce e rt s1 -> wt_stmt ce e rt s2 -> wt_stmt ce e rt s.
Lemma swhile_sound: forall a s1 s, swhile a s1 = OK s -> wt_expr ce e a -> wt_stmt ce e rt s1 -> wt_stmt ce e rt s.
Lemma sdowhile_sound: forall a s1 s, sdowhile a s1 = OK s -> wt_expr ce e a -> wt_stmt ce e rt s1 -> wt_stmt ce e rt s.
Lemma sfor_sound: forall s1 a s2 s3 s, sfor s1 a s2 s3 = OK s -> wt_stmt ce e rt s1 -> wt_expr ce e a -> wt_stmt ce e rt s2 -> wt_stmt ce e rt s3 -> wt_stmt ce e rt s.
Lemma sreturn_sound: forall a s, sreturn rt a = OK s -> wt_expr ce e a -> wt_stmt ce e rt s.
Lemma sswitch_sound: forall a sl s, sswitch a sl = OK s -> wt_expr ce e a -> wt_lblstmts ce e rt sl -> wt_stmt ce e rt s.
Lemma retype_expr_sound: forall a a', retype_expr ce e a = OK a' -> wt_expr ce e a' with retype_exprlist_sound: forall al al', retype_exprlist ce e al = OK al' -> wt_exprlist ce e al'.
Lemma retype_stmt_sound: forall s s', retype_stmt ce e rt s = OK s' -> wt_stmt ce e rt s' with retype_lblstmts_sound: forall sl sl', retype_lblstmts ce e rt sl = OK sl' -> wt_lblstmts ce e rt sl'.
Lemma retype_function_sound: forall ce e f f', retype_function ce e f = OK f' -> wt_function ce e f'.
Theorem typecheck_program_sound: forall p p', typecheck_program p = OK p' -> wt_program p'.
Lemma pres_cast_int_int: forall sz sg n, wt_int (cast_int_int sz sg n) sz sg.
Lemma wt_val_casted: forall v ty, val_casted v ty -> wt_val v ty.
Lemma pres_sem_cast: forall m v2 ty2 v1 ty1, wt_val v1 ty1 -> sem_cast v1 ty1 ty2 m = Some v2 -> wt_val v2 ty2.
Lemma pres_sem_binarith: forall (sem_int: signedness -> int -> int -> option val) (sem_long: signedness -> int64 -> int64 -> option val) (sem_float: float -> float -> option val) (sem_single: float32 -> float32 -> option val) v1 ty1 v2 ty2 m v ty msg, (forall sg n1 n2, match sem_int sg n1 n2 with None | Some (Vint _) | Some Vundef => True | _ => False end) -> (forall sg n1 n2, match sem_long sg n1 n2 with None | Some (Vlong _) | Some Vundef => True | _ => False end) -> (forall n1 n2, match sem_float n1 n2 with None | Some (Vfloat _) | Some Vundef => True | _ => False end) -> (forall n1 n2, match sem_single n1 n2 with None | Some (Vsingle _) | Some Vundef => True | _ => False end) -> sem_binarith sem_int sem_long sem_float sem_single v1 ty1 v2 ty2 m = Some v -> binarith_type ty1 ty2 msg = OK ty -> wt_val v ty.
Lemma pres_sem_binarith_int: forall (sem_int: signedness -> int -> int -> option val) (sem_long: signedness -> int64 -> int64 -> option val) v1 ty1 v2 ty2 m v ty msg, (forall sg n1 n2, match sem_int sg n1 n2 with None | Some (Vint _) | Some Vundef => True | _ => False end) -> (forall sg n1 n2, match sem_long sg n1 n2 with None | Some (Vlong _) | Some Vundef => True | _ => False end) -> sem_binarith sem_int sem_long (fun n1 n2 => None) (fun n1 n2 => None) v1 ty1 v2 ty2 m = Some v -> binarith_int_type ty1 ty2 msg = OK ty -> wt_val v ty.
Lemma pres_sem_shift: forall sem_int sem_long ty1 ty2 m ty v1 v2 v, shift_op_type ty1 ty2 m = OK ty -> sem_shift sem_int sem_long v1 ty1 v2 ty2 = Some v -> wt_val v ty.
Lemma pres_sem_cmp: forall ty1 ty2 msg ty c v1 v2 m v, comparison_type ty1 ty2 msg = OK ty -> sem_cmp c v1 ty1 v2 ty2 m = Some v -> wt_val v ty.
Lemma pres_sem_binop: forall ce op ty1 ty2 ty v1 v2 v m, type_binop op ty1 ty2 = OK ty -> sem_binary_operation ce op v1 ty1 v2 ty2 m = Some v -> wt_val v1 ty1 -> wt_val v2 ty2 -> wt_val v ty.
Lemma pres_sem_unop: forall op ty1 ty v1 m v, type_unop op ty1 = OK ty -> sem_unary_operation op v1 ty1 m = Some v -> wt_val v1 ty1 -> wt_val v ty.
Lemma wt_load_result: forall ty chunk v, access_mode ty = By_value chunk -> wt_val (Val.load_result chunk v) ty.
Lemma wt_decode_val: forall ty chunk vl, access_mode ty = By_value chunk -> wt_val (decode_val chunk vl) ty.
Lemma wt_deref_loc: forall ge ty m b ofs t v, deref_loc ge ty m b ofs t v -> wt_val v ty.
Lemma wt_bool_cast: forall ty, wt_bool ty -> wt_cast ty type_bool.
Lemma wt_cast_self: forall t1 t2, wt_cast t1 t2 -> wt_cast t2 t2.
Lemma binarith_type_int32s: forall ty1 msg ty2, binarith_type ty1 type_int32s msg = OK ty2 -> ty2 = incrdecr_type ty1.
Lemma type_add_int32s: forall ty1 ty2, type_binop Oadd ty1 type_int32s = OK ty2 -> ty2 = incrdecr_type ty1.
Lemma type_sub_int32s: forall ty1 ty2, type_binop Osub ty1 type_int32s = OK ty2 -> ty2 = incrdecr_type ty1.
Lemma wt_rred: forall ge tenv a m t a' m', rred ge a m t a' m' -> wt_rvalue ge tenv a -> wt_rvalue ge tenv a'.
Lemma wt_lred: forall tenv ge e a m a' m', lred ge e a m a' m' -> wt_lvalue ge tenv a -> wt_lvalue ge tenv a'.
Lemma rred_same_type: forall ge a m t a' m', rred ge a m t a' m' -> typeof a' = typeof a.
Lemma lred_same_type: forall ge e a m a' m', lred ge e a m a' m' -> typeof a' = typeof a.
Lemma wt_subexpr: forall from to C, context from to C -> wt_expr_kind cenv tenv to (C a) -> wt_expr_kind cenv tenv from a with wt_subexprlist: forall from C, contextlist from C -> wt_exprlist cenv tenv (C a) -> wt_expr_kind cenv tenv from a.
Lemma typeof_context: forall from to C, context from to C -> typeof (C a') = typeof (C a).
Lemma wt_arguments_context: forall k C, contextlist k C -> forall tyl, wt_arguments (C a) tyl -> wt_arguments (C a') tyl.
Lemma wt_context: forall from to C, context from to C -> wt_expr_kind cenv tenv to (C a) -> wt_expr_kind cenv tenv from a' -> wt_expr_kind cenv tenv to (C a') with wt_contextlist: forall from C, contextlist from C -> wt_exprlist cenv tenv (C a) -> wt_expr_kind cenv tenv from a' -> wt_exprlist cenv tenv (C a').
Lemma wt_select_switch: forall n ce e rt sl, wt_lblstmts ce e rt sl -> wt_lblstmts ce e rt (select_switch n sl).
Lemma wt_seq_of_ls: forall ce e rt sl, wt_lblstmts ce e rt sl -> wt_stmt ce e rt (seq_of_labeled_statement sl).