# Lean4Agent：面向智能体工作流与轨迹的形式化建模与验证

- 来源：HuggingFace Daily Papers（社区热门论文）
- 发布时间：2026-06-02 08:00
- AIHOT 分数：49
- AIHOT 链接：https://aihot.virxact.com/items/cmq662pg105issl5i8qra2ckt
- 原文链接：https://arxiv.org/abs/2606.06523

## AI 摘要

大语言模型执行多步工作流缺乏形式化规范与验证。受形式语言克服自然语言歧义启发，Lean4Agent 首次用依赖类型形式语言 Lean4 建模和验证智能体行为。其核心 FormalAgentLib 是可扩展的 Lean4 库，在显式假设下验证工作流语义一致性并定位运行时故障。LeanEvolve 利用验证结果修正工作流。在 SWE-Bench-Verified 困难子集和 ELAIP-Bench 子集上，5 个 LLM 的验证通过工作流性能平均高 11.94%，LeanEvolve 进一步将 SWE 性能提升 7.47%。

## 正文

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.
