-
Notifications
You must be signed in to change notification settings - Fork 67
fix(phl): emit the non-negativity of the bound as a separate goal in rnd (on #1105)
#1135
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
Open
Yiping106283
wants to merge
1
commit into
EasyCrypt:main
Choose a base branch
from
Yiping106283:fix-phoare-rnd-nonneg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122
−34
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| (* pHL `rnd` with an upper bound (upstream #1119): the bound check is lifted | ||
| into the post-condition of a hoare judgment on the statements preceding | ||
| the sampling, which only constrains their terminating runs. The rule must | ||
| also require the bound to be non-negative; under #1105 a pHL judgment | ||
| with a bound that is negative in some memory is false, so that goal is | ||
| quantified over all memories, unconditionally: after the ordinary goal, | ||
| `0%r <= -1%r` must remain and must be unprovable. *) | ||
| require import AllCore Distr. | ||
|
|
||
| module M = { | ||
| proc f() : unit = { var x : int; while (true) { } x <$ dunit 0; } | ||
| }. | ||
|
|
||
| lemma bad : phoare[M.f : true ==> true] <= (-1)%r. | ||
| proof. | ||
| proc. | ||
| rnd (fun (_ : int) => true). | ||
| + by while (true); auto. | ||
| (* remaining goal: forall &hr, 0%r <= -1%r *) | ||
| move=> &hr. | ||
| fail (by smt()). | ||
| abort. | ||
|
|
||
| (* Same with the event inferred from the post-condition. *) | ||
| module N = { | ||
| proc f() : int = { var x : int; while (true) { } x <$ dunit 0; return x; } | ||
| }. | ||
|
|
||
| lemma bad' : phoare[N.f : true ==> res = 0] <= (-1)%r. | ||
| proof. | ||
| proc. | ||
| rnd. | ||
| + by while (true); auto. | ||
| (* remaining goal: forall &hr, 0%r <= -1%r *) | ||
| move=> &hr. | ||
| fail (by smt()). | ||
| abort. | ||
|
|
||
| (* Loop-free: the prefix terminates, but the bound is still negative. *) | ||
| module L = { | ||
| proc f() : unit = { var y : int; var x : int; y <$ dnull; x <$ dunit 0; } | ||
| }. | ||
|
|
||
| lemma bad'' : phoare[L.f : true ==> true] <= (-1)%r. | ||
| proof. | ||
| proc. | ||
| rnd (fun (_ : int) => true). | ||
| + by auto=> /> y; rewrite supp_dnull. | ||
| (* remaining goal: forall &hr, 0%r <= -1%r *) | ||
| move=> &hr. | ||
| fail (by smt()). | ||
| abort. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 have a preference for the old comment which was clearer to me :