-
Notifications
You must be signed in to change notification settings - Fork 30
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
[CN] Misleading warning on necessary use of extract
#498
Comments
The way that extract works is that it marks a particular index as valid to move in or out of the iterated resources of the matching type in the context. I thought "movable" would have been clearer a while back but I failed to convince others. The actual issue with the warning here is a bit silly. Usually we say extract because we want to break an element off an array. But in this case we need to say extract because we need to glue it back on, to a different array & type it came from. AFAIR, the warning checks for the first case but not the second, and this confusing example should disappear if it also checked for the second. There is no up/down casting of resources going on - it's literally just that "Block" means "may be uninitiatialised, so only write, no reads" and once you write to a block you know you are definitely initialised and so you may read and write "Owned". We used to infer indexes, and it lead to a complicated and slow inference scheme. I agree we can and should infer more, but it's an area of research. Having used both the old and current, I can say that the predictability and speed of this is much more preferable especially in terms of explaining (I can show you a formalisation of the old inference rules!). It was also the old scheme of inferring indices which required the first argument of every predicate to be a pointer. TL;DRExtract does not move resources, but marks them as movable in or out of iterated resources. Currently the code is "if resource not moved out then warn", but it should be "if neither resource moved out OR moved in then warn". |
...
The CN tutorial has an issue where we've been discussing renaming I recorded that as a new issue also in the Cerberus repository ( #499 ). Regarding the warning: the warning ocasionally provides useful output, but I'm tempted to remove it altogether, because it doesn't reflect well how The reason for making |
Thanks for looking at this. I was also puzzled with the second extract Owned was after the indexing statement. |
Thanks @dc-mak and @cp526 - this is indeed rather subtle, and I wish we could avoid the need for it in proofs.
I am not sure about this. I often make mistakes when writing |
It seems to me like often the correct argument to
This seems better than adding additional proof search to figure out |
@septract One very easy change that would obviate As I recall, one concern you previously mentioned about this scheme was that, if users are not used to regularly doing I haven't thought much about what the gaps in the automation would be, though. |
@cp526 Yes, that's a good point too. But now that we are seeing that |
I've looked into this briefly. There's a two-line change that would implement what I described, but it creates an awkward gap between Owned+Block (automatically inferred The right way to do it, I think, is to link it with your earlier suggestion of giving |
This is the issue: #311 |
Problem: CN generates warnings implying that
extract
is redundant, when in fact theextract
is necessary for the proof.Example code (from a discussion with our friends at BAE):
CN produces this warning:
This is very misleading!
I think the reason this happens is that
extract
keyword does two things in CN:q.back
Owned<int>
If you try to prove this code, the 1st step does not occur, but the 2nd step does. That is, extract takes the
Block<int>
resource, and casts it to theOwned<int>
resource.Suggested resolution:
CN should correctly log that
extract
has up-cast a resource, and suppress the misleading warning.(Longer term, we should automatically infer most or all uses of
extract
).The text was updated successfully, but these errors were encountered: