FormalConjecturesUtil/Linters/FormalProofLinter.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
5 declarations, 1 contain sorry, 0 declared as axioms
The Formal Proof Linter
A conditional formal_proof names the hypotheses its proof assumes, each stated
in the same file with a sorry proof. If one of those is later proved, the proof
is no longer conditional on it and the annotation should be revisited.
Noticing that means reading the hypothesis's proof term, which the attribute
cannot do from inside a module: env.find? returns nothing useful there, so the
check silently does nothing in exactly the files a test would live in. See #4780.
A linter can, through findAsync?, which is the same route CategoryLinter takes
for the equivalent check on category.
Imported by 2 files
- def
FormalProofLinter.isProvedWhetherdeclNamehas a proof term with nosorryin it, waiting on the declaration to finish elaborating line 48 sourceSource documentation
Whether
declNamehas a proof term with nosorryin it, waiting on the declaration to finish elaborating.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Lean.Name,Lean.Elab.Command.CommandElabM,BoolProof uses:
Bind.bind,Lean.Environment,Lean.MonadEnv.getEnv,Option,Lean.AsyncConstantInfo,Lean.Environment.findAsync?,Bool.false,Pure.pure,Lean.Elab.Command.Context,StateRefT',IO.RealWorld,Lean.Elab.Command.State,EIO,Lean.Exception,Option.any,Lean.Expr,Bool.not,Lean.Expr.hasSorry,Lean.ConstantInfo.value?,Lean.AsyncConstantInfo.toConstantInfoand 1 more8 instances, coercions and auxiliary constants left out.
def isProved (declName : Name) : CommandElabM Bool := do …
- def
FormalProofLinter.getFormalProofTagsForReturn every formal-proof tag attached todeclNameline 56 sourceSource documentation
Return every formal-proof tag attached to
declName.A declaration may have more than one proof. Linter policy must therefore be computed over the complete list rather than the legacy singular accessor.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Lean.Name,Lean.Elab.Command.CommandElabM,Array, ProblemAttributes.FormalProofTagProof uses:
Bind.bind,Lean.Elab.Command.liftTermElabM, ProblemAttributes.getFormalProofTags,Lean.Elab.Term.TermElabM,StateRefT',IO.RealWorld,Lean.Elab.Term.State,Lean.Meta.MetaM,Lean.Elab.Term.Context,Pure.pure,Lean.Elab.Command.Context,Lean.Elab.Command.State,EIO,Lean.Exception,Array.filter,BEq.beq,ProblemAttributes.FormalProofTag.declName,OfNat.ofNat,Nat,Array.size13 instances, coercions and auxiliary constants left out.
def getFormalProofTagsFor (declName : Name) : CommandElabM (Array ProblemAttributes.FormalProofTag) := do …Mentions: ProblemAttributes.FormalProofTag
- def
FormalProofLinter.checkAssumptionsStillOpenWarns when a hypothesis assumed by aconditional formal_proofhas since been proved, so the proof may no longer be conditional on it line 63 sourceSource documentation
Warns when a hypothesis assumed by a
conditional formal_proofhas since been proved, so the proof may no longer be conditional on it.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 29 more37 instances, coercions and auxiliary constants left out.
def checkAssumptionsStillOpen (mods : TSyntax ``Lean.Parser.Command.declModifiers) (declId : Syntax) : CommandElabM Unit := do …
- def
FormalProofLinter.checkProofIsSorryIfFormalProofWarns when a statement with aformal_proofannotation has a proof that is not exactlysorryorby sorry, unless it is conditional sorry line 87 sourceSource documentation
Warns when a statement with a
formal_proofannotation has a proof that is not exactlysorryorby sorry, unless it is conditional. The main branch is a statement repository, so proofs should live in their own repository or branch.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 28 more28 instances, coercions and auxiliary constants left out.
def checkProofIsSorryIfFormalProof (mods : TSyntax ``Lean.Parser.Command.declModifiers) (declId : Syntax) (val : TSyntax ``Lean.Parser.Command.declVal) : CommandElabM Unit := do …
- def
FormalProofLinter.formalProofLinterChecks the assumptions named by aconditional formal_proofand ensuresformal_proofstatements aresorryline 111 sourceSource documentation
Checks the assumptions named by a
conditional formal_proofand ensuresformal_proofstatements aresorry.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 16 more8 instances, coercions and auxiliary constants left out.
def formalProofLinter : Linter where …