Algorithm Search⌘K

Proofs: Björklund's chromatic number algorithm

These are the human proofs of Björklund's chromatic number algorithm, at full length.

Björklund's algorithm returns the chromatic number full

This proof shows: correctness, termination.

Let G=(V,E)G = (V, E) be a finite simple undirected graph with V={0,…,n−1}V = \{0, \ldots, n - 1\}, and identify subsets of VV with bit masks. A set T⊆VT \subseteq V is independent if no edge has both ends in TT; the empty set is independent. For S⊆VS \subseteq V let

f(S)=∣{T⊆S:T independent}∣.f(S) = |\{ T \subseteq S : T \text{ independent} \}|.

If n=0n = 0, line L1 returns 0=χ(G)0 = \chi(G). Assume n≥1n \ge 1 from now on.

Lemma 1 (lines L2 and L3). After line L3 has run for every nonempty mask, ind[S]=1\mathrm{ind}[S] = 1 if SS is independent and 00 otherwise, for every SS.

Proof. Induction on the mask value. ind[∅]=1\mathrm{ind}[\emptyset] = 1 and ∅\emptyset is independent. For S≠∅S \ne \emptyset, let vv be its smallest vertex. The mask of S−vS - v is smaller, so ind[S−v]\mathrm{ind}[S - v] is already correct when SS is processed. SS is independent if and only if S−vS - v is independent and vv has no neighbor in S−vS - v; since v∉N(v)v \notin N(v), the second condition is N(v)∩S=∅N(v) \cap S = \emptyset. □\square

Lemma 2 (lines L4 and L5). After line L5 has run for every vertex, f[S]=f(S)f[S] = f(S) for every SS.

Proof. Let v1,…,vnv_1, \ldots, v_n be the vertices in the order of line L4, and Dj={v1,…,vj}D_j = \{v_1, \ldots, v_j\}. We claim that after the first jj rounds,

f[S]=∑{ind[T]:T⊆S, S∖T⊆Dj}.f[S] = \sum \{ \mathrm{ind}[T] : T \subseteq S,\ S \setminus T \subseteq D_j \}.

For j=0j = 0 the only such TT is SS, and f=indf = \mathrm{ind}. In round jj, line L5 changes only the entries f[S]f[S] with vj∈Sv_j \in S, and it reads f[S−vj]f[S - v_j], which round jj does not change because vj∉S−vjv_j \notin S - v_j. So, for vj∈Sv_j \in S, the new f[S]f[S] is the sum of the old f[S]f[S] and the old f[S−vj]f[S - v_j]. By the claim for j−1j - 1, the first sums over the T⊆ST \subseteq S with S∖T⊆Dj−1S \setminus T \subseteq D_{j-1}, which are those with vj∈Tv_j \in T; the second sums over the T⊆S−vjT \subseteq S - v_j with (S−vj)∖T⊆Dj−1(S - v_j) \setminus T \subseteq D_{j-1}, which are those with vj∉Tv_j \notin T. Together they are the T⊆ST \subseteq S with S∖T⊆DjS \setminus T \subseteq D_j. For vj∉Sv_j \notin S, no T⊆ST \subseteq S differs from SS at vjv_j, and the entry is already right. After round nn, Dn=VD_n = V, so f[S]=∑T⊆Sind[T]=f(S)f[S] = \sum_{T \subseteq S} \mathrm{ind}[T] = f(S) by Lemma 1. □\square

Lemma 3 (covers). For every k≥1k \ge 1, the value cc of line L7 equals the number covk\mathrm{cov}_k of kk-tuples (I1,…,Ik)(I_1, \ldots, I_k) of independent sets with I1∪⋯∪Ik=VI_1 \cup \cdots \cup I_k = V.

Proof. By Lemma 2, f(S)kf(S)^k is the number of kk-tuples of independent sets that all lie in SS, that is, whose union UU satisfies U⊆SU \subseteq S. So

c=∑S⊆V(−1)n−∣S∣f(S)k=∑(I1,…,Ik) ∑U⊆S⊆V(−1)n−∣S∣,c = \sum_{S \subseteq V} (-1)^{n - |S|} f(S)^k = \sum_{(I_1, \ldots, I_k)} \ \sum_{U \subseteq S \subseteq V} (-1)^{n - |S|},

where the outer sum on the right runs over all kk-tuples of independent sets and UU is the union of the tuple. Writing S=U∪RS = U \cup R with R⊆V∖UR \subseteq V \setminus U, and r=∣V∖U∣r = |V \setminus U|, the inner sum is ∑R(−1)r−∣R∣=(1−1)r\sum_{R} (-1)^{r - |R|} = (1 - 1)^r, which is 1 if r=0r = 0 and 0 if r>0r > 0. So each tuple with union VV counts once and every other tuple counts zero. □\square

Lemma 4. For k≥1k \ge 1, covk>0\mathrm{cov}_k > 0 if and only if χ(G)≤k\chi(G) \le k.

Proof. If c:V→{1,…,k}c : V \to \{1, \ldots, k\} is a proper coloring, the color classes Ii=c−1(i)I_i = c^{-1}(i) are independent, possibly empty, and their union is VV, so covk≥1\mathrm{cov}_k \ge 1. Conversely, given a cover (I1,…,Ik)(I_1, \ldots, I_k) by independent sets, color each vertex vv with the least ii such that v∈Iiv \in I_i. Every vertex gets a color, since the union is VV. If uvuv is an edge and both get color ii, then u,v∈Iiu, v \in I_i, which contradicts independence. So this is a proper coloring with at most kk colors. □\square

Theorem. BJORKLUND-CHROMATIC(G)(G) terminates and returns χ(G)\chi(G).

Proof. The case n=0n = 0 is line L1. For n≥1n \ge 1, lines L2 to L5 are loops over finite ranges. The loop of line L6 tries k=1,2,…,nk = 1, 2, \ldots, n in order. By Lemmas 3 and 4, at round kk line L8 returns exactly when χ(G)≤k\chi(G) \le k. Since 1≤χ(G)≤n1 \le \chi(G) \le n, because the nn singletons form a proper coloring, the loop returns at round k=χ(G)k = \chi(G) and not before. In the implementation, line L7 builds f(S)kf(S)^k as the product of the stored f(S)k−1f(S)^{k-1} and f(S)f(S), which equals the value in the pseudocode. ■\blacksquare

Back to Björklund's chromatic number algorithm