FormalConjecturesUtil/Linters/CategoryLinter.lean

GitHub source file

Explanation legend Lean4 Domain Explanation Language (L4DEL)

L4DEL explanations are a separate layer. They do not change the Lean source. Intuition is explanatory prose; numbered items are a reading path; sources link the wording back to evidence.

L4DEL
Lean4 Domain Explanation Language

Credit: The upstream authors and contributors retain credit for the project and mathematics. lean4-explainer only renders their pinned source and adds the separately disclosed explanation layer.

Project sources: Pinned project documentation, Formal Conjectures paper, arXiv v1

4 declarations, 0 contain sorry, 0 declared as axioms

The Category Linter

The categoryLinter is a linter to aid with formatting contributions to the Formal Conjectures repository by ensuring that results in a file have the appropriate tags in order to distinguish between open/already solved problems and background results/sanity checks.

Imports (2)
Imported by 2 files
  1. def CategoryLinter.toCategory Checks if a command has the category attribute line 42 source

    Source documentation

    Checks if a command has the category attribute.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Lean.TSyntax, List.cons, Lean.SyntaxNodeKind, Lean.Name.mkStr4, List.nil, Lean.Elab.Command.CommandElabM, Array

    Proof uses: ite, Eq, Bool, Lean.Syntax.isOfKind, Lean.TSyntax.raw, Bool.true, Lean.Syntax, Lean.Syntax.getArg, OfNat.ofNat, Nat, Lean.Syntax.matchesNull, Option, Array.mapM, Lean.TSyntax.mk, Option.some, Array.getSepElems, Lean.Syntax.getArgs, Array.filterM, Lean.Name.mkStr2, Pure.pure and 10 more

    9 instances, coercions and auxiliary constants left out.

    def toCategory
      (stx : TSyntax ``Command.declModifiers) :
        CommandElabM (Array <| TSyntax ``attrInstance) := do
    …
  2. def CategoryLinter.checkNotOpenIfSorryFree Warns when a problem categorised as research open turns out to have a sorry-free proof line 63 source

    Source documentation

    Warns when a problem categorised as research open turns out to have a sorry-free proof.

    This check used to live in the category attribute, at .afterTypeChecking, where it never fired for a theorem: proof terms elaborate asynchronously, so value? was still none. It did fire for a def, which is why the gap went unnoticed.

    .afterCompilation is late enough to see the proof term in an ordinary file, but not inside a module, and every file in FormalConjecturesTest is a module. An attribute-based check therefore cannot be given a test. A linter runs once the command has finished and works in both, so the check lives here and findAsync? waits on the elaboration task.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Lean.TSyntax, List.cons, Lean.SyntaxNodeKind, Lean.Name.mkStr4, List.nil, Lean.Syntax, Lean.Elab.Command.CommandElabM, Unit

    Proof uses: Bind.bind, Lean.Elab.Modifiers, Lean.Elab.elabModifiers, StateRefT', IO.RealWorld, Lean.Elab.Command.State, EIO, Lean.Exception, Lean.Elab.Command.Context, Prod, Lean.Name, Lean.Elab.expandDeclIdCore, Lean.Environment, Lean.MonadEnv.getEnv, ite, Eq, Bool, Lean.Elab.Modifiers.isPrivate, Bool.true, Lean.mkPrivateName and 41 more

    31 instances, coercions and auxiliary constants left out.

    def checkNotOpenIfSorryFree (mods : TSyntax ``Lean.Parser.Command.declModifiers)
        (declId : Syntax) : CommandElabM Unit := do
    …
  3. def CategoryLinter.checkExactlyOneCategory Warns unless a carries exactly one category attribute line 91 source

    Source documentation

    Warns unless a carries exactly one category attribute. Returns whether it does, so the caller can go on to the checks that need one. stx is only used to place a warning when the modifiers carry no attribute list to point at.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Lean.TSyntax, List.cons, Lean.SyntaxNodeKind, Lean.Name.mkStr4, List.nil, Lean.Syntax, Lean.Elab.Command.CommandElabM, Bool

    Proof uses: Bind.bind, Array, CategoryLinter.toCategory, ite, Eq, Lean.Syntax.isOfKind, Lean.TSyntax.raw, Bool.true, Lean.Syntax.getArg, OfNat.ofNat, Nat, Lean.Syntax.matchesNull, Lean.TSyntax.mk, GT.gt, Array.size, Unit, Lean.Linter.logLintIf, linter.style.category_attribute, Function.comp, String and 13 more

    17 instances, coercions and auxiliary constants left out.

    def checkExactlyOneCategory (a : TSyntax ``Lean.Parser.Command.declModifiers) (stx : Syntax) :
        CommandElabM Bool := do
    …
  4. def CategoryLinter.categoryLinter The problem category linter checks that every theorem/lemma/example has been given a problem category attribute line 109 source

    Source documentation

    The problem category linter checks that every theorem/lemma/example has been given a problem category attribute.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Lean.Elab.Command.Linter

    Proof uses: Lean.Elab.Command.Linter.mk, Lean.withSetOptionIn, Lean.Syntax, ite, Lean.Elab.Command.CommandElabM, Unit, Eq, Bool, Lean.Syntax.isOfKind, Lean.Name.mkStr4, Bool.true, Lean.Syntax.getArg, OfNat.ofNat, Nat, cond, Bool.or, Bool.false, Lean.TSyntax, List.cons, Lean.SyntaxNodeKind and 18 more

    9 instances, coercions and auxiliary constants left out.

    def categoryLinter : Linter where
    …