The Whiley Theorem Prover (WyTP) is an automatic and interactive theorem prover designed to discharge verification conditions generated by the Whiley Compiler. WyTP operates over a variant of first-order logic which includes integer arithmetic, arrays and quantification.
define contains(int[] env, int n) is:
exists(int i):
n <= i
env[i] == 0
assert "loop invariant not restored":
forall(int[] env, int n):
if:
contains(env,n)
env[n] != 0
then:
contains(env,n+1)
But, if we rename i to p as follows:
define contains(int[] env, int n) is:
exists(int p):
n <= p
env[p] == 0
The key problem seems to be the relative ordering between variable n and i. If i is renamed to something alphabetically above n then it fails. The invalid proof is:
The following passes verification:
But, if we rename
i
top
as follows:The key problem seems to be the relative ordering between variable
n
andi
. Ifi
is renamed to something alphabetically aboven
then it fails. The invalid proof is:In contrast, the valid proof is: