Lean archive

From MechMath/MechMath-agent-team · View interactive version

Lean archive is an AI agent skill from the GitHub repository MechMath/MechMath-agent-team. Use when organizing a registered Lean 4 source file into thematic files, creating Lean wiki cards, and cross-indexing formal proofs with KBManager concept pages.

How to use this skill

Skill file

Lean Archive

Use this skill after a .lean file has been registered under

${DATA_DIR:-data}/raw_sources/<hash12>/.

This workflow has three phases. Each phase needs human confirmation before

proceeding.

Phase 1: Organize

  1. Locate the file:

```bash

find "${DATA_DIR:-data}/raw_sources" -maxdepth 2 -name "<filename.lean>" | head -1

```

  1. Read the full file.
  2. Build a structural map:

abbrev, axiom, structure, class, instance

  1. Propose thematic split:

```text

Raw file: <filename> (<n> declarations)

Proposed units:

[A] <ThematicName> (<n> declarations)

Declarations: ...

```

  1. Wait for confirmation.
  2. Write confirmed units to ${DATA_DIR:-data}/lean/<ThematicName>.lean with

an archive header preserving source path and date.

Phase 2: Index

For each organized file, create

${DATA_DIR:-data}/wiki/Lean_<ThematicName>.md:

---
tags: [lean, formal-proof]
date: YYYY-MM-DD
lean_file: $DATA_DIR/lean/<ThematicName>.lean
proof_status: proved | partial | mixed
source_count: 1
---

Include:

Update ${DATA_DIR:-data}/wiki/index.md:

Wait for confirmation before Phase 3.

Phase 3: Cross-Index

  1. Read ${DATA_DIR:-data}/wiki/index.md.
  2. Match Lean cards to existing Concept_* pages by declaration names, type

signatures, and docstrings.

  1. Add ## Formal Proofs links to matched concept pages.
  2. Fill ## Connections in each Lean card.
  3. Move the raw source manifest entry to ## Ingested; Wiki page should list

all created [[Lean_*]] cards.

  1. Append ${DATA_DIR:-data}/wiki/log.md:

```markdown

## [YYYY-MM-DD] ingest-lean | <original filename>

```

  1. Commit changed ${DATA_DIR:-data}/lean/, ${DATA_DIR:-data}/wiki/, and

manifest files unless the human asks not to.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.