문제

I want to do that in JML:

//@ requires (\forall int i : array[i] < array[i+1])
void calculatesDistances(int[] array){
 ..
}

I couldn't make it work, saw a lot of examples in JML specs, but couldn't find a way how to do it.

So, how can i make it?

도움이 되었습니까?

해결책

One way is to "guard" against nonsense array values using implication:

  (\forall int i; (i >= 0 && i < array.length-1) ==> (array[i] < array[i+1]))

With the newer syntax for \forall, I believe you could also write:

  (\forall int i; (i >= 0 && i < array.length-1) ; (array[i] < array[i+1]))

where (i >= 0 && i < array.length-1) is the range expression.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top