【发布时间】:2018-11-01 07:59:49
【问题描述】:
在以下方法中,Dafny 报告后置条件可能不成立,尽管我很确定它确实成立。
method toArrayConvert(s:seq<int>) returns (a:array<int>)
requires |s| > 0
ensures |s| == a.Length
ensures forall i :: 0 <= i < a.Length ==> s[i] == a[i] // This is the postcondition that might not hold.
{
a := new int[|s|];
var i:int := 0;
while i < |s|
decreases |s| - i
invariant 0 <= i <= |s|
{
a[i] := s[i];
i := i + 1;
}
return a; // A postcondition might not hold on this return path.
}
【问题讨论】:
标签: verification dafny