Open
Description
Created by @mschwerhoff on 2016-02-15 20:15
Last updated on 2016-02-15 22:23
The postcondition of test02
fails in Silicon and Carbon if the assertion in the body is commented.
#!text
function zip(xs: Seq[Ref], ys: Seq[Ref]): Seq[Ref]
requires |xs| == |ys| || |xs| == |ys| + 1
{
(ys == Seq[Ref]())
? xs
: Seq(xs[0], ys[0]) ++ zip(xs[1..], ys[1..])
}
method test02(xs: Seq[Ref], ys: Seq[Ref], x: Ref, y: Ref)
requires xs == Seq(x)
requires ys == Seq(y)
ensures Seq(x, y) == zip(xs, ys) // Fails w/o A1
{
assert zip(xs, ys) == Seq(x, y) ++ zip(xs[1..], ys[1..]) // Required (A1)
// assert zip(xs, ys) == Seq(x, y) ++ zip(Seq[Ref](), Seq[Ref]()) // Fails w/o A1
}