Counterexamples involving seqs should present elements ordered by index #2975
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm working on debugging a particular counterexample involving a sequence (at least in theory - hence the debugging!) of contiguous intervals, like
[(0, 4), (5, 9), (10, 20)]
. In this case, figuring out where I'm going wrong really means needing to look at sequence elements in the order that they appear. This is the counterexample I'm given (extracted to the clipboard with this IDE patch):The particulars of the counterexample aren't of interest, save the indices that Boogie/Z3 generates for me in the sequence itself. Only after awhile did I notice that the sequence in the counterexample is actually out of order:
@1
's indices are0, 6285, 6283, 6284
(Either it's a coincidence or Boogie is giving us the initial and final elements first?). I would have expected those indices to be in ascending order (i.e.0, 6283, 6284, 6285
) and would expect the intermediate subexpressions to be ordered similarly.This patch modifies how the Dafny model expands element variables so that index-by-index sequence generation is sorted:
I'm not exactly sure of the current behaviour in the "build operator" case, and so I left that code branch unmodified.
(While I was in there, I found an incorrect docstring in an unrelated function related to passing null as an argument, and correspondingly fixed that.)
Fixes #
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.