Leanstral: Open-Source foundation for trustworthy <br> vibe-coding
In the rapidly evolving landscape of artificial intelligence, the need for reliable and efficient coding agents has become paramount. Mistral AI has introduced Leanstral, the first open-source code agent specifically designed for Lean 4, a powerful proof assistant. This article explores the capabilities, advantages, and practical applications of Leanstral, highlighting its significance in the realm of formal verification and coding.
The Challenge of Code Verification
As AI agents become increasingly adept at code generation, they encounter a significant bottleneck in high-stakes domains such as frontier research mathematics and mission-critical software development. The primary challenge lies in the human review process, which is often time-consuming and requires specialized expertise. Mistral AI envisions a new generation of coding agents that not only perform tasks but also formally prove their implementations against strict specifications.
Introducing Leanstral
Leanstral represents a major advancement in this vision. It is designed to be highly efficient, featuring 6 billion active parameters and optimized for realistic formal repositories. Unlike existing proving systems that merely wrap around large generalist models or focus on isolated mathematical problems, Leanstral aims to enhance engineering velocity by enabling users to dictate their requirements directly.
Key Features of Leanstral
- Open and Accessible: Leanstral’s weights are released under an Apache 2.0 license, allowing developers to utilize the agent mode within Mistral Vibe and access a free API endpoint.
- Efficient and Powerful: Leanstral employs a highly sparse architecture, optimized for proof engineering tasks. This design allows for parallel inference with Lean as a verifier, making it both performant and cost-effective compared to existing closed-source competitors.
- Upgradable via MCP: Leanstral supports arbitrary Model-Checking Protocols (MCPs) through Vibe, specifically trained to maximize performance with the widely used lean-lsp-mcp.
Evaluation and Benchmarking
To evaluate Leanstral’s effectiveness in realistic proof engineering scenarios, it was benchmarked against leading coding agents and open-source models. The evaluation focused on completing formal proofs and defining new mathematical concepts within the context of the FLT project.
Comparison with Other Models
| Model | Cost ($) | Score |
|---|---|---|
| Haiku | 184 | 23.0 |
| Sonnet | 549 | 23.7 |
| Claude Opus | 1,650 | 39.6 |
| Leanstral | 182 | 21.9 |
| Leanstral pass@2 | 182 | 26.3 |
| Leanstral pass@4 | 182 | 29.3 |
| Leanstral pass@8 | 182 | 31.0 |
| Leanstral pass@16 | 182 | 31.9 |
Leanstral demonstrates a significant efficiency advantage over larger open-source models, achieving superior scores with fewer computational passes. For instance, while the Qwen3.5 model requires four passes to reach a score of 25.4, Leanstral achieves a score of 26.3 with only two passes.
Case Studies
Real-World Application: Stack Exchange Migration
One of the practical applications of Leanstral involved addressing a real-world question from the Proof Assistants Stack Exchange. When a new Lean release introduced breaking changes, Leanstral was tasked with diagnosing a script that failed to compile. The model successfully recreated the failing environment, identified the issue, and proposed a simple fix, demonstrating its ability to reason about programming problems effectively.
Translating and Proving Properties of Programs
Leanstral also showcased its capabilities by converting definitions from the Rocq programming language into Lean. It not only translated the code but also implemented custom notation and proved properties about the translated programs. For example, it defined a command that adds 2 to a variable and proved its correctness using Lean’s theorem proving capabilities.
Try Leanstral Today
Leanstral is available for immediate use through Mistral Vibe, allowing developers to engage in zero-setup vibe coding and proving. Users can access the model via the free or near-free API endpoint, making it accessible for a wide range of applications.
Conclusion
Leanstral represents a significant step forward in the development of trustworthy coding agents. Its open-source nature, efficiency, and powerful capabilities make it an invaluable tool for developers engaged in formal verification and proof engineering. By enabling users to dictate their coding requirements and providing robust proof capabilities, Leanstral is poised to enhance productivity and reliability in high-stakes programming environments.
Note: This article reflects information available as of October 2023 and may be subject to change as new developments arise in the field of AI and coding technologies.

