Leanstral 1.5: AI for Formally Proving Code Correctness in Lean 4
Generated: 2026-07-05 · API: Gemini 2.5 Flash · Modes: Summary
Leanstral 1.5: AI for Formally Proving Code Correctness in Lean 4
Clip title: Leanstral 1.5 119B A6B: The Free AI That Proves Your Code Is Correct Author / channel: Fahd Mirza URL: https://www.youtube.com/watch?v=3IXH_ZVLVWQ
Summary
The video introduces Mistral AI’s Leanstral 1.5, a free and open-source model designed specifically for writing formal proofs in the Lean 4 programming language. Unlike traditional AI models that may generate code which merely appears functional or passes conventional tests, Leanstral’s core innovation lies in its ability to formally prove the correctness of mathematical theorems and code. The presenter highlights that AI-generated code can often look correct and pass initial tests but still contain subtle bugs; Leanstral aims to overcome this by ensuring every step of a proof holds, a method proven to uncover real bugs missed by standard testing.
The demonstration begins with the installation of the Mistral Vibe command-line interface, which acts as the agent for interacting with Leanstral. The presenter then runs a simple mathematical proof in Lean 4, asking the agent to prove that adding zero to any natural number (n + 0 = n) leaves it unchanged. Leanstral successfully generates a Lean file containing the theorem and its proof, which is then verified by the Lean 4 compiler. This initial success showcases the model’s fundamental capability to not just produce an answer but to create a formally checked and accepted proof.
Further complex examples illustrate Leanstral’s advanced reasoning. The model is tasked with proving the sum of natural numbers and a coding identity related to list reversal. For these more involved problems, Leanstral demonstrates “genuine reasoning” rather than simple shortcuts. It constructs proofs involving multiple steps, utilizing known mathematical identities, setting up intermediate stages, and even generating helper lemmas to build up to the final, complex proof. The underlying workflow involves a constant feedback loop: Leanstral generates a proof, which is then rigorously checked by the Lean 4 verifier. If incorrect, the error feedback is processed by the model, which then attempts to refine its approach until the proof is successfully accepted by the compiler.
The video concludes by emphasizing the critical advantage of Leanstral: trustworthiness. Because every generated proof is formally verified by a compiler, users can have high confidence in the correctness of the output. This capability transforms Leanstral from a mere code generator into an “AI engineer” capable of understanding existing codebases, logically constructing proofs, and ensuring the absolute correctness of code and theorems. This blend of AI generation and formal verification positions Leanstral as a powerful tool for advancing the reliability and robustness of software and mathematical reasoning in real-world applications.
Video Description & Links
Description
This video tests Leanstral 1.5 which is an open-source code agent model designed for Lean 4.
🔥 Buy Me a Coffee to support the channel: https://ko-fi.com/fahdmirza
PLEASE FOLLOW ME: ▶ LinkedIn: https://www.linkedin.com/in/fahdmirza/ ▶ YouTube: https://www.youtube.com/@fahdmirza ▶ Blog: https://www.fahdmirza.com
Resources:
▶ https://huggingface.co/mistralai/Leanstral-1.5-119B-A6B
All rights reserved © Fahd Mirza