Karp reductions, -hardness and -completeness
DefinitionPvsNP_reductionsA polynomial-time many-one (Karp) reduction from a decision problem to a decision problem , written , is a polynomial-time computable map with for every input .
A problem is -hard if for every , and -complete if in addition . This follows Arora–Barak, Definition 2.7.
import Definitions.Def_PvsNP_complexity_classes /-! # Polynomial-time many-one reductions, NP-hardness and NP-completeness Following Arora–Barak, *Computational Complexity: A Modern Approach* (2009), Definition 2.7. -/ namespace PvsNP /-- `PolyTimeReducible L K` (Karp reduction `L ≤ₚ K`): there is a polynomial-time computable map `f` on bitstrings with `L x = K (f x)` for every input `x`. -/ def PolyTimeReducible (L K : DecisionProblem) : Prop := ∃ f : List Bool → List Bool, IsPolyTime f ∧ ∀ x, L x = K (f x) /-- `NPHard L`: every problem in `NP` reduces to `L` by a polynomial-time many-one reduction. -/ def NPHard (L : DecisionProblem) : Prop := ∀ K ∈ NP, PolyTimeReducible K L /-- `NPComplete L`: `L` lies in `NP` and is `NP`-hard. -/ def NPComplete (L : DecisionProblem) : Prop := L ∈ NP ∧ NPHard L end PvsNP
Read-back
What the Lean code literally says, in plain math · aristotle-harmonic
Working with decision problems (total functions from bitstrings to Booleans) and with the previously defined notion of a polynomial-time computable function between types carrying canonical bitstring encodings, this file defines three propositions.
For decision problems and , asserts: there exists a function from bitstrings to bitstrings such that is polynomial-time computable (there is a two-stack Turing machine computing within a polynomial number of steps in the length of the encoded input) and, for every bitstring , the Boolean values and are equal. The equality is of Booleans, so it covers both the case and the case ; no constraint is placed on the length of beyond what polynomial-time computability implies, and need not be injective or surjective.
For a decision problem , asserts that for every decision problem belonging to , holds — i.e. every problem of reduces to in the above many-one sense. itself is not required to lie in , nor in any other class.
For a decision problem , asserts the conjunction of and .
Only Karp-style many-one reductions appear; no Turing (oracle) reductions are defined. No existence claim is made: nothing here asserts that any -hard or -complete problem exists.