Developing provably correct Rust code with Verus
Thread
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
Developing provably correct Rust code with Verus
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
sourdecor · · focus · HN ↗
I was talking to Gemini about comparing Verus to TLA+ and it said that TLA+ is usually used (for example) "to prove that a distributed consensus protocol is logically sound" but when I asked if Verus can do that too, it said yes. So Verus can be compiled and integrated with Rust, whereas TLA+ is used more for blueprint development that then guides the implementation in the mind of the implementer.
Seems awesome!
[0]: <a href="https://news.ycombinator.com/item?id=12357976">https://news.ycombinator.com/item?id=12357976
japgolly · · focus · HN ↗
[dead]
pjmlp · · focus · HN ↗
I rather push for tooling that allows code generation based on the formal proofs like FStart or Dafny, or is integrated with specific programming languages like SPARK, Frama-C or this Verus.
igornotarobot · · focus · HN ↗
kreneskyp · · focus · HN ↗
I'm targeting Rust primarily but my goal is that any language could sit under it via an integration layer.
<a href="https://github.com/agent-ix/quoin" rel="nofollow">https://github.com/agent-ix/quoin
The first public version of the formal specification standard isn't available yet. Pushing hard to get it out soon! But Quoin ships with an earlier version of the spec standard. It features derived property tests, which was the POC for fully adopting a formal-spec-to-derived-formal-verification ecosystem.
pjmlp · · focus · HN ↗
jgalt212 · · focus · HN ↗
Preach. I feel like I'm taking crazy pills every time someone claims TLA+ as the sine qua non of provably correct systems. They should sub probably for provably.
zozbot234 · · focus · HN ↗
digilypse · · focus · HN ↗
jgalt212 · · focus · HN ↗
Fair enough, but to be truly safe you really need the whole pipeline connected. model -> validation -> emitted code.
kobahiro · · focus · HN ↗
[dead]
jdw64 · · focus · HN ↗
Jtsummers · · focus · HN ↗
jdw64 · · focus · HN ↗
kite42 · · focus · HN ↗
anonymousDan · · focus · HN ↗
hwayne · · focus · HN ↗
anonymousDan · · focus · HN ↗
canadiantim · · focus · HN ↗
jongjong · · focus · HN ↗
IMO, formal verification is never going to work. It's very clear that a lot of people are desperate to see it used in mainstream software development, but every innovation which proponents have seen as an opportunity to finally prove its utility has only served to further discredit it.
Now proponents are at a point that they literally have to convince us that people who aren't able to write correct code are somehow able to write correct mathematical specifications!
This is quite an extraordinary claim given that the mathematical specification is an order of magnitude longer and more complex than the code itself... And every experienced software engineer knows that mistakes grow proportionally to the size of the logic... Unfortunately, mathematical spec is logic; just like code, except it's more complex and thus more error-prone.
And don't even get me started on the fact that APIs, engines and languages change constantly from under you and thus the mathematical spec would get completely invalidated every week or so each time you did an update. Unfortunately, even in the best case scenario, reality is always going to change and invalidate our proofs faster than we can publish them. By the time you've proven the theory, its underlying assumptions already ceased to hold true.
Even in a far simpler world, the software's execution would change the reality which it relied on to prove its own correctness and would thus invalidate its own correctness.
gr_norm · · focus · HN ↗
You can show that your specifications satisfy well-accepted criteria like confidentiality and integrity. This is usually done as the final verification step. For example, AWS just did it for the Nitro hypervisor used by EC2: <a href="https://aws.amazon.com/blogs/compute/aws-nitro-isolation-engine-formally-verifying-the-hypervisor-in-the-aws-nitro-system" rel="nofollow">https://aws.amazon.com/blogs/compute/aws-nitro-isolation-eng....
stevenhuang · · focus · HN ↗
I don't understand this type of thinking. Proving what you can is still better. Don't let perfect be the enemy of good.
jongjong · · focus · HN ↗
I feel like the exact same line could be used to argue the opposite point against formal verification.
I'm not saying that proof is inherently bad. If it was free, then I agree it would be good, but my point is that it's not free, proofs are expensive to produce, maintain, they lock-down flawed implementations, discourage change and they create false confidence about reliability because sometimes the bug is in the spec itself, especially as the spec gets more complicated.
atoav · · focus · HN ↗
lou1306 · · focus · HN ↗
This describes about one or two thirds of the Theoretical CS academic community (conservative estimate) /s
> This is quite an extraordinary claim given that the mathematical specification is an order of magnitude longer and more complex than the code itself
I find this hard to believe. The mathematical specification for "array a is sorted" is "forall n in Nat: 0 < n < len(a) -> a[n] >= a[n+1]". The average sorting algorithm is usually a tad longer than this.
> the mathematical spec would get completely invalidated every week or so each time you did an update
Well of course nobody serious advocates for formalizing/verifying code that is subject to that much churn (be it internal or external).
imtringued · · focus · HN ↗
If developers decide to build a complete specification of the algorithm, you counter that the specification is now too long so they should not bother.
You are basically arguing with yourself.
The update argument doesn't make sense either, because you generally want to prove properties like absence of panics throughout your entire codebase. Again this is just a roundabout way of arguing against the very idea of a tradeoff.
homarp · · focus · HN ↗
m00dy · · focus · HN ↗
Welcome to Rust
Ohentis · · focus · HN ↗
m00dy · · focus · HN ↗
m00dy · · focus · HN ↗
gregwebs · · focus · HN ↗
Meneth · · focus · HN ↗
nottorp · · focus · HN ↗
Betelbuddy · · focus · HN ↗
Jesus, I cant stand formal methods people...
nottorp · · focus · HN ↗
cmrx64 · · focus · HN ↗
it’s all rubbish, grandparent is a small mind who can’t figure out how it’s a step up from nothing.
svieira · · focus · HN ↗
nottorp · · focus · HN ↗
What formal correctness proof will detect that?
cmrx64 · · focus · HN ↗
Jtsummers · · focus · HN ↗
Betelbuddy · · focus · HN ↗
Jtsummers · · focus · HN ↗
Betelbuddy · · focus · HN ↗
"Program testing can be used to show the presence of bugs, but never to show their absence"
Jtsummers · · focus · HN ↗
Betelbuddy · · focus · HN ↗
Jtsummers · · focus · HN ↗
Betelbuddy · · focus · HN ↗
The quote from Dijkstra stands on its own...quoting a famous person stating something independently demonstrable, does not magically turn the statement into an appeal to authority :-))
>> a man who was a major proponent of formal methods.
No he was not, but you see, its irrelevant in the context of the argument you failed to defend.And Dijkstra fails you purity test. He himself wrote that he saw "no specific virtue in being a formalist" and would use formal methods "when I feel they help."
rcxdude · · focus · HN ↗
Betelbuddy · · focus · HN ↗
Apparently their lawyers never got the memo that the tests already guaranteed the software...
rcxdude · · focus · HN ↗
lukeify · · focus · HN ↗
bcjdjsndon · · focus · HN ↗
Why then does rust even need the unsafe keyword?
ijustlovemath · · focus · HN ↗
bsaul · · focus · HN ↗
bcjdjsndon · · focus · HN ↗
Jtsummers · · focus · HN ↗
ijustlovemath · · focus · HN ↗
I also think the functional style, typestate, and borrow checker is enough for writing correct code across many business domains, so there's no need to add this to your toolchain. We are a med device company building a class III (really 3 class II) device, and Verus is making our verification story extremely compelling.
hwayne · · focus · HN ↗
afdbcreid · · focus · HN ↗
112233 · · focus · HN ↗
what about proving safety of not-unsafe code? The meme that rust is "safe" is becoming tiring. Does this thing allow proving absence of infinite loops? Bounded resource use? Correctness of comparison operations? Etc.
Also, why is there still no hardware tagging to simply prevent memory misuse at cpu level, if it actually is such an important issue?
ijustlovemath · · focus · HN ↗
112233 · · focus · HN ↗
Yet the pitch is that it is needed for the "unsafe" unsafe code, to make it "safe". Not for all code, to make all code safe.
63 · · focus · HN ↗
[0]<a href="https://github.com/rust-lang/miri" rel="nofollow">https://github.com/rust-lang/miri
[1]<a href="https://github.com/model-checking/kani" rel="nofollow">https://github.com/model-checking/kani
[2]<a href="https://github.com/creusot-rs/creusot" rel="nofollow">https://github.com/creusot-rs/creusot
gregwebs · · focus · HN ↗
Kani: use in a test suite
Creusot: annotations
Verus: annotations or macro
The macro system looks very nice if it doesn't slow down the normal build.
gregwebs · · focus · HN ↗
MeetingsBrowser · · focus · HN ↗
But maybe this changes in the age of LLMs. A deterministic check to let LLMs verify the correctness of an API could improve the success rate of large scale refactors or performance optimizations.
Exciting!
afdbcreid · · focus · HN ↗
MeetingsBrowser · · focus · HN ↗
Sorry if I wasn’t clear.
My point is that the annotations are manual and inherently prone to error.
If humans could correctly write annotations according to a spec, we wouldn’t need verifiers at all. We could just write correct code directly.
There is an argument to be made that the annotations are a smaller surface than full blown code and therefore easier for humans to reason about.
However, in practice formal verification tools and annotations are far more obscure than regular code.
Most people writing annotations have a PhD in some field adjacent to formal verification.
rcxdude · · focus · HN ↗
MeetingsBrowser · · focus · HN ↗
My point is that this is the hard part, and writing annotations does nothing to help with this problem.
rcxdude · · focus · HN ↗
MeetingsBrowser · · focus · HN ↗
To me, it’s essentially implementing the same code twice in two languages and checking the behavior matches.
If the same person implements both, what are the odds they implement the same bug in both?
Only verification annotations are generally even harder to read and write than the code itself, making it even more difficult to tell if you implemented the proof according to the spec, or just mirrored what the function actually does.
afdbcreid · · focus · HN ↗
MeetingsBrowser · · focus · HN ↗
Programmer intends to write code that does Y, but writes code that does X. Then they make the same mistake again and write an annotation that verifies the function does X.
Verification passes, but the code does the wrong thing.
afdbcreid · · focus · HN ↗
If it is public API, it indeed can pass. This is similar to theorem provers - if you get your axioms or theorems wrong, you can incorrectly "prove" things. But verifiers are still useful because most of the code has larger internal surface than external surface.
rzmmm · · focus · HN ↗
For example if you are trying to prove that your new sorting algorithm yields sorted list for all inputs.
If there is as much annotations as there is code, then testing is better tool for the job than verification.
freethinky · · focus · HN ↗
genxy · · focus · HN ↗
reddit_clone · · focus · HN ↗
I am new to Rust and also new to formal verification.
Can someone ELI5 this for me?
(Also, when does the proof happen? During compilation or by running extra tests during unit testing?)
Jtsummers · · focus · HN ↗