Skip to content
Discussion options

You must be logged in to vote

Well, apparently I should have read this Zulip thread that I linked in my related posts section more carefully, because it actually contained the solution.

Solution

When allocating each object in counters I need to remind Dafny that it's a freshly allocated object--i.e., each Counter was freshly allocated inside of the Impl method. Here is version of my problem that verifies correctly:

method Impl2()
{
  var counters: seq<Counter> := [];

  for i := 0 to 10
    invariant |counters| == i
    // Inform Dafny that each Counter is freshly allocated
    invariant forall j | 0 <= j < i :: fresh(counters[j])
  {
    var c := new Counter();
    counters := counters + [c];
  }

  // This assertion…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nwad123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant