Hi,
I have some "reads" and "termination" errors for the following code (http://rise4fun.com/Dafny/zHqA):
What did I miss here ?
Thanks in advance.
best,
Yuhui
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