chars
int64
40
24k
content_type
stringclasses
9 values
id
stringlengths
13
64
source
stringclasses
5 values
subset
stringclasses
31 values
text
stringlengths
40
24k
45
leanexplore_declaration
leanexplore:384846
leanexplore_sqlite
leanexplore_declarations
/-- Approximations and expansions -/ | «41»
46
leanexplore_declaration
leanexplore:384847
leanexplore_sqlite
leanexplore_declarations
/-- Sequences, series, summability -/ | «40»
51
leanexplore_declaration
leanexplore:384848
leanexplore_sqlite
leanexplore_declarations
/-- Difference and functional equations -/ | «39»
52
leanexplore_declaration
leanexplore:384849
leanexplore_sqlite
leanexplore_declarations
/-- Dynamical systems and ergodic theory -/ | «37»
46
leanexplore_declaration
leanexplore:384850
leanexplore_sqlite
leanexplore_declarations
/-- Partial differential equations -/ | «35»
47
leanexplore_declaration
leanexplore:384851
leanexplore_sqlite
leanexplore_declarations
/-- Ordinary differential equations -/ | «34»
61
leanexplore_declaration
leanexplore:384853
leanexplore_sqlite
leanexplore_declarations
/-- Several complex variables and analytic spaces -/ | «32»
47
leanexplore_declaration
leanexplore:384855
leanexplore_sqlite
leanexplore_declarations
/-- Functions of a complex variable -/ | «30»
46
leanexplore_declaration
leanexplore:384858
leanexplore_sqlite
leanexplore_declarations
/-- Topological groups, Lie groups -/ | «22»
48
leanexplore_declaration
leanexplore:384859
leanexplore_sqlite
leanexplore_declarations
/-- Group theory and generalizations -/ | «20»
52
leanexplore_declaration
leanexplore:384861
leanexplore_sqlite
leanexplore_declarations
/-- Category theory; homological algebra -/ | «18»
49
leanexplore_declaration
leanexplore:384862
leanexplore_sqlite
leanexplore_declarations
/-- Nonassociative rings and algebras -/ | «17»
46
leanexplore_declaration
leanexplore:384863
leanexplore_sqlite
leanexplore_declarations
/-- Associative rings and algebras -/ | «16»
61
leanexplore_declaration
leanexplore:384864
leanexplore_sqlite
leanexplore_declarations
/-- Linear and multilinear algebra; matrix theory -/ | «15»
44
leanexplore_declaration
leanexplore:384867
leanexplore_sqlite
leanexplore_declarations
/-- Field theory and polynomials -/ | «12»
40
leanexplore_declaration
leanexplore:384869
leanexplore_sqlite
leanexplore_declarations
/-- General algebraic systems -/ | «8»
60
leanexplore_declaration
leanexplore:384870
leanexplore_sqlite
leanexplore_declarations
/-- Order, lattices, ordered algebraic structures -/ | «6»
49
leanexplore_declaration
leanexplore:384872
leanexplore_sqlite
leanexplore_declarations
/-- Mathematical logic and foundations -/ | «3»
45
leanexplore_declaration
leanexplore:384874
leanexplore_sqlite
leanexplore_declarations
/-- General and overarching topics -/ | «0»
2,992
leanexplore_declaration
leanexplore:384875
leanexplore_sqlite
leanexplore_declarations
inductive AMS /-- General and overarching topics -/ | «0» /-- History and biography -/ | «1» /-- Mathematical logic and foundations -/ | «3» /-- Combinatorics -/ | «5» /-- Order, lattices, ordered algebraic structures -/ | «6» /-- General algebraic systems -/ | «8» /-- Number theory -/ | «11...
215
leanexplore_declaration
leanexplore:384876
leanexplore_sqlite
leanexplore_declarations
/-- Get the formal proof tag for a given declaration, if any. -/ def getFormalProofTag (declName : Name) : m (Option FormalProofTag) := do let tags ← getFormalProofTags return tags.find? (·.declName == declName)
119
leanexplore_declaration
leanexplore:384877
leanexplore_sqlite
leanexplore_declarations
def getFormalProofTags : m (Array FormalProofTag) := do return formalProofExt.getState (← MonadEnv.getEnv) |>.toArray
107
leanexplore_declaration
leanexplore:384878
leanexplore_sqlite
leanexplore_declarations
def getSubjectTags : m (Array SubjectTag) := do return subjectExt.getState (← MonadEnv.getEnv) |>.toArray
138
leanexplore_declaration
leanexplore:384879
leanexplore_sqlite
leanexplore_declarations
def getCategoryStats : m (Category → Nat) := do let cats ← getStatementTags return fun c ↦ (cats.map <| fun _ arr ↦ arr.size).getD c 0
126
leanexplore_declaration
leanexplore:384880
leanexplore_sqlite
leanexplore_declarations
def getStatementTags : m (Std.HashMap Category (Array CategoryTag)) := do return splitByFun CategoryTag.category (← getTags)
102
leanexplore_declaration
leanexplore:384881
leanexplore_sqlite
leanexplore_declarations
def getTags : m (Array CategoryTag) := do return categoryExt.getState (← MonadEnv.getEnv) |>.toArray
530
leanexplore_declaration
leanexplore:384882
leanexplore_sqlite
leanexplore_declarations
/-- Split an array into preimages of a function. `splitByFun f arr` is the hashmap such that the value for key `b : β` is the array of `a : α` in `arr` that get mapped to `b` by `f` -/ def splitByFun {α β : Type} (f : α → β) [BEq β] [Hashable β] (arr : Array α) : Std.HashMap β (Array α) := Array.foldr addPreimag...
56
leanexplore_declaration
leanexplore:384883
leanexplore_sqlite
leanexplore_declarations
syntax (name := problemSubject) "AMS" subjectList : attr
599
leanexplore_declaration
leanexplore:384884
leanexplore_sqlite
leanexplore_declarations
/-- Converts a syntax node to an array of `AMS` subjects. This also annotates the every natural number litteral encountered, with the description of the corresponding AMS subject (i.e. hovering over the number in VS Code will show the subject.) -/ def Syntax.toSubjects (stx : TSyntax ``subjectList) : MetaM (Array AMS)...
90
leanexplore_declaration
leanexplore:384886
leanexplore_sqlite
leanexplore_declarations
syntax (name := FormalProof_attr) "formal_proof" &"using" formalProofKind &"at" str : attr
63
leanexplore_declaration
leanexplore:384887
leanexplore_sqlite
leanexplore_declarations
syntax (name := Category_attr) "category" CategorySyntax : attr
1,168
leanexplore_declaration
leanexplore:384888
leanexplore_sqlite
leanexplore_declarations
/-- Convert from a syntax node to a term of type `Category` and annotate the syntax with the corresponding name's docstring. -/ def Syntax.toCategory (stx : TSyntax ``CategorySyntax) : CoreM Category := do match stx with | `(CategorySyntax| high_school) => Elab.addConstInfo stx ``Category.highSchool return ...
227
leanexplore_declaration
leanexplore:384889
leanexplore_sqlite
leanexplore_declarations
def addSubjectEntry {m : Type → Type} [MonadEnv m] (name : Name) (subjects : List AMS) (informal : String) : m Unit := modifyEnv (subjectExt.addEntry · { declName := name, subjects := subjects, informal := informal })
318
leanexplore_declaration
leanexplore:384890
leanexplore_sqlite
leanexplore_declarations
/-- Defines the `tagExt` extension for adding a `HashSet` of `Tag`s to the environment. -/ initialize subjectExt : SimplePersistentEnvExtension SubjectTag (Std.HashSet SubjectTag) ← registerSimplePersistentEnvExtension { addImportedFn := fun as => as.foldl Std.HashSet.insertMany {} addEntryFn := .insert }
298
leanexplore_declaration
leanexplore:384901
leanexplore_sqlite
leanexplore_declarations
structure SubjectTag where /-- The name of the declaration with the given tag. -/ declName : Name /-- The subject(s) of the problem. -/ subjects : List AMS /-- The (optional) comment that comes with the given declaration. -/ informal : String deriving Inhabited, BEq, Hashable, ToExpr
236
leanexplore_declaration
leanexplore:384902
leanexplore_sqlite
leanexplore_declarations
def addFormalProofEntry {m : Type → Type} [MonadEnv m] (declName : Name) (kind : FormalProofKind) (link : String) : m Unit := modifyEnv (formalProofExt.addEntry · { declName := declName, proofKind := kind, proofLink := link })
329
leanexplore_declaration
leanexplore:384903
leanexplore_sqlite
leanexplore_declarations
/-- Defines the `formalProofExt` extension for recording formal proof annotations. -/ initialize formalProofExt : SimplePersistentEnvExtension FormalProofTag (Std.HashSet FormalProofTag) ← registerSimplePersistentEnvExtension { addImportedFn := fun as => as.foldl Std.HashSet.insertMany {} addEntryFn := .i...
359
leanexplore_declaration
leanexplore:384914
leanexplore_sqlite
leanexplore_declarations
/-- A tag recording the existence and location of a formal proof for a declaration. -/ structure FormalProofTag where /-- The name of the declaration with the given tag. -/ declName : Name /-- The kind of formal proof. -/ proofKind : FormalProofKind /-- A link to the formal proof. -/ proofLink : String de...
225
leanexplore_declaration
leanexplore:384915
leanexplore_sqlite
leanexplore_declarations
def addCategoryEntry {m : Type → Type} [MonadEnv m] (declName : Name) (cat : Category) (comment : String) : m Unit := modifyEnv (categoryExt.addEntry · { declName := declName, category := cat, informal := comment })
326
leanexplore_declaration
leanexplore:384916
leanexplore_sqlite
leanexplore_declarations
/-- Defines the `categoryExt` extension for adding a `HashSet` of `Tag`s to the environment. -/ initialize categoryExt : SimplePersistentEnvExtension CategoryTag (Std.HashSet CategoryTag) ← registerSimplePersistentEnvExtension { addImportedFn := fun as => as.foldl Std.HashSet.insertMany {} addEntryFn := .inse...
295
leanexplore_declaration
leanexplore:384927
leanexplore_sqlite
leanexplore_declarations
structure CategoryTag where /-- The name of the declaration with the given tag. -/ declName : Name /-- The status of the problem. -/ category : Category /-- The (optional) comment that comes with the given declaration. -/ informal : String deriving Inhabited, BEq, Hashable, ToExpr
135
leanexplore_declaration
leanexplore:384928
leanexplore_sqlite
leanexplore_declarations
syntax CategorySyntax := &"high_school" <|> &"undergraduate" <|> &"graduate" <|> (&"research" problemStatus) <|> &"test" <|> &"API"
104
leanexplore_declaration
leanexplore:384936
leanexplore_sqlite
leanexplore_declarations
/-- An "API" statement, i.e. a statement that constructs basic theory around a new definition -/ | API
89
leanexplore_declaration
leanexplore:384937
leanexplore_sqlite
leanexplore_declarations
/-- A test statement that serves as a sanity check (e.g. for a new definition)-/ | test
112
leanexplore_declaration
leanexplore:384938
leanexplore_sqlite
leanexplore_declarations
/-- A reseach level math problem. This can be open, or already solved -/ | research : ProblemStatus → Category
50
leanexplore_declaration
leanexplore:384939
leanexplore_sqlite
leanexplore_declarations
/-- A graduate level math problem. -/ | graduate
60
leanexplore_declaration
leanexplore:384940
leanexplore_sqlite
leanexplore_declarations
/-- An undegraduate level math problem. -/ | undergraduate
55
leanexplore_declaration
leanexplore:384941
leanexplore_sqlite
leanexplore_declarations
/-- A high school level math problem. -/ | highSchool
638
leanexplore_declaration
leanexplore:384942
leanexplore_sqlite
leanexplore_declarations
/-- A type to capture the various types of statements that appear in our Lean files. -/ inductive Category /-- A high school level math problem. -/ | highSchool /-- An undegraduate level math problem. -/ | undergraduate /-- A graduate level math problem. -/ | graduate /-- A reseach level math problem. Thi...
261
leanexplore_declaration
leanexplore:384943
leanexplore_sqlite
leanexplore_declarations
/-- Convert from a syntax node to a name. -/ def problemStatus.toName (stx : TSyntax ``problemStatus) : Option Name := match stx with | `(problemStatus| open) => ``ProblemStatus.open | `(problemStatus| solved) => ``ProblemStatus.solved | _ => none
45
leanexplore_declaration
leanexplore:384944
leanexplore_sqlite
leanexplore_declarations
syntax problemStatus := &"open" <|> &"solved"
322
leanexplore_declaration
leanexplore:384945
leanexplore_sqlite
leanexplore_declarations
def formalProofKind.toName (stx : TSyntax ``formalProofKind) : Option Name := match stx with | `(formalProofKind| formal_conjectures) => ``FormalProofKind.formalConjecturesProof | `(formalProofKind| lean4) => ``FormalProofKind.lean4 | `(formalProofKind| other_system) => ``FormalProofKind.otherSystem | _ => no...
80
leanexplore_declaration
leanexplore:384946
leanexplore_sqlite
leanexplore_declarations
syntax formalProofKind := &"formal_conjectures" <|> &"lean4" <|> &"other_system"
156
leanexplore_declaration
leanexplore:384954
leanexplore_sqlite
leanexplore_declarations
/-- Indicates that a mathematical problem is already solved, i.e., there is a published (informal) proof that is widely accepted by experts. -/ | solved
68
leanexplore_declaration
leanexplore:384955
leanexplore_sqlite
leanexplore_declarations
/-- Indicates that a mathematical problem is still open. -/ | open
297
leanexplore_declaration
leanexplore:384956
leanexplore_sqlite
leanexplore_declarations
inductive ProblemStatus /-- Indicates that a mathematical problem is still open. -/ | open /-- Indicates that a mathematical problem is already solved, i.e., there is a published (informal) proof that is widely accepted by experts. -/ | solved deriving Inhabited, BEq, Hashable, ToExpr
112
leanexplore_declaration
leanexplore:384964
leanexplore_sqlite
leanexplore_declarations
/-- The problem is formally solved in a different system (Roqc, Isabelle, Lean 3, HOL, etc.). -/ | otherSystem
130
leanexplore_declaration
leanexplore:384965
leanexplore_sqlite
leanexplore_declarations
/-- The problem is solved in Lean 4 (e.g. in Mathlib or some other repository), perhaps as an equivalent statement. -/ | lean4
296
leanexplore_declaration
leanexplore:384966
leanexplore_sqlite
leanexplore_declarations
/-- The problem exactly as stated in formal-conjectures has a formal proof. The link points to a commit that fills the `sorry` relative to the current commit (i.e., the commit where this category is added, or the commit with the latest fix for this statement). -/ | formalConjecturesProof
675
leanexplore_declaration
leanexplore:384967
leanexplore_sqlite
leanexplore_declarations
/-- The type of formal proof that exists for a problem. -/ inductive FormalProofKind /-- The problem exactly as stated in formal-conjectures has a formal proof. The link points to a commit that fills the `sorry` relative to the current commit (i.e., the commit where this category is added, or the commit with the ...
1,940
leanexplore_declaration
leanexplore:384968
leanexplore_sqlite
leanexplore_declarations
/-- The problem category linter checks that every theorem/lemma/example has been given an `AMS` attribute. -/ def AMSLinter : Linter where run := withSetOptionIn fun stx => do match stx with | `(command| $a:declModifiers theorem $_ $_:bracketedBinder* : $_ := $_) | `(command| $a:declModifiers lemma $_...
129
leanexplore_declaration
leanexplore:384969
leanexplore_sqlite
leanexplore_declarations
def mkAMSSyntax (nums : TSyntaxArray `num) : CommandElabM <| TSyntax ``attrInstance := do return ← `(attrInstance | AMS $nums*)
397
leanexplore_declaration
leanexplore:384970
leanexplore_sqlite
leanexplore_declarations
/-- Checks if a command has the `AMS` attribute. -/ def toAMS (stx : TSyntax ``Command.declModifiers) : CommandElabM (Array <| TSyntaxArray `num) := do match stx with | `(declModifiers| $(_)? @[$[$atts],*] $(_)? $(_)? $(_)? $(_)?) => atts.filterMapM fun att ↦ do match att with | `(attrInstance |...
128
leanexplore_declaration
leanexplore:384971
leanexplore_sqlite
leanexplore_declarations
register_option linter.style.ams_attribute : Bool := { defValue := true descr := "enable the `AMS` attribute style linter" }
613
leanexplore_declaration
leanexplore:384972
leanexplore_sqlite
leanexplore_declarations
/-- The actual linter object -/ def answerLinter : Linter where run := withSetOptionIn fun stx => do -- Ensure we are looking at a declaration if stx.getKind == ``Lean.Parser.Command.declaration then let answer_start ← stars_with_answer_sorry_iff stx let early_args ← contains_early_args stx ...
476
leanexplore_declaration
leanexplore:384973
leanexplore_sqlite
leanexplore_declarations
def stars_with_answer_sorry_iff (stx : Syntax) : CommandElabM Bool := do let decl := stx[1] if decl.getKind != ``Lean.Parser.Command.theorem then return false -- declSig -> typeSpec [":", term] let typeSpec := decl[2][1] if typeSpec.getNumArgs < 2 then return false let term := typeSpec[1] -- Check kind a...
261
leanexplore_declaration
leanexplore:384974
leanexplore_sqlite
leanexplore_declarations
def contains_early_args (stx : Syntax) : CommandElabM Bool := do let decl := stx[1] if decl.getKind != ``Lean.Parser.Command.theorem then return false -- declSig consists of [binders, typeSpec] let binders := decl[2][0] return binders.getArgs.size > 0
131
leanexplore_declaration
leanexplore:384975
leanexplore_sqlite
leanexplore_declarations
register_option linter.style.answer_attribute : Bool := { defValue := true descr := "enable the `answer(sorry)` style linter" }
208
leanexplore_declaration
leanexplore:384976
leanexplore_sqlite
leanexplore_declarations
/-- An non-exampe: here `answer(sorry)` is not a `Prop`, and not the entire left hand side of the iff. -/ theorem not_flagged_non_prop_answer (h : True) (b : Nat) : answer(sorry) = 2 ↔ 1 + 1 = 2 := by sorry
135
leanexplore_declaration
leanexplore:384977
leanexplore_sqlite
leanexplore_declarations
/-- An non-exampe: we want don't to lint against this case-/ theorem not_flagged_no_arguments : answer(sorry) ↔ 1 + 1 = 2 := by sorry
142
leanexplore_declaration
leanexplore:384978
leanexplore_sqlite
leanexplore_declarations
/-- An non-exampe: we want don't to lint against this case -/ theorem not_flagged_no_answer_sorry (_ : True) (_ : Nat) : 1 + 1 = 2 := by rfl
137
leanexplore_declaration
leanexplore:384979
leanexplore_sqlite
leanexplore_declarations
/-- An exampe of what we want to lint against -/ theorem flagged_by_linter (h : True) (b : Nat) : answer(sorry) ↔ 1 + 1 = 2 := by sorry
629
leanexplore_declaration
leanexplore:384980
leanexplore_sqlite
leanexplore_declarations
/-- The linter checking for docstrings on research statements. -/ def categoryDocstringLinter : Linter where run := withSetOptionIn fun stx => do match stx with | `(command| $mods:declModifiers theorem $name:declId $sig:declSig $val:declVal) | `(command| $mods:declModifiers lemma $name:declId $sig:declSig...
210
leanexplore_declaration
leanexplore:384981
leanexplore_sqlite
leanexplore_declarations
/-- Whether the declaration modifiers contain a docstring. -/ def hasDocstring (stx : TSyntax ``Command.declModifiers) : Bool := let docstring := stx.raw[0]! !(Syntax.getAtomVal (docstring[0]![1]!)).isEmpty
181
leanexplore_declaration
leanexplore:384982
leanexplore_sqlite
leanexplore_declarations
/-- Whether the given category requires a docstring. -/ def categoryNeedsDocstring : ProblemAttributes.Category → Bool | .research .open | .research .solved => true | _ => false
356
leanexplore_declaration
leanexplore:384983
leanexplore_sqlite
leanexplore_declarations
/-- Extract the categories from a declaration's modifiers. -/ def toCategories (stx : TSyntax ``Command.declModifiers) : CommandElabM (Array ProblemAttributes.Category) := do let cats ← toCategorySyntax stx cats.mapM fun | `(attrInstance | category $s) => liftCoreM <| ProblemAttributes.Syntax.toCategory...
432
leanexplore_declaration
leanexplore:384984
leanexplore_sqlite
leanexplore_declarations
/-- Extract the `category` attributes from a declaration's modifiers. -/ def toCategorySyntax (stx : TSyntax ``Command.declModifiers) : CommandElabM (Array <| TSyntax ``attrInstance) := do match stx with | `(declModifiers| $(_)? @[$[$atts],*] $(_)? $(_)? $(_)? $(_)?) => atts.filterM fun att ↦ do m...
145
leanexplore_declaration
leanexplore:384985
leanexplore_sqlite
leanexplore_declarations
register_option linter.style.category_docstring : Bool := { defValue := true descr := "enable the research category docstring style linter" }
82
leanexplore_declaration
leanexplore:384986
leanexplore_sqlite
leanexplore_declarations
@[category test] theorem not_flagged_test_without_docstring : True := by trivial
147
leanexplore_declaration
leanexplore:384987
leanexplore_sqlite
leanexplore_declarations
/-- A documented open problem statement should not be flagged. -/ @[category research open] theorem not_flagged_with_docstring : True := by sorry
91
leanexplore_declaration
leanexplore:384988
leanexplore_sqlite
leanexplore_declarations
@[category research solved] theorem flagged_solved_missing_docstring : True := by trivial
85
leanexplore_declaration
leanexplore:384989
leanexplore_sqlite
leanexplore_declarations
@[category research open] theorem flagged_open_missing_docstring : True := by sorry
998
leanexplore_declaration
leanexplore:384990
leanexplore_sqlite
leanexplore_declarations
/-- The problem category linter checks that every theorem/lemma/example has been given a problem category attribute. -/ def categoryLinter : Linter where run := withSetOptionIn fun stx => do match stx with | `(command| $a:declModifiers theorem $_ $_:bracketedBinder* : $_ := $_) | `(command| $a:declMod...
408
leanexplore_declaration
leanexplore:384991
leanexplore_sqlite
leanexplore_declarations
/-- Checks if a command has the `category` attribute. -/ def toCategory (stx : TSyntax ``Command.declModifiers) : CommandElabM (Array <| TSyntax ``attrInstance) := do match stx with | `(declModifiers| $(_)? @[$[$atts],*] $(_)? $(_)? $(_)? $(_)?) => atts.filterM fun att ↦ do match att with | `(...
138
leanexplore_declaration
leanexplore:384992
leanexplore_sqlite
leanexplore_declarations
register_option linter.style.category_attribute : Bool := { defValue := true descr := "enable the `category` attribute style linter" }
963
leanexplore_declaration
leanexplore:384993
leanexplore_sqlite
leanexplore_declarations
/-- The copyright linter ensures that every file has the right copyright header. -/ def copyrightLinter : Linter where run := withSetOptionIn fun stx ↦ do -- The formal-conjectures CI uses a global import file called `All.lean` but we don't want -- to run this linter there. if (← getFileName).endsWith "FormalConj...
125
leanexplore_declaration
leanexplore:384994
leanexplore_sqlite
leanexplore_declarations
register_option linter.style.copyright : Bool := { defValue := true descr := "enable the copyright header style linter" }
142
leanexplore_declaration
leanexplore:384995
leanexplore_sqlite
leanexplore_declarations
/-- The current correct copyright header. -/ def correctCopyrightHeader : String := correctCopyrightPrefix ++ "2026" ++ correctCopyrightSuffix
319
leanexplore_declaration
leanexplore:384996
leanexplore_sqlite
leanexplore_declarations
/-- Check whether a file, given as a `String`, is prefixed with the correct copyright header. -/ def hasCorrectCopyright (file : String) : Bool := Id.run do let .some suffix := file.dropPrefix? correctCopyrightPrefix | false correctCopyrightSuffix.isPrefixOf (suffix.extract (suffix.startPos.nextn 4) suffix.endPos)
664
leanexplore_declaration
leanexplore:384997
leanexplore_sqlite
leanexplore_declarations
/-- The part of the expected copyright after the year. -/ def correctCopyrightSuffix : String := " The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www....
113
leanexplore_declaration
leanexplore:384998
leanexplore_sqlite
leanexplore_declarations
/-- The part of the expected copyright before the year. -/ def correctCopyrightPrefix : String := "/- Copyright "
202
leanexplore_declaration
leanexplore:384999
leanexplore_sqlite
leanexplore_declarations
/-- This name is here due to the reappearance of https://github.com/leanprover/lean4/issues/10175.-/ initialize zzzThisIsASillyButNecessayNameSeeMyDocstring : Unit ← do addLinter existsImplicationLinter
458
leanexplore_declaration
leanexplore:385000
leanexplore_sqlite
leanexplore_declarations
/-- The `existsImplicationLinter` detects expressions of the form `∃ a, P a → Q` and flags them to the user since those are rarely correct. -/ def existsImplicationLinter : Linter where -- TODO(Paul-Lez): Running in `StateT Unit MetaM Unit` is a bit of a hack. -- Do this with a non-StateT version of `runTermLinter`...
1,010
leanexplore_declaration
leanexplore:385001
leanexplore_sqlite
leanexplore_declarations
/-- Checks if an expression contains the pattern `∃ x, P x → Q`. -/ partial def checkExistsArrow (stx : Syntax) (e : Expr) : MetaM Unit := do match e with | .mdata _ e => checkExistsArrow stx e | .app .. => -- Check if this is an application of `Exists` if e.isAppOfArity ``Exists 2 then let la...
337
leanexplore_declaration
leanexplore:385002
leanexplore_sqlite
leanexplore_declarations
/-- Changes and expression of the form `∀ (h1 : Prop1) (h2 : Prop2) ..., Propn` to `Prop1 ∧ Prop2 ∧ ... ∧ Propn`. -/ def forallToAnd (expr : Expr) : MetaM Expr := forallTelescope expr fun vars final => do let varsAsProp ← vars.mapM inferType varsAsProp.foldrM (fun var currentBigAnd => mkAppM ``And #[var, curr...
175
leanexplore_declaration
leanexplore:385003
leanexplore_sqlite
leanexplore_declarations
register_option linter.style.existsImplication : Bool := { defValue := true descr := "Detects misformalisations caused by writing ∃ x, P x → Q rather than ∃ x, P x ∧ Q " }
749
leanexplore_declaration
leanexplore:385004
leanexplore_sqlite
leanexplore_declarations
/-- The module docstring linter warns when a file contains more than one `/-! ... -/` block. The first such block is the module docstring; all subsequent ones should be regular comments (`/- ... -/`). -/ def moduleDocstringLinter : Linter where run := withSetOptionIn fun stx ↦ do unless stx.getKind == ``Lean.Parser.C...
131
leanexplore_declaration
leanexplore:385005
leanexplore_sqlite
leanexplore_declarations
register_option linter.style.moduleDocstring : Bool := { defValue := true descr := "enable the module docstring count linter" }
688
leanexplore_declaration
leanexplore:385006
leanexplore_sqlite
leanexplore_declarations
/-- The namespace linter checks that every declaration is inside a namespace. -/ def namespaceLinter : Linter where run := withSetOptionIn fun stx ↦ do if getLinterValue linter.style.namespace (← getLinterOptions) then for id in (← Mathlib.Linter.getNamesFrom (stx.getPos?.getD default)) do let declName := i...
430
leanexplore_declaration
leanexplore:385007
leanexplore_sqlite
leanexplore_declarations
/-- The `namespace` linter is set on by default. It emits a warning on any declaration that is not inside a namespace (i.e., declarations at the root level). For instance, `theorem foo` would trigger a warning, while `Nat.foo` would not. This helps maintain organization and avoid polluting the global namespace. -/ re...