This document codifies the conventions for pull requests, issues, code review, Lean style, and CI automation used in the TNLean project.
Use mathlib-style conventional titles:
type(scope): short description
| Type | When to use |
|---|---|
feat |
New definition, lemma, theorem, or module |
fix |
Broken proof, wrong identifier, or wrong statement |
refactor |
Reorganization without changing mathematical content |
doc |
Documentation or blueprint changes only |
style |
Naming, formatting, prose, or title cleanup |
ci |
CI workflow changes |
chore |
Dependency bumps, linting, toolchain updates |
Scope is a shortened module path: MPS/Symmetry, Channel, blueprint+docgen,
MPS/Core, etc. Omit the TNLean/ prefix.
Examples:
feat(MPS/CanonicalForm): assemble cyclic sectors at a common blocking lengthdoc(Wolf Chapter 6): add Lean tags for spectral theoremsstyle(MPS/CanonicalForm): rewrite equal-case prose in MPS language
Every PR body must contain three sections:
### Motivation
- Why this change is needed (1--3 bullets).
- For mathematical work, cite the paper theorem, blueprint entry, or issue
that fixes the scope.
- For mathematical work whose source is in `blueprint/`, `Papers/`, or
`Notes/`, give the source file path, line range,
theorem/lemma/definition/equation label when available, and a short quotation
of the source statement.
### Description
- What was changed: files added/modified, definitions introduced, lemmas proved.
- Use bullet points.
- State the mathematical content precisely enough for a reader who has not read
the issue thread.
- When renaming a public declaration and intentionally omitting a
`@[deprecated] alias` because the old name encodes misleading terminology,
explicitly note: `No compatibility alias is provided — the old name encodes
[term] (see docs/CONTRIBUTING.md Section Mathematical-language renames).`
### Testing
- What was verified and how.
- Examples: `lake env lean TNLean/Foo/Bar.lean`, `lake build TNLean`,
`rg -n "sorry|axiom" TNLean/Foo/Bar.lean || true`.
---
Addresses #NUse Addresses #N (keeps the issue open) or Closes #N (auto-closes on merge)
in the footer to link the relevant issue.
A PR template (.github/pull_request_template.md) auto-fills the
Motivation / Description / Testing sections. Fill in the placeholders — do not
delete the headings.
Apply all relevant labels from the taxonomy in Section 4.
Three issue templates are available in .github/ISSUE_TEMPLATE/:
| Template | When to use |
|---|---|
| Formalization Task | A specific theorem, definition, or lemma to formalize |
| Bug Report | Broken proof, type error, sorry regression, CI failure |
| Tracking Issue | Umbrella issue tracking a group of sub-issues |
Issue titles are plain mathematical or repository-maintenance titles, not PR-title prefixes. Labels carry the type, topic, paper, chapter, priority, and status metadata.
Use these forms:
| Issue kind | Title form |
|---|---|
| Overall tracker | Tracking: <area> |
| Formalization task | <area>: <mathematical result or construction> |
| Blueprint or documentation task | <document area>: <mathematical documentation change> |
| CI or repository maintenance | <area>: <concrete maintenance task> |
| Daily record | <record type> -- <date> |
Keep issue titles bracket-free. Use Wolf Chapter 6: ..., not [Wolf Chapter 6] ....
Do not put feat(...), fix(...), doc(...), or formalization(...) at
the start of an issue title. Put parent issue numbers, PR numbers, audit
filenames, and implementation notes in the body unless they are needed to
disambiguate the title.
Use a descriptive title that names the mathematical content:
MPS/Symmetry: twisted tensor and on-site symmetry
Label with area + arXiv paper + topic as applicable.
The body must identify the mathematical source precisely. Include the paper or
book citation and, when the source is in blueprint/, Papers/, or Notes/,
the repository file path, line range, theorem/lemma/definition/equation label
when available, and a short quotation of the source statement. Use a precise
paraphrase only when the source is not available as repository text. Avoid AI
vocabulary, software-process metaphors, and local shorthand when describing the
mathematics.
For work spanning multiple PRs, create an umbrella tracking issue and put the part numbering in the body or in native GitHub sub-issue relations when it is not needed to distinguish the mathematical statement:
RFP/MPDO: algebra structure and fusion isometries
RFP/MPDO: commuting parent Hamiltonians and decorrelation theorem
Attach child issues using GitHub's native Sub-issues panel so that each child displays "Tracked by #N" in its sidebar. Do not mirror that relation with Markdown tasklists or checkbox lists in the tracking issue body. If the tracking template includes issue numbers in the body, attach those numbers through the Sub-issues panel after creation and keep the body for mathematical scope, sources, dependencies, and order.
Generated tracking issues should create sub-issues for the mathematical tasks. Each sub-issue should carry its own source citation and precise statement.
Use the Tracking Issue template (.github/ISSUE_TEMPLATE/tracking-issue.yml).
Label with tracking. The tracking-issue-sync workflow reads the native
Sub-issues relation and will automatically:
- Post progress comments when sub-issues are closed or reopened.
- Post progress comments on linked issues when PRs are merged (what was done, what remains).
- Add the
all-resolvedlabel when every native sub-issue is complete.
The three most active tracking issues are pinned to the top of the Issues tab.
Update pins when priorities shift (gh issue pin/unpin). GitHub allows at most
3 pinned issues.
Use milestones to group issues targeting a shared deadline (e.g., a paper submission or a toolchain bump). Assign a milestone when the issue has a concrete target date; remove it when the date no longer applies.
GitHub Discussions is enabled for design questions, proof strategy debates, and topics that do not determine a single concrete issue (e.g., "Should MPDO live under MPS/?"). Use issues for concrete work items; use discussions for open-ended conversations.
When the LaTeX blueprint is out of sync with Lean code, open an issue with
the blueprint-sync label. Describe which chapter, theorem, or definition
needs \lean{} / \leanok tags.
- Use imperative mood in the subject line ("Add", not "Added").
- Keep the subject under 72 characters.
- When squash-merging a PR, the commit message should match the PR title format.
- Reference issue numbers where applicable (
(#N)suffix orAddresses #Nin body).
| Label | Description |
|---|---|
formalization |
Lean 4 formalization task |
infrastructure |
Definitions and basic lemmas |
documentation |
Improvements or additions to documentation |
ci |
CI/CD workflow changes |
cleanup |
Code cleanup and style fixes |
| Label | Description |
|---|---|
0802.0447 |
arXiv:0802.0447 -- String order and symmetries (PRL 2008) |
1606.00608 |
arXiv:1606.00608 -- MPDO RFP |
1708.00029 |
arXiv:1708.00029 -- Periodic FT for MPS (De las Cuevas et al.) |
1804.04964 |
arXiv:1804.04964 -- FT for normal tensor networks |
2011.12127 |
arXiv:2011.12127 -- RMP review (Cirac--Perez-Garcia--Schuch--Verstraete) |
| Label | Description |
|---|---|
parent-hamiltonian |
Parent Hamiltonian theory for MPS (RMP IV.C) |
correlation-decay |
Exponential decay of correlations in MPS |
symmetry-SPT |
MPS symmetries, projective representations, and SPT classification |
rfp-mpdo |
Renormalization fixed points and MPDO theory |
algebraic-FT |
Algebraic approach to Fundamental Theorem |
wolf-ch1 |
Wolf Lecture Notes -- Chapter 1: Deconstructing Quantum |
wolf-ch2 |
Wolf Lecture Notes -- Chapter 2: Representations |
wolf-ch5 |
Wolf Lecture Notes -- Chapter 5: Schwarz Inequalities |
wolf-ch6 |
Wolf Lecture Notes -- Chapter 6: Spectral Properties |
wolf-ch7 |
Wolf Lecture Notes -- Chapter 7: Semigroup Structure |
| Label | Description |
|---|---|
tracking |
Tracking issue for a formalization area |
blueprint-sync |
Blueprint out of sync with Lean code |
automation |
Automated documentation/sync PR |
bug, enhancement, good first issue, help wanted, question,
duplicate, invalid, wontfix.
Every PR touching Lean code should be reviewed against these criteria:
-
Proof correctness -- No unexplained
sorry. Noaxiomunless discussed. Runrg -n "sorry|axiom" <file>to verify. -
Mathlib style -- Follow the naming conventions in MATHLIB_naming.md and documentation standards in MATHLIB_doc.md. See MATHLIB_pr-review.md for the full Mathlib review guide. For renames that intentionally omit deprecated aliases under the mathematical-language exception, confirm the PR body states the reason (see CONTRIBUTING.md Section Mathematical-language renames).
-
Type safety -- No universe mismatches, coercion problems, or unresolved metavariables.
-
Performance -- Avoid expensive tactics on large types (e.g.,
decideonFin 1000). Watch for timeout-prone proof terms. -
Modularity -- Are new lemmas general enough to be reused? Could any be upstreamed to Mathlib?
-
Documentation -- Every new
defand majortheoremmust have a docstring. Module files should have a header comment with## Referencesciting the relevant arXiv paper(s). -
Blueprint sync -- If the PR formalizes a statement from the blueprint, add
\lean{LeanDeclName}and\leanoktags to the correspondingblueprint/src/chapter/*.texfile.
This project follows Mathlib conventions with project-specific additions.
- Documentation style: MATHLIB_doc.md -- module headers, docstrings, LaTeX in comments, sectioning comments.
- Naming conventions: MATHLIB_naming.md -- capitalization rules, symbol-to-name dictionary, variable conventions.
- Review guide: MATHLIB_pr-review.md -- detailed examples of style, documentation, location, and improvement considerations.
Module header: Every .lean file should start with a module docstring that
includes:
/-!
# Title
Summary of what this file contains.
## Main definitions / statements
- `FooBar` : description
- `fooBar_baz` : description
## References
- [arXiv:XXXX.XXXXX](https://arxiv.org/abs/XXXX.XXXXX) -- Author, *Title*
-/Docstrings: Required on every def, structure, class, and significant
theorem. Encouraged on supporting lemmas. Use Markdown; refer to Lean
identifiers in backticks.
Sectioning comments: Use /-! ### Section Title -/ to organize long files
into logical sections.
Variable naming: Follow the conventions in MATHLIB_naming.md. For this project specifically:
A,Bfor MPS tensorsEfor transfer matrices / quantum channelsdfor physical dimension,Dfor bond dimensionN,Lfor chain length
The standard Mathlib deprecation convention says renamed declarations should keep
a @[deprecated] alias. When the old name encodes misleading terminology —
process jargon, project-internal shorthand, or non-mathematical phrasing — a clean
one-step rename without a deprecated alias is preferred.
Skip the alias when the old name contains a term that appears in, or is a
contextual variant of, the banned-vocabulary list in
docs/prose_style.md Section 2.
Apply context-qualified bans only in the stated context: for example, "Assembly"
is banned as a section or chapter title, but not when it is part of a standard
mathematical phrase.
Examples of terms that make an alias inappropriate in declaration names:
- exact entries or variants of process/software metaphors from the prose guide:
pipeline,package,scaffolding/scaffold,workflow,plumbing,boilerplate,glueLayer,reexport - additional project-internal cleanup terms with the same non-mathematical force:
raw,helper,wrapper,endpointwhen it means a proof milestone rather than a boundary point - project-internal shorthand:
liveBlock,oneShot,deadProof,sourceAnchor - AI/LLM vocabulary in declaration names
Keep the @[deprecated] alias when the old name uses genuine mathematical language that
is merely imprecise or outdated (e.g., transferMap → transferMatrix when the object is
a matrix) — the old name is not misleading, just suboptimal.
When a rename skips a deprecated alias under this exception, the PR body must explicitly say:
No compatibility alias is provided. The old name encodes [misleading term] (see
docs/CONTRIBUTING.mdSection Mathematical-language renames).
This makes the exception visible to reviewers and prevents downstream users from wondering whether the omission was an oversight.
In the same PR, update every \lean{OldName} tag in blueprint/src/ to
\lean{NewName}. Run leanblueprint checkdecls to confirm no stale references
remain.
Before deleting or renaming, search the project for call sites of the old name
(rg -n "oldName" TNLean/) and update them in the same PR. If the old name
appears in a module docstring or comment, rewrite the surrounding prose to use
the new mathematical name.
The following workflows run automatically:
| Workflow | Trigger | What it does |
|---|---|---|
Lean CI (lean_action_ci.yml) |
Push to main, PRs touching .lean/lakefile.toml/lean-toolchain |
Runs lake build with Mathlib cache |
Claude Code Review (claude-code-review.yml) |
PR opened/synced/reopened touching .lean, .tex, lakefile.toml, lean-toolchain |
Automated review for sorrys, Mathlib style, type safety, performance, modularity, documentation |
Issue Tracker (tracking-issue-sync.yml) |
Issue closed/reopened; PR merged/opened; review submitted | Reads native Sub-issues, posts progress comments on tracking and linked issues, scans merged PRs for follow-ups (deferred review feedback, new sorry markers, missing blueprint tags), creates follow-up issues with follow-up label, adds all-resolved when all native sub-issues complete |
Blueprint Lint (lint-blueprint.yml) |
PRs touching blueprint files | Validates LaTeX blueprint for broken labels and references |
Oversized Lean File Guard (oversized-lean-files.yml) |
PRs | Reports .lean files above the 1000-line style limit; advisory while main still has existing oversized files |
Lean Linter-Warning Sweep (lean-linter-warning-sweep.yml) |
Weekly + manual dispatch | Captures Lean compiler/linter warnings and uploads a report for maintainer triage |
Lean Linter-Warning Auto-Fix (lean-linter-warning-autofix.yml) |
Manual dispatch | Runs the warning sweep and can open a guarded Lean-only PR when explicitly requested |
Docs & Blueprint Sync (docs-blueprint-sync.lock.yml) |
Daily (weekdays) + manual dispatch | Detects stale documentation and opens a sync PR if needed |
Lean Audit (lean-audit.yml) |
On demand | Audits Lean code for style and correctness |
PR Cleanup (pr-cleanup.yml) |
Bot-generated PR opened (claude/* or codex/* branches) |
Normalizes title to type(scope): desc, restructures body to PR template, copies labels from linked issue, adds Addresses #N reference, comments on the issue |
lake build TNLeanmust succeed (no type errors, no broken imports).- No new
sorrywithout explicit justification. - Blueprint labels must resolve (no broken
\refor\label). - Claude Code Review should not flag critical issues (proof correctness, type safety).