Skip to content

Verification parity between method and function. #5414

Answered by stefan-aws
rdivyanshu asked this question in Q&A
Discussion options

You must be logged in to vote

I suspect this has to do with i) triggers and ii) the such-that assignment :|. If you externalise the predicate in the quantifier, add {:trigger true}, and turn your function ghost to avoid having to prove the uniqueness of your choice, things work out:

ghost predicate P(p: (int, int), ss: set<(int, int)>, i: int, r: set<(int, int)>) {
    p in ss <==> (p.0 + i, p.1 + i) in r
}

method pairSetMap(ss: set<(int, int)>, i: int) returns (r: set<(int, int)>) 
  ensures forall p {:trigger true} :: P(p, ss, i, r)
  ensures |r| == |ss|
{
    if |ss| < 1 {
      r := set pair | pair in ss :: (pair.0 + i, pair.1 + i);
    }
    else { 
        var s :| s in ss;
        var t := pairSetMap(ss - {s},…

Replies: 1 comment

Comment options

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