Balanced Judicious Partition is Fixed-Parameter Tractable

The family of judicious partitioning problems, introduced by Bollob\'as and Scott to the field of extremal combinatorics, has been extensively studied from a structural point of view for over two decades. This rich realm of problems aims to counterbalance the objectives of classical partitioning problems such as Min Cut, Min Bisection and Max Cut. While these classical problems focus solely on the minimization/maximization of the number of edges crossing the cut, judicious (bi)partitioning problems ask the natural question of the minimization/maximization of the number of edges lying in the (two) sides of the cut. In particular, Judicious Bipartition (JB) seeks a bipartition that is"judicious"in the sense that neither side is burdened by too many edges, and Balanced JB also requires that the sizes of the sides themselves are"balanced"in the sense that neither of them is too large. Both of these problems were defined in the work by Bollob\'as and Scott, and have received notable scientific attention since then. In this paper, we shed light on the study of judicious partitioning problems from the viewpoint of algorithm design. Specifically, we prove that BJB is FPT (which also proves that JB is FPT).


Introduction
More than twenty years ago, Bollobás and Scott [3] defined the notion of judicious partitioning problems. Since then, the family of judicious partitioning problems has been extensively studied in the field of Extremal Combinatorics, as can be evidenced by the abundance of structural results described in surveys such as [7,36]. This rich realm of problems aims to counterbalance the objectives of classical partitioning problems such as Min Cut, Min Bisection, Max Cut and Max Bisection. While these classical problems focus solely on the minimization/maximization of the number of edges crossing the cut, judicious (bi)partitioning problems ask the natural questions of the minimization/maximization of the number of edges lying in the (two) sides of the cut. Another significant feature of judicious partitioning problems that also distinguishes them from other classical partitioning problems is that they inherently and naturally encompass several objectives, aiming to minimize (or maximize) the number of edges in several sets simultaneously.
In this paper, we shed light on properties of judicious partitioning problems from the viewpoint of the design of algorithms. Up until now, the study of such problems has essentially been overlooked at the algorithmic front, where one of the underlying reasons for this discrepancy might be that standard machinery does not seem to handle them effectively. Specifically, we focus on the Judicious Bipartition problem, where we seek a bipartition that is "judicious" in the sense that neither side is burdened by too many edges, and on the Balanced Judicious Bipartition problem, where we also require that the sizes of the sides themselves are "balanced" in the sense that neither of them is too large. Both of these problems were defined in the work by Bollobás and Scott, and have received notable scientific attention since then. Formally, Balanced Judicious Partition is defined as follows.
We note that in the literature, the term BJB refers to the case where µ = |V (G)| 2 , and hence it is more restricted then the definition above. By dropping the requirement that |V 1 | = µ, we get the Judicious Bipartition (JB) problem. By using new crucial insights into these problems on top of the most advanced machinery in Parameterized Complexity to handle partitioning problems, 1 we are able to resolve the question of the Parameterized Complexity of BJB (and hence also of JB). In particular, we prove the following theorem. Structural Results. Denote n = |V (G)| and m = |E(G)|. To survey several structural results about judicious partitioning problems, we first define the notions of t-cut and max (min) t-judicious partitioning. Given a partition of V (G) into t parts, a t-cut is the number of edges going across the parts, while a max (min) judicious t-partitioning is the maximum (minimum) number of edges in any of the parts. When t = 2, we use the standard terms bipartite-cut and judicious bipartitioning, respectively. Furthermore, by t-judicious partitioning we mean max t-judicious partitioning. As stated earlier, Bollobás and Scott [3] defined the notion of judicious partitioning problems in 1993. In that paper, they showed that for any positive integer t and graph G, we can partition V (G) into t sets, V 1 , . . . , V t , so that |E(G[V i ])| ≤ t t+1 m for all i ∈ {1, . . . , t}. Bollobás and Scott also studied this problem on graphs of maximum degree ∆, and showed that there exists a partition of V (G) into t sets V 1 , . . . , V t so that it simultaneously satisfies an upper bound and a lower bound on the number of edges in each part as well as on edges between every pair of parts. Later, Bollobás and Scott [7] gave several new results, leaving open other new questions around judicious partitioning. In [8] they showed an optimal bound for judicious partitioning on bounded-degree graphs. These problems have also been studied on general hypergraphs [4], uniform hypergraphs [24], 3-uniform hypergraphs [6] and directed graphs [26].
The special cases of judicious partitioning problems called judicious bipartitioning and balanced judicious bipartitioning problems have also been studied intensively. Bollobás and Scott [5] proved an upper bound on judicious bipartitioning and proved that every graph that achieves the essentially best known lower bound on bipartite-cut, given by Edwards in [18] and [19], also achieves this upper bound for judicious bipartitioning. In fact, they showed that this is exact for complete graphs of odd order, which are the only extremal graphs without isolated vertices. Alon et al. [1] gave a non-trivial connection between the size of a bipartite-cut in a graph and judicious partitioning into two sets. In particular, they showed that if a graph has a bipartite-cut of size at least m 2 + δ where δ ≤ m/30, then there exists a bipartition (V 1 , V 2 ) of V (G) such that |E(G[V i ])| ≤ m 4 − δ 2 + 10δ 2 m + 3 √ m for i ∈ {1, 2}. They complemented these results by showing an upper bound on the number of edges in each part when δ > m/30. Bollobás and Scott [9] studied similar relations between t-cuts and t-judicious partitionings for t ≥ 3. Recently, these results were further refined [39,28]. Xu et al. [38] and Xu and Yu [40] studied balanced judicious bipartitioning where both parts are of almost equal size (that is, one of the sizes is n 2 ). Both of these papers concern the following conjecture of Bollobás and Scott [7]: if G is a graph with minimum degree of at least 2, then V (G) admits a balanced bipartition (V 1 , V 2 ) such that for each i ∈ {1, 2}, |E(G[V i ])| ≤ m 3 . For further results on judicious partitioning, we refer to the surveys [7,36]. Algorithmic Results. While classical partitioning problems such as Min Cut, Min Bisection, Max Cut and Max Bisection have been studied extensively algorithmically, the same is not true about judicious partitioning problems. Apart from Min Cut, all the above mentioned partitioning problems are NP-complete. These NP-complete partitioning problems were investigated by all algorithmic paradigms meant for coping with NP-complete, including approximation algorithms and parameterized complexity. In what follows, we discuss known results related to these problems in the realm of parameterized complexity.
First, note that for every graph G, there always exists a bipartition of the vertex set into two parts (in fact equal parts [22,Corollory 1]) such that at least m/2 edges are going across. This immediately implies that Max Cut and Max Bisection are FPT when parameterized by the cut size (the number of edges going across the partition). This led Mahajan and Raman [29] to introduce the notion of above-guarantee parameterization. In particular, they showed that one can decide whether a graph has a bipartite-cut of size m 2 + k in time O(m + n + k4 k ). However, Edwards [18] showed that every connected graph G has a bipartite-cut of size m 2 + n−1 4 . Thus, a more interesting question asks whether finding a bipartite-cut of size at least m 2 + n−1 4 + k is FPT. Crowston et al. [16] showed that indeed this is the case as they design an algorithm with running time O(8 k n 4 ). Recently, Etscheid and Mnich [20] discovered a kernel with a linear number of vertices (improving upon a kernel by Crowston et al. [15]), and the aforementioned algorithm was sped-up to run in time O(8 k m) [20]. Gutin and Yeo studied an above-guarantee version of Max Bisection [22], proving that finding a balanced bipartition such that it has at least m 2 + k edges is FPT (also see [33]). 2 In this context Max Bisection, it is also relevant to mention the (k, n − k)-Max Cut, which asks for a bipartite-cut of size at least p where one of the sides is of size exactly k. Parameterized by k, this problems is W[1]-hard [11], but parameterized by p, this problem is solvable in time O * (2 p ) [35] (this result improved upon algorithms given in [10,37]).
Until recently, the parameterized complexity of Min Bisection was open. Approaches to tackle this problem materialized when the parameterized complexity of -Way Cut was resolved. Here, given a graph G and positive integers k and , the objective is to delete at most k edges from G such that it has at least components. Kawarabayashi and Thorup [25] showed that this problem is FPT. Later, Chitnis et al. [13] developed a completely new tool based on this, called randomized contractions, to deal with plethora of cut problems. Other cut problems that have been shown to be FPT include the generalization of Min Cut to Multiway Cut and Multicut [12,31,32]. Eventually, Cygan et al. [17], combining ideas underlying the algorithms developed for Multiway Cut, Multicut, -Way Cut and randomized contractions together with a new kind of decomposition, showed Min Bisection to be FPT. Finally, let us also mention the min c-judicious partitioning (which is a maximization problem), called c-Load Coloring, where given a graph G and a positive integer k, the goal is to decide whether V (G) can be partitioned into c parts so that each part has at least k edges. Barbero et al. [2] showed that this problem is FPT (also see [21]).
Despite the abundance of work described above, the parameterized complexity of JB and BJB has not yet considered. We fill this gap in our studies by showing that both of these problems are FPT. It is noteworthy to remark that one can show that the generalization of Min Bisection to c-Min Bisection, where the objective is to find a partition into c-parts such that each part are almost equal and there are at most k edges going across different parts, is FPT [17]. However, such a generlization is not possible for either JB or BJB. Indeed, even the existence of an algorithm with running time n f (k) , for any arbitrary function f , would imply a polynomial-time algorithm for 3-Coloring, where k is set to 0. Our Approach. For the sake of readability, our strategy of presentation of our proof consists of the definition of a series of problems, each more "specialized" (in some sense) than the previous one, where each section shows that to eventually solve BJB, it is sufficient to focus on some such problem rather than the previous one. We start by showing that we can focus on the solution of the case of BJB where the input graph is bipartite at the cost of the addition of annotations. For this purpose, we present a (not complicated) Turing reduction that employes a known algorithm for the Odd Cycle Transversal problem (see Section 3). The usefulness of the ability to assume that the input graph is bipartite is a key insight in our approach. In particular, the technical parts of our proof crucially rely on the observation that a connected bipartite graph has only two bipartitions (here, we consider bipartitions as ordered pairs). Keeping this intuition in mind, our next step is to reduce the current annotated problem to one where the input graph is also assumed to be connected (this specific argument relies on a simple application of dynamic programming).
Having at hand an (annotated) problem where the input graph is assumed to be a connected bipartite graph, we proceed to the technical part of our proof, which employs the (heavy) machinery developed by Cygan et al. [17]. While this machinery primarily aims to tackle problems where one seeks small cuts in addition to some size constraint, our problem involves a priori seemingly different type of constraints. Nevertheless, we observe that once we handle a connected graph, the removal of any set of k edges (to deal with the size constraint and annotations) would not break the graph to more than k + 1 connected components, and each of these components would clearly be a bipartite graph. Hence, we can view (in some sense) our problem as a cut problem. In practice, the relation between our problem and a cut problem is quite more intricate, and to realize our idea, we crucially rely on the fact that the connected components are bipartite graphs, which allows us to "guess" a binary vector specifying the biparition of their vertex sets in the final solution. This operation entitles the employment of coloring functions (employing k + 1 colors) and their translation into bipartitions (which at a certain point in our paper, we would start viewing as colorings employing two colors). Let us remark that the machinery introduced by [17] is the computation of a special type of tree decomposition. Accordingly, our approach would eventually involve the introduction of a specialization of BJB that aims to capture the work to perform when handling a bag of the tree decomposition. The definition of this specific problem is very technical, and hence we defer the description of related intuitive explanations to the appropriate locations in Section 5, where we have already set up the required notations to discuss it.

Preliminaries
General Notation. Let f : A → B be some function. Given A ⊆ A, the notation f (A ) = b indicates that for all a ∈ A , it holds that f (a) = b. An extension f of the function f is a function whose domain A is a superset of A and whose range is B, such that for all a ∈ A, it holds that f (a) = f (a). For any Graph Theory. Given a graph G, we let V (G) and E(G) denote the vertex-set and the edge-set of G, respectively. For a subset A ⊆ V (G), we denote by δ(A) the set of boundary vertices of A, that is, δ(A) = {v ∈ A : there exists u ∈ V (G) \ A such that {u, v} ∈ E(G)}. We let G \ A denote the subgraph of G induced by V (G) \ A. A bipartite graph is a graph G such that there exists a bipartition (X, Y ) of V (G) where X and Y are independent sets. In this paper, we treat such bipartitions as ordered pairs. That is, if (X, Y ) is a bipartition of some bipartite graph G, then (Y, X) is assumed to be a different bipartition of the graph G. For connected bipartite graphs, we have the following simple yet powerful insight.
The treewidth of a graph aims to measure how close the graph is to a tree. Formally, this notion is defined as follows.

Definition 1.
A tree decomposition of a graph G is a pair (T, β) such that T is a rooted tree, β : V (T ) → 2 V (G) , and the following conditions are satisfied.
Given t, t ∈ V (G), the notation t t indicates that t is a descendant of t in T . Note that t is a descendant of itself. For any t ∈ V (T ), let t denote the unique parent of t in T . We also need the standard notations σ(t) = β(t) ∩ β(t ) and γ(t) = t t β( t).
Proposition 2 (Folklore). Let (T, β) be a tree decomposition of a graph G. Given a node t ∈ V (T ), let t 1 , . . . , t s denote the children of t in T , and for all i . Then, the vertex-set of each connected component of G \ β(t) is a subset of one of V t1 , . . . , V ts , V t .
Let H be some hypergraph. A spanning forest of H is a subset E ⊆ E(H) of minimum size such that the set containing all endpoints of the hyperedges in E is equal to V (H). In this paper, we implicitly assume that hypergraphs contain no isolated vertices. Unbreakability. A separation of a graph G is a pair (X, Y ) such that X, Y ⊆ V (G) and X ∪ Y = V (G). The order of a separation (X, Y ) is equal to |X ∩ Y |.
We also define a notion of unbreakability in the context of functions.
Let us now claim that there do no exist "too many" (q, k)-unbreakable functions.
Lemma 1. For all q, k ∈ N, the number of (q, k)-unbreakable functions from a universe U to

Solving Balanced Judicious Bipartition
In this section, we prove Theorem 1 under the assumption that we are given an algorithm for an annotated, yet restricted, variant of BJB. Throughout this section, an instance of BJB is denoted by BJB(G, µ, k 1 , k 2 ), and we define k = k 1 + k 2 . Given a partition (V 1 , V 2 ) that witnesses that an instance BJB(G, µ, k 1 , k 2 ) is a YES-instance, we think of the vertices in V 1 as colored 1 and the vertices in V 2 as colored 2; hence, we call such a partition a witnessing coloring of BJB(G, µ, k 1 , k 2 ). To prove Theorem 1, we first define the Odd Cycle Transversal problem. Here, given a graph G, a set S ⊆ V (G) is called an odd cycle transversal if G \ S is a bipartite graph.
Odd Cycle Transversal (OCT) Parameter: k Input: An undirected multi-graph graph G, and an integer k. Question: Does G have an odd cycle transversal of size at most k?
An instance of Odd Cycle Transversal is denoted by OCT(G, k). The algorithm given by the result below shall be a central component in the design of our algorithm for BJB. Apart from OCT, we also need to define an auxiliary problem that we call Annotated Bipartite-BJB (AB-BJB). As we proceed with our proofs, we shall continue defining auxiliary problems, where each problem captures a task more specific and technically more challenging than the previous one. The choice of this structure aims to ease the readability of our paper. Intuitively, AB-BJB is basically the BJB problem on bipartite graphs, with an extra constraint that demands that certain vertices are assigned a particular color by the witnessing coloring. We remark that the necessity of the reduction to bipartite graphs stems from the fact that we would like to employ Proposition 1 later. The formal definition of AB-BJB is given below.

Annotated Bipartite-BJB (AB-BJB)
Parameter: k 1 + k 2 Input: A bipartite multi-graph G with bipartition (P, Q), A, B ⊆ V (G) such that A ∩ B = ∅, and integers µ, k 1 and k 2 . Question: Does there exist a partition ( An instance of AB-BJB is denoted by AB-BJB(G, A, B, µ, k 1 , k 2 ). A partition (V 1 , V 2 ) satisfying the above properties is called a witnessing coloring of AB-BJB(G, A, B, µ, k 1 , k 2 ). Furthermore, we need the following theorem, proven later in this paper.
Let us now turn to focus on the proof of Theorem 1.
Proof of Theorem 1. Given an instance BJB(G, µ, k 1 , k 2 ), call the algorithm given by Proposition 3 with the instance OCT(G, k) as input.
. Then, observe that G \ E is a bipartite graph. Let V be a set of vertices of minimum size such that every edge in E has at least one endpoint in V . Since |E | ≤ k, it holds that |V | ≤ k. Moreover, G \ V is bipartite. Therefore, V is an odd cycle transversal of G of size at most k. Thus, OCT(G, k) is a YES-instance.
Henceforth, let S be an odd cycle transversal of G of size at most k. Then, G \ S is a bipartite graph. Fix some bipartition (P, Q) of G \ S. Let F be the family of all subsets of S, that is, F = 2 S . For any F ∈ F, , and let G F be the graph constructed as follows (see Fig. 1).
Observe that G F is a bipartite graph with (P ∪ {x F , y F }, Q ∪ {w F , z F }) as a bipartition.
In the forward direction, suppose that BJB(G, µ, k 1 , k 2 ) is a YES-instance, and let (V 1 , V 2 ) be a witnessing coloring for BJB(G, µ, k 1 , k 2 ). Moreover, let F = V 1 ∩ S. Now, we define a partition (V 1 , V 2 ) of V (G F ) as follows: is a YES-instance, and let (V 1 , V 2 ) be a witnessing coloring for this instance. We now define a partition (V 1 , V 2 ) of V (G) as follows: This concludes the proof of the claim. Thus, to solve an instance of BJB, it is enough to solve 2 |S| ≤ 2 k instances of AB-BJB. Hence, by Theorem 2, BJB can be solved in time 2 k O(1) n O(1) .

Solving Annotated Bipartite-BJB
Recall the problem definition of Annotated Bipartite-BJB (AB-BJB) from Section 3. In this section, we prove Theorem 2. For this purpose, let us define another auxiliary problem, which we call Annotated Bipartite Connected-BJB (ABC-BJB). Intuitively, ABC-BJB is exactly the same problem as AB-BJB where we are interested in an answer for every choice of µ ∈ [n] 0 , l 1 ∈ [k 1 ] 0 and l 2 ∈ [k 2 ] 0 , and additionally we demand the input graph to be connected.
Having Theorem 3 at hand, a simple application of the method of dynamic programming results in the proof of Theorem 2. Proof of Theorem 2. Let AB-BJB(G, A, B, µ, k 1 , k 2 ) be an instance of AB-BJB. Let C 1 , . . . , C r be the con- Let aJP i be the output table for the instance I i , returned by the algorithm of Theorem 3. For any j ∈ [r], let C i ]. Note that G = G r . Let us define a 4-dimensional binary table M in the following way. For all recursively using the following recurrences.
where for all j ∈ {1, 2}, µ j , l j 1 and l j 2 are non-negative integers. Note that the time taken to compute M[r, µ, k 1 , k 2 ] is at most (r · n 2 · k 2 1 · k 2 2 · τ ), where τ is the time taken to solve an instance of ABC-BJB. Since from Theorem 3, an instance of ABC-BJB can be solved in time

Solving Annotated Bipartite Connected-BJB
Recall the problem definition of ABC-BJB from Section 5. In this section, we prove Theorem 3. Let us start by stating a known result that is a crucial component of our proof. By this result, we would have an algorithm that efficiently computes a special type of tree decomposition, that we call a highly connected tree decomposition, where every bag is "highly-connected" rather than "small" as in the case of standard tree decompositions. While this property is the main feature of this decomposition, it is also equipped with other beneficial properties, such as a (non-trivial) upper bound on the size of its adhesions, which are all exploited by our algorithm.

Theorem 4 ([17]
). There exists an 2 O(k 2 ) n 2 m-time algorithm that, given a connected graph G together with an integer k, computes a tree decomposition (T, β) of G with at most n nodes such that the following conditions hold, where η = 2 O(k) .

For each non-root
In order to process such a tree decomposition in a bottom-up fashion, relying on the method of dynamic programming, we need to address a specific problem associated with every bag, called Hypergraph Painting (HP). We chose the name HP to be consistent with the choice of problem name in [17], yet we stress that our problem is more general than the one in [17] (since the handling of a bag in our case is more intricate than the one in [17]).
Roughly speaking, an input of HP would consist of the following components. First, we are given "budget" parameters k 1 and k 2 as in an instance of ABC-BJB. Second, we are given an argument b which would simply be n (to upper bound |γ(t)|) when we construct an instance of HP while processing some node t in the tree decomposition. Third, we are given a hypergraph H which would essentially be the graph G[β(t)] to which we add hyperedges that are supposed to represent the sets σ( t) for the children t of t. Fourth, we are given an integer q whose purpose is clarified in the discussion below the definition of HP (in Definition 6). Finally, for every hyperedge F , we are given a function f F : To roughly understand the meaning of this function, first recall that F is supposed to represent σ( t) for some child t of t. Now, the function f F aims to capture all information obtained while we processed the child t of t that might be relevant to the node t. In particular, let us give an informal, intuitive interpretation of an element (Γ, µ, l 1 , l 2 ) in the domain of f F . For this purpose, note that when we remove at most k edges from the (connected) graph G[γ( t)], we obtain at most k + 1 connected components. The function Γ can be thought of as a method to assign to each vertex in σ( t) the connected component in which it should lie. Such information is extremely useful since each such connected component is in particular a bipartite graph, and hence by relying on Proposition 1 and an exhaustive search, we would be able to use it to extract a witnessing coloring for an instance of ABC-BJB. The arguments µ, l 1 and l 2 can be thought of as those in the definition of an output of ABC-BJB. Now, the value f F (Γ, µ, l 1 , l 2 ) aims to indicate whether Γ, µ, l 1 and l 2 are "realizable" in the context of the child t (the precise meaning of this value would become clearer later, once we establish additional necessary definitions.) Let us now give the formal definition of HP. In this definition, we denote k = k 1 + k 2 .
Hypergraph Painting (HP) Input: Integers k 1 , k 2 , b, d and q, a multi-hypergraph H with hyperedges of size at most d, and for all For a particular choice of µ, l 1 and l 2 , a function Υ witnessing that aHP[µ, l 1 , l 2 ] = 1 is called a witnessing coloring for aHP[µ, l 1 , l 2 ]. An instance of Hypergraph Painting is denoted by Although we are not able to tackle HP efficiently at its full generality, we are still able to solve those instances that are constructed when we would like to "handle" a single bag in a highly connected tree decomposition. For the sake of clarity, let us now address the beneficial properties that these instances satisfy individually, where each of them ultimately aims to ease our search for a witnessing coloring. The first property, called local unbreakability, unconditionally restricts the way a function Γ : F → [k] 0 , to be thought of as a restriction of the witnessing coloring we seek, can color a hyperedge F so that the value of f F is 1. 3 Definition 4 (Local Unbreakability). An instance HP(k 1 , k 2 , b, d, q, H, {f F }| F ∈E(H) ) is locally unbreakable if every F ∈ E(H) satisfies the following property: for any Γ : The second property, called connectivity, implies that if we would like to use a function Γ : F → [k] 0 to color a hyperedge (as a restriction of a witnessing coloring) with more than one color, then we would have to "pay" at least 1 from our budget l 1 + l 2 .
The third property, called global unbreakability, directly restricts our "solution space" by implying that we only need to determine whether there exists a (q, k)-unbreakable witnessing coloring.
is called a favorable instance of HP if it is locally unbreakable, connected and globally unbreakable. For such instances we have the following theorem.

Theorem 5. HP on favorable instances is solvable in time
The proof of this theorem is very technical, involving non-trivial analysis of a very "messy" picture obtained by guessing part of a hypothetical witnessing coloring via the method of color coding. We defer the proof of Theorem 5 to Section 6.
From now onwards, to simplify the presentation of arguments ahead with respect to ABC-BJB, we would abuse notation and directly define a witnessing coloring as a function rather than a partition. More precisely, the term witnessing coloring for aJP[µ, l 1 , l 2 ] = 1 would refer to a function col : To proceed to our proof of Theorem 3, we first need to introduce an additional notation. Roughly speaking, this notation translates a coloring Υ of the form that witnesses some aHP[µ, l 1 , l 2 ] = 1 to a coloring of the form that witnesses aJP[µ, l 1 , Suppose we are given an instance ABC-BJB(G, A, B, k 1 , k 2 ). Fix some bipartition (P, Q) of G. Let (T, β) be the highly connected tree decomposition computed by the algorithm of Theorem 4, and let r be the root of T . In what follows, η = 2 O(k) as in Theorem 4, and q = (η + k)k. We now proceed to define a binary variable that is supposed to represent the answer we would like to compute when we process the bag of a specific node of the tree. Hence, one of the arguments is a node t, and three additional arguments are µ ∈ [n] 0 , l 1 ∈ [k 1 ] 0 and l 2 ∈ [k 2 ] 0 . However, we cannot be satisfied with one answer, but need an answer for every possible "interaction" between the bag of t and the bag of its parent t . Thus, the definition also includes a coloring of σ(t). The tuple v ∈ {0, 1} k+1 is necessary for the translation process described in Definition 7 (the way in which we shall obtain such a "right" tuple later in the proof would essentially rely on brute-force).

For all
4. The set of edges between vertices receiving different colors by Υ is exactly the set of edges between vertices that are mapped to the same side by the translation Υ v , that is, A function Υ as above is called a witnessing coloring for y[t, Υ σ , v, µ, l 1 , l 2 ]. Proof. Let us prove the backward direction first. Let v ∈ {0, 1} k+1 be such that y[r, ∅, v, µ, l 1 , l 2 ] = 1 and let Υ : V (G) → [k] 0 be one of its witnessing coloring. Then, Definition 8 directly implies that Υ v is a witnessing coloring for aJP[µ, l 1 , l 2 ] = 1. For the forward direction, let col : V (G) → {V 1 , V 2 } be a witnessing coloring for aJP[µ, l 1 , l 2 ]. Let ). Let C 0 , . . . , C r be the connected components of G \ X. Since X ⊆ E(G) and |X| ≤ l 1 + l 2 ≤ k 1 + k 2 = k, we have that the number of connected components r is upper bounded by k. For any i ∈ [r] 0 , let (P i = (P ∩ C i ), Q i = (Q ∩ C i )) be a bipartition of C i (recall that G is a connected bipartite graph with fixed bipartition (P, Q)).

Claim 3. For any
. Since C i is connected, from Proposition 1, either P i ⊆ P i and Q i ⊆ Q i , or P i ⊆ Q i and Q i ⊆ P i . Hence the claim follows.
Let us now construct a k-length binary string, v, as follows. For any , and note that j ∈ {1, 2}, i ∈ [k] 0 and b ∈ {0, 1}. We divide the argument into two cases corresponding to whether Since the choice of v was arbitrary, by the definition of Υ v , we have that Υ v (v) = V j .
Claim 5. For the binary string v constructed as above, the function Υ constructed above is a witnessing coloring for y[r, ∅, v, µ, l 1 , l 2 ] = 1.
This concludes the proof of the lemma.
By Lemma 2, it is sufficient to compute y[r, φ, v, µ, l 1 , l 2 ] for all µ ∈ [n], l 1 ∈ [k 1 ] 0 and l 2 ∈ [k 2 ] 0 . To this end, we need to compute y[t, Υ σ , v, µ, l 1 , l 2 ] for every node t ∈ V (T ), function Υ σ : Here, we employ bottom-up dynamic programming over the tree decomposition (T, β). Let us now zoom into the computation of y[t, Υ σ , v, µ, l 1 , l 2 ] for all µ ∈ [n], l 1 ∈ [k 1 ] 0 and l 2 ∈ [k 2 ] 0 , for some specific t, Υ σ and v. Note that we now assume that values corresponding to the children of t (if such children exist) have been already computed correctly. Moreover, note that |σ(t)| ≤ η, the number of (3k 2 , k)-unbreakable functions Υ σ : Lemma 1), and the number of binary vectors of size k + 1 is at most 2 k+1 . Thus, the total running time would consist of the computation time of (T, β), and n · q O(k) · 2 k+1 times the computation time for a set of values as the one we examine now. Hence, it remains to show how to compute the current set of values in time 2 k O(1) .
To compute our current set of values, let us construct an instance HP(k 1 , k 2 , n, η, q, H, {f F }| F ∈E(H) ) of HP where V (H) = β(t), and E(H) and {f F }| F ∈E(H) are defined as follows.
. Let us first claim that witnessing colorings related to HP(k 1 , k 2 , n, η, q, H, {f F }| F ∈E(H) ) are useful in the sense that they can be extended to witnessing colorings for the binary values in which we are interested. l F 2 ≤ l 2 , such that for all F ∈ E(H), f F (Υ| F , µ F , l F 1 , l F 2 ) = 1. In particular, the following conditions hold.

For any
We thus derive that there exists a witnessing coloring Υ i : γ(t i ) → [k] 0 for the condition y[t i , Υ| F , µ F + µ , l F 1 + l 1 , l F 2 + l 2 ] = 1. Specifically, the following conditions are satisfied.
Keeping the above items in mind, we proceed to identify a witnessing coloring for y[t, Υ σ , v, µ, l 1 , l 2 ] = 1. We construct such a coloring Υ : γ(t) → [k] 0 as follows. For all v ∈ γ(t), if v ∈ β(t), then define Υ (v) = Υ(v), and otherwise there exists a unique child t i of t such that v ∈ γ(t i ), in which case we define Υ (v) = Υ i (v). For the sake of clarity, let us extract the required argument to the proof of a separate claim. Claim 6. The aforementioned Υ is a witnessing coloring for y[t, Υ σ , v, µ, l 1 , l 2 ] = 1.
Proof. First, note that by Item 1, we have that Υ σ ⊆ Υ and therefore Υ σ ⊆ Υ . Let us now verify that all of the other conditions specified in Definition 8 are satisfied.
• Let us first prove Condition 1. To this end, we observe that by Items 1, 3a and 3b, we have that the three following equalities hold.

Thus, since
F is a type-2 hyperedge • Next, we prove Condition 2. However, by Items 1 and 3c, we directly deduce that both A ∩ γ(t) ⊆ • We now turn to prove Condition 3. In light of Item 3a, note that Now, observe that by Items 2, 3a and 3d, the two following equations hold.
• Finally, we prove Condition 4. In the first direction, consider some edge e ∈ E( ). Let us denote e = {u, v}, and observe that Υ v (v) = Υ v (u). If u, v ∈ γ(t i ) for some child t i of t, then by Item 3e, we have that e ∈ i,j∈[k]0, i =j E(Υ −1 (i), Υ −1 (j)). Otherwise, u, v ∈ β(t), and thus e is some type- In the other direction, consider some edge e ∈ i,j∈[k]0, i =j E(Υ −1 (i), Υ −1 (j)). Let us denote e = {u, v}, and observe that Υ (v) = Υ (u). If u, v ∈ γ(t i ) for some child t i of t, then by Item 3e, we have that . Otherwise, u, v ∈ β(t), and thus e is some type-2 hyperedge F .
Thus, we have proved that Υ is a witnessing coloring for y[t, Υ σ , v, µ, l 1 , l 2 ]. Moreover, Υ , which extends Υ, is the desired function for the second part of the lemma.
This concludes the proof of the lemma.
In light of Lemma 3, we now turn to verify that HP(k 1 , k 2 , n, η, q, H, {f F }| F ∈E(H) ) is of the form that we are actually able to solve. Proof. Let us verify that each of the three properties of a favorable instance is satisfied.
• Local Unbreakability: Let us choose an arbitrary F ∈ E(H). If F is a type-1 or a type-2 hyperedge, then since |F | ≤ 2, we have that local unbreakability is trivially satisfied. Otherwise, if F is a type-3 hyperedge, then the satisfaction of local unbreakability directly follows from the construction of f F .
• Connectivity: Choose an arbitrary F ∈ E(H) along with a tuple (Γ, µ, l 1 , l 2 ) in the domain of f F such that f F (Γ, µ, l 1 , l 2 ) = 1. If F is a type-1 hyperedge, then connectivity trivially holds. If F is a type-2 hyperedge, then connectivity follows from the construction of f F . Indeed, to see this, let us denote F = {u, v}. Then, if Γ(u) = Γ(v), by the second and last cases in the definition of f F , we deduce that Γ v (u) = Γ v (v), else we contradict the supposition that f F (Γ, µ, l 1 , l 2 ) = 1. Then, connectivity directly follows from the third and fourth cases. Now, suppose that F = σ( t) is a type-3 hyperedge, and say Γ : We need to show that l 1 + l 2 ≥ 1. Since f F (Γ, µ, l 1 , l 2 ) = 1, it holds that y[ t, Γ, µ + µ , l 1 + l 1 , l 2 + l 2 ] = 1, where µ , l 1 and l 2 are as defined at the construction of f F . Let Υ : γ( t) → [k] 0 denote some witnessing coloring for this condition. Since (T, β) is a highly connected tree decomposition, the Property 1 of such a decomposition implies that ) is connected and that every vertex in σ( t has at least one vertex in V (G * ) that is its neighbor in G[γ( t]. In particular, every two vertices in σ( t) are connected by a path in G * (observe that V (G * ) = γ( t) as we have only edges are discarded when G[γ( t)] is modified to be G * ). Let u ∈ Γ −1 (i) and v ∈ Γ −1 (j). Note that u = v and i = j. Since u and v are connected by a path in G * , we derive that G * has an edge e such that Recall that . Therefore, we have that . Thus, by the inductive hypothesis, l 1 + l 2 ≥ 1. • Global Unbreakability: Suppose that aHP[µ, l 1 , l 2 ] = 1. Then, by Lemma 5, there exists Υ : γ(t) → [k] 0 satisfying the properties listed in that lemma. From here, we get that We argue that Υ | β(t) is a witnessing coloring for global unbreakability, that is, this function is (q, k)-unbreakable. In this context, we remind that q = (η + k)k. To prove our argument, we first prove the following claim.
Proof. Suppose that the claim is false. Then, both |Υ −1 (i) ∩ β(t)| > η + k and is a separation of order at most k of G[γ(t)] as we have already shown that Thus, if there exist i ∈ [k] 0 as defined in Claim 7, then we are done. That is, we conclude that Υ | β(t) is a (q, k)-unbreakable. Otherwise, for all i ∈ [k] 0 , it holds that |Υ −1 (i)| ≤ η + k. In particular, Thus, we again conclude that Υ |β(t) is (q, k)-
To do so, we proceed as follows. First, for any hyperedge F ∈ E(H), let us define µ F , l 1 F and l 2 F as follows.
Having Claim 8 at hand, we now verify that each function f F assigns 1 to the required tuple.
Claim 9. For any F ∈ E(H), f F (Υ| F , µ F , l F 1 , l F 2 ) = 1. Proof. First, note that since Υ be a witnessing coloring for y[t, Υ σ , v, µ, l 1 , . Thus, from the construction of a type-1 hyperedge F and the corresponding function f F with respect to HP (k 1 , k 2 , n, η, q, H, (f F ) F ∈E(H) ), it is clear that f F (Υ| F , µ F , l F 1 , l F 2 ) = 1. Second, suppose F is a type-2 hyperedge. The specifications of f F , together with our definition of µ F , l F 1 and l F 2 , directly implies that f F (Υ| F , µ F , l F 1 , l F 2 ) = 1. Third, suppose that F is a type-3 hyperedge, and denote F = σ(t i ) for some t i that is a child of t in T . Note that y[t i , Υ| F , v, µ F + µ , l F 1 + l 1 , l F 2 + l 2 ] = 1 because Υ| γ(ti) is a witnessing coloring for this equality, where We now need to show that Υ| F is (3k 2 , k)-unbreakable, as then we would be able to conclude that f F (Υ| F , µ F , l F 1 , l F 2 ) = 1. By Claim Finally, we present our third claim.
Proof. By the property of (T, β) being a tree decomposition, for any two children t i and t j of t in T , γ(t i ) ∩ γ(t j ) ⊆ β(t), and also from definition, σ(t i ) ⊆ β(t) for any child t i of t. Now, note that µ = | Υ −1 v (V 1 )|. Thus, to show that µ = F ∈E(H) µ F , it is sufficient to show that | Υ −1 v (V 1 )| = F ∈E(H) µ F . However, keeping the above argument in mind, the claim that | Υ −1 v (V 1 )| = F ∈E(H) µ F directly follows from the satisfaction of the three following conditions. We remark that the satisfaction of these conditions is a direct consequence of the supposition that Υ be a witnessing coloring for y[t, Υ σ , v, µ, l 1 , l 2 ] = 1, together with our definition of the values µ F , l F 1 and l F 2 .
1. For any type-1 hyperedge F , we have that µ F = 1 only if Υ v (F ) = V 1 . In particular, 2. For any type-2 hyperedge F , µ F = 0. Thus, Similarly, let us observe that However, the latter inequality that directly follows from the satisfaction of all of the following conditions.

For any type-3 hyperedge
This concludes the proof of the claim. As we have proved Claims 9 and 10, we derive that Υ| β(t) is a witnessing coloring for aHP[µ, l 1 , l 2 ] = 1. This concludes the proof of the lemma.
Recall that we have argued that to prove Theorem 5, it is sufficient to show that the current set of values y[t, Υ σ , v, µ, l 1 , l 2 ] can be computed in time 2 k O(1) n O(1) . Here, n refers to |V (G)|. By Lemmas 3 and 5, this set of values can be derived from the solution of HP(k 1 , k 2 , n, η, q, H, {f F }| F ∈E(H) ). Since HP(k 1 , k 2 , n, η, q, H, {f F }| F ∈E(H) ) is a favorable instance of HP (by Lemma 4), the algorithm given by Theorem 5 solves it in

Solving Favorable Instances of HP
Recall the problem statement of Hypergraph Painting (HP) and the definition of a favourable instance of HP from Section 5. In this section, we prove Theorem 5. For this purpose, let HP (k 1 , k 2 , b, d, q, H, (f F ) F ∈E(H) ) be a favorable instance of HP. We aim to show how to compute aHP[µ, l 1 , l 2 ] in time 2 O(min(k,q) log(k+q)) d O(k 2 ) m O(1) for an arbitrarily fixed choice of 0 ≤ µ ≤ b, 0 ≤ l 1 ≤ k 1 and 0 ≤ l 2 ≤ k 2 . Since there are only (b + 1)(k 1 + 1)(k 2 + 1) choices for such µ, l 1 and l 2 , we would thus indeed derive the correctness of Theorem 5.

Classifying Hyperedges
We begin by analyzing the structure of the input instance HP (k 1 , k 2 , b, d, q, H, (f F ) F ∈E(H) ) under the assumption that aHP[µ, l 1 , l 2 ] = 1. Recall that k = k 1 + k 2 . Then, by the property of global unbreakability, there exists a witnessing coloring Υ : Without loss of generality, suppose that i = 0 is such an index, that is, j∈[k] |Υ −1 (j)| ≤ q. In the forthcoming arguments, we aim to elucidate the behavior of the function that is the restriction of the witnessing coloring Υ with respect to each hyperedge of the hypergraph H. As we see later, we may not be able to find the restriction of Υ on every hyperedge, but we would be able to assign a set of colorings to each hyperedge and prove that one of them is exactly the restriction of Υ to that hyperedge. We will then use this information together with dynamic programming procedures to compute aHP[µ, l 1 , l 2 ]. The difficulty lies in the fact that if the set of colorings (with the above-mentioned property) that we would like to have with respect to each hyperedge is arbitrary, the efficiency of our dynamic programming based procedures would not be guaranteed. More precisely, at any given point of the computation, when we choose some coloring for a specific hyperedge using the respective set of colorings of that hyperedge, we would like to be able to automatically assume that this coloring together with all previously chosen colorings should form one coherent coloring that is compatible with a global witnessing coloring. In order to achieve such a property, we perform several phases of color coding of the hypergraph (here, these phases of color coding are hidden under a layer of derandomization tools). These phases would exploit the properties of a favourable instance, and eventually highlight a "nice" structure that would help us achieve our goal.
To proceed with the implementation of the above-mentioned idea, we first categorize the hyperedges of H into the following types, based on the witnessing coloring Υ. In this context, we remind that the notation f (A ) = b indicates that for all a ∈ A , it holds that f (a) = b (see Section 2).
Here, 's' stands for small.
Observe that each hyperedge F ∈ E(H) belongs to exactly one of the sets E b , E m , E s1 , . . . , E s k . Furthermore, let E si denote the edge set of some arbitrary spanning forest of the hypergraph on the vertex set V (H) and the edge set E si . Let E s = i∈[k] E si denote the union of these edge sets. Since we are working with a favourable instance of HP, we would see (in Lemmas 6 and 7) that the sizes of the sets E s and E m can be upper bounded by q and k, respectively. We exploit these bounds to highlight the hyperedges in E m and E s (Lemma 9) efficiently. In addition to this, as we shall see in Lemma 8, the total number of possible restrictions of Υ on any hyperedge can also bounded effectively. Thus, we can not only highlight the hyperedges in E m and E s , but we can also guess the restrictions of Υ to these hyperedges. We remark that since we aim to solve a favourable instance of HP in time that is proportional to a single exponential function of q, we do not guess the restriction of Υ to the hyperedges of E s straightaway (as |E s | ≤ q from Lemma 6). The proof of Lemma 9 would capture the idea of the performance of highlighting and guessing. As one would expect, this highlighting does concludes our arguments, as it does not just highlight the hyperedges in E m and E s , but also some hyperedges from E b . We deal with the inherent challenges of handling such a "messy picture" later in our proof.
Proof. Recall that for each i ∈ [k], we defined E si as the edge set of a spanning forest of the hypergraph with the vertex set V (H) and the edge set E si . Hence, by this definition, |E si | ≤ |Υ −1 (i)|. Now, recall that since Υ witnesses the global unbreakability property, we assumed w.l.o.g. that i∈[k] |Υ −1 (i)| ≤ q. We thus have that i∈[k] |E si | ≤ q. Therefore, |E s | ≤ q.
Proof. Since aHP[µ, l 1 , l 2 ] = 1, for all F ∈ E(H) there exist µ F , l F 1 and l F 2 such that f F (Υ |F , µ F , l F 1 , l F 2 ) = 1. Hence, the connectivity property implies that for each F ∈ E m , we have that l F 1 + l F 2 ≥ 1. However,

Introducing Good Assignments
Let us first note that by Lemma 1, for any hyperedge F ∈ E(H), the number of (3k 2 , k)-unbreakable functions (that we call (3k 2 , k)-unbreakable colorings) from F to [k] 0 is at most α = 3k 2 l=1 d l · (3k 2 ) k · (k + 1) = d O(k 2 ) . For each hyperedge F , let us arbitrarily order all possible (3k 2 , k)-unbreakable colorings. For each i ∈ [α], let λ F,i denote the i-th such coloring. If for an heperedge F , the number of such colorings is strictly smaller than α, then we extend its list of possible colorings to be of size α by letting some colorings be present multiple times. Thus, for each F ∈ E(H) and i ∈ [α], we ensure λ F,i is well-defined.
Here, we are interested in assignments that are functions associating each hyperedge F ∈ E(H) with a coloring λ F,i . Let us proceed by defining which assignments would be useful for us to have at hand. 1. For all F ∈ E s , p(F ) = 0.

For all
To employ coloring coding, we first mention the required derandomization tools.
Proposition 4 (Lemma 1.1, [14]). Given a set U of size n and y, z ∈ [n] 0 , we can construct in time O(2 O(min(y,z) log(y+z)) n log n) a family F of at most O(2 O(min(y,z) log(y+z)) log n) subsets of U , such that the following holds: for all sets Y, Z ⊆ U such that Y ∩ Z = ∅, |Y | ≤ y and |Z| ≤ z, there exists a set S ∈ F with Y ⊆ S and Z ∩ S = ∅. We are now ready to present our color coding phases. Lemma 9. There exists a set A of assignments from E(H) to [α] 0 , such that |A| ≤ 2 O(min(k,q) log(k+q)) · d O(k 2 ) · log 2 |E(H)| and there exists a good assignment in A. Moreover, such a set A is computable in time For each set S j ∈ F, function κ ∈ P j and function κ 0 ∈ Q, let p[S j , κ, κ 0 ] : E(H) → [α] 0 be defined as follows.
Recall that α = d O(k 2 ) . Now, as we have upper bounded ν and ζ, we observe that The time taken to compute A is proportional to the time taken to compute F, P j for each j ∈ {ν} and Q. By Propositions 4 and 5, we thus derive that the running time is upper bounded The algorithm we design to compute aHP[µ, l 1 , l 2 ] first constructs the set A of Lemma 9. Observe that this computation can be done regardless of whether aHP[µ, l 1 , l 2 ] = 1 or aHP[µ, l 1 , l 2 ] = 0. (We only use the supposition that aHP[µ, l 1 , l 2 ] = 1 to analyze structural properties of an input instance satisfying this condition.) Next, the algorithm branches on all possible assignments in A. By Lemma 9, assuming that aHP[µ, l 1 , l 2 ] = 1, we know that there exists at least one assignment from E(H) to [α] 0 that is good. Henceforth, we assume that we currently consider a branch that corresponds to a good assignment, denoted by p : E(H) → [α] 0 . Thus, we would like to show that we correctly determine at the current branch that aHP[µ, l 1 , l 2 ] = 1. (If it were the case that aHP[µ, l 1 , l 2 ] = 0, it would also be clear from our arguments that we would not determine that aHP[µ, l 1 , l 2 ] = 1, which would overall imply that no branch determines that this condition holds, and hence we would eventually decide that aHP[µ, l 1 , l 2 ] = 0.) 6.3 Associating the Graph L p with an Assignment p For our assignment p : E(H) → [α] 0 , let us now construct an undirected simple graph L p with V (L p ) = V (H). For each F ∈ E(H) such that p(F ) = 0, make F a clique in L p . We say that the edges of this clique are the edges that correspond to the hyperedge F . For any F ∈ E(H) such that p(F ) = i > 0, for each j ∈ [k] 0 , make the set λ F,i −1 (j) a clique in L p . We say that the edges of all such cliques are the edges that correspond to the hyperedge F . Since we want L p to be a simple graph, between any two vertices of L p we retain at most one copy of the edge between them (if one exists). If a deleted copies of some edge e in L p corresponds to some hyperedge F , then in the simple graph the retained copy of that edge e is the one that is said to correspond to that hyperedge F (even if we originally added the retained copy of e due to a different hyperedge). Note that it may thus be the case that one edge in L p corresponds to to seversal hyperedges in E(H).
We proceed by analyzing the connected components of L p . Informally, we first argue that every connected component behaves as a single unit with respect to Υ. i ∈ [k] 0 . Otherwise, F 1 ∈ E m . In this case, let p(F 1 ) = s > 0. Since p is a good assignment, λ F1,s = Υ| F1 . Since each component D of L p [F 1 ] is either an isolated vertex or λ −1 F1,s (i) for some i ∈ [k] 0 , we conclude that Υ(D) = i for some i ∈ [k] 0 .
We now suppose that j ≥ 2. By induction hypothesis, for each connected component D of L p [F j−1 ], we have that Υ(D) = i for some i ∈ [k] 0 . Let us now examine the graph L p [F j ] and the hyperedge F j . Note that F j = F j \ F j−1 . If F j ∈ E m , then Υ(F j ) = i for some i ∈ [k] 0 (from the definition of E m ). Let D be the collection of every connected components of L p [F j−1 ] which intersects F j . Then, the definition of L p and the inductive hypothesis directly imply that Υ( D) = i for some i ∈ [k] 0 . Thus, by the inductive hypothesis, for each connected component D of L p [F j ], we have that Υ(D) = i for some i ∈ [k] 0 . Otherwise, F j ∈ E m . Then, denote p(F 1 ) = s > 0. Since p is a good assignment, λ F1,s = Υ| F1 . For each i ∈ [k] 0 , let D i be the collection of all connected components of L p [F j−1 ] that intersect λ −1 Fj ,s (i). Then, the definition of L p and the inductive hypothesis directly imply Υ(D i ) = i. Hence, by the inductive hypothesis, for each connected Roughly speaking, we now argue that hyperedges crossing several different components, where to at least one of them Υ assigns some i > 0, should belong to E m . Proof. Suppose that the statement is false, that is, there exists F ∈ E(H) \ E m such that F ∩ D = ∅ and F \ D = ∅. Since F / ∈ E m , F ∩ D = ∅ and Υ(D) > 0, there exists j ∈ [k] such that F ∈ E sj . Since F ∩ D = ∅ and Υ(D) = i, we have that j = i, that is, F ∈ E si . Consider any spanning forest E si of the hypergraph with vertex set V (H) and edge set E si . Observe that by the definition of L p , for any spanning forest E si , all vertices of F are present in some single tree of that spanning forest. Therefore, there exists some F ∈ E si , where F could be the same as the hyperedge F , such that the vertices of F form a superset of F . Since p is a good assignment, p(F ) = 0. Thus, the definition of L p implies that all the vertices of F belong to the same connected component, which contradicts that F \ D = ∅.

Rules to Modify a Good Assignment
We first modify the good assignment p by applying the following two rules exhaustively, prioritizing Rule 1 over Rule 2. Note that whenever we change p, we update L p accordingly.
Lemma 12. After any application of Rule 1 and Rule 2, p remains a good assignment.
Proof. Let us first prove that if p was a good assignment, then after the application of Rule 1, the modified p is still a good assignment. From Lemma 10, Υ(D) = i for some i ∈ [k] 0 . Thus, if F ⊆ D, then F ∈ E m . Hence, when we redefine p(F ) = 0, p remains a good assignment.
Let us now prove that if p was a good assignment, then after the application of Rule 2, the modified p is still a good assignment. To prove this, it is enough to prove that F 1 / ∈ E m . Suppose, for the sake of contradiction, that F 1 ∈ E m . Since p is a good assignment, λ F1,i = Υ| F . Denote λ F1,i (v 1 ) = c, where c ∈ [k].
For each connected component D of L p , let us now define a label set L(D) ⊆ [k] 0 as follows. For any i ∈ [k] 0 , we insert i into L(D) if and only if there exists F ∈ E(H) such that F ∩ D = ∅, p(F ) = j > 0 and λ F,j (F ∩ D) = i. Observe that L(D) could be empty.
Let us now turn to analyze the labels sets we have just defined. Let us continue modifying the good assignment p, now with the following rule. Again, whenever we modify p, we update L p accordingly.

Rule 3:
If there exist F ∈ E(H) and two distinct 0-connected components of L p , D 1 and D 2 , such that F ∩ D 1 = ∅ and F ∩ D 2 = ∅, then update p(F ) = 0. Lemma 16. The assignment resulting by applying Rule 3 to p is a good assignment.
Proof. To prove the lemma, it is sufficient to show that F / ∈ E m . Suppose that this claim is false, that is, F ∈ E m and hence after the update, we obtain an assignment that is not good. Since (the original) p is a good assignment, we have that p(F ) = i > 0 such that λ F,i = Υ| F . Since D 1 and D 2 are different connected components of L p , (F ∩ D 1 ) ⊆ λ −1 F,i (j 1 ), (F ∩ D 2 ) ⊆ λ −1 F,i (j 2 ) and j 1 = j 2 . However, since D 1 and D 2 are 0-components of L p , Υ(D 1 ) = 0 and Υ(D 2 ) = 0. This contradicts that λ F,i = Υ| F . Therefore, F / ∈ E m .
To further analyze 0-components, define B as the set containing every vertex v ∈ V (H) such that Υ(v) = 0 and there exists F ∈ E m that is incident to v. In other words, we next show that either all constituent components of D * are colored 0 by Υ or Υ colors each constituent component with the color represented by the label of that constituent component. To this end, let D be the collection of all constituent components of D * such that for all D i ∈ D , Υ(D i ) = l di and let D be the collection of all constituent components of D * such that for all D i ∈ D , Υ(D i ) = 0. We need to show that either D = ∅ or D = ∅. Suppose not, that is, D = ∅ and D = ∅. Then, there exist D 1 ∈ D and D 2 ∈ D . Since D * is a connected component in L * p , there exists F ∈ E(H) such that F ∩ D 1 = ∅ and F ∩ D 2 = ∅. Since Υ(D 1 ) = l d1 = 0, from Lemma 11, we have that F ∈ E m . Since Υ(D 2 ) = 0, F ∩ D 2 = ∅ and F ∈ E m , we deduce that D contains a vertex from the set B. Thus, by Lemma 17, we have that D 2 is a 0-component of L * p . Since no constituent component of D * (which contains at least two constituent components) can be a 0-component from the construction of L * p , we have reached a contradiction.

Dynamic Programming
For the sake of clarity of presentation, for every hyperedge F ∈ E D * , we denote h F (µ , l 1 , l 2 ) = i∈ l 2 j ≤ l 2 , and each µ j , l j 1 , l j 2 is a non-negative integer. l 2 j ≤ l 2 , and each µ j , l j 1 , l j 2 is a non-negative integer.
Proof. By Lemma 20, we have the following equality.  This concludes the proof of the lemma.
Clearly, for all i ∈ [y], F ∈ E D * i , µ ≤ µ, l 1 ≤ l 1 and l 2 ≤ l 2 , it holds that h F (µ , l 1 , l 2 ) is computable in polynomial time. Thus, by Lemmas 23 and 24, we conclude the proof of Theorem 5.