we are entering a renaissance in programming language and runtime research, and a golden age of software testing and verification
it’s time to rewrite all software
while i'm quite bullish on formal methods, i think it's worth tempering expectations and doing your own research on it (disclaimer: i am not an expert in it). it cannot guarantee your code is bug free, only that it matches the spec under certain assumptions, and the specs come from what people want, not math. as long as we build software for humans, nothing can prove that your spec is right, only you can judge.
i created the /statechart skill in pstack primarily because it helps make the state machines implicit in your code more obvious and legible to you, so you can shrink the review surface and review the work at a higher level: does it actually match your intent and goal? i used this skill a ton while building my game https://t.co/sa18sM28uD, below you can see the statechart for story mode where i was able to find many bugs with it.
in that sense, i think model checking (eg TLA+ with TLC) is quite useful for understanding and checking properties of your system e2e, and you don't have to write tons of new verification code for it. the spec isn't your actual code so there's always a risk of drift, but so far i've had good experiences finding actual bugs with it. i tend to pair it with empirical verification (running the code) also to confirm it's real
other types of formal verification like proving theorems (eg Lean, Dafny), bounded model checking (eg CBMC, Kani) etc have their own tradeoffs. proofs cover every possible input, but only for the properties specified, and it takes a lot more code/work. bounded model checking can run on your actual code, which avoids drift, but it only checks up to a certain number of steps, so it's better at finding bugs than proving there aren't any
so i think in the near-medium term you'll still need to layer your codebase: constraints and guardrails (types, lint rules, api design, refactoring), empirical verification (tests, evals, real usage), and formal verification for the parts that really need it. none of these catch everything on their own, but layered together, they catch a lot more and shrink what's left for you to review
but also maybe in the limit, the bitter lesson will prevail and flawless code will just be printed out perfectly every time with no bugs. even in that scenario, /statechart still seems very helpful in confirming that the agent understood your intent correctly. give it a try if you haven't already!
https://t.co/9erGZLOzxO
It won't.
I understand, why people see it as a next silver bullet.
But formally verifying code is not solving the problem. Verification doesn't mean the code is bugfree, it means that code adheres to the specification; which itself can be wrong. If you don't read the spec, how do you know it is correct? It just moves the goalpost.
Also, it is not economical. There's no point in formally verifying that your framework validates e-mail addresses correctly.
To prove 1 LOC of code, you need 5-50 LOC of proof. And now, we live in a world of explosion of new source code. I manage over 3MLOC. I am not going to study 60MLOC of proofs and underlying specs/assumptions.
What makes sense is to formally verify main core of your app. The thing that can save lives, cure cancer, optimize manufacturing, logistics... a few thousands of lines of code, where you really are willing to engage with their specs, and proofs.
We seriously should not keep saying this. Pretty soon some "formally verified" software is going to have bugs, and people are going to start questioning what value formal verification really has.
Delete Lean bro. We're switching to Agda. Did you verify with Rocq yet? I sent you a theorem to TLA⁺. Check your prototype on F*. You need to make an LCF proof to access Phox. Hold on, lemme add you to Wang tiles
Store coins yourself. You fight hackers yourself, and guard from losing wallet yourself. Computer breaks, USBs gets lost.
Store on an exchange. Only use the most reputable, proven secure, exchanges.
Or move to DEX, disrupt ourselves.
yesterday my barber brought up Rocket Lab organically. turns out he's a massive fanboy, tells everyone about the company, bet the house on $RKLB .
we spent the entire haircut talking about rockets and space systems.
not long ago, I was telling investors "I used to work at a company called Rocket Lab. believe it or not, they build rockets."
Okay, let's do this.
Isabelle, Lean, and Rocq (formerly Coq*) are theorem provers. They are meant to prove mathematical theorems. We use them for formal verification by either 1) translating a program to the theorem prover (risking a translation error) or 2) using a language built into the theorem prover that extracts into a working binary.
Fizzbee, TLA+, Spin, Alloy, Quint, and P are specification languages. They are meant for checking high-level blueprints of programs. After checking the blueprint, you still need to make sure your program matches it, which is a hard problem.
Specification languages differ in what they make easy to express. P, Spin, and Fizzbee are designed to be closer to the code implementations. P looks like interacting state machines, Spin looks like C with CSP, Fizzbee looks like a dialect of Python. It's easier to use a codelike specification language and refine it to code, but you can't do as much with it.
Alloy, TLA+, and Quint are more abstract. Alloy looks like a bunch of algebraic relationships, TLA+ is a much of logical formula, and Quint is a programmer-oriented (and statically typed) condensation of TLA+. Abstract modeling languages are harder to get started with and harder to represent things, but you can represent a wider class of systems with them.
I believe UPPAAL is a specification language for realtime systems. This is a field I have no experience in. It seems a graphical language, though, which would make LLM-assistance difficult.
Dafny is a verifiable programming language. It has regular programming language features, but also a bunch of features to express and prove properties of the program. It uses SMT solvers to actually prove the properties, meaning you don't need to learn a proof language (though you need to learn to cajole the solver). Dafny is probably the easiest thing on your list to get started with, but also the least likely to meet any weirder needs you might have.
I don't know what Ivy is but some cursory Kagiing suggests it falls in the specification language category.
Some other things @spin_lock_init didn't mention:
- Other theorem provers: Agda, Metamath
- Other abstract specification languages: mcrl2, NuXMV, Event-B
- Other verifiable programming languages: Idris, F*, Whiley
- There's also using a verifiable subset of a language, like Verus for Rust or SPARK for Ada.
So, what you need to pick depends on what you want to do.
You'll get the maximum power with a theorem prover. Lean is the de facto language for vibeproving, but Anthropic recently published a post about vibeproving in Rocq so YMMV.
If you want to make abstract models of software systems, go for a specification language. Which you choose depends on a lot of factors. If your system can be represented as lots of simple communicating state machines over a network, try P. Spin, I believe, is close to simple C/Go with a network and channels. I have never used Fizzbee.
Alloy is good for domain modeling, but struggles with really complicated temporal actions, nested data structures, and largish numbers. Also AIs aren't to good at it (last I checked, in March). Runs fast and makes good visualizations though.
TLA+ and Quint are for modeling complex temporal systems. I'm partial to TLA+ but know a lot of people who say Quint is easier to get into.
Note P, Fizzbee, and Quint all claim to have features for testing a codebase against a spec. I can't vouch for any of them, though. None of the languages I mentioned (except maybe NuXMV?) are particularly good at modeling sequential, deterministic algorithms.
Use Dafny if you need to just write a verified program and don't care which language it's in. I don't think other verifiable programming languages are as user-friendly for the time being. Consider a verified subset if you already know a language and want to just augment it with more correctness.
You may need other, more exotic tools depending on your particular needs. Regardless of the above advice, don't be afraid to use the wrong tool for the job. If you vibe well with a language, and you achieve good LLM-sympathy with it, you'll be able to go farther than using a "right tool" you don't like.