crychic-dafny-acsl / sources /program_0029.dfy
neurips2026-crychic's picture
Upload anonymized CRYCHIC NeurIPS E&D dataset release
9d2cf97 verified
Raw History Blame Contribute Delete
311 Bytes
method SwapFirstAndLast(a: array<int>)
requires a.Length > 0
modifies a
ensures a[0] == old(a[a.Length - 1])
ensures a[a.Length - 1] == old(a[0])
ensures forall k :: 1 <= k < a.Length - 1 ==> a[k] == old(a[k])
{
var tmp := a[0];
a[0] := a[a.Length - 1];
a[a.Length - 1] := tmp;
}