by hresvelgr · 1w ago · 0 comments
Formal correctness does not guarantee desired function. People have written TLA+ specs for their software[1] and not have it materially improve the quality or reliability. You cannot just throw formal verification at a problem.
I am very much of the opinion that crap code is an issue of organisation and aesthetics, and that can be automated. This is something that is enforced by frameworks, and despite the popular consensus that LLMs are good at frameworks because of training data, I make another argument that LLMs are good at them because frameworks massively restrict the possibility space of code that can exist and enforce a consistent organisation and aesthetic. The solution as I see it is to make more restrictive frameworks that have a higher chance of producing desired functionality, then afterward we can worry about correctness.
Given how vibe coded the rest of that whole DB appears to be, and the number of holes the Jepsen test found, I’m not terribly sure I’d trust, or use it as an example of “used formal methods”.
A better example would be the AWS S3 team who used TLA+ to formally verify their permissions model, especially around whether something was publicly accessible.
The first paragraph is
> To save software engineering from LLMs, we need a mainstream verifiable language
Formal verification will not save us from LLMs, whatever it is we want to try and save (human civilization or programmers or users).
Formal verification is one necessary building block, not the whole structure needed. You want to do Verification and Validation.
Currently, people have dollar signs over their eyes and don't see the perils their greed is leading them into.
You cannot substitute human expertise with LLMs. That's like believing your rational brain was superfluous and you'd be better off without it, relying on "others" (LLMs) instead.
Nobody in the public sphere has thought that through really. Apparently, they've become so accustomed to other people solving their problems when paid, they just assume it would be the same or better with "non-people", who don't even get paid.
Rust doesn't guarantee desired function either. It doesn't mean that average rust program has the same probability to have segfault at runtime as a similar program written in C.
"Formal correctness doesn't guarantee desired function, therefore we don't need it."
But in reality it will actually catch bugs, in addition to other verification methods, and give more confidence in software.
Requirements, code, verification, etc are a process to turn a human mental model of something into an process a computer can do. You can verify the computer's side of that all day long but if the human side is wrong no amount of verification is going to make your software do what you wanted it to do.
Ever more cycles spent checking we're building the thing right doesn't address the issue of whether we're building the right thing.
The debate has always been whether running cycles on "compile" which is checking against a largely fixed set of rules is better than "testing" which is checking against a largely dynamic set of rules. "Testing" tends to be able to do validation better than "compile".
That's been the running debate between dynamic typed and static typed computer languages for the last half century or so. It swings backwards and forwards.
Like centralised vs distributed I don't see there being "a" answer other than "it depends".
Actually, I haven't seen a good dynamic vs static types debate for a long long time. Some of these fundamental debates have become tired and people don't debate them anymore, which is understandable.
But, in the age of LLMs, maybe it's time to have that debate again.
The major disadvantage of typed languages is they're harder to write at times, the type checker gets in your hair. But if LLMs write the code, what argument remains against static types?
That particleDB link is VERY unconvincing. All the folks I know who wrote a TLA+ spec have said that it helped them discover bugs. Just that it was a massive pain to keep maintaining code and spec independently.
However, I am confused on why new PL is needed. Why not just improve lean and its libraries so that it becomes a standard big-software language like Go/Java/Rust ?
Lean wouldn't be able to match Rust in performance without a fundamental restructure of its core calculus.
> Lean wouldn't be able to match Rust in performance without a fundamental restructure of its core calculus.
Why so?Lean is garbage collected and you don't control the layout of types in memory (and everything is boxed)
I start with prose requirements, then use Elenxis (https://github.com/kbr-/elenxis) to translate into formal Lean model.
Then I state signatures and conjectures that the spec must have. Properties that the future implementation must hold. No implementation yet.
Only once all conjectures are there, we are ready to roll.
If I write in Lean, I can now fill in the signatures' implementations. Then prove theorems. Proof doesn't go through => bug. Fix, retry, repeat.
If I write in an inferior language, there is extra Intermediate step: translating the conjectures into property test in the language. Only once these are ready, I can write implementation.
You must not write implementation before having all conjectures stated -- otherwise the implementation will bias your thinking, and you will try to prove properties of your implementation instead of what you needed.
All of the above applies equally to AI agents.
> You must not write implementation before having all conjectures stated -- otherwise the implementation will bias your thinking, and you will try to prove properties of your implementation instead of what you needed.
Most software engineers don't really have a background in it, and tbh I kinda don't know where to start, and have heard that right now if you're already experienced with formal methods then you can get great results out of approaches like this with LLMs, but if you just vibecode up the Lean or TLA+ etc then you're not going to get out of it what you were expecting. I suspect your statement here is exactly the kind of thing that makes all the difference, but I don't know how to know what the other things that make the difference are. Any other pointers?
Nothing so critical.
My first serious full-time job was at ScyllaDB, where I worked on distributed database system core. My main area of interest (carried over from University) were distributed algorithms. There, formal methods are basically necessary; if you design a distributed algorithm and don't use formal methods, you *will* fuck up. In ScyllaDB I used TLA+.
Today I have a different job but my passion for formal methods didn't go away.
I updated my HN profile with link to my website, you can look me up.
On Formal Methods Thinking/Levels and (In)Formal Methods - https://news.ycombinator.com/item?id=50478624
On Design By Contract (DbC) - https://news.ycombinator.com/item?id=50108540
On Combining Tests and Proofs with Contracts - https://news.ycombinator.com/item?id=50108206
On Correctness-by-Construction - https://news.ycombinator.com/item?id=49613696
Note that the above is based on using classical logic predicates to "steer" the program through its "state space". This is the more fundamental and "simpler" approach since it uses only First-Order Logic.
Another way is to use the Type System (constructive logic, dependent types in Lean4 etc.) to embed the above directly into the program types. This is harder since you need Typed Lambda Calculus, Higher-Order Logic and need to think quite differently. For this you can read Types and Programming Languages by Benjamin Pierce and/or any number of lambda calculus books. The Curry-Howard Correspondence helps you understand this if you have some idea of the above state space approach.
Finally, if you want to know/study the whole of above you need to read Understanding Formal Methods by Jean-Francois Monin - https://news.ycombinator.com/item?id=50506655
It is all overwhelming at first if you are completely new to it so use it as a roadmap. Survey all of the above to get a grip on the jargon, notation and application and then choose your approach/logic/tool based on your interests/needs.
One could maybe combine this with Rust code verified by Aenas (which runs Lean proofs)
Property test can state general properties about the signature being tested. E.g. let's say you're proving correctness of addition in an abelian group. You can state Associativity, Commutativity, Identity Element (0), Additive Inverse, Closure, Cancellation Property, as properties of the signature, in the Property Testing framework you're using (Haskell: QuickCheck, Python: Hypothesis, and so on). The framework will generate test cases using a specially-crafted random distribution (one crafted to maximize the chance of catching a bug), then if it finds a failing case, it will shrink it, so your counterexample is minimal.
It is a "normal test" except that you use a powerful framework to give you these mechanisms.
It still depends on randomness, so it's still inferior to a theorem, which gives you 100% correctness.
Formal verification is a useful tool, but I don't think it meaningfully combats "slop," which I argue is primarily disorganised, voluminous, and lacking in aesthetics.
> That is, the design should be started by modelling with some formal language
I would make sure what I am developing demonstrably works before formally verifying the characteristics of the system.
1. The slop is incorrect
2. The slop is bloated
3. The slop is not human readable
Formal verification together with human validation is the answer to point 1. The second point needs additional measures to keep the artificial author in check which is in my experience quite easy to accomplish.
If these two are in place I found that human readability falls out mostly for free.
So, to summarize, in my opinion formal verification together with measures to keep the code minimal and concise is our best way to tackle slop.
TL;DR it impacts the trajectory of the LLM negatively in a massive way IMHO.
If you have proofs attached to an actual implementation, things get much, much better.
For example, you can have type-checked distributed APIs (you can't omit a parameter for an HTTP request), you can have adherence to protocols checked at compile time (API calls sequences, etc), you can have many other things to be checked before any program run.
Boris said they heavily use TLA+ for Claude Code and they've noticed an improvement. Comparing CC with 6 months ago, it has indeed improved in terms of reliability and screen flicker, etc.
The concurrency bugs SPIN and TLA+ find also eat tons of debugging time because they are hard to replicate. They're often called heisenbugs for how they're there and not there depending on the observer.
Static analyzers with low, false positives catch tedious or corner-case bugs developers often miss. That already tells you that any formal method that makes software immune to those big classes will also improve quality. SPARK Ada and Frama-C both do that.
Favourite line:
> Under normal operation, ParticleDB was slow, deadlocked, and crashed without warning.
Loosely related: the German TÜV now wants to certify AI systems https://www.tuev-verband.de/pressemitteilungen/tuev-organisa... (original in German, use your favorite translation tool)
I wonder whether such a certificate will be a future requirement for selling or running certain hosted software. It would be hilariously German when the certificate then mandates using formally verifiable programming languages.
That link is a pretty weak strawman. Also TLA+ is special in that it (usually) does not directly verify the implementation but a model of it.
Oh. Look external stripe calls are hanging. (HALT problem)
They have said they wrote them, but I doubt it. The quote from the report:
"We found several incompatibilities or bugs involving static or dynamic type safety, or behaviors that would normally have been caught by static analysis of a query, such as referring to a nonexistent column. These issues occurred with a single server, single client, and no faults.
They failed to catch references to a nonexistent column with a formal proof? I doubt it, the more likely explanation they hadn't proven their code, they probably did something that allowed them to claim that they wrote TLA+ specs, and stopped at that.
Formal proof is a static analysis on steroids, if it can't catch bugs that can be caught by a static analysis then what the point of it?
The report doesn't answer how it happened (I presume) because of: "during our collaboration no TLA+ specification was available. It is unclear what properties might be proven, or whether they described ParticleDB as built.