utwente-fmt / vercors

The VerCors verification toolset for verifying parallel and concurrent software
https://utwente.nl/vercors
Mozilla Public License 2.0
56 stars 26 forks source link

Wand is not correctly documented. #1245

Open sakehl opened 2 months ago

sakehl commented 2 months ago

I was trying to write a simple example of wands, and the tutorial does not help at the moment: link

This example does work, so maybe we could replace it in the tutorial.

class LinkedList {
  int value;
  LinkedList next;

}

resource state(LinkedList l) = Perm(l.value, write) ** Perm(l.next, write) **
  (l != null ==> state(l.next)) ;

  requires l != null ** state(l);
  ensures l != null ** state(l);
int sum(LinkedList l) {
  int s = 0;
  LinkedList p = l;

  package state(p) -* state(l) {

  }

    loop_invariant state(p);
    loop_invariant state(p) -* state(l);
  while(p != null) {
    LinkedList old = p;
    unfold state(p);
    s = s + p.value;
    p = p.next;
    package state(p) -* state(l) {
      fold state(old);
      apply state(old) -* state(l);
    }
  }

  apply state(p) -* state(l);
  return s;
}
ArmborstL commented 1 month ago

Indeed, the tutorial was written for old VerCors, where wands were encoded into methods. PR #760 changed that, instead mapping VerCors wands to Viper wands, also modifying the syntax in the process. It seems that the wiki wasn't updated accordingly. Feel free to update the wiki :) Some notes: