PhysLean/HepLean/Meta/Remark/Properties.lean

42 lines
1.1 KiB
Text
Raw Normal View History

2025-01-23 06:31:11 +00:00
/-
Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license.
Authors: Joseph Tooby-Smith
-/
import HepLean.Meta.Remark.Basic
/-!
## Underlying structure for remarks
-/
namespace HepLean
open Lean
variable {m} [Monad m] [MonadEnv m] [MonadError m]
2025-01-23 06:31:11 +00:00
2025-02-08 13:07:54 +00:00
/-- All remarks in the environment. -/
def allRemarkInfo : m (Array RemarkInfo) := do
2025-01-23 06:31:11 +00:00
let env ← getEnv
return remarkExtension.getState env
2025-01-23 06:31:11 +00:00
2025-01-23 14:31:03 +00:00
/-- The full name of a remark (name and namespace). -/
def RemarkInfo.toFullName (r : RemarkInfo) : Name :=
2025-01-23 06:31:11 +00:00
if r.nameSpace != .anonymous then
.str r.nameSpace r.name.toString
2025-01-23 06:31:11 +00:00
else
r.name
2025-02-10 10:51:44 +00:00
/-- A Bool which is true if a name corresponds to a remark. -/
def RemarkInfo.IsRemark (n : Name) : m Bool := do
let allRemarks ← allRemarkInfo
let r := allRemarks.find? fun r => r.toFullName == n
return r.isSome
2025-01-23 06:31:11 +00:00
2025-01-23 14:31:03 +00:00
/-- Gets the remarkInfo from a name corresponding to a remark.. -/
def RemarkInfo.getRemarkInfo (n : Name) : m RemarkInfo := do
let allRemarks ← allRemarkInfo
match allRemarks.find? fun r => r.toFullName == n with
| some r => return r
2025-01-23 06:31:11 +00:00
| none => throwError s!"No remark named {n}"
end HepLean