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

New Post: "reads" and "termination" errors

$
0
0
Hi,

I have some "reads" and "termination" errors for the following code (http://rise4fun.com/Dafny/zHqA):

class Tree{ 
    var left : Tree;
    var right : Tree;
    var val : int;

    ghost var repr: set <object>;

  function Valid(): bool
    reads this, repr;
  {
    this in repr &&
    ((left == null && right == null) ||
    (((left != null) ==> (left.repr < repr && this !in left.repr && left.Valid())) &&
    ((right != null) ==> (right.repr < repr && this !in right.repr && right.Valid()))
    ))
  }
}
i.e. on line
    (((left != null) ==> (left.repr < repr && this !in left.repr && left.Valid())) &&
and
    ((right != null) ==> (right.repr < repr && this !in right.repr && right.Valid()))
However, if I add "left in repr" and "right in repr", these errors go away. These two are, in my mind, logically redundant, as "left in repr" can be inferred by "left.repr < repr" and "left in left.repr".

What did I miss here ?

Thanks in advance.

best,
Yuhui

Viewing all articles
Browse latest Browse all 1106

Trending Articles



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