-
Notifications
You must be signed in to change notification settings - Fork 108
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
Improve corres
rules whileLoop
#650
Conversation
ce4e9fb
to
3d50d01
Compare
Sorry, forced pushed to correct the commit message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having spent a bit of time poking that compare time while loop, this improvement makes a lot of sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, much nicer rules! Minor style nitpicks only.
lib/ExtraCorres.thy
Outdated
and body_inv: "\<And>r. \<lbrace>P r and C r\<rbrace> B r \<lbrace>\<lambda>r. P r\<rbrace>" | ||
"\<And>r'. \<lbrace>P' r' and C' r'\<rbrace> B' r' \<lbrace>\<lambda>r'. P' r'\<rbrace>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm undecided myself, but could using rv
in these postconditions to distinguish from the bound r
improve readability? I guess a potential concern is that it could also be confused with the final return value of the whole loop.
and body_inv: "\<And>r. \<lbrace>P r and C r\<rbrace> B r \<lbrace>\<lambda>r. P r\<rbrace>" | |
"\<And>r'. \<lbrace>P' r' and C' r'\<rbrace> B' r' \<lbrace>\<lambda>r'. P' r'\<rbrace>" | |
and body_inv: "\<And>r. \<lbrace>P r and C r\<rbrace> B r \<lbrace>\<lambda>rv. P rv\<rbrace>" | |
"\<And>r'. \<lbrace>P' r' and C' r'\<rbrace> B' r' \<lbrace>\<lambda>rv'. P' rv'\<rbrace>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The situation is quite tricky with these whileLoop
s. There is the (blue) initial value given to the whileLoop
(you can see an example of this in the conclusion of the statement of corres_whileLoop_ret
). Then there is the (green) return value given by the loop body. I think it would be nicer to stick with the r
for here, to reinforce that connection. But happy to discuss it some more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other alternative for these valid
bits is that I could just eta contract the postcondition. I left it written out to emphasise that these guards do talk about the return value, but maybe that's clear enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would usually prefer the eta-contracted version unless we're trying to do the bound-name preservation trick where Isabelle would replace rv
with whatever name was in the goal (which is not the case here).
Also, most of these lemmas use the |
I thought it would do this:
hmm. |
I usually avoid the
The |
164fe2d
to
78ba96f
Compare
Signed-off-by: Michael McInerney <[email protected]>
Signed-off-by: Michael McInerney <[email protected]>
78ba96f
to
7170ef1
Compare
Please see the commit message for a brief explanation