100 points mpweiher 15 hours ago 70 comments
tiffanyh 13 hours ago | parent
danilafe 12 hours ago | parent
I was aware of SPARK but not particularly familiar, and dropped it from my enumeration of relevant technologies unintentionally (though, the purpose of the post was not specifically to enumerate relevant tech). I really should read up on SPARK!
tiffanyh 11 hours ago | parent
https://www.adacore.com/blog/should-i-choose-ada-spark-or-ru...
(I enjoyed your post btw)
danilafe 11 hours ago | parent
kccqzy 12 hours ago | parent
This is actually also what I realized after a year or so in industry. (I was quite enamored of formal verification in college.)
rrook 12 hours ago | parent
danilafe 12 hours ago | parent
rrook 11 hours ago | parent
A ──f──> B ──g──> C
Any single proof can first be thought of as proving an assertion about the graph. "There exists a path from A to C that traverses g." From there, the proof is bog standard graph maths.
In the abstract, all expressions of logic are graphs, like...statements of graph state, mutation, comparison, relation, differentiation, etc. An expression of language can be an incomplete expression of a graph, and other expressions can fill in the missing pieces or assert things about it. The language can express both the computation and the logic we use to reason about that computation.
In a sense, proof languages typically operate this way. They build a graph, assert something about it, and prove it in the mathy-graphy-sense. Mainstream programming languages have not yet put the graph structures front-and-center in the language design, and in the gap between the two we feel friction.
soulofmischief 11 hours ago | parent
nylonstrung 6 hours ago | parent
The example you gave in the comment below is something that seems to me like it could be expressed in purely algebraic terms without explicitly invoking graphs or hypergraph as foundation.
Ericson2314 11 hours ago | parent
danilafe 11 hours ago | parent
Ciantic 9 hours ago | parent
Its macro capabilities make it very nice for SQL driven apps. I've been working one small invocing schema, and you can derive the Insert, Patch etc types with just macros with `deriving Patch` at the end of your type.
Also, one of my reasoning is that if these AI LLMs are tuned to work with millions of lines of Lean, it probably is very efficient for it.
nylonstrung 9 hours ago | parent
https://github.com/palladin/lean-linq https://github.com/palladin/lean-cloud
kzrdude 10 hours ago | parent
logicchains 10 hours ago | parent
armchairhacker 8 hours ago | parent
Lean:Rust::Rocq:C++
nylonstrung 6 hours ago | parent
As a result of that and other choices Lean also felt more natural and ergonomic to mathematicians than Coq. And the early Lean community did a very good job at using this to build Mathlib which coalesced into a comprehensive library for reusable proofs and math concepts which compounded and built upon itself with standardized conventions
In contrast much of the Coq ecosystem's output has increasingly fragmented rather then accreting like Lean's has
It also helps that Lean is uniformly 1-2 orders of magnitude faster than Coq, partially because it compiles to C
smj-edison 11 hours ago | parent
Another difficulty is with programming, we succeed by making abstractions that don't leak, where with math we're constantly opening up mathematical objects and messing around with their internals, chaining together the internals with theorems to get to our desired outcome.
Since we so often need access to the guts of the objects we're working with to prove facts, it makes it really hard to interoperate with other systems, because either we have to make assumptions about those systems which can compromise correctness or we have to be able to plug in all the way.
Signed, an undergrad in math with decent coding experience.
random3 9 hours ago | parent
I'd sum it up as starting to code before/without trying to get a proper* understanding of the end-to-end problem, and then incrementally adjusting along the way. This often solves a chicken and egg problem, of not being able to advance understanding before building. The problem is not rewriting or fully refactoring the code once your understanding persist. Often this is too late (aka "shipping the prototype"). Then everything expands into more complexity over more or less** time.
I think this whole process can actually be described formally. I'm not sure how much it matters anymore, but I suspect agent generated code suffers from the same issue, just with different measures due to speed/memory advantages agents have.
----
* I say "proper" assuming "full" is likely unachievable in most settings
** the difference between many software projects can be reduced to how fast they become dead ends based on how fast complexity explodes.
bigbadfeline 12 minutes ago | parent
That's good but it doesn't prove your point, or any point for that matter.
> I'd sum it up as starting to code before/without trying to get a proper* understanding... [chicken, egg, omelet] ... > I think this whole process can actually be described formally.
I'm not sure why anyone in his right mind would want to describe formally this entire process. Formal verification proves the correctness of the code produced by this process, not the process itself - and correctness is always provable, if in fact the code is correct.
latentsea 7 hours ago | parent
So, we basically fail then.
somethingsome 7 hours ago | parent
you usually define the internals of your mathematical object based on the requirements of the 'rest of the system' and then you study the objects a lot to see it they even make sense or collapse.
As soon as you have an object that does not collapse, you know you can use it.
Take for example measure theory, you start with the basics axioms that are there to make the measure useful to others, then, based on the axioms you derive everything that you need to ensure that it's well defined, and then some more theorems that are like glue code to be able to use that measure for particular cases.
In this view, the axioms are your basic API, and the 'glue' theorems for an application are your frameworks.
Now a big difference between maths and programming is that maths is way bigger and more complex though
kenferry 4 hours ago | parent
I also somewhat disagree with you about abstraction. In programming as well we move "up and down the ladder of abstraction", which means opening up objects and revisiting how we've built their abstractions. If you're doing performance work or debugging, while you don't exactly IGNORE abstractions, you're definitely opening them up.
Signed, professional software engineer with math degrees. :)
smj-edison 26 minutes ago | parent
Of course, when I have a good design for a program I also have a mental map of how it all connects, but the methods I use to morph a problem in programming is sequential and directed in a way, where proof by contradiction or contrapositive feels very different.
kccqzy 3 hours ago | parent
The idea of making abstractions comes from mathematics. The entire field of algebra is just abstractions. Algebraists think about the group, the ring, the field rather than the underlying objects. These abstractions absolutely don’t leak. These are some of the most elegant abstractions available, and this style of abstractions is known as type classes (in Haskell) or traits (in Rust), and is far superior to programmer-derived object-oriented abstractions. Why do most programmers create abstractions that leak? Because they are only taught object-oriented programming and yet without even learning about the Liskov substitution principle.
smj-edison 37 minutes ago | parent
I'm aware about bidirectional implication, but that's not quite what I'm getting at. With programming I think in terms of starting with some input data, successively applying calculations, and then ending with a result. There's a step-by-stepness to it. With math I have to think of it existing in all ways, simultaneously. Equality works both directions, but variable assignment doesn't. Math functions go both ways (at least when they're bijective), but programming functions only go one way. Maybe I haven't done enough math yet, but it hurts my brain in ways that programming never has. I don't usually program contrapositively or by contradiction.
And it's true that math arguments are presented linearly, but that's because there's not really another way. I have to reconstruct the mathematical framework from the linear presentation, but it hardly feels linear once it's all brought together in my head.
> The entire field of algebra is just abstractions.
I'm afraid I haven't taken abstract algebra yet, that'll be next semester! But I hadn't considered about how algebra works with objects that satisfy certain properties, so I'm glad you've brought that up. Thus far I've mainly been done proofs in linear algebra and my intro to proofs class, so that certainly colors my understanding.
yehoshuapw 2 hours ago | parent
smj-edison 29 minutes ago | parent
NatKarmios 45 minutes ago | parent
nylonstrung 9 hours ago | parent
Lean is already an extremely powerful and performant FP whose capability is essentially a superset of all other FPs and which has the most powerful metaprogramming and DSL building features outside of Racket
It has massive, likely insurmountable network effects in terms of the lemmas already written for it which can be reused in general purpose contexts
What we need is more libraries, frameworks, contributions to Core and Batteries which make it more useful outside of the domain of pure proofs and mathematics which has obviously been the focus so far.
danilafe 9 hours ago | parent
It's not clear to me, however, that the space is completely filled. I find it hard to imagine using Lean for software that deeply interacts with the OS or hardware, or even just "doesn't refcount". Am I unaware of progress in this area? In a similar vein, in terms of practical software success, I think we've seen the most with model checking, yet Lean is not particularly amenable to this. It remains to be seen whether tactics and proofs (+ some sort of repair) will beat out the incumbent.
jeremyjh 8 hours ago | parent
I think Lean could perhaps serve in most server application use cases (and many others - roughly any use case where you could use Haskell), and Aeneas or something like it could leverage Lean only for verification. https://lean-lang.org/use-cases/aeneas/
danilafe 8 hours ago | parent
jeremyjh 8 hours ago | parent
nylonstrung 8 hours ago | parent
And it compounds with Lean's dependent type system and the ability for proofs to be "bundled" into said dependent types and then erase at elab time
erichocean 8 hours ago | parent
Update: Google did something similar here: https://deepmind.google/blog/introducing-alphaproof-code/
nylonstrung 8 hours ago | parent
> I find it hard to imagine using Lean for software that deeply interacts with the OS or hardware, or even just "doesn't refcount".
This is true: my thought is that the path to using Lean for "practical software" looks like delegating a lot of stuff like I/O to Rust libs. Lean will soon be able to compile to LLVM IR instead of just C and IMO it makes more sense to think about how to fill the gaps with the smartest cross-lang approaches rather than to rebuild a lot of basic stuff as pure Lean
danilafe 8 hours ago | parent
> my thought is that the path to using Lean for "practical software" looks like delegating a lot of stuff like I/O to Rust libs. Lean will soon be able to compile to LLVM IR instead of just C and IMO it makes more sense to think about how to fill the gaps with the smartest cross-lang approaches rather than to rebuild a lot of basic stuff as pure Lean
I think this is the sort of approach we should pursue to make progress towards verification as an industry. But every time I write low-level code, and have to think through complicated cases, I feel that it is there that I need the most help. That's when I dream of a tool that can meet me at my level of abstraction and help me lean on rigor and verification. This is part of why mainstream verifiable languages have been on my mind personally, and I admit this implicit bias may affect the focus of the article and original claims.
smj-edison 14 minutes ago | parent
[1] https://digama0.github.io/mm0/thesis.pdf, page 67, and https://github.com/digama0/mm0/blob/master/mm0-rs/mmc.md
kccqzy 3 hours ago | parent
dnautics 8 hours ago | parent
Is that what we really want? For SW verification you mostly want "just plain logic" and really "set theory" is enough. Sure, the result will be more verbose, but do we care anymore now that the LLMs are writing so much of things? We should pivot to one where these two properties hold:
1. The bridge between the code and the proof is obvious
2. The proof is easily checkable by a human. That could mean more verbose, if you don't elide logical step or steps where the prover goes and looks for a theorem that satisfies the assertion.
jeremyjh 8 hours ago | parent
I haven't gotten far enough into this to really speak knowledgeably about this, but my intuition suggests that the intrinsic model has some significant advantages - specifically it encourages/forces you to model all your invariants in a dependent type system in the first place, and then you can prove things about the interaction of those invariants in a higher abstraction layer that is continuously checked as the program evolves.
A language without a dependent type system is significantly constrained in the invariants it can prove in its type system alone - perhaps there are properties you'd have to prove with (pure) unit tests to supplement the type system, and this further constrains design.
dnautics 8 hours ago | parent
I mean, no? Sure, you can't prove that some user function doesn't make a syscall that under the hood allocates on page, for example, but you can certainly derive invariants (like safety guarantees) based on stdlib usage, and report if a stray syscall or ffi occurs for manual review. You could also maintain a list of "cleared" syscalls/ffis that the prover should just ignore moving forward.
As for other things, you're going to have to annotate your software in general. Be that in comments, some sort of metadata tag, even some in-tree manifest file. For example rust does not encode "this is a database call" in its type system. So if you want to instrument your code to verify that no consistency errors can occur (for example, not wrapping a read-modify-write in a transaction) you can't just do it by analyzing the language, you'll have to write your "own plugin". That's why having access to the IR (versus the asm) is better, because you have access to metadata that gets chucked out the window when it goes to asm.
jeremyjh 7 hours ago | parent
Right, and some languages - like Lean - can do that.
nylonstrung 8 hours ago | parent
I think all the capability it has to verify software and improve correctness are realized far more fully and elegantly if the software itself is built with Lean. Ironically, much of the of software verification by proof it's known for can be rendered unnecessary IMO because for example typechecker itself can enforce correctness by construction
"Come for the verification, stay for the type system and metaprogramming." At the very least the proof/verification usecase has resulted in hundreds of millions poured into Lean-centric startups like Harmonic and LLM post-training which gives it an advantage no other existing functional language has had or will ever have.
jeremyjh 8 hours ago | parent
* Lean 4 is self-hosting
* Lean has monadic I/O, do notation, type classes and other Haskell inspired syntax and language features.
* There is at least one guy building infrastructure fundamentals for web app development: https://github.com/paulbutcher?tab=repositories&q=&type=&lan...
* If you know and like Haskell, Lean is quite approachable (at least initially).
* Dependent types can be much easier to understand than the capabilities possible with the many different type extensions in Haskell. For example, lean-pq has compile time verification of usage of table schemas (that are defined in code) and the machinery for that is very simple to understand compared to the various Haskell libraries that achieve this (click the Try it link at the bottom of the README section on this at https://github.com/typednotes/lean-pq#compile-time-column-ve...)
latentsea 7 hours ago | parent
blacksqr 9 hours ago | parent
A subset of Ada (SPARK) is formally provable.
Both are relatively easy to learn and use.
Options to produce better code have been available for a long time.
The more interesting and perplexing question to me is why weren't they brought into the mainstream decades ago?
And what will have to change for them to get serious consideration?
It seems to me that even total evisceration of existing code by LLMs has not been enough to prompt meaningful reconsideration in the mainstream of how programs are developed.
dnautics 8 hours ago | parent
dnautics 8 hours ago | parent
Inspired by that, I think that an interesting place to patch verification in to an existing language is at the IR level. At the IR level, you have usually (effectively) a highly-regularized schema for all operations, that is usually still embued with semantic information (for example: the function you called is "malloc") that can be used to generate invariants that you'd like to prove (or refute).
Of course you still have to trust that the IR->ASM part of the compiler is good, but at least the program logic has been verified.
saithound 8 hours ago | parent
> One of the most interesting things is how Sel4 works -- IIUC they compile to arm64 assembler, and then run verification proofs on that
But that's not how seL4 works. The seL4 proofs are refinement proofs. No assembly is involved, and the verification work is done on the abstract mathematical spec, and the C implementation. Here's how it works:
1. They write a mathematical specification in Isabelle.
2. They prove good security properties about the mathematical specification. They show that a correct implementation of the specification wouls prevent applications running on top of it from modifying data without authorisation (integrity), from interfering with resource access of other applications (availability), and from learning information from other applications without explicit authorisation (confidentiality).
3. They prove (in Isabelle, an interacrive theorem prover) that a Haskell program refines an abstract Isabelle specification, then prove that the C implementation of seL4 refines the Haskell program.
4. They compile the C program using gcc, then prove (using an automated tool) that the machine code was compiled correctly. This works on ARM and RISC-V. Assembly is not involved in the proof, only machine code and C code.
5. Together, the chain of refinements in 3,4 imply that the running binary correctly implements the mathematical specification. Sincw the specification satisfies the good properties, so does the implementation. In other words, the seL4 KERNEL prevents applications running on top of seL4 from modifying data without authorisation (integrity), from interfering with resource access of other applications (availability), and from learning information from other applications without explicit authorisation (confidentiality). Together these security properties enforce the isolation of components running on top of the kernel, allowing critical components to securely run alongside untrusted software.
dnautics 7 hours ago | parent
saithound 3 hours ago | parent
A small change in the code can trigger quite radical and unpredictable changes in the IR. In fact, the IR can change without ever touching the code, e.g. when you update to a newer compiler.
danilafe 7 hours ago | parent
1. The mechanical effort required to show that the IR satisfies some abstract specification. Sel4 requires several refinement proofs (I am trusting the sibling comment on this), which suggests a great deal of effort. Perhaps LLMs (taken as "smart heuristics for proof code generation") can be of use here.
2. IR serves a secondary purpose as a target for compiler transformations. I've written myself about formally verifying compiler analyses[1] and I've proven a rudimentary LICM optimization in Lean based on these analyses (I haven't had a chance to write that one up), but it took a great deal of effort. We may then be forced either not to optimize or to trust something like LLVM (but...here be dragons? :P ).
So there is a tension between "simple core language" and "mutable substrate for optimization". And that doesn't even bring into question MLIR dialects and progressive lowering!
[1]: https://danilafe.com/series/static-program-analysis-in-agda/
dnautics 7 hours ago | parent
danilafe 7 hours ago | parent
nylonstrung 6 hours ago | parent
imtringued 7 hours ago | parent
If you want to go mainstream you need to be able to convince users that they can prove useful properties about their software and so far the article has managed to entirely avoid that topic.
danilafe 7 hours ago | parent
nylonstrung 6 hours ago | parent
There's really no need to argue at this point that "users can prove useful properties about their software" and I think this article was good specifically because it didn't retread this topic yet again and instead focused on the technical details that the discourse specifically is missing right now
budro 7 hours ago | parent
Although that all being said, I think you could do verification in addition to everything I mentioned before if that "gradually verified language" open question in the blog post was satisfactorily answered. SPARK and Verus seem popular so I'll definitely have to look into them.
bbminner 5 hours ago | parent
It appears that proper summarization of how much soft constraints push against invalid but promising attempts works better than hard constraining the search to the valid solution space.
Despite how promising it sounds, if one were to design a language that does not allow you to express certain types of harmful patterns or code that disagrees with coders intent, it might constraint one to a search space so narrow that searching it would become too hard.
It feels like TLA+ and rust borrow checker are more of a hard constraint. I am not sure what would count as soft constraints here through? A very smart linter that takes your smart expression of the guarantees for different parts of the code and checks them against guarantees provided by the implementation? But that's kinda like what rust checker does. Not sure how to make it even softer..
stschaef 5 hours ago | parent
If we put in the effort to design the right libraries/DSLs for correct-by-construction development, we do not need to trust the program writer. So a slop-machine can write whatever, and we can use typechecking to statically guarantee correctness. This is more robust to refactors and does not require a human or agent to do manual proof repair. Moreover, we pay much of the verification cost up front and then don’t need to do ad hoc work upon every instantiation of the framework
I expect that if we as a community invest in the right abstractions now, we will see a flourishing of verified software
lopatin 5 hours ago | parent
They already have published formal specs for JavaScript among other main stream languages. You can combine that with this paper for formal semantics of React hooks: https://dl.acm.org/doi/10.1145/3763067?__cf_chl_tk=xOyr8JU2v...
Cyphase 4 hours ago | parent
The need for a formally verifiable mainstream programming language - https://news.ycombinator.com/item?id=50663089 - November 2026 (343 comments)
summarity 2 hours ago | parent