[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"lEpoSw86hR":3},"# imp-lab\n\nImpLab is a Lean playground for programming language modeling and teaching-oriented tooling.\n\nToday the core feature is the debugger, available in two modes:\n\n- as a [Debug Adapter Protocol (DAP)](https://microsoft.github.io/debug-adapter-protocol/) server (`toydap`) for editor integration, and,\n- as an in-editor Lean UI built with [ProofWidgets](https://github.com/leanprover-community/ProofWidgets4).\n\nImpLab was built using [Lean](https://lean-lang.org/) and [OpenAI's Codex](https://openai.com/codex/)\n\n**Note**: ImpLab is not production ready! It is designed to demonstrate and explore Lean’s capabilities. The code is a prototype and has not undergone the rigorous review and testing required for production use.\n\n## Run the Imp debugger\n\n### 1) Build the project\n\n```bash\nlake build\ncd client && npm install && npm run compile\n```\n\n### 2) Run in VS Code (DAP mode)\n\n1. Open the extension project:\n\n```bash\ncode client\n```\n\n2. In that VS Code window, press `F5` and run one of:\n- `Run ImpLab Toy DAP Extension (watch)`\n- `Run ImpLab Toy DAP Extension (compile once)`\n\n3. In the Extension Development Host window:\n- open the folder at the root of this repository,\n- open `examples/Main.lean`,\n- run debug config `ImpLab Toy DAP (auto-export ProgramInfo)`.\n\nNotes:\n- The launch config should auto-generate the debugger meta-data `.dap/programInfo.generated.json` using `dap-export` automatically.\n- The adapter binary is `toydap`.\n\n### 3) Run in Lean (ProofWidgets mode, less involved, less features)\n\n1. Open `examples/Main.lean`.\n2. Ensure the Lean infoview is active.\n3. Evaluate the widget declaration at the end of the file:\n\n```lean\n#widget ImpLab.traceExplorerWidget with ImpLab.Lang.Examples.sampleTracePropsJson\n```\n\nThis launches a debugger session directly in infoview.\n\n## Language\n\nImpLab includes a small imperative language with:\n\n- integer literals and local variables,\n- top-level mutable globals (`global g := N`) stored in a heap,\n- arithmetic operations (`add`, `sub`, `mul`, `div`),\n- heap operations (`get g`, `set g := v`),\n- function calls with parameters,\n- source-aware program metadata used by the debugger.\n\nPrograms are written with:\n\n- `imp%[...] : ImpLab.ProgramInfo`\n\nExample:\n\n```lean\ndef sample : ImpLab.ProgramInfo := imp%[\n  global counter := 0,\n  def inc(x) := {\n    let one := 1,\n    let out := add x one,\n    return out\n  },\n  def main() := {\n    let seed := 5,\n    let out := call inc(seed),\n    set counter := out,\n    let latest := get counter\n  }\n]\n```\n\n`get` and `set` on undeclared globals fail with a runtime error.\n\nLanguage reference:\n- `docs/language.md`\n\n## Additional links\n\n- Debugger architecture and launch contract: `docs/debugger.md`\n- Debugger roadmap (active priorities): `docs/debugger-roadmap.md`\n- VS Code extension details: `client/README.md`\n- Agent instructions (global): `AGENTS.md`\n- Agent instructions (debugger-local): `ImpLab/Debugger/AGENTS.md`\n",1780846766965]