TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Verified Rust for low-level systems code

284 pointsby gz09about 1 year ago

14 comments

lsureshabout 1 year ago
We&#x27;ve used Verus to write formally verified Kubernetes controllers.<p>Basically, we can prove liveness properties of the form &quot;eventually, the controller will reconcile the cluster to the requested desired state&quot;. As you can imagine, there is a lot of subtlety and nuance to even specifying correctness here (think rapid changes to the desired state requirement, asynchrony, failures and what not).<p>Code: <a href="https:&#x2F;&#x2F;github.com&#x2F;vmware-research&#x2F;verifiable-controllers&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;vmware-research&#x2F;verifiable-controllers&#x2F;</a>, with a corresponding paper due to appear at OSDI 2024.
评论 #40266638 未加载
jphabout 1 year ago
If you want a small stepping stone toward Versus, you can add Rust debug_assert for preconditions and postconditions; the Rust compiler strips these out of production builds by default.<p>Example from the Versus tutorial with verification:<p><pre><code> fn octuple(x1: i8) -&gt; (x8: i8) requires -16 &lt;= x1, x1 &lt; 16, ensures x8 == 8 * x1, { let x2 = x1 + x1; let x4 = x2 + x2; x4 + x4 } </code></pre> Example using debug_assert with runtime checks:<p><pre><code> fn octuple(x1: i8) -&gt; i8 { debug_assert(-16 &lt;= x1); debug_assert(x1 &lt; 16); let x2 = x1 + x1; let x4 = x2 + x2; let x8 = x4 + x4; debug_assert(x8 == 8 * x1); x8 }</code></pre>
评论 #40263686 未加载
评论 #40263343 未加载
评论 #40265220 未加载
评论 #40263871 未加载
sdsdabout 1 year ago
Noob question from someone with little real CS experience, when the README for this project says:<p>&gt; verifying the correctness of code<p>What is the difference between &quot;verifying&quot; the correctness of code, as they say here, vs &quot;proving&quot; the correctness of code, as I sometimes see said elsewhere?<p>Also, is there a good learning resource on &quot;proving&quot; things about code for working programmers without a strong CS &#x2F; math background?<p>Edit: I&#x27;m also very curious why &quot;zero knowledge&quot; proofs are so significant, and why this is so relevant. Eg I heard people talking about this and don&#x27;t really understand why it&#x27;s so cool: x.com&#x2F;ZorpZK
评论 #40260557 未加载
评论 #40260439 未加载
评论 #40260453 未加载
评论 #40260454 未加载
评论 #40261152 未加载
评论 #40264997 未加载
评论 #40260552 未加载
评论 #40260886 未加载
评论 #40263862 未加载
评论 #40262863 未加载
ComputerGuruabout 1 year ago
For those that are interested but perhaps not aware of this similar project, Dafny is a &quot;verification-aware programming language&quot; that can compile to rust: <a href="https:&#x2F;&#x2F;github.com&#x2F;dafny-lang&#x2F;dafny">https:&#x2F;&#x2F;github.com&#x2F;dafny-lang&#x2F;dafny</a>
评论 #40261424 未加载
im3w1labout 1 year ago
This looks really cool. One thing I think would be really useful for people is some instructions &#x2F; examples of how to add proofs for an existing codebase.<p>So maybe an example could be a bare-bones gui app with a single textbox, that does an http request to some resource (having data that is unknown at compile-time and potentially untrusted is a very common thing) and fetches an array, which is bubble-sorted and displayed in the box. The bubble sort has some intentional bug (maybe due to some off by one error, the last element remains untouched). There are unit-tests that somehow don&#x27;t trigger the bug (worrying that your tests are incomplete would be a primary motivator to go for proofs). It could then show how to replace the unit tests with a proof, in the process discovering the bug and fixing it.<p>The example wouldn&#x27;t need to go into huge detail about the proof code itself as it is potentially advanced, instead it would focus on the nitty-gritty details of adding the proof, like how the interface between proved mathematical code and non-proved io code works, what command line to run to prove&amp;build, and finally a zip archive with all of that, that you can play around with.<p>Edit: Actually just reading from stdin and writing to stdout is probably good enough.
dist1llabout 1 year ago
One of the main contributors gave an excellent talk [0] on Verus at the Rust meetup in Zürich. I was really impressed how clean this &quot;ghost&quot; code fits into programs (reminded me a bit of Ada).<p>[0] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ZZTk-zS4ZCY" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ZZTk-zS4ZCY</a>
eggyabout 1 year ago
Is there a Rust standard yet like there is for C&#x2F;C++, Common Lisp, and Ada&#x2F;SPARK2014? Without that, it is a moving target compared to the verification tools that have been developed for say, Ada&#x2F;SPARK2014. Not to mention the legacy of Ada&#x2F;SPARK2014 in high-integrity, safety-critical applications from bare metal up.
评论 #40266237 未加载
TachyonicBytesabout 1 year ago
Is there any relationship between this and Kani[1]? Do they work differently?<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;model-checking&#x2F;kani">https:&#x2F;&#x2F;github.com&#x2F;model-checking&#x2F;kani</a>
评论 #40260901 未加载
berkeleynerdabout 1 year ago
How does Versus compare to SPARK? Are they of the same general class of verifier? How is Versus different other than a verifier for Rust rather than a verifier for Ada?
camkegoabout 1 year ago
Could someone familiar with Verus comment on the power and expressiveness of Verus vs. Lean4<p>I understand Verus is an SMT based verification tool, and Lean is both an interactive prover and SMT based tool.<p>But my understanding in the area of formal verification is limited, and it would be good to get an opinion from someone well versed in formal methods for software.
评论 #40264612 未加载
jimsimmonsabout 1 year ago
What exactly do SMT systems &quot;solve&quot; in cases like this?<p>If I wrote a simple BFS or DFS and enumerated the search space how far would I get.. Is that not what TLA+ does in principle.<p>I am surprised people prefer having a dependency of something like Z3 at compiler level.
评论 #40263295 未加载
评论 #40263930 未加载
评论 #40260435 未加载
评论 #40261081 未加载
IshKebababout 1 year ago
Interesting! Looks most similar to Creusot. The syntax is definitely nicer but wrapping your entire code in a macro surely is going to upset rust-analyzer?
评论 #40260760 未加载
评论 #40260449 未加载
lifeinthevoidabout 1 year ago
Is there some way to implement this so that the resulting code is still valid Rust code that can be compiled using vanilla Rust tools?
评论 #40263074 未加载
nulloremptyabout 1 year ago
Hm, so you write the code twice :)
评论 #40262910 未加载
评论 #40265646 未加载
评论 #40262838 未加载