FormalConjecturesUtil/Linters/CategoryLinter.lean
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.
- def
CategoryLinter.toCategoryChecks if a command has thecategoryattribute line 42 sourceSource documentation
Checks if a command has the
categoryattribute.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,ArrayProof 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.pureand 10 more9 instances, coercions and auxiliary constants left out.
def toCategory (stx : TSyntax ``Command.declModifiers) : CommandElabM (Array <| TSyntax ``attrInstance) := do … - def
CategoryLinter.checkNotOpenIfSorryFreeWarns when a problem categorised asresearch openturns out to have a sorry-free proof line 63 sourceSource documentation
Warns when a problem categorised as
research openturns out to have a sorry-free proof.This check used to live in the
categoryattribute, at.afterTypeChecking, where it never fired for a theorem: proof terms elaborate asynchronously, sovalue?was stillnone. It did fire for adef, which is why the gap went unnoticed..afterCompilationis late enough to see the proof term in an ordinary file, but not inside a module, and every file inFormalConjecturesTestis 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 andfindAsync?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,UnitProof 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.mkPrivateNameand 41 more31 instances, coercions and auxiliary constants left out.
def checkNotOpenIfSorryFree (mods : TSyntax ``Lean.Parser.Command.declModifiers) (declId : Syntax) : CommandElabM Unit := do … - def
CategoryLinter.checkExactlyOneCategoryWarns unlessacarries exactly one category attribute line 91 sourceSource documentation
Warns unless
acarries exactly one category attribute. Returns whether it does, so the caller can go on to the checks that need one.stxis 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,BoolProof 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,Stringand 13 more17 instances, coercions and auxiliary constants left out.
def checkExactlyOneCategory (a : TSyntax ``Lean.Parser.Command.declModifiers) (stx : Syntax) : CommandElabM Bool := do … - def
CategoryLinter.categoryLinterThe problem category linter checks that every theorem/lemma/example has been given a problem category attribute line 109 sourceSource 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.LinterProof 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.SyntaxNodeKindand 18 more9 instances, coercions and auxiliary constants left out.
def categoryLinter : Linter where …