This page documents Regula 0.10.0. The latest release is Regula 0.11.1: this page in Regula 0.11.1.
RG5001: Claimed modules need a leading module docstring and no repeated import
- Category Documentation
- Scope module
- Subreason
module-documentation
A module in a claimed surface has no module docstring (/-! โฆ -/ or Verso module documentation), has one that is not the first command after its imports, or repeats an import with the same modifiers.
What to do. Add a module docstring that identifies the module's material declarations and assumptions, directly after the imports and before any public section, and delete repeated imports.
- Requirement
- Every claimed module has a module docstring (
/-! โฆ -/) as its first command after the imports, and its header repeats no import with the same modifiers. - Reported in
- Enforcement
- Strict, like every rule: see how rules are enforced.
Checked example
Violating input
Example.leansource examples/rules/RG5001/Violation.leantheorem reflexive (n : Nat) : n = n := rfl
Findings of the violating run
RG5001 error violation fresh project, claim kernel-only
Subject Example at module `Example`
module-documentation: add a module doc comment describing this moduleCorrection
Example.lean+ /-! # Reflexivity
+
+ Reflexivity for every natural number; no additional assumptions. -/
theorem reflexive (n : Nat) : n = n := rfl
Example.leansource examples/rules/RG5001/Fixed.lean/-! # Reflexivity
Reflexivity for every natural number; no additional assumptions. -/
theorem reflexive (n : Nat) : n = n := rfl
The correction adds module documentation to the unchanged reflexivity evidence.
Checked by a fresh whole-project audit of <example> (axiomGate): violating run rejected, corrected run completed.
How to fix it
-
Add
/-! # Title โฆ -/as the first command after the imports. -
In a
modulefile, move the module docstring above@[expose] public sectionorpublic section. -
Delete the second copy of a repeated import;
public import Aandimport all Aare different imports. -
Follow the template in standard ยง5.3: a
#title and summary, main declarations with their results and hypotheses, assumptions and dependencies, design notes. Keep only sections that help.
Why it matters
Module documentation tells a reader which declarations carry the module's claims and under which assumptions, so the claims can be reviewed without reading every proof. The Lean community puts it first, where readers and tools look. A repeated import adds nothing and obscures which dependencies a module declares.
What triggers it
When a claimed module finishes elaborating, the checker asks Lean for its module documentation and parses the module's header and first command from its source with Lean's own parser. The proved decision RegulaPolicy.ModuleHeader.failures then rejects, with applicability module-documentation, a module without module documentation; a module whose first command after the imports is not a module docstring (for example @[expose] public section or a declaration; a set_option โฆ in prefix, the community's form for a Verso module docstring, is read through); and each import that occurs twice with the same public, meta and all modifiers. Empty modules are included.
What a passing result establishes
Every claimed module has module documentation, its first command after the imports is a module docstring, and its header repeats no import.
It does not establish:
-
That the documentation identifies all material declarations and assumptions, or describes them faithfully (R-DOC). Presence and position say nothing about content; no section layout is imposed.
-
Import minimality: an unused or transitively redundant import that is not repeated is not reported.
It leaves these review obligations open: R-DOC.
Limitations and unsupported cases
The editor reports this rule only when the module has finished elaborating without errors; a module with elaboration errors gets RG2005 (incomplete) instead.
Sources
- Normative clauses
- standard ยง5.3 Module Documentation, standard ยง6.4 Import Discipline
- Checklist rows
DOC-01,DECL-01- Detector, policy and proof sources
lean/RegulaPolicy/ModuleHeader.lean,lean/Regula/Linter/Documentation.lean,lean/Regula/Checker/AxiomGate.lean,website/RegulaStandard/DocumentationStandards.lean- Proved linkage
RegulaPolicy.ModuleHeader.failures_eq_nil_iffandmem_repeated_iff, andRegula.Checker.Acceptance.modulePresence_iffanddocumentationPresence_modes. Parsing the module header is operational.