Add stack size troubleshooting

This commit is contained in:
Leni Ven 2023-05-14 15:22:41 -07:00
parent 3cb0795bb6
commit 2ec4efde55
3 changed files with 25 additions and 1 deletions

View File

@ -52,7 +52,9 @@ def catalog (args: Catalog): Subroutine CatalogResult := do
match state.environments.get? args.id with
| .some env =>
let names := env.constants.fold (init := []) (λ es name info =>
if es.length > 3000 is_symbol_unsafe_or_internal name info then es else (toString name)::es)
match to_filtered_symbol name info with
| .some x => x::es
| .none => es)
return { theorems := names }
| .none => throw s!"Invalid environment id {args.id}"

View File

@ -15,4 +15,21 @@ def is_symbol_unsafe_or_internal (n: Lean.Name) (info: Lean.ConstantInfo): Bool
| .num _ _ => true
nameDeduce stemDeduce info.isUnsafe
def to_compact_symbol_name (n: Lean.Name) (info: Lean.ConstantInfo): String :=
let pref := match info with
| .axiomInfo _ => "axiom"
| .defnInfo _ => "defn"
| .thmInfo _ => "thm"
| .opaqueInfo _ => "opaque"
| .quotInfo _ => "quot"
| .inductInfo _ => "induct"
| .ctorInfo _ => "ctor"
| .recInfo _ => "rec"
s!"{pref}|{toString n}"
def to_filtered_symbol (n: Lean.Name) (info: Lean.ConstantInfo): Option String :=
if is_symbol_unsafe_or_internal n info
then Option.none
else Option.some <| to_compact_symbol_name n info
end Pantograph

View File

@ -35,4 +35,9 @@ $ lake env build/bin/Pantograph
```
## Troubleshooting
If lean encounters stack overflow problems when printing catalog, execute this before running lean:
```sh
ulimit -s unlimited
```