[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"eAlS6WRDxR":3},"# TRZK\n\nTRZK compiles Lean specifications of zero-knowledge primitives to optimized\nlow-level implementations via equality saturation with hardware-aware cost\nmodels.\n\nThis cut is a deliberately minimal end-to-end pipeline. Future growth happens\non a working foundation.\n\n## Current abilities\n\n- Expression language: `ArithExpr = Const Int | Var Nat | Add ArithExpr ArithExpr`\n- One rewrite rule: `e + 0 → e` (right-identity)\n- Rust emitter targeting `isize` arithmetic\n- CLI `trzk` that turns a `.lean` spec file into a Rust function\n- Integration test with crafted and fuzz vectors\n\n## Not yet supported\n\nMultiplication, left-identity of `+`, commutativity, constant folding, finite\nfields, ZK primitives. All deferred to future iterations.\n\n## Dependencies\n\nSaturation is delegated to [optisat / LambdaSat](https://github.com/lambdaclass/truth_research),\na formally verified e-graph + saturation engine. We plug in via typeclass\ninstances; we do not reimplement the engine.\n\n## Usage\n\n```bash\n# Build\nlake build\n\n# Compile a spec to Rust\ncat > /tmp/spec.lean \u003C\u003C'EOF'\nopen TRZK (ArithExpr)\ndef spec : ArithExpr := .add (.var 0) (.const 0)\nEOF\n./.lake/build/bin/trzk /tmp/spec.lean --output /tmp/out.rs\ncat /tmp/out.rs\n# → pub fn arith_spec(x0: isize) -> isize { x0 }\n\n# Run the integration test\n./integration_tests/run.sh --op add0\n./integration_tests/run.sh --op add0 --fuzz -n 1000\n```\n\n## Pipeline\n\nFour stages, each with one owner:\n\n1. **Parse** — Lean itself. The user writes `def spec : ArithExpr := ...` in a\n   `.lean` file; the CLI runs it via `lake env lean --run`.\n2. **Saturate** — optisat. Our `ArithOp` type plugs in via `NodeOps` and\n   `Extractable` typeclass instances.\n3. **Emit** — hand-rolled Rust emitter (`TRZK/Emit.lean`).\n4. **Execute** — scripted harness (`integration_tests/`).\n\nSee [`docs/pipeline.md`](docs/pipeline.md) for details.\n\n## Layout\n\n| Path | Purpose |\n|------|---------|\n| `TRZK/ArithExpr.lean` | AST users write specs in |\n| `TRZK/ArithOp.lean` | e-graph node + optisat typeclass instances |\n| `TRZK/Rule.lean` | rewrite rule registry |\n| `TRZK/Pipeline.lean` | embed + optimize |\n| `TRZK/Emit.lean` | Rust emitter |\n| `Compile.lean` | trzk CLI |\n| `Tests/*.lean` | `#guard` tests |\n| `integration_tests/` | end-to-end harness |\n| `docs/` | pipeline, saturation, onboarding, glossary |\n\n## License\n\nSee [`LICENSE`](LICENSE).\n",1777494176875]