Skip to content

About

Computational complexity theory in Lean built on top of CSLib.

Resources

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

Complexitylib

Complexitylib is a Lean 4 library of computational complexity theory, built on CSLib and Mathlib. It develops reusable arguments about algorithms, resource bounds, reductions, lower bounds, and cryptographic security.

A central goal is to let you write recognizable functional programs and prove their efficiency compositionally, with Turing-machine implementations justified underneath. Nonconstructive mathematics and model-specific lower bounds also belong. Developments should establish useful results or make those results easier to state, prove, and reuse.

Development is AI-assisted. Contributors are responsible for the mathematical statements, source attribution, and maintainability of their changes. Lean checks proofs against their stated definitions; independent review checks that those definitions and statements express the intended mathematics. See Contributing to propose, implement, or review a development.

Start here

I want to… Start with…
Certify functional programs and loops PolyTime examples
Construct circuits for polynomial-time function families Uniform circuit examples
Write probabilistic programs or oracle reductions PPT examples, oracle examples
Find a computational model or mathematical tool Module index; each module documents its definitions, results, and references
Contribute a result or improve an API Contributing

The checked examples show fun_prop, polytime, and ppt with explicit encodings and client-supplied invariants. The deterministic backend builds on Christian Reitwiessner's tidy machine calculus.

The selected formal abstracts present a small set of major results with inspectable definitions and checked Lean statements. The combined PDF and individual PDFs are generated from those sources. Each states its model and limitations; the selection is not an exhaustive API reference.

Selected results

Build and use

The package is named complexitylib; imports begin with Complexity.. Most declaration namespaces begin with Cslib, and Turing-machine declarations use Turing. Use the version in lean-toolchain and the pinned dependencies in lakefile.toml. From a checkout:

lake exe cache get
lake build --wfail --iofail

Import the specific modules you need. import Complexity imports the whole library.

To build searchable API documentation from the module docstrings (Python 3.11+):

python3 scripts/check_docs.py --config-only
lake -d docbuild build Complexity:docs
python3 scripts/check_docs.py
python3 -m http.server --bind 127.0.0.1 --directory docbuild/.lake/build/doc

Open http://localhost:8000 to browse and search. The on-demand API documentation workflow also produces an api-docs artifact; serve it by replacing the directory argument above with the extracted artifact directory.

This is the canonical CSLib-based Complexitylib. The renamed historical pre-CSLib implementation remains available with archival pending; it has a different API, and some developments remain to be ported. The temporary repository and package name complexitylib2 was retired when this repository moved to CSLib Community. Downstream projects using that package name should change it to complexitylib; Lean imports remain unchanged. APIs are still evolving, so downstream projects should pin a commit.

Project information

Modules follow CSLib's APIs, paths, namespaces, and contribution standards so they can move upstream with the import prefix changed from Complexity. to Cslib.. Acceptance requires CSLib review. ROADMAP.md records outstanding work; UPSTREAM.md records upstream coordination and exceptional integration decisions.

Source headers retain authorship, module docstrings credit mathematical and formalization sources, and references.bib contains the bibliography. Licensed under Apache 2.0.

About

Computational complexity theory in Lean built on top of CSLib.

Resources

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages