我是 Frama-C 的新手,我想正确学习 ACSL 语法。我有这个虚拟示例,Jessie 插件无法验证第 9 行和第 12 行。我错过了什么吗?要验证的函数(相等)将检查两个数组(a 和 b)在每个索引处是否具有相同的值:
/*@
requires \valid_range(a,0,n-1);
requires \valid_range(b,0,n-1);
requires n >= 0;
requires i >= 0 && i <= n;
assigns i;
behavior all_equal:
assumes i == n;
ensures \result == 1;
behavior some_not_equal:
assumes i != n;
ensures \result == 0;
*/
int equal(int a[], int n, int b[], int i) {
/*@
loop invariant 0 <= i <= n;
loop assigns i;
loop variant n-i;
*/
for (i = 0; i < n; i++) {
if (a[i] != b[i])
return 0;
}
return 1;
}