Add working catalog code and example
This commit is contained in:
parent
b5cb464694
commit
7c96479bb5
|
@ -45,7 +45,9 @@ def catalog (args: Catalog): Subroutine CatalogResult := do
|
||||||
let state ← get
|
let state ← get
|
||||||
match state.environments.get? args.id with
|
match state.environments.get? args.id with
|
||||||
| .some env =>
|
| .some env =>
|
||||||
let names := env.constants.toList.map (λ ⟨x, _⟩ => toString x)
|
let names := env.constants.fold (init := []) (λ es name info =>
|
||||||
|
if info.isUnsafe ∨ es.length > 500 then es else (toString name)::es)
|
||||||
|
--let names := env.constants.toList.map (λ ⟨x, _⟩ => toString x)
|
||||||
return { theorems := names }
|
return { theorems := names }
|
||||||
| .none => throw s!"Invalid environment id {args.id}"
|
| .none => throw s!"Invalid environment id {args.id}"
|
||||||
|
|
||||||
|
@ -96,5 +98,6 @@ unsafe def loop : T IO Unit := do
|
||||||
| .ok obj => IO.println <| toString <| obj
|
| .ok obj => IO.println <| toString <| obj
|
||||||
loop
|
loop
|
||||||
|
|
||||||
unsafe def main : IO Unit :=
|
unsafe def main : IO Unit := do
|
||||||
|
Lean.initSearchPath (← Lean.findSysroot)
|
||||||
StateT.run' loop ⟨#[]⟩
|
StateT.run' loop ⟨#[]⟩
|
||||||
|
|
17
README.md
17
README.md
|
@ -8,14 +8,21 @@ Install `elan` and `lean4`. Then, execute
|
||||||
``` sh
|
``` sh
|
||||||
lake build
|
lake build
|
||||||
```
|
```
|
||||||
|
In order to use `mathlib`, its binary must also be built
|
||||||
|
|
||||||
|
``` sh
|
||||||
|
lake build std
|
||||||
|
lake build mathlib
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Before usage, put the packages that you wish the REPL to use into a directory
|
The binary must be run inside a `lake env` environment.
|
||||||
and build them. Put this directory into the variable `$LEAN_PATH`. Then
|
|
||||||
```
|
|
||||||
$ build/bin/Pantograph
|
|
||||||
{"cmd": "create", "payload": {"imports": ["Mathlib.Analysis.Seminorm"]}}
|
|
||||||
```
|
```
|
||||||
|
$ lake env build/bin/Pantograph
|
||||||
|
{"cmd": "create", "payload": {"imports": ["Mathlib.Analysis.Seminorm"]}}
|
||||||
|
{"cmd": "catalog", "payload": {"id": 0}}
|
||||||
|
```
|
||||||
|
There is temporarily a limit of 500 symbols to prevent stack overflow.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue