Hacker News new | ask | show | jobs
by hansvm 2 days ago
Yes, but there's an implicit assumption that many parts of the contract are easier to understand than the corresponding code.

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.

1 comments

My MSc is a spec for a business system. It’s a state machine in Alloy. For accounting. Basically it is free of a lot of accounting errors. It is painful to write such a spec. Very much so. But it pays off handsomely. Throwing my thesis in an LLM generates amazing software. It took two years to write so yep that’s not something you can do easily. On the other hand asking an LLM to write a spec given the natural language version of the thesis say yields a terrible Alloy model! So it pays off if your software is mission critical
I think my point is that for business logic I often see code like

  candidates.remove_all(x -> x.tracking_disallowed)
And specs like

  require candidates.all(x -> !x.tracking_disallowed);
Getting the spec right is not just equally hard to getting the code right; it's equally hard in _exactly_ the same ways.

And that doesn't invalidate the use of specs and formal verification. I use them a lot, especially any time I touch nontrivial concurrent code (which is most concurrent code).

It also doesn't invalidate it for any specific use case (accounting seems like a classic example where there are known invariants which are easy to prove and harder to get right).

As a new language tailored for LLMs though, the presence of specs doesn't seem to me like it'll solve enough of the normal classes of errors to pay for its complexity budget. It doesn't seem, by itself, like the next big thing. Without some solution to that "business logic" problem I mentioned, which very well might include formal methods as a component, my baseline prediction would be a resounding lack of notable success for the project on almost any axis the author cares about. I'm happy to be proven wrong of course; I really do like when people succeed, especially with clever new ideas; but my normal optimism is wavering here.