feat: new lint function, and split informal

This commit is contained in:
jstoobysmith 2024-12-05 06:49:50 +00:00
parent 9fb18af0d9
commit 84b328f13f
28 changed files with 138 additions and 83 deletions

View file

@ -106,7 +106,8 @@ import HepLean.Mathematics.SO3.Basic
import HepLean.Mathematics.SuperAlgebra.Basic
import HepLean.Meta.AllFilePaths
import HepLean.Meta.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
import HepLean.Meta.Informal.Post
import HepLean.Meta.Notes.Basic
import HepLean.Meta.Notes.HTMLNote
import HepLean.Meta.Notes.NoteFile

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import HepLean.StandardModel.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# The Georgi-Glashow Model

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import HepLean.StandardModel.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# The Pati-Salam Model

View file

@ -5,7 +5,7 @@ Authors: Joseph Tooby-Smith
-/
import HepLean.BeyondTheStandardModel.PatiSalam.Basic
import HepLean.BeyondTheStandardModel.GeorgiGlashow.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# The Spin(10) Model

View file

@ -7,7 +7,7 @@ import Mathlib.Data.Complex.Exponential
import Mathlib.Analysis.InnerProductSpace.PiL2
import HepLean.Lorentz.SL2C.Basic
import HepLean.Lorentz.ComplexVector.Modules
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
import Mathlib.RepresentationTheory.Rep
import HepLean.Lorentz.PauliMatrices.SelfAdjoint
/-!

View file

@ -3,7 +3,7 @@ Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
import HepLean.Lorentz.SL2C.Basic
import Mathlib.RepresentationTheory.Rep
import Mathlib.Logic.Equiv.TransferInstance

View file

@ -6,7 +6,7 @@ Authors: Joseph Tooby-Smith
import HepLean.Lorentz.Group.Basic
import HepLean.Lorentz.Group.Proper
import HepLean.Lorentz.Group.Orthochronous
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# The Restricted Lorentz Group

View file

@ -6,7 +6,7 @@ Authors: Joseph Tooby-Smith
import Mathlib.Data.Complex.Exponential
import Mathlib.Analysis.InnerProductSpace.PiL2
import HepLean.Lorentz.Group.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
import Mathlib.RepresentationTheory.Rep
import HepLean.Lorentz.RealVector.Modules
/-!

View file

@ -3,7 +3,7 @@ Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
import HepLean.Lorentz.Group.Basic
import Mathlib.RepresentationTheory.Rep
import Mathlib.Logic.Equiv.TransferInstance

View file

@ -8,7 +8,7 @@ import HepLean.Lorentz.RealVector.Basic
import Mathlib.RepresentationTheory.Basic
import HepLean.Lorentz.Group.Restricted
import HepLean.Lorentz.PauliMatrices.SelfAdjoint
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# The group SL(2, ) and it's relation to the Lorentz group

View file

@ -3,7 +3,7 @@ Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
import HepLean.Lorentz.SL2C.Basic
import Mathlib.RepresentationTheory.Rep
import HepLean.Lorentz.Weyl.Modules

View file

@ -3,7 +3,7 @@ Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
import HepLean.Lorentz.SL2C.Basic
import Mathlib.RepresentationTheory.Rep
import Mathlib.Logic.Equiv.TransferInstance

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import Mathlib.RingTheory.GradedAlgebra.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# Super Algebras

View file

@ -8,7 +8,7 @@ import Lean
import Mathlib.Lean.Expr.Basic
import Mathlib.Lean.CoreM
import ImportGraph.RequiredModules
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
## Basic Lean meta programming commands
@ -185,24 +185,6 @@ def noLines : IO Nat := do
let x := x.flatten
pure x.toList.length
/-- The number of informal lemmas in HepLean. -/
def noInformalLemmas : MetaM Nat := do
let imports ← allImports
let x ← imports.mapM Imports.getUserConsts
let x := x.flatten
let x := x.filter (Informal.isInformal)
let x := x.filter (Informal.isInformalLemma)
pure x.toList.length
/-- The number of informal definitions in HepLean. -/
def noInformalDefs : MetaM Nat := do
let imports ← allImports
let x ← imports.mapM Imports.getUserConsts
let x := x.flatten
let x := x.filter (Informal.isInformal)
let x := x.filter (Informal.isInformalDef)
pure x.toList.length
/-- The number of TODO items. -/
def noTODOs : IO Nat := do
let imports ← HepLean.allImports

View file

@ -8,11 +8,14 @@ import Lean
## Informal definitions and lemmas
This file contains the necessary structures that must be imported into a file
for it to contain informal definitions and lemmas.
Everything else about informal definitions and lemmas are in the `Informal.Post` module.
-/
open Lean Elab System
/-! TODO: Derive a means to extract informal definitions and informal lemmas. -/
/-! TODO: Can likely make this a bona-fide command. -/
/-- The structure representating an informal definition. -/
@ -240,43 +243,4 @@ def $name : InformalLemma := {
dependencies := $(dep_def?.getD (← `([])))
})
/-- Is true if and only if a `ConstantInfo` corresponds to an `InformalLemma` or a
`InformalDefinition`. -/
def isInformal (c : ConstantInfo) : Bool :=
match c with
| ConstantInfo.defnInfo c =>
if c.type.isAppOf ``InformalDefinition c.type.isAppOf ``InformalLemma then true else false
| _ => false
/-- Is true if and only if a `ConstantInfo` corresponds to an `InformalLemma`. -/
def isInformalLemma (c : ConstantInfo) : Bool :=
match c with
| ConstantInfo.defnInfo c =>
if c.type.isAppOf ``InformalLemma then true else false
| _ => false
/-- Is true if and only if a `ConstantInfo` corresponds to an `InformalDefinition`. -/
def isInformalDef (c : ConstantInfo) : Bool :=
match c with
| ConstantInfo.defnInfo c =>
if c.type.isAppOf ``InformalDefinition then true else false
| _ => false
/-- Takes a `ConstantInfo` corresponding to a `InformalLemma` and returns
the corresponding `InformalLemma`. -/
unsafe def constantInfoToInformalLemma (c : ConstantInfo) : MetaM InformalLemma := do
match c with
| ConstantInfo.defnInfo c =>
Lean.Meta.evalExpr' InformalLemma ``InformalLemma c.value
| _ => panic! "Passed constantInfoToInformalLemma a `ConstantInfo` that is not a `InformalLemma`"
/-- Takes a `ConstantInfo` corresponding to a `InformalDefinition` and returns
the corresponding `InformalDefinition`. -/
unsafe def constantInfoToInformalDefinition (c : ConstantInfo) : MetaM InformalDefinition := do
match c with
| ConstantInfo.defnInfo c =>
Lean.Meta.evalExpr' InformalDefinition ``InformalDefinition c.value
| _ => panic! "Passed constantInfoToInformalDefinition a
`ConstantInfo` that is not a `InformalDefinition`"
end Informal

View file

@ -0,0 +1,78 @@
/-
Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license.
Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.Informal.Basic
import HepLean.Meta.Basic
/-!
## Informal definitions and lemmas
-/
open Lean Elab System
namespace Informal
/-- Is true if and only if a `ConstantInfo` corresponds to an `InformalLemma` or a
`InformalDefinition`. -/
def isInformal (c : ConstantInfo) : Bool :=
match c with
| ConstantInfo.defnInfo c =>
if c.type.isAppOf ``InformalDefinition c.type.isAppOf ``InformalLemma then true else false
| _ => false
/-- Is true if and only if a `ConstantInfo` corresponds to an `InformalLemma`. -/
def isInformalLemma (c : ConstantInfo) : Bool :=
match c with
| ConstantInfo.defnInfo c =>
if c.type.isAppOf ``InformalLemma then true else false
| _ => false
/-- Is true if and only if a `ConstantInfo` corresponds to an `InformalDefinition`. -/
def isInformalDef (c : ConstantInfo) : Bool :=
match c with
| ConstantInfo.defnInfo c =>
if c.type.isAppOf ``InformalDefinition then true else false
| _ => false
/-- Takes a `ConstantInfo` corresponding to a `InformalLemma` and returns
the corresponding `InformalLemma`. -/
unsafe def constantInfoToInformalLemma (c : ConstantInfo) : MetaM InformalLemma := do
match c with
| ConstantInfo.defnInfo c =>
Lean.Meta.evalExpr' InformalLemma ``InformalLemma c.value
| _ => panic! "Passed constantInfoToInformalLemma a `ConstantInfo` that is not a `InformalLemma`"
/-- Takes a `ConstantInfo` corresponding to a `InformalDefinition` and returns
the corresponding `InformalDefinition`. -/
unsafe def constantInfoToInformalDefinition (c : ConstantInfo) : MetaM InformalDefinition := do
match c with
| ConstantInfo.defnInfo c =>
Lean.Meta.evalExpr' InformalDefinition ``InformalDefinition c.value
| _ => panic! "Passed constantInfoToInformalDefinition a
`ConstantInfo` that is not a `InformalDefinition`"
end Informal
namespace HepLean
/-- The number of informal lemmas in HepLean. -/
def noInformalLemmas : MetaM Nat := do
let imports ← allImports
let x ← imports.mapM Imports.getUserConsts
let x := x.flatten
let x := x.filter (Informal.isInformal)
let x := x.filter (Informal.isInformalLemma)
pure x.toList.length
/-- The number of informal definitions in HepLean. -/
def noInformalDefs : MetaM Nat := do
let imports ← allImports
let x ← imports.mapM Imports.getUserConsts
let x := x.flatten
let x := x.filter (Informal.isInformal)
let x := x.filter (Informal.isInformalDef)
pure x.toList.length
end HepLean

View file

@ -91,7 +91,6 @@ initialize noteAttribute : Unit ←
modifyEnv fun env => noteDeclExtension.addEntry env declName
}
/-- Enviroment extention to store `note_attr_informal`. -/
initialize noteInformalDeclExtension : SimplePersistentEnvExtension Name (Array Name) ←
registerSimplePersistentEnvExtension {

View file

@ -5,7 +5,7 @@ Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.Notes.NoteFile
import HepLean.Meta.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Post
/-!
## Turns a delaration into a html note structure.

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import HepLean.PerturbationTheory.FeynmanDiagrams.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# Wick contraction in position space

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import Mathlib.Logic.Function.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# Wick Species

View file

@ -3,7 +3,7 @@ Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
import HepLean.PerturbationTheory.Wick.Species
import Mathlib.Data.Fin.Tuple.Basic
/-!

View file

@ -7,7 +7,7 @@ import Mathlib.Data.Complex.Exponential
import Mathlib.Geometry.Manifold.Instances.Real
import Mathlib.LinearAlgebra.Matrix.ToLin
import HepLean.SpaceTime.Basic
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# The Standard Model

View file

@ -11,7 +11,7 @@ import Mathlib.Geometry.Manifold.VectorBundle.SmoothSection
import Mathlib.Geometry.Manifold.Instances.Real
import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Geometry.Manifold.ContMDiff.Product
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# The Higgs field

View file

@ -5,7 +5,7 @@ Authors: Joseph Tooby-Smith
-/
import Mathlib.Algebra.QuadraticDiscriminant
import HepLean.StandardModel.HiggsBoson.PointwiseInnerProd
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Basic
/-!
# The potential of the Higgs field

View file

@ -66,6 +66,11 @@ name = "notes"
supportInterpreter = true
srcDir = "scripts/MetaPrograms"
[[lean_exe]]
name = "lint_all"
supportInterpreter = true
srcDir = "scripts"
[[lean_exe]]
name = "free_simps"
srcDir = "scripts/MetaPrograms"

View file

@ -7,7 +7,7 @@ import Batteries.Lean.HashSet
import Lean
import Mathlib.Lean.Expr.Basic
import Mathlib.Lean.CoreM
import HepLean.Meta.Informal
import HepLean.Meta.Informal.Post
import ImportGraph.RequiredModules
/-!

26
scripts/lint_all.lean Normal file
View file

@ -0,0 +1,26 @@
/-
Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license.
Authors: Joseph Tooby-Smith
-/
import Batteries.Lean.HashSet
import Lean
import Mathlib.Lean.Expr.Basic
import Mathlib.Lean.CoreM
import HepLean.Meta.Informal.Post
import ImportGraph.RequiredModules
def main (_: List String) : IO UInt32 := do
println! "Building ... "
let build ← IO.Process.output {cmd := "lake", args := #["build"]}
println! build.stdout
println! "File imports ... "
let importCheck ← IO.Process.output {cmd := "lake", args := #["exe", "check_file_imports"]}
println! importCheck.stdout
println! "Style lint ... "
let styleLint ← IO.Process.output {cmd := "lake", args := #["exe", "hepLean_style_lint"]}
println! styleLint.stdout
println! "Doc check ..."
let docCheck ← IO.Process.output {cmd := "lake", args := #["exe", "no_docs"]}
println! docCheck.stdout
pure 0

View file

@ -3,7 +3,7 @@ Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license.
Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.Basic
import HepLean.Meta.Informal.Post
/-!
# HepLean Stats