arXiv:2606.06523cs.AIcs.LG2026-06

用形式化语言验证大模型任务流程,提升可靠性。

Lean4Agent: Formal Modeling and Verification for Agent Workflow and Trajectory

论文配图:Lean4Agent: Formal Modeling and Verification for Agent Workflow and Trajectory
图 1 · 摘自论文原文
  • 用依赖类型逻辑语言Lean4构建可验证的代理流程模型
  • 验证通过的流程平均性能提升11.94%,优化后进一步提升7.47%
  • 适合关注大模型可信执行与系统调试的研究者

让大型语言模型(LLMs)可靠执行多步任务已成为人工智能的核心挑战。尽管LLM的代理能力有所提升,但大多数代理系统仍缺乏对工作流和执行轨迹的形式化建模、验证与调试方法。受数学中自然语言模糊性催生形式语言的启发,我们提出**Lean4Agent**,据我们所知首个使用依赖类型形式语言Lean4来建模和验证代理行为的框架。**Lean4Agent**推出了**FormalAgentLib**,一个可扩展的Lean4库,用于在显式假设下形式化建模和验证代理工作流的语义一致性,并定位执行时故障。基于**FormalAgentLib**,我们进一步开发了**LeanEvolve**,利用验证结果改进工作流。在SWE-Bench-Verified的困难子集和ELAIP-Bench的一个子集上,针对5个主流LLM的实验表明,验证通过的工作流平均性能优于未通过者11.94%,而**LeanEvolve**使SWE性能平均再提升7.47%。此外,**Lean4Agent**为利用表达性强的依赖类型语言形式化建模与验证代理行为开辟了新方向。

原文摘要 · Abstract (English)

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.

形式化验证智能体大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。