问题
The Dafny documentation doesn't go through using 'exists' quantifiers.
method Main() {
assert (exists n: int :: n > 1);
}
This comes up with an AssertionError
回答1:
The following works:
predicate dummy(n: int) {true}
method Main() {
assert dummy(2);
assert (exists n : int {:trigger dummy(n)} :: n > 1);
}
You can replace dummy(2)
with dummy(m)
for any integer m > 1
.
This answer isn't great, since I can't tell you exactly why the above works. However, for more information on triggers you can read this.
来源:https://stackoverflow.com/questions/58315561/how-to-use-exists-quantifier