Lean 4 Framework for Poly-Time Reductions
- Lean 4 framework is a mechanized formal system that rigorously verifies Karp reductions and complexity claims using dependent type theory.
- It automates tactic-based reduction composition and explicit polynomial-time bookkeeping to certify NP, coNP, and Σ₂^P memberships.
- The framework streamlines large-scale complexity proofs through modular abstractions and precise management of polynomial bounds.
A Lean 4 framework for polynomial-time reductions provides a mechanized setting for formalizing reductions and complexity-theoretic proofs in a dependent type theory based on Lean 4. It enables rigorous verification of computational complexity statements and automates many aspects of both reduction construction and complexity class membership certification. The framework centralizes the notion of a Karp (many-one) reduction, incorporates explicit polynomial-time witnesses, establishes compositionality, supplies instance-derivation mechanisms for standard classes (NP, coNP, ), and encodes combinators and tactics for scalable proofs.
1. Core Structure: PolyReduction
The foundational abstraction is the Lean structure PolyReduction, which formalizes a Karp (many-one) reduction between countable types and . A PolyReduction instance consists of:
- `reduce : \alpha \to \beta\text{PolyReduction}\,(\alpha,\beta) : \left\{\,\text{reduce}:\alpha\to\beta,\,\exists\,p:\mathbb N\to\mathbb N,\,\text{polynomial } p \wedge \forall x,\,\text{runtime}(\text{reduce }x)\le p(\text{size }x) \right\}\alphapf : \alpha \mapsto \betag : \beta \mapsto \gammag \circ f : \alpha \mapsto \gamma\beta$8
with the composed runtime bound $p(n) = p_2(p_1(n))\alpha$0 and $\alpha$1 are the polynomials certifying the runtime of $\alpha$2 and $\alpha\alpha$4 is encoded as Lean classes (
InNP,InCoNP,InSigma2), each consisting of:- a witness type (or types, for $\alpha$5),
- a verification/refutation predicate (in the form $\alpha$6 or similar),
- explicit polynomial-time bounds for the verifier,
- and a logical specification relating solutions to witnesses.
For example,
InCoNPrequires$\alpha$7
with all computations in polynomial time.
A distinctive aspect is that, once a reduction from an established complete problem (e.g., TAUTOLOGY for coNP, SET-COVER for NP) to $\alpha$8 is encoded as a
PolyReduction, membership in the relevant class is inherited automatically, greatly reducing the burden of boilerplate proofs: $\beta$9 Similar mechanisms exist for NP and $\alpha$9, accelerating the classification of new decision problems.4. Explicit Polynomial-Time Bookkeeping
The framework requires precise management of polynomial-time witnesses for every reduction or verifier. The idiom is to construct an explicit $\beta$0, prove
polynomial p, and establish the inequality $\beta$1. The granular control extends to fine details, such as composition, additive constants, and utilization of monotonicity for handling the arithmetic of size and running time propagation: $\text{PolyReduction}\,(\alpha,\beta) : \left\{\,\text{reduce}:\alpha\to\beta,\,\exists\,p:\mathbb N\to\mathbb N,\,\text{polynomial } p \wedge \forall x,\,\text{runtime}(\text{reduce }x)\le p(\text{size }x) \right\}$0 Intermediate reasoning unfolds in Lean viacalcblocks and numeric coercions to maintain correctness and transparency throughout polynomial-time bound construction.This explicit bookkeeping reinforces the foundational correctness guarantees of the formalization and ensures verifiability of all complexity claims.
5. Example Reduction: Set-Cover to Sufficiency-Check
To illustrate, the reduction from SET-COVER to SUFFICIENCY-CHECK is formalized as a
PolyReduction: $\text{PolyReduction}\,(\alpha,\beta) : \left\{\,\text{reduce}:\alpha\to\beta,\,\exists\,p:\mathbb N\to\mathbb N,\,\text{polynomial } p \wedge \forall x,\,\text{runtime}(\text{reduce }x)\le p(\text{size }x) \right\}$1 Here, the concretely describedreducefunction repackages SET-COVER instances as SUFFICIENCY-CHECK problems via appropriate encodings of actions, coordinates, and query sets. The explicit polynomial $\beta$2 bounds runtime for all steps, ensuring the reduction is correct within the formal framework.Once such reductions are established, the framework automatically derives that SUFFICIENCY-CHECK is coNP-complete (TAUTOLOGY $\beta$3 SET-COVER $\beta$4 SUFFICIENCY-CHECK), with the compositional infrastructure handling all requisite instance constructions (Simas, 22 Jan 2026). The result is a formally verified complexity landscape for the problem of identifying decision-relevant information.
6. Workflow and Formalization Scale
The full workflow comprises:
- Defining
structure PolyReductionwith explicit reduction and runtime bound fields. - Proving combinators such as
comp,id, and others for building new reductions. - Building tactic support to streamline reduction assembly and polynomial-bound verification.
- Defining class-level encodings for NP, coNP, and $\beta$5 along with instance constructors.
- For a new problem $\beta$6, either producing an explicit reduction from a known complete problem or directly building a verifier or $\beta$7 witness.
- Letting Lean’s type-class and instance inference propagate memberships automatically.
The mechanized artifact spans approximately 5,600 lines of Lean 4 code across 36 files, supporting 230+ theorems, with all polynomial bounds and complexity claims fully explicit and machine-checked.
7. Significance and Scope of the Framework
The Lean 4 framework enables exhaustive and trustworthy formalization of classical and novel complexity-theoretic reductions, systematically capturing coNP-completeness, hardness of approximation, exponential lower bounds (ETH), and parameterized complexity (W[2]-hardness) for problems such as SUFFICIENCY-CHECK. The dichotomy between explicit and succinct encodings is directly formalized, and reduction correctness together with time bounds are mechanically verified. This strongly facilitates research in complexity theory by removing ambiguity and human error from reduction-based arguments and by enabling large-scale, reusable mechanized libraries for complexity-theoretic reasoning (Simas, 22 Jan 2026).