You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RustanLeino opened this issue
Nov 28, 2019
· 0 comments
Labels
kind: enhancementEnhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafnypart: verifierTranslation from Dafny to Boogie (translator)
The current encoding of function values in the verifier only expands a function value to its definition if the static types involved in its application are exactly as in the original function definition. This means that, if Y is a subset type of X, then a function of type X -> int cannot be used in a context that expects a Y -> int.
The following repro illustrates:
function Apply<T>(x: T, f: T -> int): int {
f(x)
}
function F(x: int): int {
x
}
lemma Test() {
assert Apply<int>(4, F) == 4; // this is verified
assert Apply<nat>(4, F) == 4; // this reports an error
}
Internally, the axiom about the function value F (which is called F#Handle in the Boogie encoding) has the form (where Apply1 is a function introduced by Dafny in the Boogie encoding to apply arity-1 function handles):
Note the parameters TInt, which make this axiom useless when these types are applied as something else. A better encoding would leave flexibility in these parameters or, ideally, leave those type parameters out altogether among the arguments to Apply.
The text was updated successfully, but these errors were encountered:
kind: enhancementEnhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafnypart: verifierTranslation from Dafny to Boogie (translator)
The current encoding of function values in the verifier only expands a function value to its definition if the static types involved in its application are exactly as in the original function definition. This means that, if
Y
is a subset type ofX
, then a function of typeX -> int
cannot be used in a context that expects aY -> int
.The following repro illustrates:
Internally, the axiom about the function value
F
(which is calledF#Handle
in the Boogie encoding) has the form (whereApply1
is a function introduced by Dafny in the Boogie encoding to apply arity-1 function handles):Note the parameters
TInt
, which make this axiom useless when these types are applied as something else. A better encoding would leave flexibility in these parameters or, ideally, leave those type parameters out altogether among the arguments toApply
.The text was updated successfully, but these errors were encountered: