Documentation

CslibFrontier.Computability.Complexity.Parameterized.ColorCoding

Color coding: colorful paths #

A path is colorful under a coloring of the vertices when its vertices have pairwise distinct colors. Alon, Yuster and Zwick decide whether a graph with k colors has a colorful path on k vertices by dynamic programming over the sets of colors [AlonYusterZwick1995, Lemma 3.1] [CyganEtAl2015, Lemma 5.5]: for each set S of colors, list the vertices v at which some colorful path with color set exactly S ends. Such a path is the single vertex v when S = {χ v}, and otherwise extends a colorful path with color set S \ {χ v} ending at a neighbor of v. Color coding then finds a path on k vertices with probability at least e ^ (-k) by running this procedure on a uniformly random coloring.

Cslib.Complexity.ColorfulPath is the problem: an instance (ColorfulPathInstance) packages a graph, a list of colors parallel to its vertex list (Cslib.Complexity.colorOf), and a target length (k), encoded by Cslib.Complexity.encColorfulPathInstance. The question is whether there is a path on k vertices with pairwise distinct colors less than k. The color sets are bit masks m < 2 ^ k, and the table (Cslib.Complexity.ColorCoding.table) has one entry per mask in increasing order, so that the entry at m - 2 ^ χ v precedes that at m.

Resources. The table on N masks is polynomial-time with N in unary (Cslib.Complexity.ColorCoding.computableInPolyTime_table), so the decider runs in polynomial time on the instance padded by 2 ^ min(n, k), with n the number of distinct vertices. Padding (Cslib.Complexity.DecidableInExpTime.of_computableInPolyTime_pad) gives a multi-tape machine within time 2 ^ (δ k) times a polynomial in the encoded length, for some constant δ (Cslib.Complexity.ColorfulPath_decidableInExpTime), so ColorfulPath is fixed-parameter tractable in k (Cslib.Complexity.ColorfulPath_mem_FPT). The constant δ is not explicit: the 2 ^ k operations of the RAM analysis are not claimed for multi-tape machines.

Main definitions #

Main results #

References #

An instance of Cslib.Complexity.ColorfulPath: a graph graph, a list of vertex colors colors parallel to its vertex list (Cslib.Complexity.colorOf), and a target path length length.

Instances For
    theorem Cslib.Complexity.ColorfulPathInstance.ext {x y : ColorfulPathInstance} (graph : x.graph = y.graph) (colors : x.colors = y.colors) (length : x.length = y.length) :
    x = y
    theorem Cslib.Complexity.encColorfulPathInstance_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Graph} {T0 S0 : γ → ℕ} {x1 : γ → List ℕ} {T1 S1 x2 T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encGraph T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat) T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encNat T2 S2) :
    Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { graph := x0 x, colors := x1 x, length := x2 x }) encIn encColorfulPathInstance (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
    theorem Cslib.Complexity.encColorfulPathInstance_graph_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ColorfulPathInstance} :
    theorem Cslib.Complexity.encColorfulPathInstance_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Graph} {x1 : γ → List ℕ} {x2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encGraph budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat) budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encNat budget) :
    Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { graph := x0 x, colors := x1 x, length := x2 x }) encIn encColorfulPathInstance budget
    theorem Cslib.Complexity.encColorfulPathInstance_length_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → ColorfulPathInstance} :

    Colorful k-Path [CyganEtAl2015, Section 5.2]: the instances ⟨G, cs, k⟩ such that G has a path on k vertices whose colors are pairwise distinct and less than k; colors are given by a list parallel to the vertex list (Cslib.Complexity.colorOf).

    theorem Cslib.Complexity.mem_ColorfulPath_iff {G : Graph} {cs : List ℕ} {k : ℕ} :
    { graph := G, colors := cs, length := k } ∈ ColorfulPath ↔ ∃ (p : List ℕ), G.IsVertexPath p ∧ p.length = k ∧ (List.map (colorOf G cs) p).Nodup ∧ ∀ v ∈ p, colorOf G cs v < k

    The color set m, read as a bit mask, is the set of colors of a colorful path of G ending at v.

    def Cslib.Complexity.ColorCoding.entry (G : Graph) (χ : ℕ → ℕ) (T : List (List ℕ)) (m : ℕ) :

    The entry of the dynamic programming table at the color set m, given the entries at smaller color sets: the vertices v with χ v ∈ m such that m = {χ v}, or some neighbor of v is in the entry at m \ {χ v}.

    The dynamic programming table on the color sets 0, …, N - 1.

    theorem Cslib.Complexity.ColorCoding.reaches_iff {G : Graph} {χ : ℕ → ℕ} {m v : ℕ} :
    Reaches G χ m v ↔ v ∈ G.vertices ∧ m.testBit (χ v) = true ∧ (m = 2 ^ χ v ∨ ∃ (u : ℕ), Reaches G χ (m - 2 ^ χ v) u ∧ G.toSimpleGraph.Adj u v)

    The recurrence of the dynamic programming [CyganEtAl2015, Lemma 5.5]: a colorful path with color set m ends at v exactly when χ v ∈ m, and either m = {χ v} or a colorful path with color set m \ {χ v} ends at a neighbor of v.

    theorem Cslib.Complexity.ColorCoding.table_succ {G : Graph} {χ : ℕ → ℕ} (N : ℕ) :
    table G χ (N + 1) = table G χ N ++ [entry G χ (table G χ N) N]
    theorem Cslib.Complexity.ColorCoding.length_table {G : Graph} {χ : ℕ → ℕ} (N : ℕ) :
    (table G χ N).length = N
    theorem Cslib.Complexity.ColorCoding.mem_table_getD {G : Graph} {χ : ℕ → ℕ} {N m v : ℕ} (hm : m < N) :
    v ∈ (table G χ N).getD m [] ↔ Reaches G χ m v

    Correctness of the colorful-path table [AlonYusterZwick1995, Lemma 3.1] [CyganEtAl2015, Lemma 5.5]: below N, the entry at the color set m lists the vertices at which some colorful path with color set m ends.

    theorem Cslib.Complexity.ColorCoding.exists_reaches_iff {G : Graph} {χ : ℕ → ℕ} {k : ℕ} (hk : 0 < k) :
    (∃ (v : ℕ), Reaches G χ (2 ^ k - 1) v) ↔ ∃ (p : List ℕ), G.IsVertexPath p ∧ p.length = k ∧ (List.map χ p).Nodup ∧ ∀ v ∈ p, χ v < k

    The colorful paths on k vertices with colors less than k are the colorful paths ending anywhere with color set {0, …, k - 1}.

    Polynomial time on padded inputs #

    Parameters for building the dynamic-programming table: the input graph, vertex color list (Cslib.Complexity.colorOf), and unary bound numSets on color-set masks.

    Instances For
      theorem Cslib.Complexity.ColorCoding.TableInput.ext {x y : TableInput} (graph : x.graph = y.graph) (colors : x.colors = y.colors) (numSets : x.numSets = y.numSets) :
      x = y
      theorem Cslib.Complexity.ColorCoding.encTableInput_graph_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TableInput} :
      Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encTableInput S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).graph) encIn✝ encGraph S✝
      theorem Cslib.Complexity.ColorCoding.encTableInput_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → Graph} {x1 : γ → List ℕ} {x2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encGraph budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat) budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encUnary budget) :
      Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { graph := x0 x, colors := x1 x, numSets := x2 x }) encIn encTableInput budget
      @[reducible, inline]

      The tuple of the fields of encTableInput.

      theorem Cslib.Complexity.ColorCoding.encTableInput_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → Graph} {T0 S0 : γ → ℕ} {x1 : γ → List ℕ} {T1 S1 x2 T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encGraph T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encNat) T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encUnary T2 S2) :
      Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { graph := x0 x, colors := x1 x, numSets := x2 x }) encIn encTableInput (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
      theorem Cslib.Complexity.ColorCoding.encTableInput_numSets_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TableInput} :
      theorem Cslib.Complexity.ColorCoding.encTableInput_colors_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TableInput} :
      @[reducible, inline]

      Binary encoding of dynamic-programming tables (List (List ℕ)): lists of vertex lists.

      The input of a step of the table computation: the table parameters, the table so far, and the color set in unary.

      • input : TableInput

        Table parameters (graph, colors, and unary numSets).

      • table : List (List ℕ)

        Dynamic-programming table rows accumulated for smaller color-set masks.

      • mask : ℕ

        Current color-set mask (encoded in unary).

      Instances For
        theorem Cslib.Complexity.ColorCoding.StepInput.ext {x y : StepInput} (input : x.input = y.input) (table : x.table = y.table) (mask : x.mask = y.mask) :
        x = y
        theorem Cslib.Complexity.ColorCoding.encStepInput_input_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → StepInput} :
        Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encStepInput S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).input) encIn✝ encTableInput S✝
        theorem Cslib.Complexity.ColorCoding.encStepInput_table_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → StepInput} :
        Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ encStepInput S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).table) encIn✝ encTable S✝
        theorem Cslib.Complexity.ColorCoding.encStepInput_mask_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → StepInput} :
        theorem Cslib.Complexity.ColorCoding.encStepInput_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → TableInput} {T0 S0 : γ → ℕ} {x1 : γ → List (List ℕ)} {T1 S1 x2 T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn encTableInput T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn encTable T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encUnary T2 S2) :
        Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { input := x0 x, table := x1 x, mask := x2 x }) encIn encStepInput (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
        theorem Cslib.Complexity.ColorCoding.encStepInput_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → TableInput} {x1 : γ → List (List ℕ)} {x2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn encTableInput budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn encTable budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encUnary budget) :
        Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { input := x0 x, table := x1 x, mask := x2 x }) encIn encStepInput budget

        The padded test of the dynamic programming: whether the table on numSets color sets has a nonempty entry at the color set numSets - 1.

        The color-coding decider for colorful k-paths [CyganEtAl2015, Lemma 5.5]: accept when k = 0; otherwise check that k is at most the number n of distinct vertices, and that the table on the color sets 0, …, 2 ^ k - 1 has a nonempty entry at {0, …, k - 1}.

        Colorful k-Path in time 2 ^ O(k) times a polynomial [AlonYusterZwick1995, Lemma 3.1] [CyganEtAl2015, Lemma 5.5], on multi-tape machines: the dynamic programming over color sets (Cslib.Complexity.colorfulPathBool) runs on the input padded to length 2 ^ min(n, k). The constant δ is not explicit; the bound 2 ^ k of the RAM analysis is not claimed.