Complexity classes, cofinal hardness, and NP
Lax904597.Classes · concepts/Lax904597/Classes.lean · lax-904597
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A complexity class is given by a membership predicate and a hardness predicate on decision problems over arbitrary relational vocabularies. The classes of this development are built from their membership predicate alone, with hardness read cofinally: a problem is hard when every member of the class reduces, by a relativized ordered first-order reduction, to every problem that itself reduces to. This is equivalent to the usual “every member reduces to ” (stated in NP is a complexity class), and is the form the library this submission comes from uses. A problem is complete for a class when it belongs to it and is hard for it.
NP is the class whose members are the -definable problems, by Fagin's theorem; more generally the level of the polynomial hierarchy has the -definable problems as members. The library this submission comes from makes closure under first-order reductions part of the definition of a class; that NP is closed is stated separately, in NP is a complexity class.
Concept map
Lean source view on GitHub
| 1 | import Lax904597.Problems |
| 2 | import Lax904597.Interpretations |
| 3 | import Lax904597.Relativized |
| 4 | import Lax904597.SecondOrder |
| 5 | |
| 6 | /-! |
| 7 | --- |
| 8 | title: Complexity classes, cofinal hardness, and NP |
| 9 | type: definition |
| 10 | --- |
| 11 | A complexity class is given by a membership predicate and a hardness |
| 12 | predicate on decision problems over arbitrary relational vocabularies. The |
| 13 | classes of this development are built from their membership predicate |
| 14 | alone, with hardness read *cofinally*: a problem is hard when every |
| 15 | member of the class reduces, by a relativized ordered first-order reduction, |
| 16 | to every problem that itself reduces to. This is equivalent to the |
| 17 | usual “every member reduces to ” (stated in *NP is a complexity |
| 18 | class*), and is the form the library this submission comes from uses. A |
| 19 | problem is complete for a class when it belongs to it and is hard for it. |
| 20 | |
| 21 | NP is the class whose members are the -definable problems, by |
| 22 | Fagin's theorem; more generally the level of the polynomial |
| 23 | hierarchy has the -definable problems as members. The |
| 24 | library this submission comes from makes closure under first-order |
| 25 | reductions part of the definition of a class; that NP is closed is stated |
| 26 | separately, in *NP is a complexity class*. |
| 27 | -/ |
| 28 | |
| 29 | namespace Lax904597.Classes |
| 30 | |
| 31 | open FirstOrder FirstOrder.Language |
| 32 | open Lax904597.Problems Lax904597.Interpretations Lax904597.Relativized Lax904597.SecondOrder |
| 33 | |
| 34 | /-- A complexity class: a membership predicate and a hardness predicate on |
| 35 | decision problems, over arbitrary relational vocabularies. -/ |
| 36 | structure ComplexityClass where |
| 37 | /-- The problems belonging to the class. -/ |
| 38 | Mem : ∀ {L : Language.{0, 0}} [L.IsRelational], DecisionProblem L → Prop |
| 39 | /-- The problems every problem of the class reduces to. -/ |
| 40 | Hard : ∀ {L : Language.{0, 0}} [L.IsRelational], DecisionProblem L → Prop |
| 41 | |
| 42 | variable {L : Language.{0, 0}} [L.IsRelational] |
| 43 | |
| 44 | /-- Cofinal hardness for a collection of problems: every problem of the |
| 45 | collection reduces to every relational problem that `P` reduces to. -/ |
| 46 | def CofinalHard (Mem : ∀ {L₀ : Language.{0, 0}} [L₀.IsRelational], DecisionProblem L₀ → Prop) |
| 47 | (P : DecisionProblem L) : Prop := |
| 48 | ∀ {L' : Language.{0, 0}} [L'.IsRelational] (S : DecisionProblem L'), |
| 49 | Nonempty (RelOrderedFOReduction P S) → |
| 50 | ∀ {L'' : Language.{0, 0}} [L''.IsRelational] (Q : DecisionProblem L''), |
| 51 | Mem Q → Nonempty (RelOrderedFOReduction Q S) |
| 52 | |
| 53 | /-- The class with the given membership and cofinal hardness. -/ |
| 54 | def ComplexityClass.ofMem |
| 55 | (Mem : ∀ {L₀ : Language.{0, 0}} [L₀.IsRelational], DecisionProblem L₀ → Prop) : |
| 56 | ComplexityClass where |
| 57 | Mem P := Mem P |
| 58 | Hard P := CofinalHard Mem P |
| 59 | |
| 60 | /-- A problem is complete for a class if it belongs to it and is hard for |
| 61 | it. -/ |
| 62 | def ComplexityClass.Complete (C : ComplexityClass) (P : DecisionProblem L) : Prop := |
| 63 | C.Mem P ∧ C.Hard P |
| 64 | |
| 65 | /-- The level `Σₖ₊₁ᵖ` of the polynomial hierarchy: the problems definable with |
| 66 | `k + 1` alternating blocks of second-order quantifiers, existential first. -/ |
| 67 | def sigmaLevel (k : ℕ) : ComplexityClass := |
| 68 | .ofMem fun P => SigmaSODefinable (k + 1) P |
| 69 | |
| 70 | /-- NP is `Σ₁ᵖ`: by definition, the existential-second-order definable |
| 71 | problems (Fagin's theorem). -/ |
| 72 | def NP : ComplexityClass := sigmaLevel 0 |
| 73 | |
| 74 | end Lax904597.Classes |
| 75 |
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments