问题
In the Dafny code below the var notUsed := t;
line seems redundant as notUsed is, as the name suggests, not used. But, with out this line the var e :| e in t
line becomes not unique. Why has this assignment changed the uniqueness?
predicate setIsSeq<T>(t : set<T>, q : seq<T>)
{ (|t| == |q|) ==>
(forall i :: (0 <= i < |q|) ==> (q[i] in t)) &&
(forall x :: x in t ==> (x in q))
}
function method fSetToSeq<T>(t : set<T>) : (r : seq<T>)
decreases t
ensures setIsSeq(t,r);
{
var notUsed := t;//with out this var e:|e in t; is not unique
if (|t| == 0) then []
else (
var e :| e in t;
var tx := t - {e};
var qx := fSetToSeq(tx);
[e] + qx //part of the var e:|e in t expression and is unique
)
}
回答1:
This is a bug. Please report it on github: https://github.com/dafny-lang/dafny/issues
来源:https://stackoverflow.com/questions/63916646/what-is-the-relation-between-dafnys-hilbert-epsilon-operator-and-apparently-red