Zing 论坛

正文

Lean4-Skills:为AI编程助手打造的定理证明工作流套件

一套跨平台兼容的Lean 4定理证明技能包,提供从草稿生成到证明优化的完整工作流,支持Claude Code、Codex、Gemini等主流AI编程工具。

Lean 4定理证明AI编程助手形式化数学mathlibMCPClaude CodeCodex工作流自动化
发布时间 2026/04/22 05:43最近活动 2026/04/22 05:52预计阅读 6 分钟
Lean4-Skills:为AI编程助手打造的定理证明工作流套件
1

章节 01

Lean4-Skills: AI-Assisted Theorem Proving Workflow Suite

Lean4-Skills: AI-Assisted Theorem Proving Workflow Suite

Lean4-Skills is a cross-platform compatible Lean 4 theorem proof workflow suite designed for AI programming assistants. It provides a complete lifecycle from draft generation to proof optimization, supporting mainstream tools like Claude Code, Codex, and Gemini. The suite aims to lower the barrier to formalized mathematics by enabling AI agents to assist in Lean 4 proof processes, integrating with mathlib and MCP for efficient feedback.

2

章节 02

Background: Formal Proof Challenges & AI Potential

Background: Formal Proof Challenges & AI Potential

Formal mathematical proof requires rigorous machine-verified reasoning, but Lean 4's complex syntax, mathlib mastery, and proof strategies create high barriers for researchers. With the rise of AI programming assistants, Lean4-Skills addresses the question: Can AI automate or assist Lean 4 formal proof? It offers a systematic solution to let AI play a practical role in theorem proving.

3

章节 03

Workflow Design: Structured Loop & Core Skills

Workflow Design: Structured Loop & Core Skills

Lean4-Skills uses a 'structured loop' design—breaking proof into repeatable stages with clear inputs/outputs and checkpoints. It includes 11 core workflows covering the full lifecycle: draft (skeleton code from informal statements), formalize (interactive formality), autoformalize (end-to-end autonomous), prove (guided proof), autoprove (budget-controlled loops), checkpoint (save & verify), review (quality check), refactor (mathlib-based optimization), golf (conciseness), learn (mathlib exploration), and doctor (diagnosis/migration).

4

章节 04

Cross-Platform Compatibility

Cross-Platform Compatibility

Lean4-Skills features a host-agnostic design, working with Claude Code, OpenAI Codex, Google Gemini CLI, Cursor, and Windsurf. Claude Code users can call workflows via /lean4:<name> commands; others use SKILL.md configurations. This avoids skill fragmentation, allowing seamless tool migration. Detailed installation guides are provided for each tool, including environment variables and path settings.

5

章节 05

Proof Engine & MCP Integration

Proof Engine & MCP Integration

The prove/autoprove engine uses a 5-stage loop: Plan → Work → Checkpoint → Review → Replan → Continue/Stop. It analyzes goal states, searches mathlib for strategies, and parallel-tests approaches for sorry placeholders. Integration with lean-lsp-mcp provides sub-second feedback (replacing 30+ second lake builds) via tools like lean_goal (target state), lean_multi_attempt (parallel strategy testing), and lean_diagnostic_messages (error checks without full builds). Claude Code users are recommended to install MCP at user scope for visibility.

6

章节 06

Application Scenarios

Application Scenarios

Typical use flow: Generate initial statements via draft/autoformalize → complete proof with prove/autoprove → review quality → refactor with mathlib → optimize via golf → save via checkpoint. Benefits: Researchers focus on mathematical insights (not formal details), educators get interactive mathlib learning tools, formal verification projects gain scalable automation.

7

章节 07

Future Directions & Community Engagement

Future Directions & Community Engagement

Current limitations: Primarily tested on Pythia/Llama models; Breaking Change handling needs user attention. Future plans: Support Coq/Isabelle, integrate ATPs (Z3/CVC5), domain-specific workflows. Community feedback is enabled via lean4-contribute plugin: bug-report, feature-request, share-insight—all confirmed by users before submission to ensure privacy and intent.