130 points · by sram1337 · 1d ago · 103 comments
My understanding of this is: You write a "contract" that defines the specification for some functionality, including inputs, outputs, preconditions, post-conditions, etc. and the contract can be formally verified by some proof checker that says it's logically consistent. Then you build the implementation and the implementation can be proven to abide by the contract (or not).
But somebody has to write the contract (either a person or AI). If the contact specifies behavior that is logically consistent as far as a proof checker is concerned, but the behavior is defined incorrectly, you could have a situation where "you built the thing right", but "you didn't build the right thing".
So someone still needs to make sure the contracts are specifying the correct behavior. Once you know you have, then I suppose the formal verification is good because everybody (people and AI) know that it guarantees its behavior.
My question then is: Assuming everything I just said isn't nonsense, aren't we still in the same place as before? Someone needs to know how to specify (and program) the right behavior?
A not-quite-there way to close the gap is that you can generate traces from the spec/proof, a sequence of states and events that must hold true. and then you can use that trace to replay back in tests, and if the implementation is correct, then it should mirror the trace.
E.g. with a normal programming language a bug in the hash-map internals that rarely returns the wrong element is undectable. With a spec, if the spec says it can ever return the wrong element, I'm going to run head first into that when I try and prove that my pathfinding algorithm using that hashmap for memoization is correct.
In situations where the specification is as complex as the program one should really wonder if one is doing the right thing.
That heavily depends on what problem you're trying to solve. The very example from TFA is quite illustrative:
contract ReplaceElement {
function replace(words: &mutable Slice<UInt64>, index: UInt64, value: UInt64) -> UInt64
requires index < words.len
ensures result == old(words[index])
and snapshot(words) == update(old(snapshot(words)), index, value)
terminates
effects { read(words), write(words) }
}
implementation InlineReplaceElement of ReplaceElement {
function replace(words: &mutable Slice<UInt64>, index: UInt64, value: UInt64) -> UInt64 {
let previous = words[index]
words[index] = value
previous
}
}
Or take, for instance, this spec in English prose: "given a predicate that returns true or false for each value, and a list of values, `filter` returns a new list that contains exactly the values in the original for which the predicate returned true". I guarantee you that turning this into the Truss contract would produce a significantly larger amount of code that the implementation that would consist of just the following 5 lines, modified accordingly: result := []{}
for _, v := range list {
if predicate(v) { result = append(result, v) }
}
return result
And of course, please note that the spec I've given is defective: it doesn't say anything about the order of the elements in the resulting list, or the presence/absence of duplicates. Also, you probably will have to insist on the predicate being a pure or at least a repeatable (reproducible?) function — I don't know how you'll spec `filter` when it's given a non-idempotent predicate.Take sorting as an example. Verifying any one instance is easy even in something like Python
all(a<=b for a,b in zip(L,L[1:]))
Which wasn't really made for the task. If you have theorem proving as part of your contracts then that just gives you extra confidence above and beyond however else you're verifying them. Note that this is much easier to understand even if you don't know Python than a typical sorting algorithm.I've personally never seen a contract system properly handle business rules well (the set of rules is usually about as verbose and we'll abstracted as the top-level code implementing them, and bugs are typically exactly the issue you posed, that the rules were improperly specified), so I'm skeptical of this approach.
Like if you want a program that sorts a list that is a subjective goal because you could just as easily choose a shuffled list, or a different sorting, or any other sort of list ordering.
Once you've established what you want fulfilling that is an objective task.
Today's programming languages entangle subjectivity and objectivity together, and better decoupling them means we can automate the objective parts which dramatically reduces the programming left over for humans.
I’m not sure where software engineers would take over, but given a sufficient spec, the system ought to be a direct translation of that spec. Ideally the spec itself should compile to realize system.
In practice, that framing also loses the distinction between expected and actual system behaviors; bugs are impossible by definition because — that’s the spec!
We’re in need of a high-level specification language that suits a product person in partnership with an LLM. Say goodbye to lengthy requirements documents and hello to very rapid implementations — high-fidelity system implementations at the speed at which product can request them.
Maybe software engineers would have a role connecting some of the lower-level pieces or maybe it would completely displace jobs for many of us. As inconvenient as that would be, the purpose of computing is to build useful systems, and a process that does that an order of magnitude better than what we do today would be the right thing to do in the long run. It might even create more demand for software engineers, in that paradoxical way that innovation sometimes works. Hard to say.
It's a bit like writing and maintaining a declarative SQL query (new-style) vs writing a query planner (old-style programming).
There is also something excellent formal code produces: modularity
You have a point, but the missing piece is the context size needed to iteratively write said contract.
Another angle to look at it -- we already do something like this (TDD) and it works, even if the classic argument says you can have bugs and gaps in your tests Yes you can, but you can also have good and helpful tests. Also type systems while not being tests are from the same general area -- they express constraints which can be wrong.
Yet another angle to look at it -- it's easier to write a lot of declarative stateless code plus a small library solving general case of the statefullness than writing ton of stateful imperative code. From the correctness standpoint of course.
Add: contract being smaller than implementation is mentioned here, but it's a correlated metric to what I mean above. Even if the contract is longer, it could in theory allow refining different desired properties and their interactions in separate context windows. The contract being longer will also mean it specifies the behaviour in more details.
Similar to that concept but applied to more than just types.
In fact specifications can be written in the form of types. So for example:
Func(int, int) -> int
Is saying this function takes two integers and the output has to be an integer. That is part of a specification.You can also write:
Func(int + N, int + M) -> int + M + N
And that’s the sort of thing formal verification is. But it also sort of changes the way you program because you have to build your program from smaller pieces that are axiomatic.For my explanation you can understand the specification part but writing a program that can be proved to fit the specifications automatically (via the axioms) is harder to illustrate. It’s all very mathy.
The hard part was never expressing the intent in a given language. The hard part is (and always has been) coming up with that intent in the first place.
The concept presented here is soemthing we do anyway in both OO and functional languages. Some syntaxes are more imperative and others are more declarative but nothing ever stops you from shipping behaviours or even tests as a package.
Source: I also tried writing an agent-optimized language (for concision and adaptability, not correctness), then I measured.
I've been building a new programming language, Zena [1], for a year and modern Claude and Gemini have absolutely no problem generating the code with about a 300-line skill: https://github.com/elematic/zena/blob/main/skills/zena/SKILL...
(I also happen to be adding contracts and formal verification for gen AI, maybe similar to Truss, but that targets Wasm for sandboxing).
https://carolina.codes/speakers/2026/redvers-davies
It was really interesting. Pony is also deeply underrated.
I think there's some truth here: linters and compilers for general purpose languages are only so powerful, and LLMs will always be tempted to use patterns they've seen before when they're knee-deep in a language they think they understand how to use for your problem. Restricting them to think about problems from first principles in languages with clear and enforced guidelines about data sharing, ownership, traceability, etc. can be very powerful.
Direct link to talk: https://www.youtube.com/watch?v=oU5sV1ljTzs
Here someone else who tried to write a coding agent optimized programming language, but I asked it to optimize for cost. Using less tokens is an obvious one but while working on it the actual engineer (LLM) decided that saving on tokens would be marginal savings compared to being able to write the same quality code by a cheaper model. But it never found out how.
After a couple of hours seeing benchmarks in which it lost from Python on pretty much everything, it told me to give up. I did.
(Or did I just describe something that has been done eleven times already?)
Incorrect. I built my own programming language [0] and agents just look up the docs and write it with great success. It helps to have static linting/analysis of course, but they always do just fine writing Rad despite it being very small.
For instance:
contract ReplaceElement {
function replace(words: &mutable Slice<UInt64>, index: UInt64, value: UInt64) -> UInt64
requires index < words.len
ensures result == old(words[index])
and snapshot(words) == update(old(snapshot(words)), index, value)
terminates
effects { read(words), write(words) }
}
This is _extremely_ similar to JS/Rust/Java style syntax mixed with common forms from general ALGOL descendant languages. LLMs should have no trouble writing this whatsoever.Similarity shits up context very quickly.
I guess the best way will be to improve on existing languages by adding the contracts and verification methods on top of them.
I went around and around today because Claude wrote to obsidian in the wrong folder even though the obsidian vault path was in the env variables. It writes to obsidian 20 times a day and suddenly it writes to a path outside the vault path. The content never synced.
It claimed it went from recall and didn’t check the environment variables. I pointed out that each process wrote successfully to the correct path and it retorted that each effort is a new effort and had nothing to do with previous successful efforts.
These situations require more and more deterministic instructions in AGENTS.md but then it’ll find another way to escape the instructions. It’s an endless digressive evasive cycle.
I couldn't find a connection between Truss's author and Microsoft, so I do wonder if he maybe got an LLM to design the syntax, which then included prior art from Microsoft etc.
My hypothesis is that if LLMs are intelligent, they should benefit from usability the same way humans do. Maybe not to the same degree, but more usable languages for humans should be more usable for LLMs compared to pathological unusability. Perhaps you can get around unusability with enough data, or maybe you can get away with fewer training data by being more usable.
Some of these esolanguages might be pathological for LLMs because they require them to engage in thinking they're actually structurally bad at -- Befunge-98 executes in two spatial dimensions, while LLMs process a linear stream of tokens; Whitespace encodes instructions entirely through spaces, tabs, and newlines, potentially confounding tokenizers; Shakespeare uses theatrical dialogue but resembles neither conventional code nor authentic dialogue; Brainfuck effectively requires the LLM to simulate execution while generating code.
So the really interesting question to me at this point is: how much can you change Python or another language that is mainstream before you see the kind of dropoff performance you see with the esolangs? I dunno.
The authors of that study you linked did a followup: https://esolang-metaprogramming.vercel.app
There, they let the LLM write Python code which then wrote the esocode, which at least shows the LLMs understand the assignment. But that doesn't really resolve the question we have.
C is such language that we should target.
- It is Optimize for correctness. - Small language footprint means easier for human verification. - Closer to hardware means greater speed.
Memory management should be handled by some library.
It can't even natively handle SIMD instructions, so in most cases you can't write the most efficient code with it.
And we a long history of how well "small language footprint means easier human verification" works.
I'm not sure I want to bother with something where the only human involvement was generating the hype.
Nothing is better than a fresh load of false dichotomy.
Benchmarks or it wasn't optimized.
I followed the link, poked around, and couldn't find any benchmarks results.
Can it do maths?
How quickly can it unseat the UK government?
Isn't that whole concept covered by a test suite? The language can't know what you want to do, so you have to write a contact/rule/etc for it - in the same way you'd write a test?