Graph homomorphism
AbbreviationGraph-homomorphism instances#✓fully proved
A graph-homomorphism instance is a quadruple \((n, E, m, F)\) where \(n\) is a natural number (the number of source vertices), \(E\) is a list of pairs of natural numbers (the source edges), \(m\) is a natural number (the number of target vertices) and \(F\) is a list of pairs of natural numbers (the target edges).
DefinitionTarget graph of a graph-homomorphism instance#✓fully proved
The target graph of a graph-homomorphism instance \((n, E, m, F)\) is the simple graph on \(\{0, \dots, m - 1\}\) in which distinct vertices \(i\) and \(j\) are adjacent when \((i, j)\) or \((j, i)\) belongs to \(F\). Pairs of \(F\) with an endpoint at least \(m\) contribute no edge.
def GraphTarget (i : GraphHomomorphismInstance) : SimpleGraph (Fin i.2.2.1) :=
Cslib.Complexity.Karp.edgeGraph i.2.2.1 i.2.2.2
abbrev GraphHomomorphismInstance := ℕ × List (ℕ × ℕ) × ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/GraphHomomorphismWanted.lean:47
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-homomorphism instances#✓fully proved
A graph-homomorphism instance \((n, E, m, F)\) is well formed when \(E\) has no repeated entries, every pair \((u, v)\) in \(E\) satisfies \(u < n\), \(v < n\), \(u \ne v\) and \((v, u) \notin E\), \(F\) has no repeated entries, and every pair \((u, v)\) in \(F\) satisfies \(u < m\), \(v < m\), \(u \ne v\) and \((v, u) \notin F\).
def WellFormed (i : GraphHomomorphismInstance) : 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) ∧
i.2.2.2.Nodup ∧ ∀ e ∈ i.2.2.2, e.1 < i.2.2.1 ∧ e.2 < i.2.2.1 ∧ e.1 ≠ e.2 ∧ (e.2, e.1) ∉ i.2.2.2
abbrev GraphHomomorphismInstance := ℕ × List (ℕ × ℕ) × ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/GraphHomomorphismWanted.lean:47
Uses 1 · Used by 1
DefinitionFeasible graph-homomorphism instances#✓fully proved
A graph-homomorphism instance \((n, E, m, F)\) is feasible when there is a map \(f : \{0, \dots, n - 1\} \to \{0, \dots, m - 1\}\) such that, for every pair \((u, v)\) in \(E\) with \(u < n\) and \(v < n\), the vertices \(f(u)\) and \(f(v)\) are adjacent in the target graph of the instance, that is, \(f(u) \ne f(v)\) and \((f(u), f(v))\) or \((f(v), f(u))\) belongs to \(F\). Pairs of \(E\) with an endpoint at least \(n\) impose no condition.
def GraphHomomorphismFeasible
(i : GraphHomomorphismInstance) : Prop :=
∃ f : Fin i.1 → Fin i.2.2.1,
∀ e ∈ i.2.1, ∀ (h1 : e.1 < i.1) (h2 : e.2 < i.1),
(GraphTarget i).Adj (f ⟨e.1, h1⟩) (f ⟨e.2, h2⟩)
abbrev GraphHomomorphismInstance := ℕ × List (ℕ × ℕ) × ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/GraphHomomorphismWanted.lean:47
def GraphTarget (i : GraphHomomorphismInstance) : SimpleGraph (Fin i.2.2.1) :=
Cslib.Complexity.Karp.edgeGraph i.2.2.1 i.2.2.2
WantedExt/Complexity/NPComplete/GraphHomomorphismWanted.lean:51
Uses 2 · Used by 1
DefinitionGRAPH HOMOMORPHISM as a decision problem#✓fully proved
The decision problem GRAPH HOMOMORPHISM accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to a graph-homomorphism instance \((n, E, m, F)\) that is well formed (neither \(E\) nor \(F\) has repeated entries, every pair \((u, v)\) in \(E\) has \(u < n\), \(v < n\), \(u \ne v\) and \((v, u) \notin E\), and every pair \((u, v)\) in \(F\) has \(u < m\), \(v < m\), \(u \ne v\) and \((v, u) \notin F\)) and for which there is a map \(f : \{0, \dots, n - 1\} \to \{0, \dots, m - 1\}\) such that, for every pair \((u, v)\) in \(E\), \(f(u) \ne f(v)\) and \((f(u), f(v))\) or \((f(v), f(u))\) belongs to \(F\). Bitstrings that do not decode are rejected.
noncomputable def graphHomomorphismDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := GraphHomomorphismInstance) x with
| some i => decide (WellFormed i ∧ GraphHomomorphismFeasible 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 GraphHomomorphismInstance := ℕ × List (ℕ × ℕ) × ℕ × List (ℕ × ℕ)
WantedExt/Complexity/NPComplete/GraphHomomorphismWanted.lean:47
def WellFormed (i : GraphHomomorphismInstance) : 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) ∧
i.2.2.2.Nodup ∧ ∀ e ∈ i.2.2.2, e.1 < i.2.2.1 ∧ e.2 < i.2.2.1 ∧ e.1 ≠ e.2 ∧ (e.2, e.1) ∉ i.2.2.2
WantedExt/Complexity/NPComplete/GraphHomomorphismWanted.lean:56
def GraphHomomorphismFeasible
(i : GraphHomomorphismInstance) : Prop :=
∃ f : Fin i.1 → Fin i.2.2.1,
∀ e ∈ i.2.1, ∀ (h1 : e.1 < i.1) (h2 : e.2 < i.1),
(GraphTarget i).Adj (f ⟨e.1, h1⟩) (f ⟨e.2, h2⟩)
WantedExt/Complexity/NPComplete/GraphHomomorphismWanted.lean:61
Uses 12 · Used by 1
TheoremGRAPH HOMOMORPHISM is NP-complete#●ready to prove
The decision problem GRAPH HOMOMORPHISM belongs to NP, and every decision problem in NP reduces to it by a polynomial-time many-one reduction.
public theorem_wanted graphHomomorphism_npComplete :
graphHomomorphismDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L graphHomomorphismDec
noncomputable def graphHomomorphismDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := GraphHomomorphismInstance) x with
| some i => decide (WellFormed i ∧ GraphHomomorphismFeasible i)
| none => false
WantedExt/Complexity/NPComplete/GraphHomomorphismWanted.lean:69
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 HOMOMORPHISM; P. Hell and J. Nesetril, "On the complexity of H-coloring" (1990).
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.