A comparison of Verus and Lean uses a verified bitset to show what proof-oriented programming looks like: specifications are proved against the implementation itself, rather than against a separate model. A bitset stores a fixed domain of numbers in 64-bit words, with set operations implemented through bit operations. Its correctness depends on two invariants: the word array has the right length, and padding bits outside the domain remain zero. The case study also defines containment by mapping each number to a word and bit, then models the structure as an ordinary set so implementation behavior can be related to familiar mathematical membership.
The languages encode these obligations differently. Lean makes the domain a type parameter and the word-array length part of its type, and carries the padding proof inside each bitset; bounded indices also make array access intrinsically safe. Verus follows Rust’s runtime-oriented representation, storing the domain as a field and expressing both invariants explicitly. Its specifications need quantifier and solver annotations, and methods state well-formedness preconditions. Lean’s supporting types and tactics make some specifications more concise, while Verus keeps code closer to idiomatic Rust; however, Verus may require verified unsafe code to eliminate bounds checks. The comparison highlights practical tradeoffs in representation, proof automation, runtime behavior, and the connection between verified specifications and executable code.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.