The question is rather simple: why does the assertion bellow return "assertion violation".
method test()
{
var a := new int[5];
a[0] := 1;
a[1] := 1;
a[2] := 2;
a[3] := 3;
a[4] := 3;
var b := new int[3];
b[0] := 1;
b[1] := 2;
b[2] := 3;
assert(forall i :: exists j :: ((0 <= i < 5) && (0 <= j < 3)) ==> (a[i] == b[j]));
}
Here's one way to fix it. Add the following assertions before your assertion.
It seems that under a quantifier can only remember the value of the most recent assignment to
b
, which explains why no extra assertion aboutb[2]
is required.