hckrnws
The need for a formally verifiable mainstream programming language
by todsacerdoti
by todsacerdoti
Personally I am having great success using Ada SPARK. The SPARK subset has been greatly enhanced over the past years. I spent yesterday taking existing C repos, translating to SPARK, lifting it to SPARK Silver (absence of runtime errors) and then reporting the findings to the various maintainers. All as a background activity.
Result: integer overflows, typically on boundary conditions, some logic mistakes, again on boundary conditions.
I have not looked into Magmide, but I think the next breakthrough is a combination of something like SysMLv2 to describe architecture and requirements, TLA+ for modeling and formal proofs at the system level and then Lean or SPARK for the implementation.
I started Zena from wanting a TypeScript-like syntax that compiled to very efficient WebAssembly GC, and AssemblyScript had issues...
The motivation for targeting Wasm was as a good sandboxing and orchestration unit for AI-generated code. So, out of both general PL curiosity and enthusiasm, and an attempt to make a language that's good for AI generation, I started adding what I thought were the best features from other languages with a lot of focus on correctness, structure, and optimizability: pattern matching with exhaustiveness checking, ADTs and sum types via sealed classes, value types, async cancelation / structured concurrency, ownership and borrow checking for resources, unicode safe strings, and recently I added runtime contracts and I'll start on refinement types and some kind of proof system soon.
The idea is exactly to take a mainstream and familiar-looking language and add more cutting-edge and academic features that help with software correctness.
I wrote about some of this here, though not the formal methods parts: https://zena-lang.dev/blog/2026/09/languages-for-the-ai-era/
So if I had some functions like:
foo_1 (must NOT access the HDD)
foo_2
foo_3
foo_4 (does access the HDD)
Only 2 of them are annotated with effects related to HDD access, but we can verify at compile time that foo_1 does NOT invoke foo_4, either directly or indirectly (we can verify this recursively).Perhaps foo_3 calls foo_4, but we forgot to annotate foo_3 with the proper effect. No matter, because foo_3 would automatically inherit the effects of foo_4 by virtue of calling it.
This is just one of the feature the blog advocates for, and I think this feature alone would be quite simple and helpful in wrangling LLM code.
A nice thing about this is that it's optional. You can annotate the effects gradually into existing systems.
Consider a specification at roughly the level that Rust crates are documented. Rust crate documents contain all the exported types and functions, along with a textual description of what each does. The document should provide enough information to use the crate without looking inside it. That's a widely accepted form of documentation.
Rust crate documents are usually created from the code. But consider going the other way. Write the crate documentation first, and let an LLM implement it from there. With an LLM creating the code and reading the documentation, the LLM can create formal contract constraints for proof purposes. Constraints visible at the API level can be re-exported to the document.
That seems within reach of current LLM technology. Is it? It's worth trying. Take some low-level crate documentation for existing crates and see what an LLM with a moderately large budget can do with it. Try to create a drop-in replacement.
Doing this on low-level Rust crates would be a useful exercise. Try to formalize the bottom of the stack.
"It also includes facilities to help program verification. For these reasons, Ada is sometimes used in critical systems, where any anomaly might lead to very serious consequences, e.g., accidental death, injury or severe financial loss. Examples of systems where Ada is used include avionics, air traffic control, railways, banking, military and space technology."
All that was once old, is new again.
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.
We could iteratively move towards this sort of thing by basically programming more directly with more formal stuff more often, basically thinking in terms of automata, process algebras, graph algorithms, etc. that’s the real design vocabulary now, not something like loops or objects
For example.. abstractions from FSMs to kahn processes whatnot can all compile to Petri nets, and suddenly you can embed a formally checked subset of a classic and well understood control flow or dataflow or graph transforms, but using the idioms available in your language (decorators, templates, annotation). You write the formal model and the informal implementation side by side, using each to generate/elaborate/constrain the other. There’s only one whole but it has two distinct views, neither of which is complete or standing alone
The lab I worked with for my thesis used Verus for our formally verified Operating System written in Rust. https://mars-research.github.io/doc/2023-kisv-atmo.pdf
It allows you to import code from any programming language (So far, Python, C++, Rust, and SystemVerilog are partially supported,) and prove stuff about it in Lean.
You don't need a "verifiable programming language". All you need is formalized semantics for the programming language you are already using.
I reimplemented the entirety of the css grammar and fully verified the data model, hydration/dehydration pipeline, and can even formally prove accessibility properties at compile time (e.g. contrast > 4.5).
I'm currently working on reimplementing the full sql grammar to allow you to formally verify your queries (and even row level security policies!) at compile time.
[deleted]
From my experience on vibed complex algorithms (like voxel terrain generation within 200km radius at sub second generation), formal software was usefull, if not necessary, prior to opus 5.5
Now it's plain useless unless you need an absolute guarantee of correctness. But that's niche, not mainstream.
So we don't need a mainstream programming language, we already have good options that are sufficient.
Something like ZFC axioms is good enough. External formal verification tools are not ideal either. Its better if the type system of the host language's got these essentials included, like having a model checker for its abstract machine or something. However, model checker for enforcing correctness(especially of the intent) will be much harder to implement in languages without a well defined, stable ABI and type system, which typically is the case with almost all mainstream languages. Even though operational semantics is the semantics of the hardware, most languages do not strictly adhere to it due to a lot of practical reasons.
Mainstream languages that become practical enough to be used by masses will usually be in a spot where it becomes very hard to formally define the language and when that happens, enforcing "correctness" becomes close to impossible. Stuff like this needs to be addressed since the start.
Selling to the entire industry the idea that "memory safety" is the only thing essential security requirement, while all else is a low priority, simply means that anyone who bought that ad either had surplus resources or was operating with inadequate requirements to justify doing so. Computer programming is about deductive reasoning of the programs and that means its much more than just writing code and handling resources properly.
[1]: https://quint.sh
The problem with formal verification is that it only lets you validate the solution against the spec, but it doesn't do anything in terms of validating the spec against reality. The spec can have a lot of conflicts. Also, as the complexity of the code grows, the contradictions and conflicts in the spec increase.
A few weeks ago, Claude wrote me a short formal proof which proved that formal proofs cannot guarantee protection from software bugs or vulnerabilities in most realistic settings; especially when software requirements change too frequently. It made some assumptions about non-salvageability which I didn't ask for a proof for but it gave me some anecdotes from formally verified projects like SeL4 where letters from collaborators hinted that small changes to the code would sometimes require rewriting large parts of the proof.
Unfortunately, we can't stop software from changing until we've developed platforms which provide optimal modularity.
Optimally modular software has the property that code in dependencies (the leaves) has to be modified less frequently and less substantially than code of the dependents (the branches and trunk) in response to requirements changes. A useful measure may be the ratio of code changes dependent_code_delta/dependency_code_delta (over some period of time) where a high ratio is good and a low ratio is bad.
It already checks boxes listed in the article:
- wasm(-gc) target
- uses gc
- rust type system, without borrow checker difficulties
- formal verification
- ...and has few more like fast compile times, which is a must/underappriciated in agentic development (see below) etc.
As an example I attempted to rewrite MSSQL 3 times:
1. TS based on SQLite [1]
2. Rust based on DuckDB [2]
3. MoonBit [3]
MoonBit version materialized more than order of magnitude faster compared to Rust version, tasks that were taking weeks in Rust took hours in MoonBit (!) – not only that, instead of using multiple build machines including maxed 128 GB RAM Ryzen box eating hundreds of gigabytes of SSD to support Rust worktrees / parallel compilation, MoonBit was run on MacMini M1 with 16GB RAM and limited disk space – still destroying Rust version in terms of development speed going more than 10x faster.
Formal proofs is early stage support, you can see some of it here [4] if you're interested.
If you find it somehow interesting, feel free to have a look at bitSQL repo/website [3] (it's public domain like all my recent projects), especially the final artifact which is a marvel – ~30 MB (!) of hardened container image, drop it replacement for MSSQL container – tiny, performant (wins all benchmarks against MSSQL), passes 25k tests, low resource usage (MBs instead of GBs of RAM needed) – what a beauty. Great for ie. running CI tests on projects using MSSQL.
[0] https://www.moonbitlang.com
[1] https://github.com/mirek/mssqlite
[2] https://github.com/mirek/msduck
[3] https://github.com/mirek/bitsql
[4] https://github.com/mirek/bitsql/blob/main/docs/design/verifi...
We have a lot of formal verification mechanics built into the language being able to handle the compilation of the lean kernel and I want to next focus on making it so the code and compiler itself is formally verified to meet it's spec.
so let me ask a simple question:
We have a file of 10 requirements defined by business in English. Then we create a Lean representation of them.
Who is verifying that the representation is the correct one with respect to the requirements? (not that the lean code is correct)
I know there is a ton of stuff I need and want to learn but no language has all the features I'd like.
Namely systems language "zero overhead" performance, modern ergonomics and compile-time guarantees like Rust, dependent types (I don't know much about type systems so maybe there is - and probably there is - some good alternative I am missing), powerful generics (the shit people do with C++ templates often leave me admiring the creativity and also wondering why it has to be so unreadable), reflection, and more stuff I currently have as ideas but not in a very solid form admittedly. And all those working synergistically and coherently.
I do have a good foundation in abstract math but there is lots to study for sure. And it has to be something that really offers some great combination of features otherwise it's not worth it for anything else than me learning how to write a proper compiler. There are too many languages already, but I am not sure whether this is because it is too hard of a problem or because of choices people made. I guess I am going to find out.
At least my motivation is in a relatively sufferable shape despite it having tendencies of going down the shitter with all this vibe-coding crap going on.
I recommend reading Cantwell Smith's "The Limits of Correctness" https://dl.acm.org/doi/pdf/10.1145/379486.379512
The TL;DR is that proofs only show that the program matches a spec, not that the spec matches the world. The gap between "what you can model" and "the real world" is generally too large for formal methods to be useful (outside of narrow domains, where they are highly useful).
In other words, computing is closer to an empirical science than a formal one.
That’s what I’m betting on anyway. I’m building a tool to write proofs for TypeScript in Lean (instead of or alongside tests) with familiar syntax. It’s called Pud (https://pud.dev). Very keen to see what others come up with in this space though!
For a lot of software, they are more like an act of writing than engineering. Especially in domains where they are most abstracted.
I would call something like SQLite and TigerStyle with TigerBeetle Software engineering.
Also your intuition for wasm is the the thing that cam to my mind when reading the headline.
I also think that go is a great language to be formally verifiable (idk about multi threading), due to its very clear and verbose syntax.
[deleted]
[deleted]
It still plugs in LLM as a module, and LLM can be misaligned, so there is no guarantee that the spec will be 100% reflecting the user's intent. (I do know how to solve this, and I will in the future.)
But even right now in practice, with Opus 5.5 or GPT 6.2 Sol (medium reasoning both) it works fantastic. I use daily at $dayjob and in personal projects.
We have now 144 proven theorems, like “an agent never passes as a person, and never approves where a person is required”. And then we link it to the actual code by using the Lean model to generate the tests.
I’ve been doing it with a custom engineering harness on top of Claude Code for a year.
I certainly see the desire for a validation framework in code generation, but until we invent that and migrate the entire world to it, let’s focus on discipline.
The reality the OP sees isn’t wrong. Most of what I see publicly is trash. Undisciplined vibe coders are in a death spiral of agentic madness.
But if you bring discipline to software construction, you can extract high-quality results.
We still need requirements. We still need invariants. We still need wireframes. We still need user experience design.
Then we reach into history and bring back Functional Design Specifications.
Add TDD, DDD, behavior testing, mutation verification. And finally people need to use it for the final validation.
Now you have a disciplined approach that works today.
I see specular has been submitted to HN a few times but has gotten zero discussion, which is a shame. (For the record I am not affiliated with specular at all, not even as a contributor. Just a happy user).
TFA opens by saying that LLMs are causing software quality to decline, but using Specular has convinced me the opposite is going to be true. If you use these tools properly your risk of shipping buggy code drops precipitously
There's lots of progress being made towards compilation to WASM and LLVM, as well as interop with Rust and other languages
LLMs are not the problem. Quality will degrade anyways because there is no reason why it shouldn’t degrade. There is no magic to any of this. It’s just economics. Quality will remain high provided there is an incentive to keep it high, but once other factors achieve a greater desired value those incentives collapse.
This is not a new problem and it has been solved countless times outside software. So long as software people continue to whine about the symptoms while intentionally ignoring the problem we should expect conditions to continue to degrade. A new programming language will not alter the trajectory or acceleration towards failure. Perverse desires always find a way.
Seamless formal verification requires a native formal specification to verify against. In my view, focusing work on formally modelling existing languages (like Rust), or if intractable at least a fragment with Cartesian closed semantics, is far more encouraging to mainstream adoption of formal methods than trying to convince the industry to adopt a new language.
Management would rather have vibe coding as the next step, following on cheap offshoring, than anything else, and the recent meltdowns aren't going to deter them, without liability in place.
How else could industry fully embrace agentic coding more while knowing they aren't compromising on reliability and security
Vibecoding is notoriously bad at writing test coverage that doesn't prevent actual bugs
Formal methods can have the same issue but allow for a more concrete burden of proof and a more tangible reward function for post-training
For various historical and self preservation reasons, some of these language ecosystems create social and technical taboos.
What are people doing that they are finding quality is nose diving? That’s completely the opposite of my experience. I’d like to know, but the link is broken
But of course software engineering has always had this problem, right? Oh! Another broken link.
Maybe we need to start closer to home when it comes to quality.
> TScert: a sound core for TypeScript. An independent checker, whose soundness is proved in Lean
Lean works well for math because there are many orders of magnitude of difference between defining a spec (ex P=NP) and implementing the proof. I don't think this applies for conventional software eng
Programmers have learned so much by doing nothing in the last 2 years!
You get to choose 2 out of 3
Maybe if we humans dont bother with proofs at all this will become irrelevant, but my speculation is that programmers familiar with formal verification may become more valuable in the sense they can write verification friendly code better.
2. While at start LLM output was not great, models are continuously improving and the quality of coding by frontier models is good. (Even weaker models like Deepseek Flash can output high quality software if driven carefully)
3. By analyzing the model output, having lots of gates, having good testing habits and by asking the models to manually test what they did, and constantly changing my workflow to improve the output, I am very happy with the results and probably my workflow using AI is of better quality than if I would do it by hand.
4. If the software isn't of worse quality than if done by human teams with realistic constrains (time, money etc.), then using AI is a net gain.
5. While striving for perfection is great, doing when to do compromises and trade-offs, is even greater.
2. While at start LLM output was not great, models are continuously improving and the quality of coding by frontier models is good. (Even weaker models like Deepseek Flash can output high quality software if driven carefully)
3. By analyzing the model output, having lots of gates, having good testing habits and by asking the models to manually test what they did, and constantly changing my workflow to improve the output, I am very happy with the results and probably my workflow using AI is of better quality than if I would do it by hand.
4. If the software isn't of worse quality than if done by human teams with realistic constrains (time, money etc.), then using AI is a net gain.
This is sort of a counterpart to my own opinion of formal verification, since first learning about it 30 years ago.
Firstly, if there's no direct link between the written code (or perhaps even the program code post-compilation) and the verification algebra, what are you really verifying? And secondly if we can 'get by' without it very well for the most part, then justifying the extra effort is very hard.
And I would argue in contrast to the author that we have achieved a hell of a lot without using it particularly widely. Much like that late-90s obsession, the semantic web, it illustrates a major disconnect between assumptions in the halls of academia about how the world should work, and real world industry practice.
So if there is value in formal verification then the author is right, if must be applicable directly to the program code under verification, and I would argue it must be low friction if it's going to get adoption. And I think LLMs can probably help us deliver that last part.
Much of what the author wants already exists!
If a language cannot balance tradeoffs between hardware and software, people will still use the most performant language, especially for resource-intensive tasks, so you end up with what we currently have. We need to rethink how we can design a language that is token-efficient, offers memory safety, is close to the metal, and lastly implements formal verification guarantees. The closest what we have to this is Rust and C++, but it's not good enough.
If it's truly needed, it will appear (or has appeared already) in one form or another.
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
[dead]
I am getting so tired of LLMs being used as leverage for people to basically thrust their random viewpoint and make it all philosophical.
"LLMs mean my thing is best and everyone needs to do it or become post-civilizational transhuman paperclips"
I almost wish the stupid AI safety sex cult could convince Sanders and Trump to nuke us back to the stone age if only to save us from the onslaught of low-quality bad faith takes.
As far as mainstream, I've usually taken that to mean in the same vein as mainstream languages, ie C++, Java, JavaScript, Python, Ruby, Rust, Swift, etc. Generally imperative, ALGO-style syntax, usually OOP + more and more functional, etc.
I'm designing Zena to be as mainstream and familiar as possible in that sense of the word. Obviously a new language isn't mainstream in terms of usage yet.
It's like a new band playing mainstream music. The band isn't itself "mainstream" at the beginning.
edit: I looked at the features on the website, I don't see anything about multi-threading, is it supported? And how about interoperability with native libraries like SQLite/QT/etc?
WebAssembly is pretty core to my main goals with Zena though: being able to run plugins, generated code, on-demand loaded apps, and other untrusted code is the whole reason why I use Wasm, and wanting a great language for Wasm is the whole reason I'm making Zena. Compiling to native would leave a lot of that out.
There's no multi-threading or any parallelism yet. Wasm GC doesn't support threads yet, and that's a while out if it ever lands, so we'll need some kind of worker/actor system. I don't just want to copy JS workers though, since those are so difficult to use. I'm much more interested in the type system encoding whether data is parallel-safe so I've been working on ownership/borrowing, value types, and immutable types to hopefully come together to form a one-writer / multi-reader, or shared immutable data, worker API, enforced by the type and borrow checker.
[1]: https://www.wingolog.org/archives/2025/10/30/wastrel-a-profl...
[dead]
This is the language I've wanted to make for many years, but it wasn't really tractable without a full team. This project would not be possible for me without LLMs.
Also, if we're talking about making a language that's better for AI-generation, it seems extremely reasonable that such a language might be built with AI, no? I would be surprised to find someone who wanted a great language to use with AI, but was a stickler about the language itself not being built with AI.
Embarrassingly parallel?
Preserving that is one reason Zena has a very explicit import syntax and uses `this.x` like JavaScript: you have to name every symbol you import, and dereference all class members explicitly, precisely so you don't need other files to know if an identifier is valid.
In a non-shared-heap language like Zena (because of Wasm GC), the question then becomes if the serialization cost of collecting those results into the checker thread pays for parallel parsing. So far it doesn't, so I haven't built workers for Zena just yet. That'll probably happen when I make the checker parallel.
Idris, Agda are (like Lean4) functional languages and proof assistants. Dafny, Ada SPARK are imperative and automated solver languages.
Languages like C/C++ which do not have powerful type systems nor are verification aware have tools like Frama-C, CBMC etc. to help with their formal verification. Rust also has some external formal verification tools.
With growing awareness of formal verification due to LLMs one (or more) of them is sure to become "mainstream".
I feel we're searching for an ordering of the universe that bumps up against thermodynamic limits as we know them, something like Shannon's Entropy, and there is no silver bullet, only choices of where to select the complexity landscape and take our stand.
Formal verification a la cocq/Agda/lean works by constructive logic. (Disregard the middle paragraphs, I'm sure I'm not telling you anything new)
The type system is strong enough to encode various statements, even about variables (dependent type system, this is a valid type: a + b == b + a)
The only way to create an instance for this type is by proving the statement. The == type can only be created by trivially equal expressions, so it will accept a == a. So in the definition of the above you will go step by step, each step itself being accepted by the compiler, and at the end you get a proof and a compiling program, a bit similarly to how you would do it on paper.
So I guess it boils down to. Could a mathematician figure out some elegant proof for the system that somehow makes "checking each state" reduced to an easier statement? If yes, then formal verification can also do so. If no, then LLMs may be able to scale up what is feasibly provable, but there is no real alternative. Real world testing is just scratching the surface of the state space.
All in all, that's why it's paramount that systems are designed with complexity in mind. We can compose simple function into a simple function and have it explode in complexity, but it's also possible to choose good primitives that are easy to "mock out" (often both in practice and theory) and not significantly increase the whole system's complexity.
I think today it's actually more possible than ever. Writing programs in this way is hard and tedious but LLM can excel at that. I also think that a hybrid of Z3+LLM is orders of magnitude stronger than pure Z3. LLMs generated a formal proof of GRH, surely than can prove banking app correct.
The most vulnerable part that will remain will be the formalization of requirements. That's impossible to solve fully because you never know what the human had in mind exactly when he ordered the program to be written.
I don't think it necessarily needs to be solved. You can combine formal verification with tests! Use tests to show that the program occasionally does what you want. Use verification to show that the program never does what you don't want (e.g. crash). The formal requirements can be quite weak this way, yet you still get a high level of assurance overall.
And you'll be surprised how many invariants you'll actually need for the simple "don't crash" requirement -- to prove anything at all in a complex program, underlying components need to be correct, or it becomes hard/impossible to prove anything at all about the code using those components.
So (admittedly without any personal experience other than studying this area an university more than decade ago) I expect even a simple "don't crash" requirement gets you the majority of the formal verification benefits. (as long as you have some tests to ensure the implementation isn't just returning a constant)
If you want actual guarantees that e.g. money won't disappear from your account some day or your messages won't be read by a third-party, then formal verification alone doesn't grant that.
Consider that Wifi WPA2 encryption was formally verified and yet broken. In simple terms the bug was in the protocol specification [1]. The "code is the law" crypto folks have even more fun stories to share.
[1] https://www.galois.com/articles/formal-methods-krack-vulnera...
Formal verification of full behavior is impossible. But formal verification of important properties is within the reach of AI.
See https://www.anthropic.com/research/formal-verification for more.
There is a "Correctness-by-Construction" approach to programming which allows one to severely restrict the state space of a program from the beginning such that every statement/block/function only operates on a much smaller "valid" set of program sub-states. This is using classical logic via predicates as explained by Hoare Triples, Dijkstra's wp-calculus, Morgan's refinement calculus and later Meyer's Design-by-Contract.
To do deductive verification statically, the basic idea is to group all computation paths (i.e. sequence of state transitions) over the entire program state space into a much smaller set of logical constraints (aka verification conditions) which is then handed off to a SAT/SMT solver to be proved/disproved.
An alternative is constructive logic using types and lambda calculus as pointed out by a sibling commentator.
There have been lots of systems which have been formally proved/verified to various extents/levels as can be seen in Industrial-Strength Formal Methods in Practice by Hinchey/Bowen and many other similar books.
- ignoring how programs are written, they are usually compiled and linked, which introduces states unknown to the original programmer,
- ignoring how they are compiled, they are executed in environments with variability, including temporal; I remember tracing a problem related to a longer trace on one of the paths of the PCB, and materially different outcomes depending on which trace the signal happen to travel on (it was a high-frequency P-I-D controller, but for whatever reason the microcontroller could transmit the same signal on one or the other path). The particular bug was traced with a oscilloscope, by a graybeard, not algebra.
The way I see it, in order to get verifiability to actual programs, one would need to cover the state space of the entire system - algo, compiled binaries, operating system, hardware, and the weather on the other side of the planet for a good measure.
I am not an expert in the area, in any way - just a regular software dude. Appreciate all the responses in this thread!
It depends upon what all parts of a "system" you want to encompass under "formal verification". There is nothing preventing you from verifying everything from hardware all the way to user-facing software or only certain layers in the chain.
As an analogy, the FIPS/Common Criteria security standards have multiple levels of certification going from simple signed binary blob to a complete hardware and software lockdown system.
You can do the exact same thing with formal verification of your system if needed. LLMs have made this possible if driven properly.
The original comment was about industrial automation and in that environment a lot of those issues are not that relevant. Unless we're talking really big systems, a lot of it is very well specified controllers which run without shell/VM/container/runtime. They just talk to some fancy general GUI on a different chip/board to load the data/config. But the state space of a lot of actual practical hardware doing the work is not that complex. Bare metal, careful io timing, state transitions and some control loops gets you very very far.
To be clear, there are bigger, complicated systems, but simpler devices with a clock, PID loop and I2C outnumber them by likely a few orders of magnitude - we can start there.
Haskell has interesting uses in industry, but in general in the last decade or so the functional paradigm has become retrofitted to basically each mainstream language. Like java's streams/lambdas, algebraic data types in basically every modern language (rust), immutable by default, etc.
Do you really think all the math proofs being done with Lean could work at all if it was imperative as opposed to a purely functional, dependentally typed language
Or like, make any web backend.
And this was 25 years ago! We now have advanced formal techniques for inductive reasoning like IC3 that run on top of SMT solvers, enabling verification of (some) bona-fide infinite state systems. Of course the problem itself is undecidable in the general case, but in practice these tools do get the job done. We have formally verified OS kernels, Lean kernels, SAT solvers out there :)
[dead]
And the ecosystem is following! There are a lot more new middleware layers, frameworks, operating systems and such being released in Ada over the past few years.
See https://forum.ada-lang.io/ for discussion and pop into the live Community Office Hours that AdaCore hosts (https://www.adacore.com/ada-spark-office-hours) to see what is going on in the space.
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.
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?"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".
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?
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.
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.
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.
[dead]
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.
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.
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.
Oh. Look external stripe calls are hanging. (HALT problem)
Iirc that in itself is a large hurdle to clear for most programming languages. I guess llms make that easier too?
Of course, some languages like Python don't have a formal spec beyond the interpreter itself. That doesn't mean you can't write one; it just means you have to update it when the language changes.
Indeed, after formalizing C/C++, you can use that to check that the Python interpreter correctly implements the Python spec you wrote. Or catch the parts where it does not.
Of course it's a lot of work, as you say, which is why I hope to attract more contributors (and their llms) to my project :-)
Once all the languages are formalized, the next step is to formalize the main software libraries people use. If you are using pytorch, you don't want to formalize all its classes and functions everytime you want to prove something about a small program you made. You want to just import that stuff.
Or rather, zero problem with accessibility linting, but don’t oversell it.
I don't think this is a niche problem when major security breaches and downtime are a weekly occurrence at this point
The world would be tangibly different in positive ways if "everyday" software and core deps had the level of proven correctness and fault-tolerance that currently is relegated to niche fields like avionics where verification is the norm
And by that I do not mean the exact, whole theory of ZFC itself but a trimmed down or a bloated version instead. The point is to have the appropriate and intuitive axiomatic semantics that cover the core constructs of the language, at least.
Axiom of Infinity - There exists an infinite set.
Axiom of Replacement - If a function is defined, then for any set, there exists a set of images under that function.
Why would these help me?Take what you need and leave what you don't, however you see fit for your requirement(s). One might not need all of the axioms.
People pushing it beyond what it was originally designed for in C++98.
Most of the template meta-programming tricks are hardly needed since C++20, and improved yet again in C++23, with C++26 static reflection making them completly not worthwhile pursuing, assuming they sort out the whole ratification drama.
The usual enum to string example, https://godbolt.org/z/aKc8Ebza4
And how to enable output of, so to say, "C-preprocessed" source?
https://blog.jetbrains.com/clion/2026/07/2026-2-release/#sup...
We want to be confident we're not being duped.
It's like we skipped over the Laws of Robotics, but we're writing some sort of Mosaic 'moral' code for generative models.
verification against whose spec?
As for reviewing AI code, have you seen some of it? Nobody wants to review that!
The sweet spot for many users is the first. Make sure that the application cannot crash. No array-out-of-bounds read/write, no memory issue on ANY input, formally proven at compile time.
This requires additional work in the program to annotate (in SPARK at leasts) and knowledge from the programmer, which meant that there was a barrier to entry.
Well, LLMs COMPLETELY remove this barrier to entry. You can write the logic and have the LLM add the contracts to get to the proof. This works in most cases.
And then, for truly critical code, you can look at functional correctness as a cherry on top of your cheesecake.
(1) security - If we want secure systems they have to be watertight. And AIs are good at hacking.
(2) reasoning ownership - The AI models not being open weight and their thinking not being published means you don't own the reasoning process. Formal modelling (of requirements and specification) and proving is a way to partially retake that ownership.
2. ????
3. Post Human Singularity or something
That won't cover all behavior, but it's more thorough than fuzzing, and even more than unit testing.
But yes: it'll just be another tool in the toolbox.
Of course you may have still written incorrect spec, and once you have IO you probably won't model the whole Linux kernel in the proof.
I vibe-coded a quick demo for that example (as I understand it), using Haskell because it makes such types easy and concise to prototype. Here it is: https://privatebin.net/?e19355429d608268#6vnv5LgavBnpM8NEfk7... (link will expire in a couple of days.)
This uses phantom types (type parameters that aren't associated with values) like `Human` and `Agent`, as well as using GADTs, but that just makes for a clean/concise example - neither of those features are essential for something like this. You could implement it in say, Go or Java, it would just be a little noisier.
It really isn't necessary to jump to Lean, and all the extra work that that entails (including linking to the actual code), to statically enforce such properties.
This is an example of what Yaron Misky described around 2010 as "make illegal states unrepresentable", or really even what Robin Milner described in 1978 as "well-typed programs don't go wrong", although the latter assumes that "well-typed" means that the program's types match its specified constraints.
The Lean theorem is that in the model, no sequence of operations, by anyone, ever yields a chain from an agent to a valid person. That's an induction over every possible history, which a type checker doesn't do.
It's been invaluable for us. It lets us think in a structured way and explore scenarios without writing all the code. It found design flaws before any code existed, and it lets us prove that things must be possible, not only forbidden.
I believe this kind of approach is going to be critical in security thinking (I think AWS's Cedar is doing more or less the same).
I think it's more that many may argue we never really reached high enough quality standards, irrespective of vibe coding. I also think that with good usage, LLMs can produce good code, but if we could also raise the bar while we are at it, why not?
It’s a huge vindication of all the architects and engineers that expressed dismay at management for not providing time to address that tech debt in real-time.
Even better. Management can never ignore tech debt ever again!
But at the same time we (architects and engineers) will be responsible for hardening our deployed systems.
I’m cool with that. That’s what I’ve been begging for my entire career.
But the problem isn’t having a fancy DSL. It’s just old school, boring, engineering discipline.
Exhaustiveness guarantees, compiler verification and feedback, powerful language features to create high-level domain syntax and languages, pure functions commonly used, and specifications/tests that can be read aloud in English and understood by domain experts… they’re even token efficient.
There will always be another use case.
Maybe something like Lean can be achieved, but constructing software in relation to a business model is vastly more complex than math.
We wouldn’t have Lean. We’d have Lean for every domain with variations for every business.
Can't really express in words how much that just pissed me off. I cannot wait for these fucking companies to get ruined by open models.
In this case, economics doesn't matter if quality is free. And users do care about quality a little bit at least.
[dead]
Exactly what the parent is saying. They are compromising on reliability and security. It’s a compromise every company is making very willingly.
And why wouldn’t they? No one is accountable for bad software anymore anyway.
The question then is if it's usable, and I'd argue it isnt any less so than other FPs or systems languages
Unless you're talking about reasoning about other languages deeply embedded in Lean, at that point we're not talking about Lean itself but about the model of that language stated in Lean.
It most certainly is not. No LLM exists which is capable of reaching, let alone exceeding, a competent human programmer.
I think this problem is functionally a subset of same the issue that FP has with modelling stuff at it's boundaries like IO
The work around algebraic effects and handlers is some of the more relevant prior art here
This is ironic considering the default GC strategy for GHC's RTS is a copying collector that puts values physically close if they are used together plus bump allocation. That has good cache side effects (heh).
There’s a reason basically every engineer at every company on Earth is using LLMs to some degree. Yes, it’s very very good for programming.
Obviously I can’t one-shot things and if you give it stupid prompts it will give you stupid output. That won’t change, ever. But that’s not a failure mode either.
You need to prompt at the right level of abstraction and carefully think about design. And if you do, it will produce higher code than you can by-hand in 1/100th the time. And, with unit tests, fuzzing tests, differential tests… the whole works.
what possible reasonable basis would i have to doggedly charge forward assuming that these immediately apparent issues with the basic language-processing-facsimile aspect of things will suddenly no longer be of concern when it's instead gnarly subsystem-spanning crosscutting concerns i expect to be tracked usefully across an entire codebase? particularly when things like parameters are to arguments as pronouns are to their antecedents which makes up but one tiny inherent subproblem of "okay computer design it good".
i'm certainly open to the argument that i'm just a weirdo who is simply not engaging with these things the same way as everyone else which may reveal a different set of problems invisible to most people's usage of the same tools. on balance it would probably be somewhat better if everyone else is not simply choosing to ignore these blatantly obvious issues, but the fact remains that i do encounter them relatively consistently and so have to grapple with that disconnect (and have been trying to basically since i first took a post-gpt nlp course). unfortunately, i don't particularly expect that to be the case given how often i see the same kind of issues apparently slip past other people and make it out to somewhere i can see it, but hey i'd love to be wrong.
anyway, i doubt i'll change your mind here and i equally doubt you'll change mine. not least because i just can't sustain enough intellectual respect for your side of the argument to take it particularly seriously given my own experiences. now, do i love the implications of that if you're right and your side nevertheless represents the unquestionable vast majority? obviously not, but here we are.
(also i believe you are missing a word somewhere in the semantic vicinity of "quality" in the middle sentence of that last paragraph unless the goal is indeed for language models to help my code experience mind-altering states on my behalf in the grand tradition of automating away the fun parts)
Verification is not about "happy path logic" but all computation paths (happy, error, cross-layer etc.) over the entire state space of a "system".
The system can include everything from hardware circuits all the way to distributed applications if needed. Across layers/components it works by composition of contracts where a higher-layer guarantees based on its lower layer's contract guarantees. The book i listed gives examples.
See also my comment here - https://news.ycombinator.com/item?id=50664740
Basically, you have to keep your module internals "pure", distinguish between domain exceptions (i.e. checked) vs. environmental runtime exceptions (i.e. unchecked) and push all "impure" operations to the boundary of the module.
Also see the following paper which shows how to formally model hardware faults;
Faulty Logic: Reasoning about Fault Tolerant Programs - http://www.cs.princeton.edu/~dpw/papers/faultylogic_esop2010...
I think software development and the tools underlying it could be wildly more powerful and exploit the underlying computer algebra more directly if dev tools didn't have to cater to the lowest common denominator imperative language dev
LLMs are valuable to me not because they can replace the types of coding these devs do, but because they have a far more deeper 'understanding' of the foundational math and algebra than could ever be expected of the average dev
There's ways software engineering could engage much more directly with these concepts to produce more sound and expressive results if the "user" could be safely assumed to be an IMO level mathematician like a sufficiently powerful LLM is
This is the correct way to look at using LLMs for coding using their "jagged intelligence". The key here is that the developer has to know enough of the formal methods mathematics to guide the LLM within proper guardrails such that it cuts down on the non-determinism. You don't have to be a master mathematician who knows every single detail but just have enough conceptual understanding of the domain that you can create modular components and link them together using pre/post/invariants/assertions and type-driven design. You keep overall control while leaving the drudgery to the LLM.
Here is one process methodology that i wrote up - https://news.ycombinator.com/item?id=50319347
JS devs are doing monadic development (async is just that), and plenty of lambda passings, with the predominant frontend framework model being one where the view is a pure function of state, driven by reactive changes of the state.
Functional won vast areas in mainstream programming. What you are saying may have been true 15 years ago, but not anymore.
Lean is garbage collected and you don't control the layout of types in memory (and everything is boxed)
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?
One of the primary structures that the project concerned itself with was written as a big fat z.object with all optional keys. In the logic, there were all kinds of runtime checks as nested if/else ifs looking for the presence of the keys and branching on their value if they existed. I discovered z.discriminatedUnions and realized that this could be checked once at compile time by defining the possible states of this structure, which progressed monotonically from one state to the next, never backwards
The logic then became a single comprehensive switch statement with an assert never default. Vastly simplified the rest of the application and obviated the nullish guards that were interspersed throughout the front- and backend logic. Life changing.
Now, I only use dynamic languages for trivial scripting or where the type system would be unneeded overhead. I am finding this to be rarer as my ambitions grow.
Also, the benefits of a good LSP provided by strongly typed languages with a robust ecosystem are huge. Makes reasoning about code so much simpler for me when I can peek any object's type in my IDE and go to definition. Ruby LSP is awful at this, you can't rename a variable globally nor can you go to a function's implementation if it cannot be determined. Not so with out-of-the-box tooling in strongly typed languages.
If by static types you mean where the verification language and the implementation language are intertwined, one has to ask: If LLMs write the code, what advantage is there to that intertwinement? That was a convenience function for human authors. LLMs don't care and can just as easily keep track of them as separate concerns.
Only if they have the context of every part of the code though. If you put type hints in your code then the LLM can understand the shape of what some code is supposed to send/receive without having to trace back through the code to the source of that data. That means a model with a much context window can successfully change it. That's both cheaper and faster.
Also, we can still do things without LLMs. You can compile and test code as a part of CICD, and having something doing a static type check is a good quality gate.
Maybe in a future where we run models locally that's not an issue, but if Anthropic 100x their prices tomorrow I'll be glad I left some aspects of development working without LLM input.
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.
Imagine all software you build is bug-free from the start. No technical debt, ever.
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.
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.
4a. The slop has been generated with rules and processes, ones that needed actual decisions and approval which never happened.
4b. Nobody reading the slop can distinguish between deliberate things that were chosen and approved, versus accidental things which were blindly generated and kept.
TL;DR it impacts the trajectory of the LLM negatively in a massive way IMHO.
If the majority say "you don't need a degree" then you don't need a degree.
If the majority believes in "move fast and break things" then things stay broken.
Why?
> You can compile and test code as a part of CICD, and having something doing a static type check is a good quality gate.
Nothing about separating concerns precludes that, of course. Most serious validation languages already avoid the intertwinement. It's not exactly a new concept. The trouble is that humans often find it hard to keep track of both at the same time, so we trick them into thinking it is one language to get around that (typically at the cost of lesser validation). But LLMs do not have the same trouble.
A type hint says "only accept things that look like this" and a compiling or a type checker can statically analyse the code to make sure that's valid everywhere. If you don't have that then the LLM would need to track back through the call tree to the originating point that defines the shape of the thing being passed to understand if it's valid all the way through the app in order to know that the data is correct. As it can't know where the originating call starts, it needs context of everything. It might only read the code it needs to read, and that can be done easily with an agent driving a small model, but it still needs complete access to every part of the app in order to trace what it needs to. With type hints it can just run the type checker to validate the code is OK and then trust the type hints.
Why wouldn't you have that? It is looking more and more likely that you accidentally replied to the wrong thread.
I agree. In fact I'd argue adding more representations (esp generative ones) just increase the chance of drift[^1].
Where types are useful is cross-cutting concerns. That is, interfaces between components/systems/whatever. I suspect the size of that boundary will grow with the capability of AI though.
They still use a language model to propose ideas though, and I have a particularly strong opinion on language models (or, as I like calling them since 2 days ago -- "well-formatted shit predictors"): https://news.ycombinator.com/item?id=50659297
Also, they are a business, so they'll probably want to sell you this stuff. I want to give it away for free (just give me a month).
They also have this footnote at the end: ``` Of course, the question of what constitutes a “mistake” is highly context-sensitive. It is perhaps more accurate to say that it is mathematically impossible for Lanyon ever to commit a misformalization. Every implementation will always match the specification, and every proof will always match the implementation, 100% of the time. In this sense, Lanyon guarantees perfect syntactic correctness. The issue of semantic correctness (i.e. how to guarantee that the formal specification actually matches the user’s natural language intent) remains an open area of research for us, spanning psychology, linguistics, philosophy, and agent harness development. We hope to have more to say about this soon. ```
for that, see Elenxis. Although Elenxis is still using a LLM as a module, and LLM can be misaligned, so it's not a complete solution. I do have some mathematical theory though for doing this well, and want to develop it further