Open DavePearce opened 7 years ago
Here is a simplified version:
define greater(int[] xs, int x) is:
forall(int i):
if:
(i >= 0) && (i < |xs|)
then:
xs[i] != x
define greater_2(int[] xs, int x) is:
forall(int m):
forall(int i):
if:
(i >= 0) && (i < |xs|)
then:
xs[i] != x
assert:
forall(int[] items, int item):
if:
greater_2(items,item)
then:
greater(items,item)
The failing proof is thus:
132. exists(int[] items, int item).(((greater_2(items, item)) && (!greater(items, item)))) ()
134. exists(int[] items, int item).(greater_2(items, item) && !greater(items, item)) (Simp 132)
133. greater_2(items, item) && !greater(items, item) (Exists-E 134)
125. greater_2(items, item) (And-E 133)
127. !greater(items, item) (And-E 133)
157. forall(int m).(forall(int i).(((((0 >= (i + 1)) || ((i + 1) >= (|items| + 1)))) || ((items[i] != it (Macro-I 125)
174. exists(int i).((((((i + 1) >= (0 + 1)) && ((|items| + 1) >= ((i + 1) + 1)))) && ((items[i] == item) (Macro-I 127)
181. forall(int m).forall(int i).((0 >= (1 + i)) || (i >= |items|) || (item != items[i])) (Simp 157)
187. exists(int i).((i >= 0) && (|items| >= (1 + i)) && (item == items[i])) (Simp 174)
186. (i >= 0) && (|items| >= (1 + i)) && (item == items[i]) (Exists-E 187)
182. i >= 0 (And-E 186)
184. |items| >= (1 + i) (And-E 186)
185. item == items[i] (And-E 186)
188. |items| >= 1 (Ieq-I 184,182)
192. forall(int m).forall(int i).((0 >= (1 + i)) || (i >= |items|) || (items[i] != items[i])) (Eq-S 181,185)
./test.wyal:16: null
assert:
^^^^^^^^^
Clearly, one option is to add a rule for merging forall(int m).(forall(int i).E)
into forall(int m, int i).E)
. That will verify, though it doesn't feel like a general solution.
The following assertion from
whiley.lang.Array
fails to verify:Observe that removing the quantifier
forall(int index$1)
(which is not actually needed) and it will verify. The failing proof looks like this:NOTE: the inclusion of the unnecessary enclosing quantifier has arisen presumably for valid reasons. Specifically, to handle flow typing which is used in the Whiley code.