[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"3Lk80aOr0H":3},"# Complexitylib\n\nA Lean 4 formalization of computational complexity theory, built on\n[Mathlib](https://github.com/leanprover-community/mathlib4). The machine\nmodel takes its shape from Arora and Barak's *Computational Complexity: A\nModern Approach*, but the library sets its own conventions — stated\nprecisely where they're used, with literature references where they help,\nand unafraid to diverge from any one text when a cleaner formalization\nexists.\n\n## Ethos\n\n**Statements you can audit, proofs you don't have to.** Every public theorem\nis stated so a reader can check it means what it claims — concrete machine\nmodel, explicit resource bounds, honest encodings — while the proof machinery\nlives out of sight in `Internal` modules whose correctness is the type\nchecker's job, not yours.\n\n**Concrete over abstract.** Machines, circuits, reductions, and encoders are\nexecutable definitions, not existence claims. Complexity is measured on real\nencodings; parsing, malformed inputs, and output conventions are explicit.\nConstructions expose an exact resource bound first and an asymptotic\ncorollary second.\n\n**Nothing on faith.** The library has no `sorry` and no custom axioms:\n`scripts/AxiomGuard.lean` mechanically asserts that the headline theorems\ndepend only on Lean's three standard axioms, and CI enforces it — along with\nMathlib's style and environment linters — on every push.\n\n## How to read the library\n\nEverything lives in the `Complexity` root namespace and splits into areas,\neach with its own entry module:\n\n| Area | Import | What it is |\n| --- | --- | --- |\n| Machine models | `Complexitylib.Models` | Arora–Barak multi-tape Turing machines — deterministic, nondeterministic, probabilistic — and everything built from them: combinators, simulations, universal machines |\n| Asymptotics | `Complexitylib.Asymptotics` | `=O`/`=o` notation on `ℕ → ℕ`, bridging to Mathlib's asymptotics |\n| Complexity classes | `Complexitylib.Classes` | `P`, `NP`, `BPP`, `PSPACE`, and friends; containments, closure properties, reductions, and the time-hierarchy theorem |\n| SAT | `Complexitylib.SAT` | CNF semantics and encoding, a verified SAT verifier, and the Cook–Levin theorem: `SAT` is NP-complete |\n| Circuits | `Complexitylib.Circuits` | Boolean circuits with size and depth, circuit families, `P/poly`, normal forms, and classical lower bounds |\n| Languages | `Complexitylib.Languages` | Concrete decidable languages exercising the machine API end to end |\n| Mathlib prelude | `Complexitylib.Mathlib` | Extensions to Mathlib types in their home namespaces; candidates for upstreaming |\n\nWithin an area, modules follow one discipline:\n\n- **`Foo/Defs.lean`** — definitions. Short, minimally-imported, auditable.\n- **`Foo.lean`** — the surface: theorem statements worth reading.\n- **`Foo/Internal…`** — proof machinery. Skip it; the type checker read it.\n\nSo: import `Complexitylib` (or one area), read `Defs` and surface files, and\ntrust the kernel for the rest. Headline results — Cook–Levin, universal-machine\nsimulation with explicit overhead, the deterministic time hierarchy — are\nindexed in the root module `Complexitylib.lean` and mechanically guarded in `scripts/AxiomGuard.lean`.\n\n## Building\n\nInstall [elan](https://github.com/leanprover/elan); Lean and Mathlib versions\nare pinned (currently v4.30.0).\n\n```bash\nlake build --wfail\n```\n\nCI additionally runs two executable regression suites and three quality gates;\nsee [CONTRIBUTING.md](CONTRIBUTING.md) for the full list and the style guide.\nAPI documentation builds with doc-gen4 from `docbuild/`.\n\n## Contributing\n\n[ROADMAP.md](ROADMAP.md) orders the open research programs by dependency —\nfrom core API consolidation through uniform circuits, interactive proofs, and\nformalized barriers — and breaks each into review-sized steps.\n[CONTRIBUTING.md](CONTRIBUTING.md) covers style, layering, naming, and commit\nconventions. Design notes for the larger completed constructions live in\n`docs/`.\n\n## License\n\nLicensed under the [Apache License, Version 2.0](LICENSE).\n",1783784684692]