Quantcast
Channel: Dafny: An Automatic Program Verifier for Functional Correctness
Viewing all articles
Browse latest Browse all 1106

New Post: Array to Sequence to Multisets and comparison

$
0
0
Hello, I am a student working on my MSc dissertation and I use dafny to specify a data structures/algorithms library. I am currently trying a Insertion sort implementation, and I am using the multisets in order to validate the permutation of my array, but I don't understand the behavior of the verifier for the following code:
class Test {
  method Main()
  {
    var arrInt := new int[5];
    arrInt[0] := 4;
    arrInt[1] := 3;
    arrInt[2] := 2;
    arrInt[3] := 1;
    arrInt[4] := 0;

    var m1 := multiset(arrInt[..]);
    var m2 := multiset([4,3,2,1,0]);
    assert m1 == m2; //The assertion is violated
  }
}
I am trying to check that the multiset m1, obtained from an array transformed in a sequence and then in a multiset (Maybe I'm doing this the wrong way) is the exact same than the multiset m2, obtained from a valid sequence (at least I think).

The debugger also give weird values for the multiset m1:
Image

Am I making a mistake somewhere or misunderstanding something ?

Many thanks
Alexis Chevalier

Viewing all articles
Browse latest Browse all 1106

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>