【发布时间】:2021-05-25 23:59:17
【问题描述】:
我想在数组上使用高阶 Count(P) 函数,例如:
Count(even, a),或Count(higher_than_10, a),其中第一个参数是谓词,第二个参数是数组。
也就是说,计算这个 P 命题在一个数组上出现了多少次。
Dafny 有办法做到这一点吗?我认为这种函数是存在的,但可能它们的语法已经改变了。
谢谢
我已经看过了:
-https://stackoverflow.com/questions/35167124/dafny-and-counting-of-occurrences
-https://stackoverflow.com/questions/51379857/polymorphism-in-dafny
-https://gitter.im/dafny-lang/community?at=5d90c402086a72719e848f24
-https://www.imperial.ac.uk/events/104961/higher-order-functions-in-the-verification-aware-programming-language-dafny-k-rustan-m-leino/
【问题讨论】:
-
它不是内置的,所以你必须自己定义它。你问怎么定义?
标签: arrays count predicate higher-order-functions dafny