Lean4Agent: Formal Modeling and Verification for Agent Workflow and Trajectory
On the map: LLM agents and tool use → Software engineering coding agents
Abstract (arXiv)
Equipping Large Language Models (LLMs) to execute reliable multi-step workflows has become a central challenge in artificial intelligence. Despite recent advances in LLMs' agentic capabilities, most agent systems still lack formal methods for specifying, verifying, and debugging their workflow and execution trajectories. This challenge mirrors a long-standing problem in mathematics, where the ambiguity of natural languages (NLs) motivates the development of formal languages (FLs). Inspired by this paradigm, we propose **Lean4Agent**, to the best of our knowledge, the first framework that uses Lean4, a dependent-type FL to model and verify agent behavior. **Lean4Agent** launches **FormalAgentLib**, an extensible Lean4 library for formally modeling and verifying agent workflows' semantic consistency under explicit assumptions, and enabling localization of execution-time failures revealed by trajectories. Building on **FormalAgentLib**, we further develop **LeanEvolve**, which applies results in **FormalAgentLib** to revise workflows to enhance its capability. Extensive experiments on a hard problem subset of SWE-Bench-Verified and a subset of ELAIP-Bench across 5 leading LLMs indicate that the verification-passing workflows outperform the failing ones by an average of **11.94%**, and **LeanEvolve** further improves SWE performance by **7.47%** on average. Furthermore, **Lean4Agent** establishes a foundation for a new field of using expressive dependent-type FL to formally model and verify agent behavior.
Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Placed in Software engineering coding agents, one of 16 directions in LLM agents and tool use. Builds on 33 of its 53 references that are in the map. First posted on arXiv 2 Jun 2026.
Builds on
33 of 53 references.
Closest ancestors · 4
Same direction, newest first
- 2026AgentSPEX: An Agent SPecification and EXecution Language14 Apr
- 2026GLM-5: from Vibe Coding to Agentic Engineering17 Feb
- 2025Live-SWE-agent: Can Software Engineering Agents Self-Evolve on the Fly?17 Nov
- 2025A Self-Improving Coding Agent21 Apr
Other references · 29
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,393
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,355
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,193
- 2026Kimi K2.5: Visual Agentic Intelligencecited by 449
- 2025Multi-Agent Collaboration Mechanisms: A Survey of LLMscited by 424
- 2025DeepSeek-Prover-V2: Advancing Formal Mathematical Reasoning via Reinforcement Learning for Subgoal Decompositioncited by 270
- 2024DeepSeek-Prover-V1.5: Harnessing Proof Assistant Feedback for Reinforcement Learning and Monte-Carlo Tree Searchcited by 189
- 2025Goedel-Prover-V2: Scaling Formal Theorem Proving with Scaffolded Data Synthesis and Self-Correctioncited by 140
- 2025Goedel-Prover: A Frontier Model for Open-Source Automated Theorem Provingcited by 126
- 2024TheoremLlama: Transforming General-Purpose LLMs into Lean4 Expertscited by 58
- 2025LLM-based Agents Suffer from Hallucinations: A Survey of Taxonomy, Methods, and Directionscited by 49
17 more
- 2025VeriGuard: Enhancing LLM Agent Safety via Verified Code Generationcited by 46
- 2025Seed-Prover 1.5: Mastering Undergraduate-Level Theorem Proving via Learning from Experiencecited by 36
- 2026Towards Verifiably Safe Tool Use for LLM Agentscited by 34
- 2025VERINA: Benchmarking Verifiable Code Generationcited by 30
- 2026MiroThinker-1.7 & H1: Towards Heavy-Duty Research Agents via Verificationcited by 28
- 2025MA-LoT: Model-Collaboration Lean-based Long Chain-of-Thought Reasoning enhances Formal Theorem Provingcited by 24
- 2024PDL: A Declarative Prompt Programming Languagecited by 14
- 2026ToolGate: Contract-Grounded and Verified Tool Execution for LLMscited by 13
- 2025Let's Reason Formally: Natural-Formal Hybrid Reasoning Enhances LLM's Math Capabilitycited by 11
- 2026AlgoVeri: An Aligned Benchmark for Verified Code Generation on Classical Algorithmscited by 11
- 2026Goedel-Code-Prover: Hierarchical Proof Search for Open State-of-the-Art Code Verificationcited by 10
- 2025Bridging LLM Planning Agents and Formal Methods: A Case Study in Plan Verificationcited by 6
- 2025FANS -- Formal Answer Selection for Natural Language Math Reasoning Using Lean4cited by 5
- 2025GAR: Generative Adversarial Reinforcement Learning for Formal Theorem Provingcited by 5
- 2025Lean4Physics: Comprehensive Reasoning Framework for College-level Physics in Lean4cited by 5
- 2025ADL: A Declarative Language for Agent-Based Chatbotscited by 3
- 2025ELAIPBench: A Benchmark for Expert-Level Artificial Intelligence Paper Understandingcited by 2
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2026Formal Verification of Agentic Systems over Operational Data
- 2026Agentics 2.0: Logical Transduction Algebra for Agentic Data Workflows
- 2026AgentProcessBench: Diagnosing Step-Level Process Quality in Tool-Using Agents
- 2026FlowScout: From Execution Feedback to Reliable Tool-Using Agent Workflows
- 2026Understanding Tool-Augmented Agents for Lean Formalization: A Factorial Analysis
- 2024The Fusion of Large Language Models and Formal Methods for Trustworthy AI Agents: A Roadmap
- 2025FlowAgent: Achieving Compliance and Flexibility for Workflow Agents
- 2025Sherlock: Reliable and Efficient Agentic Workflow Execution