继续我从 Dafny 转录到 SPARK 的努力,我遇到了为数组创建先决条件的问题,该数组应该在调用函数时进行排序:
type Integer_Array is array (Positive range <>) of Integer;
function BinarySearch(a : Integer_Array; key: Integer) return Integer
with
-- requires forall i,j :: 0 <= i < j < a.Length ==> a[i] <= a[j] // a is a sorted array
Pre => ((a'Length >= 2) and then (for all i in 1 .. a'Length - 1 => a(i-1) < a(i)))
-- | ^---- array index check might fail
-- \------------- array index check might fail
我错过了什么?