=Paper= {{Paper |id=Vol-3193/paper1ASPOCP |storemode=property |title=Computing H-Partitions in ASP and Datalog |pdfUrl=https://ceur-ws.org/Vol-3193/paper1ASPOCP.pdf |volume=Vol-3193 |authors=ChloΓ© Capon,Nicolas Lecomte,Jef Wijsen |dblpUrl=https://dblp.org/rec/conf/iclp/CaponLW22 }} ==Computing H-Partitions in ASP and Datalog== https://ceur-ws.org/Vol-3193/paper1ASPOCP.pdf
Computing H-Partitions in ASP and Datalog
ChloΓ© Capon, Nicolas Lecomte and Jef Wijsen
University of Mons, Mons, Belgium


                                       Abstract
                                       An 𝐻-partition of a finite undirected simple graph 𝐺 is a labeling of 𝐺’s vertices such that the constraints
                                       expressed by the model graph 𝐻 are satisfied. These constraints concern the adjacency or nonadjacency of
                                       vertices depending on their label. For every model graph 𝐻, it can be decided in non-deterministic polynomial
                                       time whether a given input graph 𝐺 admits an 𝐻-partition. Moreover, it has been shown in [1] that for most model
                                       graphs, this decision problem is in deterministic polynomial time. In this paper, we show that these polynomial-
                                       time algorithms for finding 𝐻-partitions can be expressed in Datalog with stratified negation. Moreover, using
                                       the answer set solver Clingo [2, 3], we have conducted experiments to compare straightforward guess-and-check
                                       programs with Datalog programs. Our experiments indicate that in Clingo, guess-and-check programs run faster
                                       than their equivalent Datalog programs.

                                        Keywords
                                       Answer Set Programming, Datalog, logic programming, graph partitioning




1. Introduction
Answer Set Programming (ASP) is a powerful programming paradigm that allows for an easy encoding
of decision problems in NP. If the answer to a problem in NP is β€œyes,” then, by definition, there is a
β€œyes”-certificate of polynomial size that can be checked in polynomial time. In an ASP guess-and-check
program, a programmer first declares the format of such a certificate, and then specifies the constraints
that a well-formatted certificate should obey in order to be a β€œyes”-certificate. For example, for the
well-known problem SAT, an ASP-programmer can first declare that certificates take the form of
truth assignments, and then specify that β€œyes”-certificates are those certificates that leave no clause
unsatisfied.
   While ASP guess-and-check programs are typically oriented towards NP-complete problems, they
can also be used for problems in P. For example, the previously mentioned encoding of SAT also solves
2SAT, which is known to be in P. In general, assume that we have an answer set solver at our disposal,
and that we have written a guess-and-check ASP program for a particular problem that is NP-complete
(for example, SAT). Assume furthermore that we know that under some restrictions, the problem can be
solved in polynomial time (for example, the restriction of SAT to 2SAT). In logic programming, it may
be possible to encode such a polynomial-time solution in a syntactic restriction of ASP, for example, in
Datalog with stratified negation [4], which guarantees the existence of a polynomial-time execution.
From a theoretical standpoint, a program in Datalog is more efficient than a general guess-and-check
ASP program. From a practical standpoint, however, one may wonder whether such a Datalog program
will run faster in our ASP engine, compared to a general guess-and-check ASP program. The latter
question will be addressed in this paper.


ASPOCP 2022: 15th Workshop on Answer Set Programming and Other Computing Paradigms, July 31, 2022, Haifa, Israel
$ jef.wijsen@umons.ac.be (J. Wijsen)
Β€ http://math.umons.ac.be/staff/Capon.Chloe/ (C. Capon); https://math.umons.ac.be/staff/Lecomte.Nicolas/ (N. Lecomte);
http://informatique.umons.ac.be/staff/Wijsen.Jef/ (J. Wijsen)
 0000-0001-8216-273X (J. Wijsen)
                                    Β© 2022 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
 CEUR
 Workshop
 Proceedings
               http://ceur-ws.org
               ISSN 1613-0073       CEUR Workshop Proceedings (CEUR-WS.org)
Figure 1: Examples of model graphs (figure copied from [1]).


   We will test this scenario on the problem of finding 𝐻-partitions in undirected graphs 𝐺 [1]. All
undirected graphs in this paper are understood to be finite and simple. Given an undirected graph 𝐺,
this problem consists in deciding whether there exists a partition of 𝐺’s vertices such that this partition
respects some constraints encoded in another graph 𝐻 with exactly four vertices, called model graph.
Each class of the partition is labeled by a vertex in 𝐻. There are two types of constraints:
    β€’ if 𝐻 contains a full edge between two vertices, 𝐴 and 𝐡, then each vertex in the class labeled by
      𝐴 must be adjacent to each vertex in the class labeled by 𝐡; and
    β€’ if 𝐻 contains a dotted edge between two vertices, 𝐴 and 𝐡, then each vertex in the class labeled
      by 𝐴 must be nonadjacent to each vertex in the class labeled by 𝐡.
   Note that there are no constraints between two vertices in the same class. All possible model graphs,
up to isomorphism, are presented in Figures 1 and 2. The 𝐻-partitioning problem for 𝐾2 + 𝑆2 , also
known as finding a skew partition, is in polynomial time [5, 6]. The 𝐻-partitioning problem for 2𝐾2
is NP-complete [7]. For each model graph in Figure 2, Dantas et al. [1] provide a polynomial-time
algorithm, of low polynomial degree, for deciding whether an undirected graph admits an 𝐻-partition.
In this paper, we show how these polynomial-time algorithms can be encoded in Datalog with stratified
negation. We then experimentally compare these Datalog programs with a guess-and-check ASP
program. In theory, the computational complexity of Datalog is in P, while guess-and-check ASP
programs can solve NP-complete problems.
   This paper is organized as follows. Section 2 formalizes the problem of finding 𝐻-partitions and
paraphrases the polynomial-time method of Dantas et al. [1]. Sections 3 and 4 focus on finding 𝐻-
partitions in logic programming, first in ASP, and then in Datalog with stratified negation. In our
experimental validation of Section 5, we first generate undirected graphs of different sizes on which our
programs can be executed. We distinguish between those input graphs that admit an 𝐻-partition, called
yes-instances, and those that do not, called no-instances. We show different methods for generating
yes-instances and no-instances, for a fixed model graph 𝐻, and then compare the running times of our
logic programs in the answer set solver Clingo [2, 3]. Finally, Section 6 concludes the paper. Due to
space limitations, some proofs have been omitted, which can be found in the extended version [8].


2. Preliminaries
In this section, we formally define the problem H-PARTITION and sketch an algorithm borrowed
from [1]. In Section 4, this algorithm will be written in Datalog with stratified negation.

2.1. The Problem H-PARTITION
A model graph 𝐻 is an undirected graph with four vertices, called 𝐴, 𝐡, 𝐢 and 𝐷 (sometimes written
in lowercase letters). The vertices are called 𝐴, 𝐡, 𝐢, and 𝐷 in anticlockwise order, starting with the
top-left vertex. Every edge is of exactly one of two types: full or dotted. All possible model graphs, up
to isomorphisms, are presented in Figures 1 and 2. We define H-PARTITION as the following decision
problem.
Figure 2: List of model graphs 𝐻 (figure copied from [1]).


Problem H-PARTITION

Input: A model graph 𝐻; an undirected graph 𝐺.

Question: Is it possible to partition 𝑉 (𝐺) into four pairwise disjoint, non-empty subsets, 𝑉𝐴 , 𝑉𝐡 , 𝑉𝐢 ,
     and 𝑉𝐷 such that, for all 𝑝, π‘ž ∈ {𝐴, 𝐡, 𝐢, 𝐷} with 𝑝 ΜΈ= π‘ž:
              β€’ if (𝑝, π‘ž) is a full edge of 𝐻, then every vertex in 𝑉𝑝 is adjacent to every vertex in π‘‰π‘ž ; and
              β€’ if (𝑝, π‘ž) is a dotted edge of 𝐻, then every vertex in 𝑉𝑝 is nonadjacent to every vertex in π‘‰π‘ž .
          Such a partition, if it exists, is called a solution or an 𝐻-partition.

We call a pair (𝐻, 𝐺) a yes-instance if H-PARTITION returns yes on input 𝐻 and 𝐺; otherwise (𝐻, 𝐺)
is a no-instance. H-PARTITION(𝐻) denotes the H-PARTITION problem for a fixed model graph 𝐻.
   The partitions 𝑉𝐴 , 𝑉𝐡 , 𝑉𝐢 , and 𝑉𝐷 are commonly denoted by 𝐴, 𝐡, 𝐢, and 𝐷, respectively. One can
view such a partition of 𝑉 (𝐺) as a labeling of 𝑉 (𝐺) with the labels 𝐴, 𝐡, 𝐢, and 𝐷. From here on, we
will often omit curly braces and commas in the denotation of subsets of {𝐴, 𝐡, 𝐢, 𝐷}. For example,
𝐴𝐡𝐷 denotes the set {𝐴, 𝐡, 𝐷}.
Definition 1. This definition is relative to a fixed model graph 𝐻. Let 𝐿 βŠ† {𝐴, 𝐡, 𝐢, 𝐷}. We define
NF (𝐿) as the set of vertices of 𝐻 that are adjacent, through a full edge, to some vertex of 𝐿. Similarly,
ND (𝐿) is the set of vertices of 𝐻 that are adjacent, through a dotted edge, to some vertex of 𝐿. We say
that 𝐿 is trivial if |𝐿| = 1.
   Informally, given a model graph 𝐻, each label among 𝐴, 𝐡, 𝐢, and 𝐷 imposes a constraint that can
be read from 𝐻. For example, for the model graph 𝐻 = (19) given in Figure 2, the label 𝐴 imposes
β€œbeing adjacent to 𝐢 and nonadjacent to 𝐷,” and 𝐢 imposes β€œbeing adjacent to 𝐴 and nonadjacent to 𝐡.” A
list of two or more labels imposes all the constraints of each label in the list. For example, for 𝐻 = (19),
the list 𝐴𝐢 imposes β€œbeing adjacent to 𝐢, nonadjacent to 𝐷, adjacent to 𝐴, and nonadjacent to 𝐡.” A list
is called conflicting if it imposes an unsatisfiable constraint. For example, for 𝐻 = (20), the list 𝐴𝐢 is
conflicting, because 𝐴 imposes β€œbeing nonadjacent to 𝐡,” while 𝐢 imposes β€œbeing adjacent to 𝐡.” We
will call a list non-maximal 1 if it can be extended into a longer list that imposes the same constraint. For
    1
        In [1], non-maximal lists are called impossible.
example, for 𝐻 = (33), the lists 𝐢𝐷 and 𝐴𝐢𝐷 impose the same constraint, namely β€œbeing adjacent to
𝐡, nonadjacent to 𝐢, and nonadjacent to 𝐷,” and therefore 𝐢𝐷 is non-maximal.

Definition 2. This definition is relative to a fixed model graph 𝐻. Let 𝐿 βŠ† {𝐴, 𝐡, 𝐢, 𝐷}. 𝐿 is
conflicting if NF (𝐿) ∩ ND (𝐿) ΜΈ= βˆ…. 𝐿 is non-maximal if there exists 𝐿′ βŠ† {𝐴, 𝐡, 𝐢, 𝐷} such that 𝐿 ⊊ 𝐿′
with NF (𝐿) = NF (𝐿′ ) and ND (𝐿) = ND (𝐿′ ).

  For example, let 𝐻 be model graph (13) of Figure 2. The list 𝐴𝐡 is non-maximal because for the set
𝐴𝐡𝐢, we have that NF (𝐴𝐡) = 𝐴𝐡𝐢 = NF (𝐴𝐡𝐢) and ND (𝐴𝐡) = 𝐷 = ND (𝐴𝐡𝐢). The list 𝐴𝐷 is
conflicting because 𝐡 ∈ ND (𝐴𝐷) ∩ NF (𝐴𝐷).

2.2. Finding 𝐻-Partitions
Dantas et al. [1] have shown that H-PARTITION(𝐻) is in polynomial time for all model graphs 𝐻
in Figure 2. Our algorithmic approach slightly differs from theirs because, unlike [1], we will not use
non-maximal or conflicting lists. We now describe our approach.

Definition 3. Let 𝐻 be a model graph, and 𝐺 an undirected graph. Let π‘₯𝐴 , π‘₯𝐡 , π‘₯𝐢 , and π‘₯𝐷 be four
distinct vertices of 𝐺. We say that the quadruplet (π‘₯𝐴 , π‘₯𝐡 , π‘₯𝐢 , π‘₯𝐷 ) is 𝐻-isomorphic if the subgraph
of 𝐺 induced by these vertices is a yes-instance of H-PARTITION(𝐻) for a labeling where π‘₯𝐴 , π‘₯𝐡 , π‘₯𝐢 ,
and π‘₯𝐷 are respectively labeled by 𝐴, 𝐡, 𝐢, and 𝐷.

   For instance, in the graph of Figure 3a, the quadruplet (2, 3, 4, 5) is 𝐻-isomorphic to the model
graph (7) of Figure 2.
   Our algorithmic approach loops over all 𝐻-isomorphic quadruplets (π‘₯𝐴 , π‘₯𝐡 , π‘₯𝐢 , π‘₯𝐷 ). Each such
quadruplet yields an initial partial labeling. Given such an initial partial labeling, we test whether it can
be extended into a complete labeling, i.e., into a solution. To this end, we repeatedly pick an unlabeled
vertex, and compute its possible labels. When we say that a label 𝑃 ∈ {𝐴, 𝐡, 𝐢, 𝐷} is possible for a
vertex, we mean that the model graph does not forbid us to label that vertex with 𝑃 , given the vertices
that have already been labeled. If only one label is possible for an unlabeled vertex, we label that vertex
with that label. If no label is possible for some unlabeled vertex, we conclude that the current labeling
cannot be extended to a complete labeling. If for every unlabeled vertex at least two labels remain
possible, then we conclude that 𝐺 is a yes-instance for H-PARTITION(𝐻) (except for model graphs
(7), (10) and (11) where some additional tests are needed).
   In [1], refined lists are obtained by removing conflicting and non-maximal lists. The description on
[DdFGK05, page 141] might suggest that we must be careful to only consider refined lists. However,
the following lemma implies that conflicting or non-maximal lists will not occur in our algorithmic
approach.

Lemma 1. Let 𝐻 be a model graph, and 𝐺 an undirected graph. Assume that, during the execution of the
previously described algorithm for H-PARTITION(𝐻) with input 𝐺, there is a vertex 𝑣 ∈ 𝑉 (𝐺) whose
set of all possible labels is 𝐿 with |𝐿| ⩾ 2. Then, 𝐿 is neither conflicting nor non-maximal.

  In Section 4, we show how to encode our algorithmic approach in Datalog with stratified negation.
However, we will first provide a straightforward guess-and-check program for H-PARTITION.


3. Guess-and-Check Program for H-PARTITION
In all logic programs of this paper, the constants are in lowercase and the variables are in uppercase
to match with Clingo syntax. We use the binary predicate e to store the edges of the input graph 𝐺,
while the unary predicate vertex stores vertices. The binary predicates full and dotted encode,
respectively, full and dotted edges of the model graph. The labels are provided to the program as
partition(a), partition(b), partition(c), and partition(d).
   The following program follows the generate-and-test (or guess-and-check) methodology that is classical
for problems in NP: generate a candidate solution, and test whether it is a true solution, i.e., whether it
satisfies all constraints. In the following program, the generating part is the rule 1 { placedIn(X,P)
: partition(P) } 1 :- vertex(X)., which places every vertex in exactly one partition. The
testing part imposes that every partition must contain at least one vertex, and that the constraints of
the model graph must be satisfied. Moreover, we suppose that e is symmetric, i.e., e(t,s) is stored
whenever e(s,t) is stored.
% Every vertex goes in exactly one partition.
1 { placedIn(X,P) : partition(P) } 1 :- vertex(X).

% No partition is empty.
filled(P) :- placedIn(X,P).
:- partition(P), not filled(P).

% Constraints of the model graph.
:- placedIn(X,P), placedIn(Y,Q), full(P,Q), not e(X,Y).
:- placedIn(X,P), placedIn(Y,Q), dotted(P,Q), e(X,Y).




4. Datalog Programs for H-PARTITION
In this section, we show how to encode H-PARTITION(𝐻) in Datalog with stratified negation, for
model graphs 𝐻 in Figure 2. Section 4.1 encodes the approach of [1] in general. We argue that this
general encoding is correct for every model graph in Figure 2 that is distinct from (7), (10), and (11).
We then show how to adjust the general encoding for these three model graphs. Finally, we show that
for model graphs 𝐻 with an isolated vertex, non-recursive Datalog with negation suffices to check the
existence of 𝐻-partitions.

4.1. General Datalog Program
Dantas et al. [1] showed that H-PARTITION(𝐻) can be solved in polynomial time for all model
graphs 𝐻 in Figure 2. Following our previously described method, we check whether some initial valid
labeling of four vertices, called a base, can be extended to a complete labeling of all vertices.

Finding a base. The algorithm loops over all quadruplets of distinct vertices and checks whether a
quadruplet is 𝐻-isomorphic. Our Datalog rules are as follows:
base(X,Y,Z,T) :- distinct(X,Y,Z,T), not problematic_base(X,Y,Z,T).

Here, the predicate distinct(X,Y,Z,T) checks whether 𝑋, π‘Œ , 𝑍, and 𝑇 are four distinct vertices
of 𝐺, and problematic_base is defined, for each possible edge in the model graph 𝐻, with two rules.
For example, if we consider the edge (π‘Ž, 𝑏), the rules are:
problematic_base(X,Y,Z,T) :- dotted(a,b), e(X,Y), vertex(Z), vertex(T).
problematic_base(X,Y,Z,T) :- full(a,b), not e(X,Y), vertex(X), vertex(Y), vertex(Z), vertex(T).

Similar rules are added for edges (π‘Ž, 𝑐), (π‘Ž, 𝑑), (𝑏, 𝑐), (𝑏, 𝑑), and (𝑐, 𝑑).
Extension to a complete labeling. First, for every base (𝐼, 𝐽, 𝐾, 𝐿) of four vertices, we label 𝐼 with
𝐴, 𝐽 with 𝐡, 𝐾 with 𝐢, and 𝐿 with 𝐷.
inPart(I,a,I,J,K,L) :- base(I,J,K,L).
inPart(J,b,I,J,K,L) :- base(I,J,K,L).
inPart(K,c,I,J,K,L) :- base(I,J,K,L).
inPart(L,d,I,J,K,L) :- base(I,J,K,L).

  We keep track that a vertex that has been labeled in a base must not be re-labeled later on.
done(I,I,J,K,L) :- base(I,J,K,L).
done(J,I,J,K,L) :- base(I,J,K,L).
done(K,I,J,K,L) :- base(I,J,K,L).
done(L,I,J,K,L) :- base(I,J,K,L).

   Next, rather than computing the set of possible labels for a yet unlabeled vertex 𝑋, we use the predicate
imp(X,P,I,J,K,L) with the meaning that the vertex 𝑋 cannot be labeled by 𝑃 ∈ {𝐴, 𝐡, 𝐢, 𝐷},
relative to the fixed base (𝐼, 𝐽, 𝐾, 𝐿). The Datalog rules are straightforward. The second rule, for
example, expresses that for a full edge (𝑃, 𝑄) in the model graph, if a vertex π‘Œ has been labeled with 𝑄,
then a vertex 𝑋 that is nonadjacent to π‘Œ cannot be labeled with 𝑃 . One should read β€œprob” as a
shorthand for β€œproblematic.”
imp(X,P,I,J,K,L) :- vertex(X), full_prob(X,P,I,J,K,L), not done(X,I,J,K,L).
full_prob(X,P,I,J,K,L) :- full(P,Q), inPart(Y,Q,I,J,K,L), not e(X,Y), vertex(X).

imp(X,P,I,J,K,L) :- vertex(X), dot_prob(X,P,I,J,K,L), not done(X,I,J,K,L).
dot_prob(X,P,I,J,K,L) :- dotted(P,Q), inPart(Y,Q,I,J,K,L), e(X,Y).

  For every vertex 𝑋 of 𝐺 that is not in the fixed base (𝐼, 𝐽, 𝐾, 𝐿), we now consider two possibilities:

(1) if three labels among 𝐴, 𝐡, 𝐢, and 𝐷 are impossible for 𝑋, then 𝑋 is labeled with the remaining
    fourth label; and

(2) if all labels among 𝐴, 𝐡, 𝐢, and 𝐷 are impossible for 𝑋, then the base cannot be extended to a
    complete labeling.

Finally, if some base never encounters the second case, the answer to H-PARTITION(𝐻) is β€œyes”;
otherwise the answer is β€œno”. Note incidentally that in a β€œyes”-instance, there may be vertices 𝑋 that
are not labeled by the first case.
% First case.
inPart(X,a,I,J,K,L) :- imp(X,b,I,J,K,L), imp(X,c,I,J,K,L), imp(X,d,I,J,K,L).
inPart(X,b,I,J,K,L) :- imp(X,a,I,J,K,L), imp(X,c,I,J,K,L), imp(X,d,I,J,K,L).
inPart(X,c,I,J,K,L) :- imp(X,a,I,J,K,L), imp(X,b,I,J,K,L), imp(X,d,I,J,K,L).
inPart(X,d,I,J,K,L) :- imp(X,a,I,J,K,L), imp(X,b,I,J,K,L), imp(X,c,I,J,K,L).

% Second case.
bad_init(I,J,K,L) :- vertex(X), base(I,J,K,L), imp(X,a,I,J,K,L),
                     imp(X,b,I,J,K,L), imp(X,c,I,J,K,L), imp(X,d,I,J,K,L).

yes_instance() :- base(I,J,K,L), not bad_init(I,J,K,L).
no_instance() :- not yes_instance().

  We have the following result.

Theorem 2. If 𝐻 is one of the model graphs of Figure 2 such that 𝐻 is distinct from model graphs (7),
(10), and (11), then H-PARTITION(𝐻) is expressible in Datalog with stratified negation.
      (a) Counterexample for the model graph (7).      (b) Counterexample for the model graph (10).

Figure 3: The corner cases of the main approach.


4.2. Adjustment for Model Graph (7)
In [1], the model graph (7) of Figure 2 is reduced to the model graph 𝐾2 . This is possible because the
constraints for 𝐴 and 𝐢 are identical (i.e., being adjacent to both 𝐡 and 𝐷), and the constraints for 𝐡
and 𝐷 are identical. Then, every non-base vertex labeled by 𝐢 can also be labeled by 𝐴, and every
non-base vertex labeled by 𝐷 can also be labeled by 𝐡. Our previous Datalog program would fail,
however, for the reason that the set of possible labels for a non-base vertex is never a singleton.
   For example, consider the graph 𝐺 in Figure 3a with the base (1, 2, 3, 4). The list of possible labels
for the vertex 5 is 𝐴𝐢, and the list of possible labels for the vertex 6 is 𝐡𝐷. Our previous algorithm
would terminate here and conclude that 𝐺 is a yes-instance. Note, however, that if vertex 5 is labeled
with 𝐴 (the case where we label 5 with 𝐢 is similar), it is impossible to label the vertex 6 with 𝐡 or 𝐷,
because vertices 5 and 6 are nonadjacent.
   We adjust our Datalog program as follows: if the set of possible labels of a vertex 𝑋 has size 2,
the new program will label 𝑋 with one of these two possibilities, arbitrarily chosen. The rest of the
program remains unchanged. That is, in the box that immediately precedes Theorem 2, we replace the
four rules for the predicate inPart by the following two rules:
inPart(X,a,I,J,K,L) :- imp(X,b,I,J,K,L), imp(X,d,I,J,K,L).
inPart(X,b,I,J,K,L) :- imp(X,a,I,J,K,L), imp(X,c,I,J,K,L).




4.3. Adjustment for Model Graphs (10) and (11)
As in [1], the model graphs (10) and (11) of Figure 2 need a special treatment. We illustrate the issue
by the model graph (10) and the graph 𝐺 given in Figure 3b. For the base (1, 2, 3, 4), the list of possible
labels for the vertex 5 is 𝐡𝐢, and the list of possible labels for the vertex 6 is 𝐴𝐷. So our original
algorithm would terminate and wrongly conclude that the base (1, 2, 3, 4) can be extended to a complete
labeling. Nevertheless, we claim that this base cannot be extended to a complete labeling. Indeed, let us
label the vertex 5 by 𝐡 (the case where we label 5 with 𝐢 is similar). Since 𝐡 is adjacent, through full
edges, to both 𝐴 and 𝐷, and since vertices 5 and 6 are nonadjacent, we cannot label 6 with 𝐴 or 𝐷. We
note incidentally that the graph 𝐺 is a yes-instance through other bases, for example, (1, 2, 3, 6).
   It can be verified that for the model graph (10), the lists of possible labels are 𝐴𝐷 and 𝐡𝐢; for the
model graph (11), the lists of possible labels are 𝐴𝐢 and 𝐡𝐷. We have the following result.

Lemma 3. (Cf. [1]) Let 𝐻 be one of the model graphs (10) or (11) in Figure 2. If there exists a solution to
H-PARTITION(𝐻) with a base (𝑖, 𝑗, π‘˜, 𝑙), then there is also a solution with the same base such that:

    β€’ each vertex having 𝐴 in its list of possible labels is labeled 𝐴; and
    β€’ each vertex having 𝐡 in its list of possible labels is labeled 𝐡.

   We now use Lemma 3 to adjust our previous Datalog program of Section 4.1. First, we copy the
labeled vertices.
label(X,a,I,J,K,L) :- inPart(X,a,I,J,K,L).
label(X,b,I,J,K,L) :- inPart(X,b,I,J,K,L).
label(X,c,I,J,K,L) :- inPart(X,c,I,J,K,L).
label(X,d,I,J,K,L) :- inPart(X,d,I,J,K,L).

   Next, if 𝐡 is an impossible label for a vertex but 𝐴 is not, the vertex is labeled by 𝐴. Symmetrically,
if 𝐴 is an impossible label for a vertex but 𝐡 is not, the vertex is labeled by 𝐡.
label(X,a,I,J,K,L) :- not imp(X,a,I,J,K,L), imp(X,b,I,J,K,L).
label(X,b,I,J,K,L) :- imp(X,a,I,J,K,L), not imp(X,b,I,J,K,L).

   We now have to check that this labeling is correct according to the model graph. If not, we reject the
initial base.
problem(X,P,I,J,K,L) :- label(X,P,I,J,K,L), full(P,Q), label(Y,Q,I,J,K,L), not e(X,Y).
problem(X,P,I,J,K,L) :- label(X,P,I,J,K,L), dotted(P,Q), label(Y,Q,I,J,K,L), e(X,Y).
bad_base(I,J,K,L) :- problem(X,P,I,J,K,L).

  Finally, the definition of yes_instance() is changed as follows:
yes_instance() :- base(I,J,K,L), not bad_base(I,J,K,L), not bad_init(I,J,K,L).
no_instance() :- not yes_instance().

  Along the lines of Theorem 2, we obtain the following result.

Theorem 4. If 𝐻 is one of the model graphs (10) or (11) in Figure 2, then H-PARTITION(𝐻) is expressible
in Datalog with stratified negation.

4.4. Model Graphs with Isolated Vertices
A vertex in a model graph 𝐻 is isolated if it is not adjacent to a full or dotted edge. The model graphs in
Figure 2 with at least one isolated vertex are (1), (2), (3), (4), (22), and (29). It can be easily seen that
for these model graphs, H-PARTITION(𝐻) can be solved in non-recursive Datalog with negation (i.e.,
in predicate logic).

Lemma 5. Let 𝐺 be an undirected graph. Let 𝐻 be a model graph with an isolated vertex. Then the
following are equivalent:

   1. 𝐺 contains an 𝐻-isomorphic quadruplet of distinct vertices; and

   2. 𝐺 is a yes-instance of the problem H-PARTITION(𝐻).

  From Section 4.1, it follows that non-recursive Datalog suffices to test the existence of an 𝐻-isomorphic
quadruplet of distinct vertices. Thus, we obtain the following result.

Theorem 6. If 𝐻 is a model graph with an isolated vertex, then H-PARTITION(𝐻) is expressible in
non-recursive Datalog with negation.
5. Experiments
To compare the efficiency of our programs in an existing answer set solver, we need a generator for
yes-instances and no-instances of arbitrary size. The motivation for distinguishing between yes- and
no-instances comes from the asymmetry of NP-problems: on a yes-instance, an algorithm can stop as
soon as the first 𝐻-partition is found; but on no-instances no such early stopping is possible. In this
section, we discuss generators for yes- and no-instances, and then we report on execution times of our
programs on these instances.

5.1. Generating Yes-Instances
Let 𝑛, π‘š be two positive integers, and 𝐻 a model graph. We want to build a graph 𝐺 with 𝑛 vertices and
π‘š edges that is a yes-instance for the problem H-PARTITION(𝐻). Necessarily, 𝑛 β©Ύ 4 and π‘š ≀ 𝑛(π‘›βˆ’1)  2   ,
where the latter is the number of edges in the complete graph with 𝑛 vertices.
  We denote N0 = {1, 2, 3, . . .}. Let π‘Ž, 𝑏, 𝑐, 𝑑 ∈ N0 such that π‘Ž + 𝑏 + 𝑐 + 𝑑 = 𝑛. One can wonder if
there exists a yes-instance with π‘š edges where the numbers of vertices labeled by 𝐴, 𝐡, 𝐢, and 𝐷 are,
respectively, π‘Ž, 𝑏, 𝑐, and 𝑑.

Definition 4. We define π‘šπ»  min (π‘Ž, 𝑏, 𝑐, 𝑑) as the smallest number π‘˜ such that some graph 𝐺 with
|𝐸(𝐺)| = π‘˜ admits an 𝐻-partition (𝑉𝐴 , 𝑉𝐡 , 𝑉𝐢 , 𝑉𝐷 ) such that |𝑉𝐴 | = π‘Ž, |𝑉𝐡 | = 𝑏, |𝑉𝐢 | = 𝑐, and
|𝑉𝐷 | = 𝑑. Analogously, we define π‘šπ»  max (π‘Ž, 𝑏, 𝑐, 𝑑) as the largest number π‘˜ such that some graph 𝐺
with |𝐸(𝐺)| = π‘˜ admits an 𝐻-partition (𝑉𝐴 , 𝑉𝐡 , 𝑉𝐢 , 𝑉𝐷 ) such that |𝑉𝐴 | = π‘Ž, |𝑉𝐡 | = 𝑏, |𝑉𝐢 | = 𝑐, and
|𝑉𝐷 | = 𝑑.

   We write 𝑝 for a label and also for the number of vertices labeled with this label. If the context is not
clear, we write #𝑝 for the number of vertices labeled by 𝑝. We have the following result.

Lemma 7. Let 𝐻 be a model graph. Let π‘Ž, 𝑏, 𝑐, 𝑑 ∈ N0 such that π‘Ž + 𝑏 + 𝑐 + 𝑑 = 𝑛. Then,
                                              βˆ‘οΈ
                    π‘šπ»min (π‘Ž, 𝑏, 𝑐, 𝑑) =             #𝑝 Β· #π‘ž                                                  (1)
                                                   (𝑝,π‘ž)∈Full(𝐻)
                                                    𝑛(𝑛 βˆ’ 1)               βˆ‘οΈ
                          π‘šπ»
                           max (π‘Ž, 𝑏, 𝑐, 𝑑) =                βˆ’                         #𝑝 Β· #π‘ž                (2)
                                                       2
                                                                    (𝑝,π‘ž)∈Dotted(𝐻)

where Full(𝐻) is the set of the full edges of 𝐻, and Dotted(𝐻) is the set of the dotted edges of 𝐻.

    βˆ‘οΈ€We give a proof of (1). We first show that there exists an undirected graph 𝐺min with 𝑛 vertices
Proof.
and (𝑝,π‘ž)∈Full(𝐻) #𝑝 Β· #π‘ž edges that has a solution where the numbers of vertices labeled by 𝐴, 𝐡, 𝐢,
and 𝐷 are, respectively, π‘Ž, 𝑏, 𝑐, and 𝑑. Let 𝐺min be an undirected graph whose vertices are

                  𝑉 (𝐺min ) = {𝐴1 , 𝐴2 , . . . , π΄π‘Ž , 𝐡1 , . . . , 𝐡𝑏 , 𝐢1 , . . . , 𝐢𝑐 , 𝐷1 , . . . , 𝐷𝑑 }

and the edges of 𝐺min are defined as follows: for 𝑝𝑖 , π‘žπ‘— ∈ 𝑉 (𝐺min ), (𝑝𝑖 , π‘žπ‘— ) is an edge of 𝐺min if and
only if (𝑝, π‘ž) is a full edge of 𝐻.
  Since for each full edge (𝑝, π‘ž) in 𝐻, each vertex labeled with 𝑝 is connected to each vertex labeled
with π‘ž, there are #𝑝 Β· #π‘ž such edges. Moreover, there are no other edges than those described here. As
we sum up these values for each full edge (𝑝, π‘ž), we obtain the desired number of edges in 𝐺min .
  We claim that this labeling satisfies all the constraints. The full constraints are satisfied by construction.
The dotted constraints are also satisfied because 𝐺min contains only edges connecting two vertices
whose labels are adjacent through a full edge in 𝐻.
Figure 4: Model graph (23).




   It remains to be shown that there exists no graph with strictly less than (𝑝,π‘ž)∈Full(𝐻) #𝑝 Β· #π‘ž edges
                                                                              βˆ‘οΈ€
that is a yes-instance where the number of vertices labeled by 𝐴, 𝐡, 𝐢, and 𝐷 are, respectively, π‘Ž, 𝑏, 𝑐,
and 𝑑. Assume for the sake of contradiction that there exists such a graph 𝐺′ . We can assume without
loss of generality that 𝐺′ and 𝐺min have the same set of vertices. Since 𝐺′ has strictly less edges than
𝐺min , there is an edge (𝑒, 𝑣) in 𝐺min that is not in 𝐺′ . Since 𝐺′ is a yes-instance, it has a solution. Let
𝑝 be the label of 𝑒 in this solution, and π‘ž the label of 𝑣. Since (𝑒, 𝑣) is an edge of 𝐺min , we have that
(𝑝, π‘ž) is a full edge of 𝐻. So, we have two vertices 𝑒 and 𝑣 that are labeled by 𝑝 and π‘ž respectively, but
there is no edge in 𝐺′ between 𝑒 and 𝑣. This is a contradiction with the fact that 𝐺′ is a yes-instance.
This concludes the proof of (1).
   The proof of (2) is similar because it suffices to consider 𝐺max which is obtained from a complete
graph with 𝑛 edges by removing all the edges between two vertices whose labels are connected by a
dotted edge in 𝐻.

  For example, let us fix π‘Ž, 𝑏, 𝑐, 𝑑 ∈ N0 with the model graph (23) of Figure 2 and 𝑛 = π‘Ž + 𝑏 + 𝑐 + 𝑑.
According to the Figure 4, we have:
                                          (23)
                                        π‘šmin (π‘Ž, 𝑏, 𝑐, 𝑑) = π‘Žπ‘ + 𝑏𝑐

                                                    𝑛(𝑛 βˆ’ 1)
                              π‘š(23)
                               max (π‘Ž, 𝑏, 𝑐, 𝑑) =            βˆ’ π‘Žπ‘ βˆ’ 𝑏𝑑 βˆ’ 𝑐𝑑
                                                       2
                                                    (23)                      (23)
Moreover, we claim that, for all π‘š such that π‘šmin (π‘Ž, 𝑏, 𝑐, 𝑑) β©½ π‘š β©½ π‘šmax (π‘Ž, 𝑏, 𝑐, 𝑑), there exists a
graph 𝐺 with 𝑛 vertices and π‘š edges such that 𝐺 is a yes-instance for a labeling where the numbers of
vertices labeled by 𝐴, 𝐡, 𝐢, and 𝐷 are, respectively, π‘Ž, 𝑏, 𝑐, and 𝑑. The idea is that we can extend the
            (23)
graph for π‘šmin (π‘Ž, 𝑏, 𝑐, 𝑑) by adding edges until we reach π‘š edges such that every added edge does not
violate any dotted constraint. We will now formalize this construction.

Definition 5. Let 𝐺 and 𝐺′ be two undirected graphs, We say that 𝐺 is an extension of 𝐺′ , denoted
𝐺′ βŠ† 𝐺, if 𝑉 (𝐺′ ) = 𝑉 (𝐺) and 𝐸(𝐺′ ) βŠ† 𝐸(𝐺). If 𝐺′ βŠ† 𝐺, we also say that 𝐺′ is extended by 𝐺.

  In other words, 𝐺 is an extension of 𝐺′ if it is possible to obtain 𝐺 from 𝐺′ by adding some edges.
One can easily see that 𝐺min βŠ† 𝐺max . Indeed, we take 𝐺min and consider the labeling induced by the
construction of 𝐺min . We can add all possibles edges that do not violate any dotted constraint. In this
way, we obtain 𝐺max by definition.

Theorem 8. Let 𝐻 be a model graph. Let π‘Ž, 𝑏, 𝑐, 𝑑 ∈ N0 and 𝑛 = π‘Ž + 𝑏 + 𝑐 + 𝑑. Let 𝐺min and 𝐺max
be the graphs with 𝑛 vertices and respectively π‘šπ»                     𝐻
                                                min (π‘Ž, 𝑏, 𝑐, 𝑑) and π‘šmax (π‘Ž, 𝑏, 𝑐, 𝑑) edges defined in (the
proof of) Lemma 7. Every graph 𝐺 such that 𝐺min βŠ† 𝐺 βŠ† 𝐺max has a solution (𝑉𝐴 , 𝑉𝐡 , 𝑉𝐢 , 𝑉𝐷 ) where
|𝑉𝐴 | = π‘Ž, |𝑉𝐡 | = 𝑏, |𝑉𝐢 | = 𝑐, and |𝑉𝐷 | = 𝑑.
                     𝐺1                         𝐺2                              𝐺3


Figure 5: For the model graph (6), we have that 𝐺1 is a yes-instance, 𝐺2 is a no-instance, and 𝐺3 is a yes-
instance.


Proof. Let us consider the same labeling of the vertices in 𝐺 as in 𝐺min . So the number of vertices
labeled by 𝐴, 𝐡, 𝐢, and 𝐷 are, respectively, π‘Ž, 𝑏, 𝑐, and 𝑑. It remains to be shown that this labeling
satisfies all the constraints.

    β€’ Let (𝑝, π‘ž) be a full edge of 𝐻. We have to show that all the vertices labeled by 𝑝 are adjacent to
      all vertices labeled by π‘ž. This holds true because 𝐺 is an extension of 𝐺min and 𝐺min already
      satisfies this constraint.
    β€’ Let (𝑝, π‘ž) be a dotted edge of 𝐻. We have to show that all the vertices labeled by 𝑝 are nonadjacent
      to all vertices labeled by π‘ž. This holds true because 𝐺max is an extension of 𝐺 and 𝐺max already
      satisfies this constraint.

All the constraints are satisfied and, consequently, 𝐺 is a yes-instance.

  This theorem has a natural corollary.

Corollary 9. Let 𝐻 be a model graph, and π‘Ž, 𝑏, 𝑐, 𝑑 ∈ N0 such that 𝑛 = π‘Ž + 𝑏 + 𝑐 + 𝑑. Let π‘š be an
integer such that π‘šπ»                          𝐻
                      min (π‘Ž, 𝑏, 𝑐, 𝑑) β©½ π‘š β©½ π‘šmax (π‘Ž, 𝑏, 𝑐, 𝑑). There is an undirected graph 𝐺 with 𝑛 vertices
and π‘š edges such that 𝐺 has a solution where the numbers of vertices labeled by 𝐴, 𝐡, 𝐢, and 𝐷 are,
respectively, π‘Ž, 𝑏, 𝑐, and 𝑑.

  Based on Corollary 9, we introduce the following generator of yes-instances.

Generator for yes-instances

Input: A model graph 𝐻; two positive integers 𝑛 and π‘š such that 𝑛 β©Ύ 4.

Output: Yes-instances with 𝑛 vertices and π‘š edges.

Generator: For every quadruplet (π‘Ž, 𝑏, 𝑐, 𝑑) of positive integers such that π‘Ž + 𝑏 + 𝑐 + 𝑑 = 𝑛 and
    π‘šπ»                        𝐻
      min (π‘Ž, 𝑏, 𝑐, 𝑑) β©½ π‘š β©½ π‘šmax (π‘Ž, 𝑏, 𝑐, 𝑑),
            build a yes-instance from 𝐺min by randomly adding edges that do not violate any
            dotted constraint, until the number of edges reaches π‘š;
      if no such quadruplet exists, return β€œthere is no such yes-instance.”

5.2. Generating No-Instances
Given an integer 𝑛 β©Ύ 4 and a model graph 𝐻, we want to build a graph 𝐺 with 𝑛 vertices that is
a no-instance for the problem H-PARTITION(𝐻). The following proposition tells us when this is
possible.
Proposition 10. Let 𝐻 be a model graph and 𝑛 an integer such that 𝑛 β©Ύ 4. There is an undirected
graph 𝐺 with 𝑛 vertices that is a no-instance for H-PARTITION(𝐻) if and only if 𝐻 is not the model
graph (1) in Figure 2.
Proof. Assume that 𝐻 is the model graph (1). Then, any graph 𝐺 with 𝑛 vertices is a yes-instance
because there is no constraint to satisfy, due to the absence of full and dotted edges.
  For the opposite direction, assume that 𝐻 is not the model graph (1). Then 𝐻 contains a dotted edge
or a full edge.
    β€’ If 𝐻 contains at least one full edge, the empty graph with 𝑛 vertices and no edge is a no-instance
      because the full constraint will never be satisfied for any labeling of the vertices.
    β€’ If 𝐻 contains at least one dotted edge, the complete graph with 𝑛 vertices and 𝑛(π‘›βˆ’1) 2  edges is a
      no-instance because the dotted constraint will never be satisfied for any labeling of the vertices.
This concludes the proof.

   The undirected graphs in the proof of Proposition 10 are of little interest in an experimental validation,
because they do not admit an 𝐻-isomorphic quadruplet of vertices, and therefore the Datalog program
would not even enter its recursive part. Instead, for a model graph 𝐻, we would like to generate
no-instances that contain an 𝐻-isomorphic quadruplet. Note here that, by Lemma 5, such no-instances
do not exist if 𝐻 has an isolated vertex.
   It would be interesting to develop an approach similar to that for yes-instances: start with a small
no-instance and extend it until some desired number of vertices is reached. Nevertheless, this seems a
difficult task, because the addition of edges for new vertices can turn no-instances into yes-instances,
and vice versa. For example, in Figure 5, 𝐺1 is extended by 𝐺2 , and 𝐺2 is extended by 𝐺3 . For the
model graph (6), we have that 𝐺2 is a no-instance, while 𝐺1 and 𝐺3 are yes-instances.
   In view of the aforementioned difficulties, we have decided to generate no-instances in a randomized
fashion. Given 𝑛 β©Ύ 4 and model graph 𝐻 that is not the model graph (1) of Figure 2, the idea is to
generate random graphs with 𝑛 vertices until a no-instance for H-PARTITION(𝐻) is found. To see
whether this approach is viable, we have generated random graphs with 𝑛 = 100 by adding an edge to
a graph with a given probability, its expected density. The expected density is considered as a random
variable whose probability distribution is a Gaussian distribution, 𝒩 (0.5, 0.25). This distribution seems
better than a β€œclassical” uniform distribution on the expected density because there are more possible
graphs with a density of 0.5 than 0.01 or 0.99. Table 1 shows, for each model graph in Figure 2, the
number of yes-instances and no-instances over a sample of 1000 generated graphs.
   For the model graphs (1), (2), (3), (4), (18), (22), (29) of Figure 2, there are more yes-instances than
no-instances. Except for (18), these model graphs have an isolated vertex and, by Lemma 5, an input
graph is a yes-instance as soon as it contains an 𝐻-isomorphic quadruplet. For the model graph (18),
a graph is easily a yes-instance because it suffices to have an edge (𝑒, 𝑣) such that 𝑒 is nonadjacent
to at least two other vertices: the vertex 𝑒 will be labeled by 𝐢, all vertices adjacent to 𝑒 will have
the label 𝐴, and all nonadjacent vertices will have label 𝐡 or 𝐷. For model graphs that are distinct
from the above seven model graphs, there are considerably more no-instances than yes-instances. In
conclusion, our approach should find a no-instance in a few tries, except for the seven models that have
been discussed before, for which we will use the no-instances of the proof of Proposition 10.

5.3. Execution Times
We have used the answer set solver Clingo [2, 3] to compare the execution times of ASP guess-and-check
programs with programs in Datalog with stratified negation. Figure 6 shows execution times on input
graphs of different small sizes that were generated as previously explained. The execution times reported
                               model graph   # yes   # no   model graph   # yes   # no
                                   (1)       1000       0      (18)        999       1
                                   (2)       1000       0      (19)        185     815
                                   (3)       1000       0      (20)          15    985
                                   (4)        998       2      (21)          35    965
                                   (5)          15    985      (22)       1000       0
                                   (6)        175     825      (23)          15    985
                                   (7)          13    987      (24)          15    985
                                   (8)          15    985      (25)          14    986
                                   (9)          13    987      (26)          56    944
                                  (10)           9    991      (27)          15    985
                                  (11)           0   1000      (28)           5    995
                                  (12)           0   1000      (29)       1000       0
                                  (13)           0   1000      (30)           0   1000
                                  (14)           2    998      (31)           0   1000
                                  (15)           4    996      (32)           6    994
                                  (16)           4    996      (33)          15    985
                                  (17)        183     817      (34)          12    988

Table 1
Proportion of yes- and no-instances.




Figure 6: Execution time in Clingo (the blue line is hidden behind the yellow line).


in Figure 6 are average execution times over the 34 model graphs of Figure 2. It is immediately clear
from this figure that when executed by Clingo, the guess-and-check program is much more efficient
than our Datalog programs with stratified negation. The difference in efficiency was even more striking
for larger graphs. In fact, on graphs with more than 50 vertices, we encountered memory problems
when executing our Datalog programs in Clingo, which seem to be due to the size of the grounded
program. In search for an explanation, we displayed and investigated the grounded rules in Clingo. The
grounded Datalog programs only contain true atoms, i.e., rules whose body has already been evaluated
as true and therefore left empty. Figure 7 shows that the Datalog programs yield significantly more
grounded rules than the guess-and-check programs. Datalog often yields more than 250 000 true atoms
while guess-and-check never results in more than 5000 ground rules.
Figure 7: Number of true atoms (Datalog) and grounded rules (ASP) in Clingo (the blue line is hidden behind
the yellow line).


6. Conclusion
We presented a logical programming approach to the problem of finding 𝐻-partitions in undirected
graphs. In particular, we showed how the polynomial-time solutions given in [1] can be encoded in
Datalog with stratified negation. In an experimental validation, we found that in the answer set solver
Clingo, these Datalog programs execute much slower than a simple guess-and-check program. We also
studied the problem of generating yes- and no-instances for H-PARTITION with a fixed number of
vertices or edges.
   Our experiments indicate that when using an answer set solver, there may be no benefit in writing
programs that are theoretically more efficient than guess-and-check programs. It would be interesting
to investigate execution times of our Datalog programs on a dedicated Datalog engine. It would also be
interesting to find systematic methods for generating no-instances with a fixed number of vertices or
edges.


References
[1] S. Dantas, C. M. H. de Figueiredo, S. Gravier, S. Klein, Finding 𝐻-partitions efficiently, RAIRO Theor.
    Informatics Appl. 39 (2005) 133–144. URL: https://doi.org/10.1051/ita:2005008. doi:10.1051/ita:
    2005008.
[2] M. Gebser, R. Kaminski, A. KΓΆnig, T. Schaub, Advances in gringo series 3, in: J. P. Delgrande,
    W. Faber (Eds.), Logic Programming and Nonmonotonic Reasoning - 11th International Conference,
    LPNMR 2011, Vancouver, Canada, May 16-19, 2011. Proceedings, volume 6645 of Lecture Notes in
    Computer Science, Springer, 2011, pp. 345–351. URL: https://doi.org/10.1007/978-3-642-20895-9_39.
    doi:10.1007/978-3-642-20895-9βˆ–_39.
[3] M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub, Clingo = ASP + control: Preliminary report, CoRR
    abs/1405.3694 (2014). URL: http://arxiv.org/abs/1405.3694. arXiv:1405.3694.
[4] S. Abiteboul, R. Hull, V. Vianu, Foundations of Databases, Addison-Wesley, 1995. URL: http://
    webdam.inria.fr/Alice/.
[5] C. M. H. de Figueiredo, S. Klein, Y. Kohayakawa, B. A. Reed, Finding skew partitions effi-
    ciently, J. Algorithms 37 (2000) 505–521. URL: https://doi.org/10.1006/jagm.1999.1122. doi:10.1006/
    jagm.1999.1122.
[6] W. S. Kennedy, B. A. Reed, Fast skew partition recognition, in: H. Ito, M. Kano, N. Katoh,
    Y. Uno (Eds.), Computational Geometry and Graph Theory - International Conference, KyotoCGGT
    2007, Kyoto, Japan, June 11-15, 2007. Revised Selected Papers, volume 4535 of Lecture Notes in
    Computer Science, Springer, 2007, pp. 101–107. URL: https://doi.org/10.1007/978-3-540-89550-3_11.
    doi:10.1007/978-3-540-89550-3βˆ–_11.
[7] C. N. Campos, S. Dantas, L. Faria, S. Gravier, 2K2 -partition problem, Electron. Notes Dis-
    cret. Math. 22 (2005) 217–221. URL: https://doi.org/10.1016/j.endm.2005.06.031. doi:10.1016/
    j.endm.2005.06.031.
[8] C. Capon, N. Lecomte, J. Wijsen, Computing h-partitions in ASP and datalog, CoRR abs/2202.03730
    (2022). URL: https://arxiv.org/abs/2202.03730. arXiv:2202.03730.