【发布时间】:2020-05-31 07:21:30
【问题描述】:
下面的代码,也在https://rise4fun.com/Dafny/I4wM,
function abst(bits: array<int>,low:int,high: int): int
requires 0<=low<=high<=8
requires bits.Length==8
decreases high-low
reads bits
{ if low==high
then 0
else 2*abst(bits,low+1,high) + bits[low]
}
method M() {
var byte: int;
var bits:= new int[8];
bits[0]:= 1;
bits[1]:= 1;
bits[2]:= 1;
bits[3]:= 1;
bits[4]:= 1;
bits[5]:= 1;
bits[6]:= 1;
bits[7]:= 1;
// assert abst(bits,2,2) == 0; // Why is this needed?
assert abst(bits,0,2) == 3;
}
无法验证最后一行的断言。 (我使用的是 Rise4Fun 的在线 Dafny。)如果前面的断言未注释,则验证成功。
我将不胜感激。谢谢!
【问题讨论】:
标签: verification assertion dafny