-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dafny 4.0 suggestion: Remove automatic compile-time filtering of subset types #2339
Comments
type N = x : int | x > 0
type T = x: int | ....
predicate method p(t: T)
function method f(n: N): Int
method f() {
var setOfT: set<T> = ...;
var x := set y: T | y in setOfT && p(y) :: f(y as N)
} Aren't you missing a |
Yes, updated |
I think in general requiring the extra
I would avoid thinking of it this way. I strongly prefer saying that a symbol has a single type. The wrinkle is just that Dafny will sometimes allow you to use the symbol in a context that requires a more specific type. It is a kind of "automatic, statically-verified downcasting" that is only allowed if the required proof obligation is verified. You are just making the argument that this can sometimes be confusing - I definitely agree with that (case in point: #2551) so I'm in favour of of this. In particular it seems to imply supporting |
As a conclusion to #1702
Basically, we can currently write:
and
This has the effect of actually implicitly emitting the condition
x > 0
as part of the loop that build the set.However, this kind of "automatic code generation" has some problems:
y
in the range (where it has to be assumed to be a T) and the term (where it can be assumed to be a N, because the compiler will emit the check). This makes reasoning about the code difficult, becausey
has two types.Proposal
In this proposal, we would remove the compiler-generated code, and:
int
in the example above), but not having two subset types.as N
where N is the subset type, so that we can verify it.Thus, we would have:
and
which enables T and N to be ghost subset types, because
p
is compiled and can help to prove thaty
is aN
anyway.The text was updated successfully, but these errors were encountered: