Complete this form and hit the "Save Changes" button!
No ratings
Are you sure you want to delete this code? Please type DELETE in the box below to confirm.
Are you sure you want to verify this code?
Are you sure you want to publish this code?
Are you sure you want to unpublish this code?
Are you sure you want to autogenerate the summary + description for this code?
xxxxxxxxxx
// RUN: /print:log.bpl
method ArrayMap<A>(f: int -> A, a: array<A>)
requires a != null
requires forall j :: 0 <= j < a.Length ==> f.requires(j)
requires forall j :: 0 <= j < a.Length ==> a !in f.reads(j)
modifies a
ensures forall j :: 0 <= j < a.Length ==> a[j] == f(j)
{
var i := 0;
while i < a.Length
invariant 0 <= i <= a.Length;
invariant forall j :: 0 <= j < i ==> a[j] == f(j)
a[i] := f(i);
i := i + 1;
}
/*method GenericSort<A>(cmp: (A, A) -> bool, a: array<A>)
requires forall x, y :: a !in cmp.reads(x, y)
requires forall x, y :: cmp.requires(x, y)
ensures forall x, y :: cmp.requires(x, y)
ensures forall x, y :: 0 <= x < y < a.Length ==> cmp(a[x], a[y])
var j := i - 1;
while j >= 0 && !cmp(a[j], a[i])
a[i], a[j] := a[j], a[i];
j := j - 1;
}*/