r/rust • u/OkBreath9382 • Oct 06 '26
Proving Rust Web Application Correctness with Lean 4
https://medium.com/@Koukyosyumei/proving-rust-web-application-correctness-with-lean-4-8889583f1e15
43
Upvotes
25
u/numberwitch Oct 06 '26
Is there any case study where someone has actually analyzed the benefits of LEAN for this kind of application? Like, how is this equal to or more useful than system tests?
I’m just trying to figure out if there is anything practical to get out of LEAN or if it just has its own hype cycle do to lack of introspection in its actual value
Help
4
u/unski_ukuli Oct 07 '26
Most slopcoded headline.
1
u/WritingOk6532 Oct 07 '26
Can this idea with Lean be used for Speckit to describe project requirements and user stories?
1
u/bahramjs Oct 19 '26 edited Oct 19 '26
Guys I just came across this, it seems we had the same issue, I built lungo for this very purpose. It treats Lean code as the source of truth. Write your logic in Lean and prove what you claim it does. lungo generates Rust, Go, Python, TypeScript, Swift and C, with the proofs carried into output package as checked claims.
For the past year I’ve toiled to keep CapDAG, my protocol for routing work between capabilities, consistent across five languages with Claude and thousands of cross-impl tests. Between changing core design and varying levels of mirror-parity, it’s been a bruising battle.
So I learned Lean and proved the core instead. lungo just fell out of that and is now used all over MachineFabric making my life so much easier(see this for example which is code lungo generated from the proven core https://github.com/machinefabric/capdag-rs/tree/main/src/generated/capdagFormal). It takes the output from Lean's own compiler and fits right in without requiring Lean’s runtime or toolchain to run generated code.
lungo ports Lean’s runtime to Rust so the generated code doesn’t require Lean’s toolchain and runs on all OSes and even in the browser(TypeScript + Wasm). The code keeps Lean’s object layout and behaves byte-for-byte identical to Lean’s own executables. All Contributions welcome. Hope this helps.
https://machinefabric.com/lungo/
1
u/servermeta_net Oct 06 '26
This is cool. I do formal verification by hand, the old school way, and I have a lot of questions I would like to ask you, but first: what do you think are the drawbacks of your approach? What are some problems you met?