Posted by sram1337 3 hours ago
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?
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.
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.
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.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
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.
Edit: if you use local models you could probably fine-tune or do a LoRA for it yourself.
I guess the best way will be to improve on existing languages by adding the contracts and verification methods on top of them.