feat: make informal_definition and informal_lemma commands (#300)
* make informal_definition and informal_lemma commands * drop the fields "math", "physics", and "proof" from InformalDefinition/InformalLemma and use docstrings instead * render informal docstring in dependency graph
This commit is contained in:
parent
6aab0ba3cd
commit
f8f94979ab
33 changed files with 666 additions and 1089 deletions
|
@ -3,17 +3,14 @@ Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
|
|||
Released under Apache 2.0 license.
|
||||
Authors: Joseph Tooby-Smith
|
||||
-/
|
||||
import Batteries.Lean.HashSet
|
||||
import Mathlib.Lean.Expr.Basic
|
||||
import Mathlib.Lean.CoreM
|
||||
import ImportGraph.RequiredModules
|
||||
import Lean.Elab.Command
|
||||
/-!
|
||||
|
||||
## Underlying structure for remarks
|
||||
-/
|
||||
|
||||
namespace HepLean
|
||||
open Lean System Meta
|
||||
open Lean
|
||||
|
||||
/-- The information from a `remark ...` command. To be used in a note file-/
|
||||
structure RemarkInfo where
|
||||
|
@ -41,7 +38,7 @@ syntax (name := remark_syntax) "remark " ident ":=" str : command
|
|||
|
||||
/-- Elaborator for the `note ...` command -/
|
||||
@[command_elab remark_syntax]
|
||||
def elabRemark : Lean.Elab.Command.CommandElab := fun stx =>
|
||||
def elabRemark : Elab.Command.CommandElab := fun stx =>
|
||||
match stx with
|
||||
| `(remark $n := $s) => do
|
||||
let str : String := s.getString
|
||||
|
|
|
@ -10,35 +10,32 @@ import HepLean.Meta.Remark.Basic
|
|||
-/
|
||||
|
||||
namespace HepLean
|
||||
open Lean System Meta
|
||||
open Lean
|
||||
variable {m} [Monad m] [MonadEnv m] [MonadError m]
|
||||
|
||||
/-- All remarks in the enviroment. -/
|
||||
def Name.allRemarkInfo : MetaM (List RemarkInfo) := do
|
||||
def allRemarkInfo : m (Array RemarkInfo) := do
|
||||
let env ← getEnv
|
||||
let allRemarks := (remarkExtension.getState env)
|
||||
pure allRemarks.toList
|
||||
return remarkExtension.getState env
|
||||
|
||||
/-- The full name of a remark (name and namespace). -/
|
||||
def RemarkInfo.toFullName (r : RemarkInfo) : Name :=
|
||||
if r.nameSpace != .anonymous then
|
||||
(r.nameSpace.toString ++ "." ++ r.name.toString).toName
|
||||
.str r.nameSpace r.name.toString
|
||||
else
|
||||
r.name
|
||||
|
||||
/-- A Bool which is true if a name correponds to a remark. -/
|
||||
def RemarkInfo.IsRemark (n : Name) : MetaM Bool := do
|
||||
let allRemarks ← Name.allRemarkInfo
|
||||
let r := allRemarks.find? (fun r => r.toFullName = n)
|
||||
match r with
|
||||
| some _ => pure true
|
||||
| none => pure false
|
||||
def RemarkInfo.IsRemark (n : Name) : m Bool := do
|
||||
let allRemarks ← allRemarkInfo
|
||||
let r := allRemarks.find? fun r => r.toFullName == n
|
||||
return r.isSome
|
||||
|
||||
/-- Gets the remarkInfo from a name corresponding to a remark.. -/
|
||||
def RemarkInfo.getRemarkInfo (n : Name) : MetaM RemarkInfo := do
|
||||
let allRemarks ← Name.allRemarkInfo
|
||||
let r := allRemarks.find? (fun r => r.toFullName = n)
|
||||
match r with
|
||||
| some r => pure r
|
||||
def RemarkInfo.getRemarkInfo (n : Name) : m RemarkInfo := do
|
||||
let allRemarks ← allRemarkInfo
|
||||
match allRemarks.find? fun r => r.toFullName == n with
|
||||
| some r => return r
|
||||
| none => throwError s!"No remark named {n}"
|
||||
|
||||
end HepLean
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue