Polynomial-time many-one reductions #
PolyTimeReducible encA encB A B: a function computable in polynomial time with respect to the
encodings encA and encB maps instances of A to instances of B, preserving membership Arora
and Barak, Definition 2.7. It is, by definition, the many-one reducibility
Cslib.Complexity.ManyOneReducibleBy by maps computable in polynomial time
(Cslib.Complexity.polyTimeReducible_iff_manyOneReducibleBy), and its preorder and complement
lemmas are instances of the core's. Its body is kept as the ∃ statement, so that the
admissibility goal of an anonymous constructor is ComputableInPolyTime f encA encB itself, as
fun_prop expects. The checked client in CslibFrontierTests.NPCompleteness supplies plain
decider,
verifier and reduction certificates, then transfers IndependentSet hardness to Clique.
A class of problems is given, as NP or coNP, by a set of problems for every type of instances
and every encoding of them. A problem B is hard for such a class C when every problem in C,
with any encoding of its instances, reduces to B (PolyTimeHard C encB B), and complete when it
also belongs to C (PolyTimeComplete C encB B), the instances of Cslib.Complexity.HardUnder
and Cslib.Complexity.CompleteUnder for PolyTimeReducible. The second conjunct of
PolyTimeComplete is stated as PolyTimeHard, so that its projection keeps the PolyTimeHard
API. NPHard, NPComplete, coNPHard
and coNPComplete are the instances for NP and coNP. When the problems of a class D are the
complements of those of C, the complement of a C-complete problem is D-complete
(PolyTimeComplete.compl).
Hardness quantifies over problems whose instances live in Type, with every encoding of instances.
Instances of complexity-theoretic problems are finite objects encoded as words, so this loses
nothing: a problem in a higher universe is equivalent, through its encoding, to the problem of
recognising the encodings of its members.
Mathlib's ManyOneReducible (Mathlib/Computability/Reduce.lean) is the computable, not the
polynomial-time, reducibility, and is stated for Primcodable types; it is not reused here.
Finding a proved NP-complete problem #
The declarations below give the exact problems, encodings and hypotheses; follow their source
module to import a result. Names in this table are relative to Cslib.Complexity. For example,
import CslibFrontier.Computability.Complexity.Problems.Clique to use Clique_npComplete and
polyTimeReducible_IndependentSet_Clique. Cook–Levin's CookLevin.SAT_npHard reduces every NP
problem to SAT. These are navigation tables, not an exhaustive list of reductions or classes.
| Problem | NP-completeness declaration |
|---|---|
| CNF satisfiability (Cook–Levin) | CookLevin.SAT_npComplete |
| At most three literals per clause | ThreeSAT_npComplete |
| Exactly three literals, repetitions allowed | ExactThreeSAT_npComplete |
| Exactly three distinct variables per clause | EUThreeSAT_npComplete |
| Not-all-equal SAT, clause width at most three | NAEThreeSAT_npComplete |
| NAE EU3SAT, exactly three distinct variables per clause | NAEEUThreeSAT_npComplete |
| Not-all-equal SAT, width and variable occurrences at most three | NAEThreeSATThree_npComplete |
| Boolean circuit satisfiability | CircuitSAT_npComplete |
| Independent set | IndependentSet_npComplete |
| Clique | Clique_npComplete |
| Vertex cover | VertexCover_npComplete |
| Three-colorability | ThreeColoring_npComplete |
Fixed k-colorability, 3 ≤ k | KColoring_npComplete |
Chromatic number, k in the input | ChromaticNumber_npComplete |
| Clique cover | CliqueCover_npComplete |
| Directed feedback vertex set (Karp's feedback node set) | FeedbackVertexSet_npComplete |
| Feedback arc set | FeedbackArcSet_npComplete |
| Directed Hamiltonian path, specified endpoints | DirHamPath_npComplete |
| Directed Hamiltonian cycle | DirHamCycle_npComplete |
| Undirected Hamiltonian path, specified endpoints | HamPath_npComplete |
| Undirected Hamiltonian cycle | HamCycle_npComplete |
| Subset sum | SubsetSum_npComplete |
| Partition | Partition_npComplete |
| Knapsack | Knapsack_npComplete |
| Weighted maximum cut | MaxCut_npComplete |
| Sequencing with deadlines and penalties | JobSequencing_npComplete |
| Zero-one integer programming | ZeroOneIP_npComplete |
| Traveling salesperson | TSP_npComplete |
| Source → target | Reduction declaration |
|---|---|
| SAT → ThreeSAT | polyTimeReducible_SAT_ThreeSAT |
| ThreeSAT → ExactThreeSAT | polyTimeReducible_ThreeSAT_ExactThreeSAT |
| SAT → CircuitSAT | SAT.polyTimeReducible_CircuitSAT |
| SAT → IndependentSet | polyTimeReducible_SAT_IndependentSet |
| IndependentSet → Clique | polyTimeReducible_IndependentSet_Clique |
| Clique → IndependentSet | polyTimeReducible_Clique_IndependentSet |
| IndependentSet → VertexCover | polyTimeReducible_IndependentSet_VertexCover |
| VertexCover → FeedbackVertexSet | polyTimeReducible_VertexCover_FeedbackVertexSet |
| FeedbackVertexSet → FeedbackArcSet | polyTimeReducible_FeedbackVertexSet_FeedbackArcSet |
| SAT → ThreeColoring | polyTimeReducible_SAT_ThreeColoring |
| ThreeSAT → ThreeColoring | polyTimeReducible_ThreeSAT_ThreeColoring |
SAT → KColoring k, for 3 ≤ k | polyTimeReducible_SAT_KColoring |
KColoring k → ChromaticNumber | polyTimeReducible_KColoring_ChromaticNumber |
| ChromaticNumber → CliqueCover | polyTimeReducible_ChromaticNumber_CliqueCover |
| SAT → DirHamPath | polyTimeReducible_SAT_DirHamPath |
| ThreeSAT → DirHamPath | polyTimeReducible_ThreeSAT_DirHamPath |
| SAT → DirHamCycle | polyTimeReducible_SAT_DirHamCycle |
| DirHamPath → HamPath | polyTimeReducible_DirHamPath_HamPath |
| DirHamCycle → HamCycle | polyTimeReducible_DirHamCycle_HamCycle |
| ThreeSAT → SubsetSum | polyTimeReducible_ThreeSAT_SubsetSum |
| SubsetSum → Partition | polyTimeReducible_SubsetSum_Partition |
| SubsetSum → Knapsack | polyTimeReducible_SubsetSum_Knapsack |
| SubsetSum → JobSequencing | polyTimeReducible_SubsetSum_JobSequencing |
| Partition → MaxCut | polyTimeReducible_Partition_MaxCut |
| SubsetSum → ZeroOneIP | polyTimeReducible_SubsetSum_ZeroOneIP |
| ThreeSAT → ZeroOneIP | polyTimeReducible_ThreeSAT_ZeroOneIP |
| HamCycle → TSP | polyTimeReducible_HamCycle_TSP |
Main definitions #
Cslib.Complexity.PolyTimeReducible.Cslib.Complexity.PolyTimeHard,Cslib.Complexity.PolyTimeComplete: hardness and completeness for a class.Cslib.Complexity.NPHard,Cslib.Complexity.NPComplete.Cslib.Complexity.coNPHard,Cslib.Complexity.coNPComplete.
Main results #
Cslib.Complexity.P_subset_NP,Cslib.Complexity.P_subset_coNP:Pis contained inNPand incoNP.Cslib.Complexity.NPComplete.P_eq_NP_of_mem_P,Cslib.Complexity.NPComplete.mem_P_iff: anNP-complete problem is inPexactly whenP = NPfor every encoding.Cslib.Complexity.NPComplete.mem_P_iff_mem_P: twoNP-complete problems are both inPor both outside it.Cslib.Complexity.PolyTimeReducible.refl,Cslib.Complexity.PolyTimeReducible.trans: polynomial-time reducibility is a preorder.Cslib.Complexity.PolyTimeReducible.mem_P:Pis closed under polynomial-time reductions.Cslib.Complexity.PolyTimeHard.trans,Cslib.Complexity.NPHard.trans,Cslib.Complexity.coNPHard.trans: hardness transfers along polynomial-time reductions.Cslib.Complexity.PolyTimeReducible.compl: a reduction between problems is one between their complements.Cslib.Complexity.PolyTimeHard.compl,Cslib.Complexity.PolyTimeComplete.compl: complements of hard and complete problems.Cslib.Complexity.NPHard.compl,Cslib.Complexity.coNPHard.compl,Cslib.Complexity.NPComplete.compl,Cslib.Complexity.coNPComplete.compl: complements exchange hardness and completeness forNPandcoNP.
References #
A reduces to B in polynomial time: some f, computable in polynomial time with respect to
encA and encB, satisfies a ∈ A ↔ f a ∈ B. This is ManyOneReducibleBy for the maps computable
in polynomial time (polyTimeReducible_iff_manyOneReducibleBy).
Construct a proof as ⟨f, by fun_prop, h⟩, where h proves the membership equivalence for every
source instance. Write f with certified Boolean, list and arithmetic operations, including
decide of connectives, (in)equalities and list membership; unfold local definitions so
fun_prop can see them. Cost and correctness are separate obligations: automation
does not prove h. See the checked graph-complement example in CslibFrontierTests.NPCompleteness.
Instances For
Polynomial-time reducibility is many-one reducibility by the maps computable in polynomial time.
B is hard for the class C under polynomial-time many-one reductions: every problem in C,
with any encoding of its instances, reduces to B. This is HardUnder for PolyTimeReducible.
Instances For
B is complete for the class C under polynomial-time many-one reductions: it is in C and
every problem in C reduces to it. This is CompleteUnder for PolyTimeReducible
(polyTimeComplete_iff_completeUnder), with its second conjunct stated as PolyTimeHard.
Instances For
Polynomial-time hardness is hardness under PolyTimeReducible.
Polynomial-time completeness is completeness under PolyTimeReducible.
Completeness for the class NP is NPComplete.
Completeness for the class coNP is coNPComplete.
Every problem reduces to itself in polynomial time by the identity function.
Polynomial-time many-one reductions compose.
If polynomial-time reductions preserve membership from D to C, they also preserve
membership in the complement classes {B | Bᶜ ∈ D} and {A | Aᶜ ∈ C}.
A polynomial-time reduction is a mapping reduction.
Hardness transfers along a polynomial-time reduction.
If the complement of every problem in 𝒟 is in 𝒞, the complement of a 𝒞-hard problem is
𝒟-hard.
If the problems in 𝒟 are exactly the complements of the problems in 𝒞, the complement of
a 𝒞-complete problem is 𝒟-complete.
The complement of an NP-complete problem is coNP-complete.
The complement of a coNP-complete problem is NP-complete.
P and NP-complete problems #
An NP-complete problem in P gives P = NP, for every encoding of instances: every
problem in NP reduces to it, and P is closed under polynomial-time reductions.