Lean backend [M2] - 1/3 - First proofs#1590
Conversation
maximebuyse
left a comment
There was a problem hiding this comment.
Generally looks good. I added a couple of comments. Didn't look too deeply into the lean code but it seems nice and well-documented.
c655c6b to
0176e01
Compare
karthikbhargavan
left a comment
There was a problem hiding this comment.
I reviewed the library and the proofs, they look good.
There is a small amount of Rust changes here, worth a quick look.
jschneider-bensch
left a comment
There was a problem hiding this comment.
I've left some comments, mostly questions for my understanding.
|
Thank you for the review. I've answered to your comments @jschneider-bensch: I've left some unresolved so you can confirm that it works for you. |
jschneider-bensch
left a comment
There was a problem hiding this comment.
With the changes coming in the follow up PRs, this looks good to me.
A small request for the future: If there's a chain of PRs with earlier ones introducing temporary fixes or constructs, it would help me if there were comments referencing the work/issues that will address the temporary things. That would make it easier for me to review the PRs on their own.
This PR contains a first set of improvements of the Lean backend, made towards the proof of the
barrettandchacha20examples. The second set of improvements relies on visitors and is separated #1591. The example proofs are in #1593Context
This PR follows #1509 and improves the Lean backend for Hax. It should still be considered experimental, and might be subjected to change in the future. The effort of this PR was mainly focused on improving the Lean prelude library for proofs, rather than extending the subset of rust supported by the Lean backend.
While the
F*backend of Hax relies on an intrinsic proof style (via the pervasive use of the SMT), theLeanbackend uses (1) an extrinsic style, achieved via (2) a monadic encoding. In other words, (1) the proofs are written separately from the definitions and (2) the extracted rust code is wrapped in aResultmonad to represent the fact that rust computations are actually partial (they can panic), unlike Lean ones.Example
Barrett reduction
The Barrett reduce function is extracted as :Its specification can be written as the following Hoare triple:
where
__requiresand__ensuresare extracted from the hax attributes in the rust code.Details
Resultmonad and error cases are borrowed from the Aeneas projectmvcgentactic, recently added to LeanGoals
folds(for loops)Lean.libfile[ ] ExamplesMoved to Lean backend [M2] - 2/3 - Examples #1593hax_machine_int_addis replaced by+?(other resugaring will be done with visitors)#[hax_lib::lean::..]attributes in Rust