Graph coloring
AbbreviationInstances of GRAPH COLORING#✓fully proved
An instance of GRAPH COLORING is a triple \((n, E, K)\) consisting of a natural number \(n\), the number of vertices, a list \(E\) of pairs of natural numbers, the edges, and a natural number \(K\), the bound on the number of colors.
abbrev GraphColoringInstance := ℕ × List (ℕ × ℕ) × ℕ
DefinitionGraph of a GRAPH COLORING instance#✓fully proved
The graph of an instance \((n, E, K)\) of GRAPH COLORING is the simple graph on \(\{0, \dots, n - 1\}\) in which distinct vertices \(i\) and \(j\) are adjacent when \((i, j)\) or \((j, i)\) belongs to \(E\).
def Graph (i : GraphColoringInstance) : SimpleGraph (Fin i.1) :=
Cslib.Complexity.Karp.edgeGraph i.1 i.2.1
abbrev GraphColoringInstance := ℕ × List (ℕ × ℕ) × ℕ
WantedExt/Complexity/NPComplete/GraphColoringWanted.lean:46
def edgeGraph (n : ℕ) (es : List (ℕ × ℕ)) : SimpleGraph (Fin n) :=
SimpleGraph.fromRel fun i j => ((i : ℕ), (j : ℕ)) ∈ es
CSLibExt/Computability/Complexity/Karp/Color.lean:51
Uses 2 · Used by 1
DefinitionWell-formed GRAPH COLORING instances#✓fully proved
An instance \((n, E, K)\) of GRAPH COLORING is well formed when the list \(E\) has no repeated entries and every pair \((u, v)\) in \(E\) satisfies \(u < n\), \(v < n\), \(u \ne v\) and \((v, u) \notin E\).
def WellFormed (i : GraphColoringInstance) : Prop :=
i.2.1.Nodup ∧ ∀ e ∈ i.2.1, e.1 < i.1 ∧ e.2 < i.1 ∧ e.1 ≠ e.2 ∧ (e.2, e.1) ∉ i.2.1
abbrev GraphColoringInstance := ℕ × List (ℕ × ℕ) × ℕ
WantedExt/Complexity/NPComplete/GraphColoringWanted.lean:46
Uses 1 · Used by 1
DefinitionFeasible GRAPH COLORING instances#✓fully proved
An instance \((n, E, K)\) of GRAPH COLORING is feasible when its graph is \(K\)-colorable, that is, when its vertices can be assigned colors from \(\{0, \dots, K - 1\}\) so that adjacent vertices receive different colors.
def GraphColoringFeasible
(i : GraphColoringInstance) : Prop :=
(Graph i).Colorable i.2.2
abbrev GraphColoringInstance := ℕ × List (ℕ × ℕ) × ℕ
WantedExt/Complexity/NPComplete/GraphColoringWanted.lean:46
def Graph (i : GraphColoringInstance) : SimpleGraph (Fin i.1) :=
Cslib.Complexity.Karp.edgeGraph i.1 i.2.1
WantedExt/Complexity/NPComplete/GraphColoringWanted.lean:49
Uses 2 · Used by 1
DefinitionGRAPH COLORING as a decision problem#✓fully proved
The decision problem GRAPH COLORING accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to an instance of GRAPH COLORING that is well formed and feasible. Bitstrings that do not decode to an instance are rejected.
noncomputable def graphColoringDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := GraphColoringInstance) x with
| some i => decide (WellFormed i ∧ GraphColoringFeasible i)
| none => false
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
abbrev GraphColoringInstance := ℕ × List (ℕ × ℕ) × ℕ
WantedExt/Complexity/NPComplete/GraphColoringWanted.lean:46
def WellFormed (i : GraphColoringInstance) : Prop :=
i.2.1.Nodup ∧ ∀ e ∈ i.2.1, e.1 < i.1 ∧ e.2 < i.1 ∧ e.1 ≠ e.2 ∧ (e.2, e.1) ∉ i.2.1
WantedExt/Complexity/NPComplete/GraphColoringWanted.lean:54
def GraphColoringFeasible
(i : GraphColoringInstance) : Prop :=
(Graph i).Colorable i.2.2
WantedExt/Complexity/NPComplete/GraphColoringWanted.lean:58
Uses 12 · Used by 1
TheoremGRAPH COLORING is NP-complete#●ready to prove
The decision problem GRAPH COLORING belongs to NP, and every decision problem \(L\) in NP has a polynomial-time many-one reduction to GRAPH COLORING.
public theorem_wanted graphColoring_npComplete :
graphColoringDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L graphColoringDec
noncomputable def graphColoringDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := GraphColoringInstance) x with
| some i => decide (WellFormed i ∧ GraphColoringFeasible i)
| none => false
WantedExt/Complexity/NPComplete/GraphColoringWanted.lean:64
def NP : DecisionComplexityClass :=
{ L | ∃ (p : Polynomial ℕ), ∃ R : (List Bool × List Bool) → Bool,
IsPolyTime R ∧
∀ x, L x ↔ ∃ w : List Bool, w.length ≤ p.eval x.length ∧ R (x, w) }
MathlibExt/Computability/Complexity.lean:200
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def PolyManyOneRed (L₁ L₂ : MetaMathlibExt.ComplexityTheory.DecisionProblem) : Prop :=
∃ reduce : List Bool → List Bool,
MetaMathlibExt.ComplexityTheory.IsPolyTime reduce ∧ ∀ x, L₁ x = L₂ (reduce x)
CSLibExt/Computability/CookLevin.lean:396
Sources
- M. R. Garey and D. S. Johnson, Computers and Intractability (1979), GRAPH COLORING (chromatic number); R. M. Karp, "Reducibility among combinatorial problems" (1972).
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.