Live data from Hacker News

Lean 4: How the theorem prover works and why it's the new competitive edge in AI

venturebeat.com

21–30 of 70 posts

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#21
> Large language models (LLMs) have astounded the world with their capabilities, yet they remain plagued by unpredictability and hallucinations – confidently outputting incorrect information. In high-stakes domains like finance, medicine or autonomous systems, such unreliability is unacceptable.

This misses a point that software engineers initmately know especially ones using ai tools:

* Proofs are one QA tool

* Unit tests, integration tests and browser automation are other tools.

* Your code can have bugs because it fails a test above BUT...

* You may have got the requirements wrong!

Working with claude code you can have productive loops getting it to assist you in writing tests, finding bugs you hadn't spotted and generally hardening your code.

It takes taste and dev experience definitely helps (as of Jan 26)

So I think hallucinations and proofs as the fix is a bit barking up the wrong tree

The solution to hallucinations is careful shaping of the agent environment around the project to ensure quality.

Proofs may be part of the qa toolkit for AI coded projects but probably rarely.

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#22
Interesting. It's essentially the same idea as in this article: https://substack.com/home/post/p-184486153. In both scenarios, the human is relieved of the burden of writing complex formal syntax (whether Event-B or Lean 4). The human specifies intent and constraints in natural language, while the LLM handles the work of formalization and satisfying the proof engine.

But Lean 4 is significantly more rigid, granular, and foundational than e.g. Event-B, and they handle concepts like undefined areas and contradictions very differently. While both are "formal methods," they were built by different communities for different purposes: Lean is a pure mathematician's tool, while Event-B is a systems engineer's tool. Event-B is much more flexible, allowing an engineer (or the LLM) to sketch the vague, undefined contours of a system and gradually tighten the logical constraints through refinement.

LLMs are inherently statistical interpolators. They operate beautifully in an Open World (where missing information is just "unknown" and can be guessed or left vague) and they use Non-Monotonic Reasoning (where new information can invalidate previous conclusions). Lean 4 operates strictly on the Closed World Assumption (CWA) and is brutally Monotonic. This is why using Lean to model things humans care about (business logic, user interfaces, physical environments, dynamic regulations) quickly hits a dead end. The physical world is full of exceptions, missing data, and contradictions. Lean 4 is essentially a return to the rigid, brittle approach of the 1980s expert systems. Event-B (or similar methods) provides the logical guardrails, but critically, it tolerates under-specification. It doesn't force the LLM to solve the Frame Problem or explicitly define the whole universe. It just checks the specific boundaries the human cares about.

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#23
post #5

I like a lot of the idea behind such theorem provers, however, I always have issues with them producing compatible code with other languages. This happened to me with idris and many others, I took some time to learn the basics, wrote some examples and then FFI was a joke or code generators for JavaScript absolutely useless. So no way of leveraging an existing ecosystem.

Apart from prioritizing FFI (like Java/Scala, Erlang/Elixir), the other two easy ways to bootstrap an integration of a new obscure or relatively new programming language is to focus on RPC (ffi through network) or file input-output (parse and produce well known file formats to integrate with other tools at Bash level).

I find it very surprising that nobody tried to make something like gRPC as an interop story for a new language, with an easy way to write impure "extensions" in other languages and let your pure/formal/dependently typed language implement the rest purely through immutable message passing over gRPC boundary. Want file i/o? Implement gRPC endpoint in Go, and let your language send read/write messages to it without having to deal with antiquated and memory unsafe Posix layer.

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#24
I am using lean as part of the prd.md description handed to a coding agent. The definitions in lean compile and mean exactly what I want them to say. The implementation i want to build is in rust.

HOWEVER … I hit something i now call a McLuhen vortex error: “When a tool, language, or abstraction smuggles in an implied purpose at odds with your intended goal.”

Using Lean implies to the coding agent ‘proven’ is a pervasive goal.

I want to use lean to be more articulate about the goal. Instead using lean smuggled in a difficult to remove implicit requirement that everything everywhere must be proven.

This was obvious because the definitions i made in lean imply the exact opposite of everything needs to be proven. When i use morphism i mean anything that is a morphism not only things proven to be morphisms.

A coding agent driven by an llm needs a huge amount of structure to use what the math says rather than take on the implications that because it is using a proof system therefore everything everywhere is better if proven.

The initial way i used lean poisoned the satisficing structure that unfolds during a coding pass.

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#25
post #17

Lean is a great idea, especially the 4th version, a huge level up from the 3rd one, but its core still deficient[1] in some particular scenarious (see an interesting discussion[2] in the Rock (formerly Coq) issue tracker). Not sure if it might hinder the automation with the AI. [1] https://artagnon.com/logic/leancoq [2] https://github.com/rocq-prover/rocq/issues/10871

The issue was a fun read, thanks for sharing.

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#26
post #20

If you want to mess with this at home, I've been vibe coding https://github.com/kig/formalanswer to plug theorem provers into an LLM call loop. It's pretty early dev but it does have a logic rap battle mode.

This is pretty interesting!

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#27
post #24

I am using lean as part of the prd.md description handed to a coding agent. The definitions in lean compile and mean exactly what I want them to say. The implementation i want to build is in rust. HOWEVER … I hit something i now call a McLuhen vortex error: “When a tool, language, or abstraction smuggles in an implied purpose at odds with your intended goal.” Using Lean implies to the coding agent ‘proven’ is a perva…

Could you put that distinction into the AGENTS.md file so it will understand and follow that nuance?

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#28
post #22

Interesting. It's essentially the same idea as in this article: https://substack.com/home/post/p-184486153 . In both scenarios, the human is relieved of the burden of writing complex formal syntax (whether Event-B or Lean 4). The human specifies intent and constraints in natural language, while the LLM handles the work of formalization and satisfying the proof engine. But Lean 4 is significantly more rigid, granular,…

So basically you are arguing a Type Theory vs Set Theory problem, Foundationalism or Engineering Refinement. Since we read here of multiple use cases for LLMs in both CS divides, we can conclude an eventual convergence in these given approaches; and if not that, some formal principles should emerge of when to use what.

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#29
post #19

I just completed the formal verification of my bachelor thesis about real time cellular automata with Lean 4, with heavy use of AI. Over the past year, I went from fully manual mode (occasionally asking chat gpt some Lean questions) to fully automatic mode, where I barely do Lean proofs myself now (and just point AI to the original .tex files, in German). It is hard to believe how much the models and agentic harnesse…

Can you give some examples of this? Maybe have something online? I would love to learn more about how to do proof driven AI assisted development.

Re: Lean 4: How the theorem prover works and why it's the new competitive edge in AI

#30
post #28
post #22

Interesting. It's essentially the same idea as in this article: https://substack.com/home/post/p-184486153 . In both scenarios, the human is relieved of the burden of writing complex formal syntax (whether Event-B or Lean 4). The human specifies intent and constraints in natural language, while the LLM handles the work of formalization and satisfying the proof engine. But Lean 4 is significantly more rigid, granular,…

So basically you are arguing a Type Theory vs Set Theory problem, Foundationalism or Engineering Refinement. Since we read here of multiple use cases for LLMs in both CS divides, we can conclude an eventual convergence in these given approaches; and if not that, some formal principles should emerge of when to use what.

This discussion started already in the sixties (see e.g. the 1969 publication by McCarthy and Hayes where they describe the "frame problem" as a fundamental obstacle to the attempt to model the dynamic world using First-Order Logic and monotonic reasoning). A popular attempt to "solve" this problem is the Cyc project. Monotonic logic is universally understood as a special, restricted case (a subset) of a broader non-monotonic theory.
Post reply on HN