20 comments

  • thesecretsquad 2 hours ago

    I'm not half as smart as most of the people on HN and I don't know much about formal verification, so maybe this is a dumb question....

    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?

    • iamwil 1 hour ago

      It is a gap, but the spec is often declarative, on what needs to be true, rather than imperative, about all the exact steps. Hence, less prone to error. You're right that it proves the protocol, but not necessarily the implementation.

      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.

      • dominotw 11 minutes ago

        > spec is often declarative

        ppl always come with weird workarounds to put in loops and if conditions and then throw it all away to use a general purpose programming languge

      • kettlecorn 48 minutes ago

        It helps substantially because it disentangles subjective and objective programming.

        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.

        • pratzc07 1 hour ago

          The spec is far smaller than the implementation. For example take the TimSort case whose implementation in Java and Python had a bug that was there for years until someone tried to formally prove it correct. I also think many valuable properties do not need specific domain judgement like never crashes, no out of bounds access, no data races etc. A spec says "what" not the "how" you still need someone who understands the requirement but they don't have to get every single edge case right. If a model writes both the implementation and the proof, the checker doesn't care who wrote them. Human review shrinks from "read all the generated code" to "read the spec".

          • Joker_vD 49 minutes ago

            > The spec is far smaller than the implementation.

            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.
          • ahussain 1 hour ago

            I would assume that the contract is much more concise than the implementation to satisfy that contract. Therefore, it's much easier for a human or AI to maintain.

            It's a bit like writing and maintaining a declarative SQL query (new-style) vs writing a query planner (old-style programming).

            • andoando 1 hour ago

              Were already trusting LLMs to write code, which means it has to translate the human language to both system requirements and make sure the implementation fits those requirements. Why not remove half the problem?

              There is also something excellent formal code produces: modularity

            • grahamlee 3 hours ago

              Difficulty: no existing model is trained on Truss. They have been trained on examples of design by contract in other languages (Ada, Eiffel, Java etc) and would do a better job with those and with contract-enforcement rules. Or even with grammar-constrained output and those languages.

              Source: I also tried writing an agent-optimized language (for concision and adaptability, not correctness), then I measured.

              • spankalee 2 hours ago

                This is not my experience at all. LLMs universal translation abilities let them pick up new languages really easily, especially if they borrow from existing languages and are consistent.

                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).

                [1]: https://zena-lang.dev/

                • brightball 3 hours ago

                  I saw a talk this year from one of the Pony Lang folks talking about this exact problem and how they essentially taught Pony to Claude.

                  https://carolina.codes/speakers/2026/redvers-davies

                  It was really interesting. Pony is also deeply underrated.

                  • btown 1 hour ago

                    That's a great talk, and it has a resonant quote: "If you let your LLM us a general purpose language, your LLM has to solve all those hard problems instead. Good languages make the illegal impossible."

                    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

                  • malloc2048 1 hour ago

                    raise hand

                    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.

                    • mikece 1 hour ago

                      Maybe the answer isn't to create a new language for AI, but add to Python the things that Claude tells me makes other languages better for some things, like type safety and a try compilation step to find errors way ahead of runtime.

                      (Or did I just describe something that has been done eleven times already?)

                      • freeone3000 1 hour ago

                        `ty` and `mypy` are efforts to add this to python. It's fairly inconsistent because of the vast library of python code that doesn't use it, much like early typescript. Unlike typescript, however, there's not the huge push right now to adopt because python coders are happy where they are.

                    • capv 3 hours ago

                      +1. You cannot teach AI a new programming language with prompts. In order to be efficient the language has to be in its "brain", i.e., AI's neural network has to be trained on large number of samples.

                      • amterp 1 hour ago

                        > You cannot teach AI a new programming language with prompts

                        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.

                        [0] https://github.com/amterp/rad

                        • rfgplk 3 hours ago

                          They already have been trained, on other languages that provide similar-enough constructs to translate over to the new language. Same principle as how a C++ developer can write Rust after looking at a few syntax examples.

                          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.
                          • cyanydeez 3 hours ago

                            you don't want anything thats extremely close; you want something that is dissimilar and users very cogent keywords.

                            Similarity shits up context very quickly.

                        • latentsea 3 hours ago

                          If any such language gets adoption or even seems like a promising direction, I think in this day and age it should be trivial for the labs to RLVR it into the model with synthetic data.

                          Edit: if you use local models you could probably fine-tune or do a LoRA for it yourself.

                          • rfgplk 3 hours ago

                            Incorrect. Models can actually adapt to new syntax quite easily, even with zero training material. Of course that does depend on how truly novel your syntax && constructs are, but generally speaking if you don't deviate too-too far from conventional wisdom you should be fine. My language is quite exotic in fact and frontier LLMs have no trouble writing it, as long as you supply a .bnf file.

                            • DonaldPShimoda 3 hours ago

                              It's funny: if we were talking about programming languages generally, I would pop in to say something about how syntax really doesn't matter and a language having "exotic" syntax is almost entirely irrelevant. But since LLMs only interact with syntax, it's interesting that they are seemingly able to adapt to novel syntax fairly well.

                              • dom96 3 hours ago

                                They do fine even with completely novel syntax. I built a programming language designed to be hard for LLMs[1] with syntax that no other programming language uses and most can get the hang of it pretty quickly.

                                1 - https://killswitch-lang.org

                                • six_seven 2 hours ago

                                  Dumb question maybe (IANAAIPowerUser)- this new teaching will now always occupy some part of the working context right? As a result of that 1) Do you have smaller usable context? 2) Does the model over-use the new teachings?

                              • alexanderabakah 2 hours ago

                                Great idea, but I believe AI you can't make an ML model efficient just through prompts. You must train the model with the language and vast samples of code written in that language. Even with python which is ubiquitous, something models struggle with optimization or smart algorithms it hasn't seen during training.

                                I guess the best way will be to improve on existing languages by adding the contracts and verification methods on top of them.

                                • sureglymop 3 hours ago

                                  Maybe I am finally getting old but I remember `truss` as a sort of `strace` alternative.

                                  • onedognight 2 hours ago

                                    MocOS still ships `dtruss`, but it’s hobbled compared to Linux’s `strace`.

                                  • npalli 55 minutes ago

                                    Declaring the contract, provider etc. in quasi-Rust? No thanks. I think there should be better ways to do that.

                                    • abeppu 2 hours ago

                                      Proofs about program correctness are great but I don't think this even really attempts to argue why a new language is needed or what this does better than other systems in the space. The only other language mentioned in this project page is Rust as "a small step", but doesn't mention F*, Dafny, Idris, Verus, CakeML etc. I think basically all of these have some greater burdens for authors which previously made them realistic for only some projects, but now that we can have agents deal with those headaches, maybe they should expect to see broader use.

                                      • miffy900 1 hour ago

                                        it's interesting you mentioned Dafny, as after taking a look myself, I see the method specification syntax that Truss uses, has keywords like ensures and requires which is straight up from Dafny, which itself is a Microsoft Research language made by a person who worked on SpecSharp (basically contracts for .NET). 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.

                                      • wavemode 1 hour ago

                                        How does this differ from just plain Lean?

                                        • irdc 1 hour ago

                                          Considering LLM performance tends to depend on how well a particular language was represented in its training set[0], is this even going to work?

                                          0. https://esolang-bench.vercel.app/

                                          • ModernMech 1 hour ago

                                            That paper is benchmarking esolangs, which are meant to demonstrate concepts, not to be usable —- some of them try to be as unusable as possible. So it’s the pathological case.

                                            • irdc 45 minutes ago

                                              But that's usability from a human perspective; an LLM shouldn't be bothered by it.

                                          • Kuyawa 3 hours ago

                                            I've been beating this drum for some time, this is the way forward

                                            • mathisfun123 1 hour ago

                                              This doesn't work without a formal spec for the target ISA.

                                              • rahen 2 hours ago

                                                Original commit two days ago with +663,934 lines of Rust. Eight commits. Already reposted six times on HN since then.

                                                I'm not sure I want to bother with something where the only human involvement was generating the hype.

                                                • ModernMech 58 minutes ago

                                                  Assuming the human is even doing the hype. I think if the author isn’t actively participating in the discussion they tried so hard to get going, we can (or should) just assume they’re a bot.

                                                • pwdisswordfishq 3 hours ago

                                                  Named for having the lifespan of an iceberg lettuce?

                                                  • nmstoker 2 hours ago

                                                    Great name for their test suite!

                                                    • Lio 43 minutes ago

                                                      There's got be a bad with cache joke in there somewhere.

                                                      • louthy 3 hours ago

                                                        Each program takes 49 days to run, and then never runs again having destroyed the computer that it was running on.

                                                        • ltrg 1 hour ago

                                                          Had to actually read the comments to find this after Ctrl-F "liz", Ctrl-F "brit" failed me.

                                                          • phoghed 3 hours ago

                                                            Named for how you have to respond to people at work questioning wtf you’re doing. “We got this bro. Truss”

                                                          • meitham 1 hour ago

                                                            Lovely idea, but I reckon the lettuce on my shelf will probably outlast this language!

                                                            • ivanjermakov 1 hour ago

                                                              > Traditional programming language: Optimize for human editing, Optimize for convenience, Minimize human authoring time

                                                              Nothing is better than a fresh load of false dichotomy.

                                                              • joshheitzman 1 hour ago

                                                                > optimized for agent-written software

                                                                Benchmarks or it wasn't optimized.

                                                                I followed the link, poked around, and couldn't find any benchmarks results.

                                                                • pmkary 1 hour ago

                                                                  If it ain't gonna formal verify, it ain't gonna rhyme (just as demonstrated)

                                                                  • semiinfinitely 2 hours ago

                                                                    so the idea is to invent a new programming language that agents have not been trained on for trillions of tokens, and somehow they're supposed to be better at it than all the languages they have been trained on for trillions of tokens??

                                                                    • IshKebab 2 hours ago

                                                                      The trouble is: a) if you want formally verified software you can write it in Lean - AI is extremely good at that, and b) why should I use your 3 day old vibe coded language when I can just as easily make one myself?

                                                                      • acedTrex 3 hours ago

                                                                        Its hard to hate a project more than this to be honest. What an anti human way to think.

                                                                        • nonethewiser 1 hour ago

                                                                          Why does that bother you? Its a programming language for an AI, of course it's not for humans.

                                                                          • IKnowMazin 1 hour ago

                                                                            Agreed

                                                                          • Incipient 2 hours ago

                                                                            We've had a few similar formally verifiable, contract based, provable languages appear recently.

                                                                            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?

                                                                            • qayxc 2 hours ago

                                                                              No. Tests can only uncover the presence of errors, never their absence. Ideally, pre conditions, post conditions, and invariants are part of every function. Nothing new really. Languages like Eiffel have been doing this for decades, but everything old is new again, I guess.