original.name="Reference_Valid_29" boogie.block=true ====== >>> main.whiley // Reverse a linked list type LinkedList is null | &{ T data, LinkedList next } property equiv(LinkedList l, int i, T[] items) -> (bool r): return (i < |items| && !(l is null) && l->data == items[i] && equiv(l->next,i+1,items)) || (i == |items| && l == null) method reverse(LinkedList v) -> (LinkedList r): // LinkedList w = null // while !(v is null): LinkedList t = v->next v->next = w w = v v = t // return w public export method test(): LinkedList l1 = null LinkedList l2 = new { data: 2, next: l1 } LinkedList l3 = new { data: 3, next: l2 } // Sanity check assert equiv(l3,0,[3,2]) // Apply the reverse LinkedList l4 = reverse(l3) // Assert reversal assert equiv(l4,0,[2,3]) --- ===== >>> main.whiley 5:7 if i < |items| && !(l is null): return l->data == items[i] && equiv(l->next,i+1,items) else if i == |items|: return l == null else: return false ---