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

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

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

reply
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

reply