You seem to understand the basic idea behind the loop invariants, which is needed to test programs using Dafny.
. - Dafny IDE Visual Studio. ( c), , , , s[c] s[m]. , , .
, . , Dafny, :
s[c], s[m] := s[m], s[c];
. -, :
assert forall k :: 0 <= k < c ==> s[k] <= s[m];
s[m] - , , - . :
invariant forall k, l :: 0 <= k < c <= l < a.Length ==> s[k] <= s[l];
, , sorted(s,c) , , sorted , , . , , . , selectionsort , ,
forall k, l :: 0 <= k < l < a.Length ==> a[k] != a[l];
( ) selectionsort. , , sorted, a[k] > a[m] a[k] >= a[m].
, assert t. m , m , FindMin, , c-1 <= m <= s.Length . decreases ; Dafny . , selectionsort , a out-parameter s; out s a .