fact
stringlengths
19
8.26k
type
stringclasses
8 values
library
stringclasses
2 values
imports
listlengths
0
7
filename
stringclasses
397 values
symbolic_name
stringlengths
1
73
docstring
stringlengths
20
499
endLineLinter (s : String) : PhysLeanTextLinter := fun lines ↦ Id.run do let enumLines := (lines.toList.zipIdx 1) let errors := enumLines.filterMap (fun (l, lno) ↦ if l.endsWith s then some (s!" Line ends with `{s}`.", lno, l.length) else none) errors.toArray /-- Number of space at new line must be even. -/
def
scripts
[ "import Lean", "import Mathlib.Tactic.Linter.TextBased", "import Batteries.Data.Array.Merge" ]
scripts/MetaPrograms/style_lint.lean
endLineLinter
/-- Substring linter. -/
numInitialSpacesEven : PhysLeanTextLinter := fun lines ↦ Id.run do let enumLines := (lines.toList.zipIdx 1) let errors := enumLines.filterMap (fun (l, lno) ↦ let numSpaces := (l.takeWhile (· == ' ')).length if numSpaces % 2 != 0 then some (s!"Number of initial spaces is not even.", lno, 1) else none) errors.toArray
def
scripts
[ "import Lean", "import Mathlib.Tactic.Linter.TextBased", "import Batteries.Data.Array.Merge" ]
scripts/MetaPrograms/style_lint.lean
numInitialSpacesEven
/-- Number of space at new line must be even. -/
PhysLeanErrorContext where /-- The underlying `message`. -/ error : String /-- The line number -/ lineNumber : ℕ /-- The column number -/ columnNumber : ℕ /-- The file path -/ path : FilePath
structure
scripts
[ "import Lean", "import Mathlib.Tactic.Linter.TextBased", "import Batteries.Data.Array.Merge" ]
scripts/MetaPrograms/style_lint.lean
PhysLeanErrorContext
/-- Number of space at new line must be even. -/
printErrors (errors : Array PhysLeanErrorContext) : IO Unit := do for e in errors do IO.println (s!"error: {e.path}:{e.lineNumber}:{e.columnNumber}: {e.error}")
def
scripts
[ "import Lean", "import Mathlib.Tactic.Linter.TextBased", "import Batteries.Data.Array.Merge" ]
scripts/MetaPrograms/style_lint.lean
printErrors
/-- The file path -/
hepLeanLintFile (path : FilePath) : IO (Array PhysLeanErrorContext) := do let lines ← IO.FS.lines path let allOutput := (Array.map (fun lint ↦ (Array.map (fun (e, n, c) ↦ PhysLeanErrorContext.mk e n c path)) (lint lines))) #[doubleEmptyLineLinter, doubleSpaceLinter, numInitialSpacesEven, longLineLinter, substringLinter...
def
scripts
[ "import Lean", "import Mathlib.Tactic.Linter.TextBased", "import Batteries.Data.Array.Merge" ]
scripts/MetaPrograms/style_lint.lean
hepLeanLintFile
/-- The file path -/
main (_ : List String) : IO UInt32 := do initSearchPath (← findSysroot) let mods : Name := `PhysLean let imp : Import := {module := mods} let mFile ← findOLean imp.module unless (← mFile.pathExists) do throw <| IO.userError s!"object file '{mFile}' of module {imp.module} does not exist" let (hepLeanMod, _) ← readModule...
def
scripts
[ "import Lean", "import Mathlib.Tactic.Linter.TextBased", "import Batteries.Data.Array.Merge" ]
scripts/MetaPrograms/style_lint.lean
main
null
PhysLeanCategory | ClassicalMechanics | CondensedMatter | Cosmology | Elctromagnetism | Mathematics | Meta | Optics | Particles | QFT | QuantumMechanics | Relativity | StringTheory | StatisticalMechanics | Thermodynamics | Other deriving BEq, DecidableEq
inductive
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
PhysLeanCategory
null
PhysLeanCategory.string : PhysLeanCategory → String | ClassicalMechanics => "Classical Mechanics" | CondensedMatter => "Condensed Matter" | Cosmology => "Cosmology" | Elctromagnetism => "Electromagnetism" | Mathematics => "Mathematics" | Meta => "Meta" | Optics => "Optics" | Particles => "Particles" | QFT => "QFT" | Qu...
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
PhysLeanCategory.string
null
PhysLeanCategory.emoji : PhysLeanCategory → String | ClassicalMechanics => "⚙️" | CondensedMatter => "🧊" | Cosmology => "🌌" | Elctromagnetism => "⚡" | Mathematics => "➗" | Meta => "🏛️" | Optics => "🔍" | Particles => "💥" | QFT => "🌊" | QuantumMechanics => "⚛️" | Relativity => "⏳" | StringTheory => "🧵" | Statistic...
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
PhysLeanCategory.emoji
null
PhysLeanCategory.List : List PhysLeanCategory := [ PhysLeanCategory.ClassicalMechanics, PhysLeanCategory.CondensedMatter, PhysLeanCategory.Cosmology, PhysLeanCategory.Elctromagnetism, PhysLeanCategory.Mathematics, PhysLeanCategory.Meta, PhysLeanCategory.Optics, PhysLeanCategory.Particles, PhysLeanCategory.QFT, PhysLean...
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
PhysLeanCategory.List
null
PhysLeanCategory.ofFileName (n : Name) : PhysLeanCategory := if n.toString.startsWith "PhysLean.ClassicalMechanics" then PhysLeanCategory.ClassicalMechanics else if n.toString.startsWith "PhysLean.CondensedMatter" then PhysLeanCategory.CondensedMatter else if n.toString.startsWith "PhysLean.Cosmology" then PhysLeanCate...
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
PhysLeanCategory.ofFileName
null
FullTODOInfo where content : String fileName : Name name : Name line : Nat isInformalDef : Bool isInformalLemma : Bool isSemiFormalResult : Bool isSorryfulResult : Bool := false category : PhysLeanCategory tag : String /-- Converts a `FullTODOInfo` to an entry in a YAML code. -/
structure
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
FullTODOInfo
null
FullTODOInfo.toYAML (todo : FullTODOInfo) : MetaM String := do let content := todo.content let contentIndent := content.replace "\n" "\n " return s!" - file: {todo.fileName} githubLink: {Name.toGitHubLink todo.fileName todo.line} line: {todo.line} isInformalDef: {todo.isInformalDef} isInformalLemma: {todo.isInformalLem...
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
FullTODOInfo.toYAML
/-- Converts a `FullTODOInfo` to an entry in a YAML code. -/
FullTODOInfo.ofTODO (t : todoInfo) : FullTODOInfo := {content := t.content, fileName := t.fileName, line := t.line, name := t.fileName, isInformalDef := false, isInformalLemma := false, isSemiFormalResult := false, category := PhysLeanCategory.ofFileName t.fileName, tag := t.tag}
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
FullTODOInfo.ofTODO
null
getTodoInfo : MetaM (Array FullTODOInfo) := do let env ← getEnv let todoInfo := (todoExtension.getState env) -- pure (todoInfo.qsort (fun x y => x.fileName.toString < y.fileName.toString)).toList pure (todoInfo.map FullTODOInfo.ofTODO) /-! ## Informal lemmas and definitions -/
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
getTodoInfo
null
informalTODO (x : ConstantInfo) : CoreM FullTODOInfo := do let name := x.name let tag ← Informal.getTag x let lineNo ← Name.lineNumber name let docString ← Name.getDocString name let file ← Name.fileName name let isInformalDef := Informal.isInformalDef x let isInformalLemma := Informal.isInformalLemma x let category :=...
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
informalTODO
null
allInformalTODO : CoreM (Array FullTODOInfo) := do let x ← AllInformal x.mapM informalTODO /-! ## Semi-formal results -/
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
allInformalTODO
null
FullTODOInfo.ofSemiFormal (t : WantedInfo) : FullTODOInfo := {content := t.content, fileName := t.fileName, line := t.line, name := t.name, isInformalDef := false, isInformalLemma := false, isSemiFormalResult := true, category := PhysLeanCategory.ofFileName t.fileName, tag := t.tag}
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
FullTODOInfo.ofSemiFormal
null
allSemiInformal : CoreM (Array FullTODOInfo) := do let env ← getEnv let semiInformalInfos := (wantedExtension.getState env) pure (semiInformalInfos.map FullTODOInfo.ofSemiFormal) /-! ## Sorryful results -/
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
allSemiInformal
null
SorryfulInfo.toFullTODOInfo (s : SorryfulInfo) : FullTODOInfo where content := s.docstring fileName := s.fileName line := s.line name := s.name isInformalDef := false isInformalLemma := false isSemiFormalResult := false isSorryfulResult := true category := PhysLeanCategory.ofFileName s.fileName tag := s.name.toString
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
SorryfulInfo.toFullTODOInfo
null
allSorryfulResults : CoreM (Array FullTODOInfo) := do let env ← getEnv let sorryfulInfos := (sorryfulExtension.getState env) pure (sorryfulInfos.map SorryfulInfo.toFullTODOInfo) /-! ## All TODOs Collecting all of the TODO items -/
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
allSorryfulResults
null
allTODOs : MetaM (List FullTODOInfo) := do let todos ← getTodoInfo let informalTODOs ← allInformalTODO let semiInformal ← allSemiInformal let sorryfulResults ← allSorryfulResults let all := todos ++ informalTODOs ++ semiInformal ++ sorryfulResults return (all.qsort (fun x y => x.fileName.toString < y.fileName.toString ...
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
allTODOs
null
categoriesToYML : MetaM String := do let todos ← allTODOs let mut cat := "Category:\n" for c in PhysLeanCategory.List do let num := (todos.filter (fun x => x.category == c)).length cat := cat ++ s!" - name: \"{c}\" num: {num} emoji: \"{c.emoji}\"" return cat ++ "\n"
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
categoriesToYML
null
todosToYAML : MetaM String := do let todos ← allTODOs /- Check no duplicate tags-/ let tags := todos.map (fun x => x.tag) if !tags.Nodup then let duplicates := tags.filter (fun tag => tags.count tag > 1) |>.eraseDups println! duplicates panic! s!"Duplicate tags found: {duplicates}" /- End of check. -/ let todosYAML ← t...
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
todosToYAML
null
fullTODOYML : MetaM String := do let cat ← categoriesToYML let todos ← todosToYAML return cat ++ todos /-! ## Main function -/
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
fullTODOYML
null
main (args : List String) : IO UInt32 := do initSearchPath (← findSysroot) println! "Generating TODO list." let env ← importModules (loadExts := true) #[`PhysLean] {} 0 let fileName := "" let options : Options := {} let ctx : Core.Context := {fileName, options, fileMap := default } let state := {env} let ymlString' ← (...
def
scripts
[ "import PhysLean.Meta.Basic", "import PhysLean.Meta.TODO.Basic", "import Mathlib.Lean.CoreM", "import PhysLean.Meta.Informal.Post", "import PhysLean.Meta.Informal.SemiFormal", "import PhysLean.Meta.Linters.Sorry" ]
scripts/MetaPrograms/TODO_to_yml.lean
main
null