Generated from
folio-assistant-sci/skills/content/folio-paper-adapter/chapter-analysis.md— do not edit here.
Chapter Analysis & Formalization
Overview
This skill performs a complete analysis-to-formalization pass on a single chapter of the manuscript. It is the union of the Ontologist, Formalizer, and Lean Generation skills applied in a structured, chunked workflow.
When to Use This Skill
- When a chapter is ready for its first Lean formalization pass
- When reviewing a chapter for glossary completeness
- When bringing a chapter’s Lean infrastructure from empty stubs to comprehensive definitions with proved structural results
- When onboarding a new mathematical domain into the Lean codebase
Prerequisites
- The chapter’s
.texfile exists inchapters/ - The corresponding
lean/<Paper>/<Chapter>.leanfile exists (may be empty) lean/<Paper>/Glossary.leanandglossary.jsonare current- The per-paper
lakefile.toml(and the root/lakefile.toml) have all needed dependencies (mathlib4, …)
Chunked Workflow
The analysis proceeds in 8 chunks. Each chunk is independently committable. Mark each chunk done before proceeding.
Chunk 1 — Narrative Inventory
- Read the chapter
.texfile in full - List every
\begin{definition},\begin{lemma},\begin{proposition},\begin{theorem},\begin{example},\begin{corollary}— excluding remarks unless explicitly requested - For each item record:
- LaTeX label (e.g.
def:core-structure) - Display name (e.g. “Core Structure”)
- Environment type (definition / lemma / proposition / …)
- Dependencies (items referenced via
\ref)
- LaTeX label (e.g.
- Output: a markdown table of all narrative items
Chunk 2 — Glossary Gap Analysis
- Compare the narrative inventory against
glossary.jsonentries for this chapter - Identify terms used in definitions but not present as glossary entries
- For each missing term, determine:
narrative_term: human-readable namelean_name: fully qualified Lean name (<Paper>.Glossary.<PascalCase>)kind:defnarrative_definition: 1–2 sentence definition from the textlatex_label: the label of the definition that uses this termchapter: chapter number
- Output: list of new glossary entries
Chunk 3 — Lean Structures (Categorical / Algebraic)
Write Lean structure or class declarations for the foundational algebraic
objects in the chapter. Follow these rules:
- Import from mathlib:
CategoryTheory.Monoidal.Basic,Functor.Basic,Algebra.Group.Basic, etc. - Use
sorryonly for axiom placeholders that represent deep mathematical content (non-degeneracy, cohomological vanishing). PreferTrue := by trivialfor conditions that are axiomatically assumed. - Every structure field gets a
/-- ... -/docstring - Naming:
PascalCasefor structures,camelCasefor defs/theorems,snake_casefor lemma names
Chunk 4 — Lean Structures (Geometric / Analytic)
Write Lean structures for any concrete/geometric realisation in the chapter:
- Manifold data, connections, model parameters
- Use
M → ℝas a simplified type for sections/fields when full differential-geometric types are not yet available in the project - Include positivity/boundedness conditions as fields
Chunk 5 — Lean Definitions (Parameter-Deformed Operators)
When the chapter introduces operators that depend on a deformation/specialization
parameter, write a noncomputable def for each. Such operators frequently
share a common interpolation structure between a base case and a correction
term; capture that shared shape once and reuse it. For example:
noncomputable def deformedOperator {M : Type*} (p : Parameter M)
(baseOp : M → ℝ) (correction : M → ℝ) (x : M) : ℝ :=
(p.field x)⁻¹ * baseOp x +
(1 - (p.field x)⁻¹) * correction x
Chunk 6 — Lemmas and Propositions
For each lemma/proposition in the chapter:
- State as a
theoremwith the correct hypotheses - If the proof is contained in the chapter, attempt formalization
- If the proof is deferred, use
sorrywith a comment citing the chapter - Prove limiting-case theorems (the parameter’s trivial value recovers
the classical/base object) — these are typically straightforward
unfold; rw; ring
Chunk 7 — Update Glossary Files
- Add new entries to
glossary.json(updateentry_count) - Add corresponding
defdeclarations tolean/<Paper>/Glossary.leanwith docstrings, LaTeX labels, and mathlib references
Chunk 8 — Commit, Push, PR
git addthe modified files (typically 3–4 files)- Commit with message pattern:
feat: formalize Chapter N definitions and add missing glossary terms - Push to the working branch
- Create PR with a table of Lean declarations and their status
Lean Style Guidelines
autoImplicitisfalse— declare all universe and type variables- Prefer
structureoverdef ... := sorryfor data-carrying types - Group declarations under
/-! ## §N Section Title -/comments - Proved theorems (no sorry) should be prioritised:
- Parameter bounds (e.g.
0 ≤ ℏ_q < 1) - Limiting cases (trivial parameter value recovers the base operator)
- Decomposition identities (
total = horizontal + vertical)
- Parameter bounds (e.g.
- Use mathlib tactics:
linarith,ring,field_simp,simp,rfl
Mathlib Import Cheat Sheet
| Concept | Import |
|---|---|
| Monoidal categories | Mathlib.CategoryTheory.Monoidal.Basic |
| Functors | Mathlib.CategoryTheory.Functor.Basic |
| Groups/rings | Mathlib.Algebra.Group.Basic, Mathlib.Algebra.Ring.Basic |
| Ordered fields | Mathlib.Algebra.Order.Field.Basic |
| Real numbers | Mathlib.Data.Real.Basic |
| Manifolds | Mathlib.Geometry.Manifold.SmoothManifoldWithCorners |
| Inner product spaces | Mathlib.Analysis.InnerProductSpace.Basic |
| Exterior algebra | Mathlib.LinearAlgebra.ExteriorAlgebra.Basic |
| Topological spaces | Mathlib.Topology.Basic |
| Continuous functions | Mathlib.Topology.ContinuousFunction.Basic |
| Fiber bundles | Mathlib.Topology.FiberBundle.Basic |
Content Object Integration
Chapter analysis should populate content object triples, not just extract items from LaTeX. Each narrative definition, theorem, lemma, proposition, example, or corollary becomes a triple:
block-name.ts— typed manifest withkind,label,lean.ref,status, anduses[]referencing other content object labels.block-name.md— narrative content (markdown with inline/display math).block-name.lean— Lean formalization (required fordefinition, expected fortheorem/lemma/proposition/corollary, optional forexample/remark/conjecture, absent forprose/equation/diagram).
Chunk 1 output should feed content object creation. The narrative
inventory table maps directly to .ts manifests: environment type becomes
kind, LaTeX label becomes label, and \ref dependencies become
uses[] entries. Populate content objects during analysis rather than
treating LaTeX as the authoritative source.
Dependency graph. Build uses[] edges from \ref cross-references
found during inventory. These edges drive both the Lean import graph and
formalization priority ordering.
Checklist
- All non-remark narrative items have Lean declarations
- Limiting-case theorems are proved (no sorry)
- Missing glossary terms are added to both
.jsonand.lean entry_countinglossary.jsonis updated- Every
sorryhas a comment explaining what it defers - Lean file compiles with
lake build(sorry warnings expected) - Commit message follows repository conventions