← 返回 Skills 市场
wu-uk

lean4-theorem-proving

作者 wu-uk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ⚠ suspicious
75
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install lean4-proof-lean4-theorem-proving
功能描述
Use when working with Lean 4 (.lean files), writing mathematical proofs, seeing "failed to synthesize instance" errors, managing sorry/axiom elimination, or...
使用说明 (SKILL.md)

Lean 4 Theorem Proving

Core Principle

Build incrementally, structure before solving, trust the type checker. Lean's type checker is your test suite.

Success = lake build passes + zero sorries + zero custom axioms. Theorems with sorries/axioms are scaffolding, not results.

Quick Reference

Resource What You Get Where to Find
Interactive Commands 10 slash commands for search, analysis, optimization, repair Type /lean in Claude Code (full guide)
Automation Scripts 19 tools for search, verification, refactoring, repair Plugin scripts/ directory (scripts/README.md)
Subagents 4 specialized agents for batch tasks (optional) subagent-workflows.md
LSP Server 30x faster feedback with instant proof state (optional) lean-lsp-server.md
Reference Files 18 detailed guides (phrasebook, tactics, patterns, errors, repair, performance) List below

When to Use

Use for ANY Lean 4 development: pure/applied math, program verification, mathlib contributions.

Critical for: Type class synthesis errors, sorry/axiom management, mathlib search, measure theory/probability work.

Tools & Workflows

7 slash commands for search, analysis, and optimization - type /lean in Claude Code. See COMMANDS.md for full guide with examples and workflows.

16 automation scripts for search, verification, and refactoring. See scripts/README.md for complete documentation.

Lean LSP Server (optional) provides 30x faster feedback with instant proof state and parallel tactic testing. See lean-lsp-server.md for setup and workflows.

Subagent delegation (optional, Claude Code users) enables batch automation. See subagent-workflows.md for patterns.

Build-First Principle

ALWAYS compile before committing. Run lake build to verify. "Compiles" ≠ "Complete" - files can compile with sorries/axioms but aren't done until those are eliminated.

The 4-Phase Workflow

  1. Structure Before Solving - Outline proof strategy with have statements and documented sorries before writing tactics
  2. Helper Lemmas First - Build infrastructure bottom-up, extract reusable components as separate lemmas
  3. Incremental Filling - Fill ONE sorry at a time, compile after each, commit working code
  4. Type Class Management - Add explicit instances with haveI/letI when synthesis fails, respect binder order for sub-structures

Finding and Using Mathlib Lemmas

Philosophy: Search before prove. Mathlib has 100,000+ theorems.

Use /search-mathlib slash command, LSP server search tools, or automation scripts. See mathlib-guide.md for detailed search techniques, naming conventions, and import organization.

Essential Tactics

Key tactics: simp only, rw, apply, exact, refine, by_cases, rcases, ext/funext. See tactics-reference.md for comprehensive guide with examples and decision trees.

Domain-Specific Patterns

Analysis & Topology: Integrability, continuity, compactness patterns. Tactics: continuity, fun_prop.

Algebra: Instance building, quotient constructions. Tactics: ring, field_simp, group.

Measure Theory & Probability (emphasis in this skill): Conditional expectation, sub-σ-algebras, a.e. properties. Tactics: measurability, positivity. See measure-theory.md for detailed patterns.

Complete domain guide: domain-patterns.md

Managing Incomplete Proofs

Standard mathlib axioms (acceptable): Classical.choice, propext, quot.sound. Check with #print axioms theorem_name or /check-axioms.

CRITICAL: Sorries/axioms are NOT complete work. A theorem that compiles with sorries is scaffolding, not a result. Document every sorry with concrete strategy and dependencies. Search mathlib exhaustively before adding custom axioms.

When sorries are acceptable: (1) Active work in progress with documented plan, (2) User explicitly approves temporary axioms with elimination strategy.

Not acceptable: "Should be in mathlib", "infrastructure lemma", "will prove later" without concrete plan.

Compiler-Guided Proof Repair

When proofs fail to compile, use iterative compiler-guided repair instead of blind resampling.

Quick repair: /lean4-theorem-proving:repair-file FILE.lean

How it works:

  1. Compile → extract structured error (type, location, goal, context)
  2. Try automated solver cascade first (many simple cases handled mechanically, zero LLM cost)
    • Order: rfl → simp → ring → linarith → nlinarith → omega → exact? → apply? → aesop
  3. If solvers fail → call lean4-proof-repair agent:
    • Stage 1: Haiku (fast, most common cases) - 6 attempts
    • Stage 2: Sonnet (precise, complex cases) - 18 attempts
  4. Apply minimal patch (1-5 lines), recompile, repeat (max 24 attempts)

Key benefits:

  • Low sampling budget (K=1 per attempt, not K=100)
  • Error-driven action selection (specific fix per error type, not random guessing)
  • Fast model first (Haiku), escalate only when needed (Sonnet)
  • Solver cascade handles simple cases mechanically (zero LLM cost)
  • Early stopping prevents runaway costs (bail after 3 identical errors)

Expected outcomes: Success improves over time as structured logging enables learning from attempts. Cost optimized through solver cascade (free) and multi-stage escalation.

Commands:

  • /repair-file FILE.lean - Full file repair
  • /repair-goal FILE.lean LINE - Specific goal repair
  • /repair-interactive FILE.lean - Interactive with confirmations

Detailed guide: compiler-guided-repair.md

Inspired by: APOLLO (https://arxiv.org/abs/2505.05758) - compiler-guided repair with multi-stage models and low sampling budgets.

Common Compilation Errors

Error Fix
"failed to synthesize instance" Add haveI : Instance := ...
"maximum recursion depth" Provide manually: letI := ...
"type mismatch" Use coercion: (x : ℝ) or ↑x
"unknown identifier" Add import

See compilation-errors.md for detailed debugging workflows.

Documentation Conventions

  • Write timeless documentation (describe what code is, not development history)
  • Don't highlight "axiom-free" status after proofs are complete
  • Mark internal helpers as private or in dedicated sections
  • Use example for educational code, not lemma/theorem

Quality Checklist

Before commit:

  • lake build succeeds on full project
  • All sorries documented with concrete strategy
  • No new axioms without elimination plan
  • Imports minimal

Doing it right: Sorries/axioms decrease over time, each commit completes one lemma, proofs build on mathlib.

Red flags: Sorries multiply, claiming "complete" with sorries/axioms, fighting type checker for hours, monolithic proofs (>100 lines), long have blocks (>30 lines should be extracted as lemmas - see proof-refactoring.md).

Reference Files

Core references: lean-phrasebook.md, mathlib-guide.md, tactics-reference.md, compilation-errors.md

Domain-specific: domain-patterns.md, measure-theory.md, instance-pollution.md, calc-patterns.md

Incomplete proofs: sorry-filling.md, axiom-elimination.md

Optimization & refactoring: performance-optimization.md, proof-golfing.md, proof-refactoring.md, mathlib-style.md

Automation: compiler-guided-repair.md, lean-lsp-server.md, lean-lsp-tools-api.md, subagent-workflows.md

安全使用建议
This skill appears to be a well-documented Lean 4 assistant, but the runtime instructions assume many local tools, helper scripts, and slash-command integrations that the skill does not declare or include. Before installing or enabling it: (1) verify you have the Lean toolchain (lake), git, bash, and python available; (2) confirm the referenced helper scripts (e.g., .claude/tools/lean4/*.sh and scripts/*.py) exist in your environment or repository — the SKILL bundle does not provide them; (3) be aware the repair workflow will read and modify files and run git apply patches, so run it only in repos you trust and back up work; (4) if you expect this skill to run in an environment without the mentioned 'Claude Code' slash-command system or subagent framework, ask the author how those commands map to your environment; and (5) request the author to either declare required binaries/scripts in the manifest or bundle the helper scripts, so the skill's requirements match its instructions.
功能分析
Type: OpenClaw Skill Name: lean4-proof-lean4-theorem-proving Version: 0.1.0 The bundle is a highly professional and comprehensive toolkit designed to assist an AI agent in Lean 4 theorem proving. It includes detailed documentation for compiler-guided proof repair, axiom elimination, and Mathlib integration, referencing standard community tools like Loogle and LeanSearch. The instructions provided in SKILL.md and the reference files are strictly aligned with the mathematical domain, focusing on build-first workflows and type-checker verification. There is no evidence of malicious intent, data exfiltration, or harmful prompt injection; the bundle functions as a legitimate productivity enhancer for formal verification tasks.
能力标签
cryptocan-make-purchases
能力评估
Purpose & Capability
The name/description describe a Lean 4 theorem-proving assistant and the included reference docs align with that purpose. However, the SKILL.md repeatedly instructs running external developer tools (lake build, git apply, bash .claude/tools/lean4/*.sh, python scripts, LSP server, slash commands in 'Claude Code') yet the skill declares no required binaries, no install steps, and ships no scripts or binaries. That mismatch (instructions requiring Lean/tooling/scripts not present or declared) is disproportionate to the declared manifest and could cause surprises at runtime.
Instruction Scope
The runtime instructions tell the agent to compile (lake build), extract errors, run local scripts (e.g., .claude/tools/lean4/check_axioms.sh, scripts/parseLeanErrors.py, scripts/solverCascade.py), apply git patches, and optionally delegate to subagents. Those actions are coherent for an automated repair workflow, but they instruct filesystem and VCS operations (reading files, applying patches) and expect existing helper scripts/commands and LSP integration that are not included. Users should expect the agent to need repository access and the ability to run these commands if they enable the skill.
Install Mechanism
Instruction-only skill with no install spec or code files. This is low-install risk because nothing is downloaded or installed by the skill bundle itself. The higher operational risk comes from instructions that assume external tooling and scripts exist in the environment.
Credentials
The skill does not request environment variables, credentials, or config paths. That is proportional to its purpose. Note, however, the instructions implicitly require access to local tools (lake, git, bash, python) and possibly to Mathlib/remote search tools (leanfinder/loogle) which may in practice need network access or additional credentials depending on how they're implemented — none of that is declared.
Persistence & Privilege
always:false and no special persistence or cross-skill configuration modifications are requested. The skill does instruct the agent to run git apply and to modify project files as part of repair workflows; this is expected for an automated code-repair capability but does mean you should only enable it in trusted repositories and with appropriate backups.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install lean4-proof-lean4-theorem-proving
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /lean4-proof-lean4-theorem-proving 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Bulk publish from all-task-skills-dedup
元数据
Slug lean4-proof-lean4-theorem-proving
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

lean4-theorem-proving 是什么?

Use when working with Lean 4 (.lean files), writing mathematical proofs, seeing "failed to synthesize instance" errors, managing sorry/axiom elimination, or... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 75 次。

如何安装 lean4-theorem-proving?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install lean4-proof-lean4-theorem-proving」即可一键安装,无需额外配置。

lean4-theorem-proving 是免费的吗?

是的,lean4-theorem-proving 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

lean4-theorem-proving 支持哪些平台?

lean4-theorem-proving 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 lean4-theorem-proving?

由 wu-uk(@wu-uk)开发并维护,当前版本 v0.1.0。

💬 留言讨论