-
Notifications
You must be signed in to change notification settings - Fork 235
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
Proposal for making un-annotated effectful top-level functions sane again #1055
Comments
Interestingly, this also works:
… but not this:
|
I should have clarified that of course this works as expected:
And so does this, for a different reason:
|
This kind of Pollack inconsistencies (e.g. #143, #581, #853) have been plaguing F* since its very beginnings, but things have been slowly getting better (e.g. purity is now the default most of the time). No proof of false here, just a very bad, recurring usability issue. How to Believe a Machine-Checked Proof. Robert Pollack Pollack-inconsistency. Freek Wiedijk
|
Is that better than defaulting to |
@nikswamy We've been staring in Paris at one more disturbing example of this kind:
We all found this very confusing. It took a while for us to realize that the difference between cases 1,3 and case 2 is caused by the fact that for pure things the default is We think that the best solution for this would be to require valid preconditions everywhere by default, but have some way to explicitly ask F* to compute a wp. Clement is suggesting a syntax like this:
(which currently of course doesn't work since it's not type inference that should be filling the hole ... but this is just concrete syntax, anything like this would do) Anyway, being able to explicitly ask F* to infer wps would still be very useful, so we're not big fans of requiring all top level definitions to be fully annotated. PS: Another confusing thing here is that we were expecting (lax) type-checking to be more restrictive than ML type-checking for the same code, but in this case it's definitely not, in a way that interacts badly with parametricity too: the preconditions inferred for cases 1,3 are (at least intuitively) equivalent to |
This issue is still there. So here's a crisper summary of the proposal here:
|
For the record, as I'm sure you intended, this isn't specific to Recall that we used to have a notion of a default for each effect. e.g., For (2), that should work, with the caveat that inference is unlikely to work except when using an irreducible effect label. For instance, if you wrote |
In the current state of the code, it is quite hard to support the @nikswamy suggested another way to solve the issue. For top-level, unannotated, effectful functions, we infer their wps, as we do right now, but additionally check that they have a trivial precondition. This gives us best of both the worlds -- surprises like For example, this works:
While this fails:
with In addition, collecting examples from the comments above, all of the following fail (look for
What do you think? cc @cpitclaudel @catalin-hritcu, @s-zanella, @kkohbrok |
I'd prefer to always require full annotation for top-level effectful definitions, but @aseemr's proposal is a good compromise. |
I like this still much better than requiring annotations everywhere. Just to make sure I understand, compared to our original proposal, it's giving us 1 (and 3) but without the 2, right? And if some people really like self-imposed discipline, maybe we can add a flag to make top level annotations required? --discipline? :) |
@catalin-hritcu, yeah (1) and (3), but no (2). |
The proposal from my last comment is implemented in F* master, here are the testcases: https://github.com/FStarLang/FStar/blob/master/examples/bug-reports/Bug1055.fst. Closing the issue, please reopen if needed. |
The following code typechecks and extracts fine:
The problem is that
g
is missing aval
annotation; printing the resulting term makes more sense:But still, this looks really fishy. What's this large inferred term doing in there, and why is that comment not reported as an error instead? And why isn't
Tot
inferred since I didn't specify an effect explicitly?I ran into this when I replaced the
checkedWrite
call in the tutorial by a call to an uncheckedwrite
, expecting the code to stop typechecking:The text was updated successfully, but these errors were encountered: