This can be proven (with alt-ergo 0.95.1) if you weaken your loop assigns.
@ loop assigns i, array[0..length-1];
The precondition i >= 0
is also needed, because it is not implied by \valid(array+(0..length-1)
. array+(0..length-1)
is a valid set of locations with length <= 0
, although an empty one.
The fact that your original loop assigns does not imply your precondition is a limitation of the current version of the WP plugin.