Skip to main content
QUICK REVIEW

[论文解读] Lean Copilot: Large Language Models as Copilots for Theorem Proving in Lean

Peiyang Song, Kaiyu Yang|arXiv (Cornell University)|Apr 18, 2024
Business Process Modeling and AnalysisBusiness, Management and Accounting被引用 3
一句话总结

该论文提出 Lean Copilot,一种框架,使大型语言模型(LLMs)能够通过外部函数接口(FFI)原生地在 Lean 定理证明器内执行推理。该框架使 LLM 能够作为人类用户的协作者,建议策略、搜索证明并选择相关前提,显著减少人工工作量,并在证明完成度和自主性方面优于基于规则的自动化系统。

ABSTRACT

Neural theorem proving combines large language models (LLMs) with proof assistants such as Lean, where the correctness of formal proofs can be rigorously verified, leaving no room for hallucination. With existing neural theorem provers pretrained on a fixed collection of data and offering valuable suggestions at times, it is challenging for them to continually prove novel theorems in a fully autonomous mode, where human insights may be critical. In this paper, we explore LLMs as copilots that assist humans in proving theorems. We introduce Lean Copilot, a general framework for running LLM inference natively in Lean. It enables programmers to build various LLM-based proof automation tools that integrate seamlessly into the workflow of Lean users. Lean users can use our pretrained models or bring their own ones that run either locally (with or without GPUs) or on the cloud. Using Lean Copilot, we build LLM-based tools that suggest proof steps, complete proof goals, and select relevant premises. Experimental results on the Mathematics in Lean textbook demonstrate the effectiveness of our method compared to existing rule-based proof automation in Lean (aesop). When assisting humans, Lean Copilot requires only 2.08 manually-entered proof steps on average (3.86 required by aesop); when automating the theorem proving process, Lean Copilot automates 74.2% proof steps on average, 85% better than aesop (40.1%). We open source all code and artifacts under a permissive MIT license to facilitate further research.

研究动机与目标

  • 为解决完全自主的基于 LLM 的定理证明器的局限性,这些系统因缺乏人类洞察力而在面对新颖或领域差异较大的定理时表现不佳。
  • 探索交互式定理证明(ITP)中的人机协作范式,其中 LLM 作为协作者自动化常规证明步骤,而人类提供高层次指导。
  • 构建一个通用且可扩展的框架,实现 LLM 推理在 Lean 证明环境内的无缝集成,克服外部模型调用的局限性。
  • 通过实证评估基于 LLM 的证明自动化工具——策略建议、证明搜索和前提选择——与现有基于规则的系统在 Lean 中的表现。
  • 将框架和模型以 MIT 许可证开源,以加速基于 LLM 的形式数学与验证研究。

提出的方法

  • 利用外部函数接口(FFI)在 Lean 环境内直接运行 LLM 推理,实现 Lean 与 LLM 之间的低延迟、原生交互。
  • 支持通过 CTranslate2 实现的本地推理(含或不含 GPU)以及基于远程服务器的 LLM 部署,提供部署和模型选择的灵活性。
  • 引入三种基于 LLM 的工具:`suggest_tactics` 用于生成下一步证明步骤,`search_proofs` 用于端到端的证明搜索,以及 `select_premises` 用于从 Mathlib 中检索相关引理。
  • 在形式数学数据上微调 LLM,包括来自 Mathlib 和 'Mathematics in Lean' 的定理与证明,以提升相关性和正确性。
  • 采用模块化架构,允许用户插入自己的模型(无论预训练或微调),以构建自定义的证明自动化流水线。
  • 在 Lean 的类型检查和证明检查工作流中同步执行 LLM 调用,确保正确性,并实现实时协助以支持交互式证明。

实验结果

研究问题

  • RQ1LLM 能否通过作为协作者而非自主代理的方式,有效协助人类用户进行交互式定理证明?
  • RQ2与外部模型调用相比,LLM 在 Lean 内原生推理在可用性、延迟和集成深度方面表现如何?
  • RQ3基于 LLM 的工具(如策略建议、证明搜索和前提选择)在多大程度上能减少证明定理所需的人工输入策略数量?
  • RQ4与基于规则的系统(如 Aesop)相比,基于 LLM 的证明自动化在证明自主性和自动化覆盖范围方面表现如何?
  • RQ5一个用于 Lean 中 LLM 推理的通用框架,能否促进基于 LLM 的证明工具在形式验证和数学中的更广泛应用与扩展?

主要发现

  • 当使用 `search_proofs` 工具时,Lean Copilot 使 LLM 将每一定理的人工输入策略平均减少至 1.02 个,显著优于 Aesop(3.62)和 `suggest_tactics`(2.72)。
  • `search_proofs` 工具实现了 64% 的定理自主证明——超过 `suggest_tactics` 的 34% 成功率两倍以上,且是 Aesop 的 12% 的五倍以上。
  • 平均而言,`search_proofs` 自动化了 81.2% 的证明步骤,相比 `suggest_tactics` 的 48.6% 和 Aesop 的 35.2%,展现出更优的端到端证明完成能力。
  • 该框架成功实现了 LLM 在 Lean 内的原生集成,支持实时、低延迟的协助,且无需外部进程依赖。
  • 以 MIT 许可证开源的代码库和模型,为未来基于 LLM 的形式推理与证明自动化研究提供了基础。
  • 实证结果证实,LLM 作为协作者可显著加速定理证明,通过处理常规证明步骤,从而提升人类在形式数学与验证中的生产力。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。