One thing I'm surprised to see little mention of here is that if you want to use Lean proofs for your code and really want good correspondence between what is proved in Lean and what your code actually does, you need a mathematical model of your programming language embedded in Lean and a deterministic parser converting your code itself into Lean. Otherwise, yes, an AI actually has no checks against hallucination and while writing Lean proofs probably helps AI identify its mistakes it really isn't an end-to-end proof of your code's functionality.
I personally think the future probably involves a combination of unit tests and formal verification to support our confidence in AI-written software, as well as means to align high-level human intent with the low-level intent of individual code pieces, which as this article mentions is the other big piece that can slip with formal proofs: we might not be proving what we think we're proving. For those interested I've written an educational post about this topic here as well: https://kellerai.io/resources/ai-proved-your-code-correct
You write laws in Erlang/Elixir, which are automatically translated to Lean alongside your Erlang/Elixir code, and you write proofs in Lean. The laws and proofs are assembled together and verified by Lean's kernel.
This technique is also known as shallow embedding, since it translates Erlang/Elixir to Lean and then use the features and properties of Lean for proofs.
To clarify: mentioned "here" meaning mentioned in the comments. HackerNews is presumably majority programmers and the comments section is mostly comments about using proofs for formal verification of code. I agree the article is coming from a mathematics standpoint
Yes, Verus (for Rust) is a good example of programming language level verification. The recent GitHub Next announcement indicates they are using it in their backend.
You're right that if you verify at the assembly language it can give you additional certainty that there are no additional errors in the compilation step. However, it can be easier for AI to reason about proofs written at the programming language level because (from what I can deduce) it matches the level that humans are operating at and it doesn't have additional details such as registers and memory operations to worry about.
AWS uses Verus for their verified layers of Nitro, too.
I have just begun working with it, but I prefer the convention of including the formalizations alongside application code, as opposed to maintaining a parallel codebase.
You don't need a model of your programming language in Lean, that's overkill.
It's already useful to isolate a DSL in your software and model that in Lean. Sure that only proves that the domain specific code is correct, but now you've factored your proof into proving high-level correctness and low-level correctness.
You need to pick an abstraction level. I don't prove in lean the impact of my programs on the price of eggs at the local market. I don't prove in lean how much energy my programs consume, or even how much RAM they consume. I do prove that say a particular pair of functions commute, or that another function is idempotent, or that under a denotational semantics a collection of functions can be composed without error.
I think that is a valid level to use formal verification but I would argue it is much more powerful to also have a formal model of code. For example, if I have:
my_value = run_some_function(some_arg_1, some_arg_2)
for some_value in my_value.some_list:
run_some_action(some_value)
Yes it is very helpful to know some properties about `run_some_function` (maybe it is commutative? idempotent?), but it is much more valuable to have a model which can translate what ultimately is being passed to `run_some_action` at the end and how that derives from the return of `run_some_function`, grounding the LLM's reasoning in something deterministic it can't break from.
Yes, there's a github tool. I just ran the Arc-to-Zen tool from https://github.com/Thinkscape/arc-to-zen and it imported everything flawlessly. Zen now appears to be a drop-in replacement. Try it out!
I personally think the future probably involves a combination of unit tests and formal verification to support our confidence in AI-written software, as well as means to align high-level human intent with the low-level intent of individual code pieces, which as this article mentions is the other big piece that can slip with formal proofs: we might not be proving what we think we're proving. For those interested I've written an educational post about this topic here as well: https://kellerai.io/resources/ai-proved-your-code-correct
reply