我目前正在尝试学习如何使用 VST。我正在使用 VST 1.5。我有这个小 C 程序(backref.c
):
char* rbr (char* out, int length, int dist) {
while (length-- > 0) { out[0] = out[-dist]; out++; }
return out;
}
我的 Coq 代码(带有微不足道的前置条件和后置条件)是
Require Import floyd.proofauto.
Require Import backref.
Local Open Scope logic.
Local Open Scope Z.
Definition rbr_spec :=
DECLARE _rbr
WITH sh : share, contents : Z -> int
PRE [ _out OF (tptr tuchar), _length OF tint, _dist OF tint ]
PROP ()
LOCAL ()
SEP ()
POST [tptr tuchar] local(fun _ => True).
作为前提,我想说out[-dist]
toout[-1]
是可读的,out[0]
toout[length-1]
是可写的。PLCC 第 210 页讲述了一个条件array_at_range
,但它似乎在 VST 1.5 中不可用。我怎样才能做到这一点?