我的简单程序是vars.c
int pure0 ()
{
return 0;
}
int get0(int* arr)
{
int z = pure0();
return z;
}我开始验证(文件verif_vars.c):
Require Import floyd.proofauto.
Require Import vars.
Local Open Scope logic.
Local Open Scope Z.
Definition get0_spec :=
DECLARE _get0
WITH sh : share, arr : Z->val, varr : val
PRE [_arr OF (tptr tint)]
PROP ()
LOCAL (`(eq varr) (eval_id _arr);
`isptr (eval_id _arr))
SEP (`(array_at tint sh arr 0 100) (eval_id _arr))
POST [tint] `(array_at tint sh arr 0 100 varr) &&
local(`(eq (Vint (Int.repr 0))) retval).
Definition pure0_spec :=
DECLARE _pure0
WITH sh : share
PRE []
PROP ()
LOCAL ()
SEP ()
POST [tint] local(`(eq (Vint (Int.repr 0))) retval).
Definition Vprog : varspecs := nil.
Definition Gprog : funspecs := get0_spec :: pure0_spec ::nil.
Lemma body_pure0: semax_body Vprog Gprog f_pure0 pure0_spec.
Proof.
start_function.
forward.
Qed.
Lemma body_get0: semax_body Vprog Gprog f_get0 get0_spec.
Proof.
start_function.
name arrarg _arr.
name zloc _z.
name zloc' _z'.
forward_call (sh).
entailer!.
auto with closed.
after_call.
forward.
entailer!.最后有了两个子目标:
Espec : OracleKind
sh : share
arr : Z -> val
Struct_env := abbreviate : type_id_env.type_id_env
Delta := abbreviate : tycontext
zloc0 : val
arrarg : val
zloc : int
TC : is_pointer_or_null arrarg
Parrarg : isptr arrarg
============================
Int.repr 0 = zloc
subgoal 2 (ID 1273) is:
!!(Int.repr 0 = zloc) |-- emppure0_spec后置条件开始。但我怎么才能告诉Coq呢?admit. entailer.)简化为TT |-- emp。这似乎又是微不足道的,但如何才能证明这一点(SearchAbout derives和SearchAbout emp没有显示任何一般的引理)?我使用:VST1.5(在2014-10-02年为6834P),CompCert 2.4,Coq 8.4pl3(1月14日)和OCaml 4.01.0。
发布于 2015-01-18 19:13:06
第一:草率地,不尝试自己复制--是否可能使用entailer!太“冒险”,因为(如文档所示) entailer!有时会将可证明的目标转化为不可证明的目标。试着在没有爆炸的情况下使用entailer,看看它是否更好看。
第二,TT |-- emp不是真的。TT适用于任何堆,而emp只应用于空堆。可以通过将pure函数的后置条件更改为
POST [tint] local(`(eq (Vint (Int.repr 0))) retval) && emp.https://stackoverflow.com/questions/28013427
复制相似问题