Open JLedelay opened 1 year ago
Viper requires that all forall
with permission expressions (forall*
in VerCors) are injective. That means that different k
must point to different heap chunks. For you concretely, that means that for i != j
, you must have arr[i] != arr[j]
. And also that arr[i].arr != arr[j].arr
(since D.arr
is a reference, so they might otherwise all point to the same inner array).
With that (and some additional null-checks), you should be able to get your program to verify.
However, we should work on the error reporting there. VerCors should not crash, and instead gracefully terminate and report what the issue is.
The problem is as such:
Perm
that you don't have).Here mySum2
does not verify because the contract is not well-formed: arr[k].arr
may be null. At the usage in mySum
we know that this is not the case, and instead we get stuck on the fact that arr[k].arr[_]
might not be injective: the error viper reports is "the precondition of mySum2
might be false, since arr[k].arr[_]
might not be injective."
The following input:
Gives the following output: