Conversation
12 tasks
8396fd3 to
1f368bb
Compare
5f850a6 to
85ae109
Compare
karthikbhargavan
approved these changes
Aug 11, 2025
Contributor
karthikbhargavan
left a comment
There was a problem hiding this comment.
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
Contributor
|
I'm looking into the nix issue Edit: I got no much time to look at it, let's postpone this. |
W95Psp
approved these changes
Aug 19, 2025
Contributor
W95Psp
left a comment
There was a problem hiding this comment.
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 <lucas@cryspen.com>
Contributor
|
🎉 CI is happy |
836eef5 to
e1686c6
Compare
Contributor
Author
|
I've rebased to squash the commits about CI, and will merge as soon as it passes. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.