Papers
Topics
Authors
Recent
Search
2000 character limit reached

LAMP: Lean-based Agentic framework with MCP and Proof Repair

Published 27 Jun 2026 in cs.LO, cs.AI, and cs.CL | (2606.28841v1)

Abstract: LLMs are increasingly capable of mathematical reasoning, but the proofs they generate are often unreliable and hard to verify. Interactive theorem provers such as Lean 4 address this by accepting only kernel-checked proofs; however, their reach is bounded by the formalized knowledge available. While Mathlib, a repository of formalized Lean 4 theorems that covers diverse mathematical areas, certain specialized areas remain underrepresented; notably, the domain of Combinatorics on Words (CoW). CoW studies sequences, exploring their properties such as periodicity, borders, conjugacy, and morphisms. As a result, specialized provers, trained on Mathlib-centered data, lack the lemmas to operate in CoW. We present two contributions. First, we introduce a Lean 4 formalization of CoW containing eight modules and \textbf{93} declarations of core definitions and foundational lemmas. Second, we present LAMP, a multi-agent framework that synthesizes kernel-verified Lean 4 proofs by providing explicit, structured domain knowledge at inference time through an ontology, rather than by fine-tuning a prover. LAMP coordinates a Planner, Builder, and Verifier with Model Context Protocol based access to a domain-specific CoW ontology. In a suite of 90 CoW theorems that span all eight modules and three difficulty levels, LAMP synthesizes verified proofs for 96.7% of theorems, substantially exceeding both an unscaffolded baseline and existing specialized provers. An ablation shows that removing LAMP's tool-grounded architecture or its Planner/Builder separation each cost roughly 12 percentage points, even with the backbone model held fixed.

Summary

  • The paper introduces LAMP, a multi-agent framework that integrates explicit, tool-augmented domain knowledge into Lean 4 proof synthesis.
  • The methodology employs a dual-loop algorithm and domain-specific ontology access to achieve a 96.7% pass@1 rate on a 90-theorem CoW evaluation suite.
  • Experimental results demonstrate that explicit MCP and agent decomposition significantly improve proof reliability over conventional LLM-based provers.

LAMP: Multi-Agent Lean-based Theorem Proving with Domain-Aware Tool Augmentation

Context and Motivation

The paper "LAMP: Lean-based Agentic framework with MCP and Proof Repair" (2606.28841) addresses critical limitations in employing LLMs and automated provers for formal mathematics, specifically targeting the generalization gap in domains inadequately represented within existing Lean 4 libraries. While LLMs trained for mathematical reasoning can yield proofs, those proofs routinely lack reliability or kernel-verifiability. Lean 4, via Mathlib, mitigates verification but is inherently constrained in domains absent from its library, exemplified by the field of Combinatorics on Words (CoW), which encompasses complex properties and results such as periodicity, borders, or conjugacy.

Specialized LLM-based provers typically fail on such domains due to their lack of access to supporting vocabulary and lemmas. The central thesis of this work is that explicit, structured domain knowledge provision at inference—rather than implicit knowledge obtained via large-scale training—can address this limitation. The proposed solution, LAMP (Lean-based Agentic framework with Model Context Protocol and Proof Repair), implements this paradigm and demonstrates strong empirical advantage.

System Architecture

LAMP is designed as a multi-agent framework for synthesizing certified Lean 4 proofs. The system is explicitly tool-oriented: agent interactions are grounded in external, MCP-exposed resources, notably a custom formalization of CoW not found in Mathlib. The architecture divides responsibilities among a Planner (proof strategy), Builder (tactic synthesis), and Verifier (kernel checking), coordinated by an Orchestrator. The key distinguishing property is context-conditioned inference: agents query an ontology of domain-specific knowledge, not just Mathlib, and the Planner/Builder functional decomposition further regularizes control flow.

Figure 1

Figure 2: LAMP architecture and data flow illustrating agentic decomposition, ontology access, and kernel-verification loop.

The Orchestrator injects source code for all relevant CoW modules into the context, localizing edits and ensuring identifier canonicalization. Planner and Builder agents maintain iterative state, enabling revision and targeted self-correction. The Semantic Toolbox provides multipurpose tool APIs, including lemma search within Mathlib as a fallback, but prioritizes retrieval from the curated CoW ontology.

Synthesis proceeds via a dual-loop algorithm: outer iterations trigger re-planning, inner iterations undertake code repair and contextual self-correction, with explicit fast paths for missing-definitions and granular error recovery. Proof acceptance requires passing both a textual sorry-elimination check and full Lean 4 REPL-based kernel verification.

Formalization of Combinatorics on Words

An integral contribution is the new Lean 4 formalization of the CoW domain, filling a gap unaddressed by Mathlib and absent in Lean-based provers or prior agentic benchmarks. The formalization encompasses eight modules: Word, Factor, ProperPrefix, ProperSuffix, Border, Conjugacy, Period, Morphism, for a total of 93 declarations. Words are encoded as lists, supporting monoid structure, concatenation, and factorization, with equational and order-theoretic properties for all relevant combinatorial notions, e.g., borders (overlapping prefix/suffix relationships), primitive roots, or morphic transformations.

This explicit formalization is both a resource for automated provers and a starting point for recursive library growth: proven theorems can be folded back as definitions and lemmas for future, more complex synthesis.

Experimental Results

CoW Evaluation Suite

The main testbed is a hand-curated evaluation suite of 90 theorems stratified by domain and difficulty, encompassing not only elementary facts but also the border-period duality—a multi-step theorem integrating several modules. Pass@1 is the principal metric, demanding that a single synthesis run produces a kernel-verified proof, with no partial credit and full conformance to Lean kernel checks.

LAMP achieves a 96.7% overall pass@1 across the suite (87/90 theorems). All easy (100%) and nearly all medium results (98.3%) are solved, and the system is robust even at harder theorems (88.2%), including those requiring nontrivial multi-module chaining.

Ablation Studies

Performance strongly depends on the architectural features:

  • Removing MCP-based domain tool access drops pass@1 by over 12 points, with most loss in harder problems.
  • Collapsing Planner/Builder into a single agent results in a similar degradation, highlighting the importance of explicit decomposition.

Backbone model choice also matters: with Claude Sonnet 4.5 the score falls to 88.9%, and to 68.9% for DeepSeek V4 Pro—even though the architecture and tool access remain identical.

Comparison with Existing Provers

State-of-the-art LLM-based Lean provers (DeepSeek-Prover-V2, Kimina-Prover, Goedel-Prover-V2), even when provided the same explicit CoW ontology context, essentially fail on the suite (1.1–8.9% pass@1). An unscaffolded backbone LLM without agentic decomposition or tool coordination achieves only 58.9%. The critical factor is therefore neither model scale nor total parameter count, but the agent-tool integration and explicit domain ontology injection during inference.

Out-of-Domain Behavior

On a balanced miniF2F subset (algebra, number theory, induction, competition math), LAMP's performance is driven by the backbone; agentic tool orchestration provides no substantial advantage in domains well covered by Mathlib and for which the backbone model has substantial prior exposure.

Failure Analysis and Limitations

The principal failure cases are intractable proof strategies (lack of multi-step modular arithmetic in LLMs), syntax errors (limited Lean 4 fluency for smaller models), and, rarely, ill-posed or false theorems. No systemic failures are attributable to the agentic framework, MCP infrastructure, or ontology retrieval: correctness ceiling is determined by LLM reasoning and tool-use capabilities.

The evaluation suite is self-constructed with internal difficulty gradation; direct comparison to benchmarks like miniF2F or PutnamBench is not possible without broader validation. Transfer to other unformalized domains remains to be demonstrated.

Implications and Future Directions

LAMP introduces a model-agnostic, tool-augmented theorem proving protocol relevant for future formalization efforts in mathematics and computer science. The central finding is a reversal of the typical scale–performance tradeoff: kernel-verified synthesis in poorly formalized domains is bottlenecked by structured, explicit knowledge injection at inference, not by implicit coverage via high-capacity model training. Specialized provers, tightly coupled to Mathlib, have low resilience in new domains.

Pragmatically, LAMP enables rapid formalization in emerging fields by allowing users to inject domain knowledge dynamically without model retraining. The architecture is also directly compatible with hybrid approaches where the Planner remains LLM-based and the Builder agent is specialized for Lean 4 tactic generation and tool calling, suggesting compatibility with future high-fidelity proof synthesis engines.

The evaluation indicates that further progress will depend on (i) refining agentic tool-use competence in LLMs, (ii) expanding the methodology to more unformalized domains, and (iii) research on meta-tooling for dynamic ontology construction, integration, and maintenance.

Conclusion

LAMP establishes the efficacy of agentic frameworks with explicit, tool-grounded domain knowledge for Lean 4 proof synthesis in unformalized mathematical domains. With a pass@1 of 96.7% on a comprehensive CoW suite—substantially above all tested baselines and existing provers—it demonstrates that domain adaptation is better served by inference-time knowledge curation and agentic orchestration than by specialized model retraining. This approach is poised to facilitate scalable formalization pipelines and offers an actionable template for future work in automated formal mathematics.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.