-
Notifications
You must be signed in to change notification settings - Fork 63
fix(fel): require per-step weights non-negative over the counter range #1096
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
namasikanam
wants to merge
1
commit into
main
Choose a base branch
from
fix/fel-counter-weight
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.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| (* Regression for the `fel` counter-jump / negative-weight bug. | ||
|
|
||
| The failure-event lemma tactic used to accept a counter that JUMPS (skipping | ||
| indices) combined with NEGATIVE per-step weights at the skipped indices. The | ||
| full-range weight sum could then be made smaller than the sum over the | ||
| counter values actually visited, letting `fel` "prove" Pr[bad] <= 0 for an | ||
| event that in fact happens with probability 1. | ||
|
|
||
| Here the counter jumps 0 -> 2 (index 1 is never visited) and the weight | ||
| ash = (fun x => if x = 0 then 1 else -1) is negative at the skipped index 1, | ||
| giving whole-range sum 1 + (-1) = 0. | ||
|
|
||
| The fixed tactic emits an extra obligation `forall i, 0 <= i < q => 0 <= ash i` | ||
| (unprovable here since ash 1 = -1). The old discharge script covers only the | ||
| original goals, so the whole `by fel ...` closing must now fail. *) | ||
| require import AllCore List Distr DBool FelTactic StdBigop. | ||
| (*---*) import Bigreal. | ||
| (*---*) import List.Range. | ||
|
|
||
| module M = { | ||
| var bad : bool | ||
| var c : int | ||
|
|
||
| proc o() : unit = { if (c = 0) { bad <- true; c <- 2; } } | ||
| proc f() : unit = { bad <- false; c <- 0; o(); } | ||
| }. | ||
|
|
||
| lemma pr_le0 &m : Pr[M.f() @ &m : M.bad] <= 0%r. | ||
| proof. | ||
| fail (by fel 2 M.c (fun x => if x = 0 then 1%r else (-1)%r) 2 M.bad [M.o : (M.c = 0)] (0 <= M.c /\ M.c <= 2); | ||
| [ (have -> : range 0 2 = [0; 1] by rewrite range_ltn // range_ltn // range_geq //); | ||
| rewrite BRA.big_cons BRA.big_cons BRA.big_nil /predT /= | ||
| | move=> &hr; smt() | ||
| | auto | ||
| | proc; rcondt 1; auto | ||
| | move=> c0; proc; auto=> /# | ||
| | move=> b0 c0; proc; auto=> /# ]). | ||
| 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.
The comments in the old easycrypt code refer to the LLM artifact "F003".
The comment in the regression test is mostly fine, though a bit verbose.
The comment in
ecPhlFelis good.