-
Notifications
You must be signed in to change notification settings - Fork 45
Lean backend [M2] - 2/3 - Examples #1593
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
Conversation
8396fd3 to
1f368bb
Compare
5f850a6 to
85ae109
Compare
karthikbhargavan
left a comment
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.
We reviewed the proofs together last week and they look great.
This is mainly a Lean PR and shouldn't require much Rust review.
1960006 to
65f3961
Compare
|
I'm looking into the nix issue Edit: I got no much time to look at it, let's postpone this. |
W95Psp
left a comment
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.
Thanks! I've been the code, it looks nice to me!
I checked the lean_barrett example, it works fine on my laptop :)
Co-authored-by: Lucas Franceschino <[email protected]>
|
🎉 CI is happy |
836eef5 to
e1686c6
Compare
|
I've rebased to squash the commits about CI, and will merge as soon as it passes. |
This PR is a follow-up of #1590. It introduces two specific examples to showcase the lean backend in
examples/lean_barrettandexample/lean_chacha20. For both, the lean extraction can be obtained by runningcargo hax into leanBarrett
The Barrett reduction allows to compute remainders without using divisions. It showcases arithmetic operations, conversions between integer types (namely
i32andi64). Specifically, the Lean backend provides panicking arithmetic operations+?,-?, etc, that panic on overflows.For the Lean extracted code, we prove panic freedom with regards to those arithmetic operations, and then we prove that the result is indeed the modulus (as long as the absolute value of the input is lower than the bound
BARRETT_R). The proof is made via bit-blasting (using Lean'sbv_decide). To limit the computation time, the boundBARRETT_Rwas lowered compared to the normal example in thebarrettfolder.The proofs are backported in the rust code (in
lean_barrett/src/lib.rs): doingcargo hax into leanextracts a valid lean file that contains the proof.Chacha20
The Chacha20 example extracts to Lean, but requires a manual edit to be wellformed (will be removed via resugarings #1591). It showcases array, vector and slices accesses, as well as loops (with loop invariants).
For the Lean extracted code, we prove panic freedom. It is not backported in rust yet.
This edit and the proofs of panic freedom can be found in
lean_chacha20/proofs/lean/extraction/lean_chacha20_manual_edit.lean.