FormalConjecturesUtil/Linters/ExistsImplicationLinter.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

3 declarations, 0 contain sorry, 0 declared as axioms

The Exists Implication Linter

Many misformalisations stem from using a pattern of the form ∃ x, P x → Q instead of ∃ x, P x ∧ Q (e.g. when formalising something of the form "there is positive x such that ..."). This is almost always incorrect (and trivial to prove) since it then suffices to pick an x that does not satisfy P. This linter flags occurrences of this pattern to the user and proposes a corrected syntax.

Imports (4)
Imported by 2 files
  1. def ExistsImplicationLinter.forallToAnd Changes and expression of the form ∀ (h1 : Prop1) (h2 : Prop2) ..., Propn to `Prop1 ∧ Prop2 ∧ line 46 source

    Source documentation

    Changes and expression of the form ∀ (h1 : Prop1) (h2 : Prop2) ..., Propn to Prop1 ∧ Prop2 ∧ ... ∧ Propn.

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

    Statement uses: Lean.Expr, Lean.Meta.MetaM

    Proof uses: Lean.Meta.forallTelescope, Lean.Meta.Context, StateRefT', IO.RealWorld, Lean.Meta.State, Lean.Core.CoreM, Array, Bind.bind, Array.mapM, Lean.Meta.inferType, Array.foldrM, Lean.Meta.mkAppM, Lean.Name.mkStr1, List.toArray, List.cons, List.nil, Array.size, OfNat.ofNat, Nat, Bool.false

    8 instances, coercions and auxiliary constants left out.

    def forallToAnd (expr : Expr) : MetaM Expr :=
    …
  2. def ExistsImplicationLinter.checkExistsArrow Checks if an expression contains the pattern ∃ x, P x → Q line 54 source

    Source documentation

    Checks if an expression contains the pattern ∃ x, P x → Q.

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

    Statement uses: Lean.Syntax, Lean.Expr, Lean.Meta.MetaM, Unit

    Proof uses: Inhabited.default

    1 instances, coercions and auxiliary constants left out.

    partial def checkExistsArrow (stx : Syntax) (e : Expr) : MetaM Unit := do
    …
  3. def ExistsImplicationLinter.existsImplicationLinter The existsImplicationLinter detects expressions of the form ∃ a, P a → Q and flags them to the user since those are rarely correct line 83 source

    Source documentation

    The existsImplicationLinter detects expressions of the form ∃ a, P a → Q and flags them to the user since those are rarely correct.

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

    Statement uses: Lean.Elab.Command.Linter

    Proof uses: Lean.Elab.Command.Linter.mk, Lean.Elab.Command.Linter.runTermLinter, Unit, ExistsImplicationLinter.linter.style.existsImplication, Lean.Syntax.Term, Lean.Expr, liftM, ReaderT, Lean.Meta.Context, StateRefT', IO.RealWorld, Lean.Meta.State, Lean.Core.CoreM, StateT, Lean.Meta.MetaM, ExistsImplicationLinter.checkExistsArrow, Lean.TSyntax.raw, List.cons, Lean.SyntaxNodeKind, Lean.Name.mkStr1 and 2 more

    5 instances, coercions and auxiliary constants left out.

    def existsImplicationLinter : Linter where
    …