Formal Verification - Lean4 Integration#7786
Open
ivan-randjelovic-cp wants to merge 10 commits into
Open
Conversation
Signed-off-by: Ivan Randjelovic <ivan@commonprefix.com>
Signed-off-by: Ivan Randjelovic <ivan@commonprefix.com>
Signed-off-by: Ivan Randjelovic <ivan@commonprefix.com>
Signed-off-by: Ivan Randjelovic <ivan@commonprefix.com>
Signed-off-by: Ivan Randjelovic <ivan@commonprefix.com>
# Conflicts: # cmake/XrplSettings.cmake
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
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 pull request showcases Lean 4 formal verification framework. In it we demonstrate what formal verification of a small part of
xrpldlooks like: less-than Number operator.Of course, alongside this one function we had to bring in the entire build process and scaffolding to have FFI unit tests (tests verifying that Lean 4 implementation is faithful to C++).
Our goals with this integration is to provide formal verification without a huge overhead for C++ software engineers. The FFI unit tests will only cover crucial aspects of the formally verified codebase that should not change often.
Here is our recommendation on how to navigate this pull request:
docs/formal-verification/README.mdis a good starting point in which we explain the motivation and technical details of implementing Lean 4 intoxrpldIf you are a person of action rather than a reader of markdowns, you may want to look into the files directly:
external/lean4-depsandexternal/lean4introduce Conan recipes to install Lean 4 dependencies. These are entirely optional and can be enabled with with the build option-o formal_verification=Trueonconan install.cmake/made changes to XrplCore.cmake, XrplSettings.cmake, and introduced XrplLean4.cmake let you build Lean 4 models and FFI unit tests with cmake option-Dformal_verification=ON(which requires-Dxrpld=ON -Dtests=ON).formal_verification/XRPL/Modelis how the code is modeled in Lean 4.formal_verification/XRPL/FFIcontains functions that expose Lean 4 to C++.formal_verification/XRPL/Propertiescontains theorems and proofs.The one proof you should start with is in:
formal_verification/XRPL/Compare.lean. This theorem depends on some other theorems and lemmas, which will be encapsulated inCommondirectories. Because this PR represents a part of a bigger picture, we left those helper theorems separated - but in reality they are reused by other theorems.Finally, we direct you to look at:
docs/formal_verification/lean4.mdThis document is a crash-course in Lean 4 and might make it easier for you to read Lean 4 code. Fair warning: it might also get you to stay up at night reading about type theory and studying proofs and tactics!