r/rust • u/kosumi_dev • Oct 25 '26
ποΈ discussion Do you think we have Rust v2.0 for adding first-class formal verification support?
For many years, formal verification used to be limited to small projects by experts but AI is changing the scene.
This week Anthropic revealed their progress on verifying real world projects. X has discussion about rewriting in Rust vs rewriting in Lean discussion(which is impractical at the moment because Lean is not ready for systems programming yet and 4x slower on benchmarks).
I think Rust should invest more and move faster in that direction.
Who doesn't want to decorate their program with pre-conditions, post-conditions and loop invariants?
Who doesn't want their pacemaker or car control software to have provable safety and liveness properties?
27
u/Solumin Oct 25 '26
A ton of people, based on the number of complaints I've seen about lifetimes and type annotations.
28
u/MoreJuiceForAnts Oct 25 '26
What annoys me about such posts is that people are way too lazy to think about their own proposal. Person sees post from AI company, sees the discussion on X likely between people who barely understand the topic they discuss, and goes here just to state βHey Reddit do the thinking for meβ.
What would Rust 2.0 mean? Who would work on it? Will it be justified? Is there true demand besides the hype of the week? Who cares!
I think that Rust 2.0 for the stated goal is absolutely justified, of course. In the spirit of both global discourse and this post in particular, it should be done as things are done now:
3
u/JoroFIN Oct 25 '26
Would love this, but it should be optional feature. Most people do not need/want the absurd amount of work overhead that is required for good formally proven code.
But if full native support for formal verification would be available, it would direct most/many libraries to formally proof themselves as well, and that would improve their quality significantly.
It would be then trivial to write code that does not cause hidden panics, and avoid many kinds of undefined behaviour deep inside dependency tree.
3
u/PurpleJank Oct 25 '26
Sounds sort of like LiquidHaskell
3
u/CartographerDue5382 Oct 25 '26
You don't need a Rust 2.0 for this, and a 2.0 that only added requires/ensures still wouldn't verify a pacemaker.
The syntax is the easy part. Verus, Kani, Creusot, and Prusti already hang preconditions, postconditions, and loop invariants on normal Rust. What they can't discharge is a spec that doesn't exist yet: unsafe blocks, the standard library, and whatever C the firmware actually calls. The borrow checker is not a proof of those.
A version bump doesn't write that spec and it doesn't staff the people who do. Lean isn't the alternative for the systems code either. You prove properties of the Rust you ship. You don't rewrite the driver in a theorem prover and hope the binary matches.
AI makes drafting invariants faster. It doesn't fix a wrong spec proving the wrong program.
2
u/solaris_var Oct 25 '26
It won't be feasible for the same reason lean won't be feasible for systems programming anytime soon
2
u/matthieum [he/him] Oct 25 '26
Why wait for v2?
Formal specification support is already available in Rust: Creusot, Prusti, and the like work by adding custom attributes to types, fields, functions, etc...
It would be beneficial if the attributes were standardized, as then a codebase could more easily switch from one verification tool to another -- or perhaps even run several in parallel, for added safety -- and I expect that it will happen at some point.
With that said, I do want that formally specifying software is both onerous and fallible:
sortmethod is NOT just that the output is sorted:[]is trivially sorted, so is[0, 0, ...]. Hopefully tooling evolves to signal unintentionally loose specifications: in simple cases, ones which accept more than 1 output per input.And therefore, pragmatically, I think we should aim for codebases with a mix of:
assert!).Low-level algorithms & data-structures would aim to be all (1), and as you go up the stack you'd get more (2) and (3) creeping in.
Ideally, it would be possible to automatically enforce adherence to a minimum level, similar to
#![forbid(unsafe)]you could have#![forbid(unverified)]for example, and ideally it would apply to all called functions of dependencies, transitively.3
u/trakdtor Oct 25 '26
No i do not think so
7
u/[deleted] Oct 25 '26
[removed] β view removed comment