← All papers
First page of Descriptive Complexity in Lean: Completeness by First-Order Reductions

Descriptive Complexity in Lean: Completeness by First-Order Reductions

Pierre Senellart, Anton Gnatenko

cs.LO Sep 16, 2026 · v1 cs.CC
A Lean library formalizes descriptive complexity, proving 73 completeness results across 14 complexity classes via first-order reductions on finite structures.
We show that descriptive complexity can serve as a foundation for formalizing computational complexity results in a proof assistant, by constructing a Lean library centered around the following concepts: decision problems are isomorphism-invariant predicates on finite structures; complexity classes are defined by their logical characterization; membership is shown by definability witnesses; hardness is shown by first-order reductions from a known hard problem. We also establish bridges to traditional machine models such as (non)deterministic Turing machines. The library proves 73 completeness results, on 68 problems or problem families, over 14 different classes; relations between the classes established inside the logic and not by machine simulation, among them NL = coNL and the Abiteboul-Vianu theorem; and unconditional lower bounds, among them $\mathrm{FO}(\leq) \subsetneq \mathrm{FO}(\leq, \mathrm{TC})$ and the failure of order-free FO(IFP) to capture PTIME.

Computational complexity hardness and completeness results are almost never formalized in proof assistants because standard proofs are anchored to machine models under resource constraints that resist mechanization. Existing developments stop at a handful of completeness theorems.

A Lean library is built around descriptive complexity: decision problems are isomorphism-invariant predicates on finite structures, complexity classes are defined by their logical characterization, membership is shown by definability witnesses, and hardness by first-order reductions from known hard problems. Classes are closed under first-order reductions via per-logic pullback lemmas built on Mathlib's FirstOrder.Language and BoundedFormula. Machine bridges link the logically defined classes to Turing-machine definitions by encoding acceptance as a decision problem over a finite structure.

The library proves 73 completeness results on 68 problems or problem families over 14 classes, including all 21 Karp problems as NP-complete. It establishes class relations inside the logic (NL = coNL, the Abiteboul-Vianu theorem) and unconditional lower bounds (FO(≤) ⊊ FO(≤,TC) and failure of order-free FO(IFP) to capture PTIME). The SAT completeness theorem's dependency closure is far smaller than machine-model developments.

LibraryProverDefined overThms
coq-library-complexityRocqcbv λ-calculus3
AFP Cook_LevinIsabelle/HOLmulti-tape TMs1
poly-reductionsIsabelle/HOLIMP- while-language0
ComplexitylibLeanmulti-tape TMsNP,coNP
Our libraryLeanfinite structures73
Mechanized complexity libraries by definitional foundation and completeness theorems proved