|
|
|
@ -255,31 +255,17 @@ elab "DefinitionDoc" name:ident "as" displayName:str template:str : command =>
|
|
|
|
|
|
|
|
|
|
|
|
/-! ## Add inventory items -/
|
|
|
|
/-! ## Add inventory items -/
|
|
|
|
|
|
|
|
|
|
|
|
-- namespace Lean.PrettyPrinter
|
|
|
|
|
|
|
|
-- def ppSignature' (c : Name) : MetaM String := do
|
|
|
|
|
|
|
|
-- let decl ← getConstInfo c
|
|
|
|
|
|
|
|
-- let e := .const c (decl.levelParams.map mkLevelParam)
|
|
|
|
|
|
|
|
-- let (stx, _) ← delabCore e (delab := Delaborator.delabConstWithSignature)
|
|
|
|
|
|
|
|
-- let f ← ppTerm stx
|
|
|
|
|
|
|
|
-- return toString f
|
|
|
|
|
|
|
|
-- end Lean.PrettyPrinter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getStatement (name : Name) : CommandElabM MessageData := do
|
|
|
|
def getStatement (name : Name) : CommandElabM MessageData := do
|
|
|
|
-- let c := name.getId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let decl ← getConstInfo name
|
|
|
|
|
|
|
|
-- -- TODO: How to go between CommandElabM and MetaM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- addCompletionInfo <| .id name c (danglingDot := false) {} none
|
|
|
|
|
|
|
|
return ← addMessageContextPartial (.ofPPFormat { pp := fun
|
|
|
|
return ← addMessageContextPartial (.ofPPFormat { pp := fun
|
|
|
|
| some ctx => ctx.runMetaM <| ppExpr decl.type
|
|
|
|
| some ctx => ctx.runMetaM <| PrettyPrinter.ppSignature name
|
|
|
|
-- PrettyPrinter.ppSignature' c
|
|
|
|
|
|
|
|
-- PrettyPrinter.ppSignature c
|
|
|
|
|
|
|
|
| none => return "that's a bug." })
|
|
|
|
| none => return "that's a bug." })
|
|
|
|
|
|
|
|
|
|
|
|
-- Note: We use `String` because we can't send `MessageData` as json, but
|
|
|
|
-- Note: We use `String` because we can't send `MessageData` as json, but
|
|
|
|
-- `MessageData` might be better for interactive highlighting.
|
|
|
|
-- `MessageData` might be better for interactive highlighting.
|
|
|
|
/-- Get a string of the form `my_lemma (n : ℕ) : n + n = 2 * n`. -/
|
|
|
|
/-- Get a string of the form `my_lemma (n : ℕ) : n + n = 2 * n`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note: A statement like `theorem abc : ∀ x : Nat, x ≥ 0` would be turned into
|
|
|
|
|
|
|
|
`theorem abc (x : Nat) : x ≥ 0` by `PrettyPrinter.ppSignature`. -/
|
|
|
|
def getStatementString (name : Name) : CommandElabM String := do
|
|
|
|
def getStatementString (name : Name) : CommandElabM String := do
|
|
|
|
try
|
|
|
|
try
|
|
|
|
return ← (← getStatement name).toString
|
|
|
|
return ← (← getStatement name).toString
|
|
|
|
@ -489,13 +475,11 @@ elab doc:docComment ? attrs:Parser.Term.attributes ?
|
|
|
|
-- the namespace?
|
|
|
|
-- the namespace?
|
|
|
|
let currNamespace ← getCurrNamespace
|
|
|
|
let currNamespace ← getCurrNamespace
|
|
|
|
|
|
|
|
|
|
|
|
let st ← match statementName with
|
|
|
|
-- Format theorem statement for displaying
|
|
|
|
| some name => getStatementString <| currNamespace ++ name.getId
|
|
|
|
let sigString := sig.raw.reprint.getD ""
|
|
|
|
| none => getStatementString <| currNamespace ++ (defaultDeclName).getId
|
|
|
|
let descrFormat : String := match statementName with
|
|
|
|
|
|
|
|
| some name => s!"theorem {name.getId} {sigString} := by"
|
|
|
|
let head := match statementName with
|
|
|
|
| none => s!"example {sigString} := by"
|
|
|
|
| some name => Format.join ["theorem ", (currNamespace ++ name.getId).toString]
|
|
|
|
|
|
|
|
| none => "example"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modifyCurLevel fun level => pure { level with
|
|
|
|
modifyCurLevel fun level => pure { level with
|
|
|
|
module := env.header.mainModule
|
|
|
|
module := env.header.mainModule
|
|
|
|
@ -505,7 +489,7 @@ elab doc:docComment ? attrs:Parser.Term.attributes ?
|
|
|
|
statementName := match statementName with
|
|
|
|
statementName := match statementName with
|
|
|
|
| none => default
|
|
|
|
| none => default
|
|
|
|
| some name => currNamespace ++ name.getId
|
|
|
|
| some name => currNamespace ++ name.getId
|
|
|
|
descrFormat := (Format.join [head, " ", st, " := by"]).pretty 10
|
|
|
|
descrFormat := descrFormat
|
|
|
|
hints := hints
|
|
|
|
hints := hints
|
|
|
|
tactics := {level.tactics with used := usedInventory.tactics.toArray}
|
|
|
|
tactics := {level.tactics with used := usedInventory.tactics.toArray}
|
|
|
|
definitions := {level.definitions with used := usedInventory.definitions.toArray}
|
|
|
|
definitions := {level.definitions with used := usedInventory.definitions.toArray}
|
|
|
|
|