<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Diversity of Answers to Conjunctive Queries (Extended Abstract)</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Timo Camillo Merkl</string-name>
          <email>timo.merkl@tuwien.ac.at</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Reinhard Pichler</string-name>
          <email>reinhard.pichler@tuwien.ac.at</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>SebastianSkritek</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Query Answering, Diversity of Solutions</institution>
          ,
          <addr-line>Complexity, Algorithms</addr-line>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>TU Wien</institution>
          ,
          <country country="AT">Austria</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>answers. Enumeration problems aim at outputting, without repetition, the set of solutions to a given problem instance. However, outputting the entire solution set may be prohibitively expensive if it is too big. In this case, outputting a small, suficiently diverse subset of the solutions would be preferable. This leads to the Diverse-version of the original enumeration problem, where the goal is to achieve a certain level d of diversity by selecting k solutions.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Answering database queries is one of the most fundamental tasks in computer science and
has thus been the topic of countless theoretical analyses from numerous diferent perspectives.
Classically, the focus of complexity studies by the database theory community has been on
decision problems such as deciding if the query result is non-empty or if a given tuple is
contained in the query result. In recent times, the enumeration problem (i.e., outputting all
answers to a query) has played a prominent role on the research agenda, see e.g1., 2[
        <xref ref-type="bibr" rid="ref3">, 3</xref>
        ].
      </p>
      <p>It is well known that even seemingly simple problems, such as answering an acyclic
Conjunctive Query, can have a huge number of solutions. Consequently, specific notions of tractability
were introduced right from the beginning of research on enumeration proble m4]st[o separate
the computational intricacy of a problem from the mere size of the solution space. However,
even with these refined notions of tractability, the usefulness of flooding the user with tons of
solutions (many of them possibly difering only minimally) may be questionable. If the solution
space gets too big, it would be more useful to provide an overview by outputting a “meaningful”
subset of the solutions.</p>
      <p>For instance, consider a variation of the car dealership example from5][. Suppose that
models the preferences of a customer and( )</p>
      <p>are all cars that match these restrictions. Now,
nEvelop-O
in a large dealership, presenting all cars in ( ) to the customer would be infeasible. Instead, it
would be better to go through a rather small list of cars that are significantly diferent from
each other. With this, the customer can point at those cars which the further discussion with
the clerk should concentrate on.</p>
      <p>This example suggests that we should focus on finding a smalldiverse set of answers to
database queries. Due to the inherent hardness of computing maximally diverse solutio5n],s [
the database community – apart from limited exception6]s –[ mostly focused on heuristic and
approximation methods to find diverse answers (see 7[] for an extensive survey). The present
work takes a step forward to fill this void, broadening our understanding of the theoretical
boundaries of diverse query answering while developing complementary exact algorithms.
More specifically, we analyze diversity problems related to answering Conjunctive Queries
(CQs) and extensions thereof.</p>
      <p>Problem statement. To formalize the problems, we roughly follow the approach from 8[] by
defining the diversity of a set of answers (tuples) to be their aggregated pairwise distances.
Furthermore, in the spirit of classical relational database theory, we consider the data untyped
and use the Hamming distancΔe( ,  ′) as the measure of distance between two answer tuples
 ,  ′. As far as the choice of an aggregator is concerned, we impose the general restriction
that it must be computable in polynomial time. Formally, for a cl assof queries we study the
following problem Diverse- :</p>
      <p>Diverse-
Instance: A database instance, query  ∈  , and integer s and  .</p>
      <p>Question: Do there exist pairwise distinct answe r1s, … ,   ∈ ( ) (diversity</p>
      <p>set) such that ((Δ(  ,   ))1≤&lt;≤ ) ≥  ?</p>
      <p>That is, we ask if a certain leve l of diversity can be achieved by choosin g pairwise distinct
answers to a given query over the database instan ce.Since we are intuitively looking fosrmall
diversity sets, we usually conside r to be a problem parameter in the sense of parameterized
complexity.</p>
      <p>For proving upper bounds on the complexity in terms of membership, we aim for the most
general setting, i.e., the most general class of aggregatorasnd the biggest query class . On
the other hand, for lower bounds in terms of hardness proofs, we aim for the most restrictive,
i.e., a concrete (but natural) aggregatorand the smallest query class . In particular, the
natural aggregators minimum and sum will be used to prove lower bounds while, for the
upper bound, we either impose no further restriction onor require them to be monotone
in addition, i.e.,(( , )1≤&lt;≤ ) ≤  (( ,′ )1≤&lt;≤ ) whenever  , ≤  ,′ holds for every 1 ≤  &lt;
 ≤  . The corresponding diversity problems are denoted bDyiversemin- , Diversesum- , and
Diversemon- , respectively.</p>
      <p>
        As for the query classes , we start our analysis with the clasCsQ of Conjunctive Queries and
then extend our studies to the classUeCsQ and CQ¬ of unions of CQs and CQs with negation.
As the most general query class, we will also look at the claFssO of all first-order queries. Recall
that, even the question if an answer tuple exists at aNllPis-complete for CQs [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. We therefore
mostly restrict our study to CQs with bounded generalized hypertree wigdhtwh)(. For CQs¬,
query answering remainsNP-complete even if we only consider queries witghhw ≤ 1 [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
Hence, for CQ¬ we impose bounded treewidtht w(), a stricter structural restriction. Lastly, for
arbitrary FO queries, we assume them to be fixed or, equivalently, bounded in size.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Preliminaries</title>
      <p>a labeling  ∶  ( ) → 2</p>
      <p>()
defined as follows:
Queries. Formally, we can consider our various query classes as fragments of first-order logic
with the corresponding database being a matching finite first-order structure and answers being
assignments on the free variables. CQs are formulae solely using the connectiv{∃e,s∧}, while
UCQs additionally allow{∨} as a top-level connective and CQ¬sadditionally allow negated
atoms.
 ∶  ( ) → 2
 ( )
Acyclicity and widths. (Generalized hyper-)tree decompositions and their corresponding widths
are staple tools to express the acyclicity of CQs (with negation) and define large tractable
query classes. A tree decompositions of a CQ¬  is a tuple ⟨ ,  ⟩
such that is a tree and
()</p>
      <p>. Furthermore, for each atom , all its variables have to appear in some
together, and for each variable, the vertice s where  appears in  ( )
have to induce a
connected subtree in. A generalized hypertree decomposition extends a tree decomposition by
such that, for every nod e in  , every variable of  ( )
appears
in some atom of( ) . Then the treewidth of and the generalized hypertree width ofare
tw() =
min max | ( )| − 1,
⟨ ,⟩

ghw() =
⟨ ,,⟩
min max |( )|.</p>
      <p>CQs  are called acyclic (ACQs) if ghw() = 1 and UCQs  = ∨    are called acyclic (UACQs) if
all conjunctions  are acyclic.</p>
      <p>Parameterized Complexity. An instance of aparameterized problem is given as a pair (, ) , where
 is the actual problem instance andis a parameter. A problem is inFPT (fixed-parameter
tractable), if it can be solved in time( () ⋅ ||
and inXP, if it can be solved in time(||</p>
      <p>
        ) (for some computable functio n and constant)
 () ). Furthermore, there is a classW[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] in between
FPT and XP, i.e., FPT ⊆ W[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] ⊆ XP. It is a generally accepted assumption in parameterized
complexity theory thaFtPT ≠ W[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] holds – similar but slightly stronger than the famous
P ≠ NP assumption in classical complexity theory.
      </p>
    </sec>
    <sec id="sec-3">
      <title>3. Main Results</title>
      <p>The main novel lower bounds of our work are the following hardness results:
Theorem 1. On
queries
of
bounded
tw,
the
problems</p>
      <p>
        Diversesum-CQ
and
Diversemin-CQ are  [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]-hard, and on queries of bounded size, the same problems remain  
hard in the unparameterized case.
      </p>
      <p>
        The theorem follows by reduction from the (parameterizeIdn)dependent Set problem. In the
case where arbitrarily large, albeit almost acyclic, queries are allowed, the reduction preserves
the parameter and impliesW[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]-hardness. On the other hand, getting by with bounded size
queries requires a more involved reduction, which then no longer preserves the parameter and
thus, only implies unparameterizedNP-hardness.
      </p>
      <p>Somewhat surprisingly, dealing with UCQs is significantly harder than dealing with CQs.
Theorem 2. On UACQs and when the size of the sought-after diversity set  is at most two, the
problems Diversesum-UCQ and Diversemin-UCQ remain   -hard.</p>
      <p>Intuitively, this comes down to the fact that even if all conjuncts of a query are acyclic, the
interconnectedness of two or more conjuncts can be arbitrarily cyclic. Furthermore, when
searching for diverse answers to UCQs, it is not suficient to solve the conjuncts independently.</p>
      <p>
        Complementing theW[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]-hardness result, we establish the following memberships:
Theorem 3. On queries of bounded ghw, the problem Diverse-CQ, and on queries of bounded tw,
the problem Diverse-CQ¬ is in   .
      </p>
      <p>This runtime can be achieved by dynamic programming algorithms which maintain data
structures storing all possible-tuples of partial solutions together with all possible pairwise
Hamming distances. This data structure is then propagated along the (generalized hyper-)tree
decompositions. In the end, a witnessing diversity set can be extracted from the root. Crucially,
the size of the data structure is exponential onl y i(nand the (generalized hyper-)tree width).</p>
      <p>For queries of bounded size, an even faster algorithm is developed.</p>
      <p>Theorem 4. On queries of bounded size, the problem Diversemon-  is in    .</p>
      <p>Such a runtime is achieved by a kernelization algorithm. Essentially, first, all (polynomially
many) query answers are computed. Then, the answers are grouped by all possible subsets of
the columns, and whenever a group exceeds a certain threshold, insuficiently diverse members
of the group are discarded.</p>
      <p>Table 1 summarizes the discussed results.</p>
      <p>Query class
bounded ghw CQ
bounded tw CQ¬</p>
      <p>UACQ
bounded size FO</p>
      <p>Lower Bound</p>
      <p>
        W[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]
      </p>
      <p>
        W[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]
NP* for  = 2
      </p>
      <p>NP*</p>
      <p>Upper Bound</p>
      <p>XP
XP
FPT</p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion and Future Work</title>
      <p>
        In this work, we took a fresh look at thDeiversity problem of query answering. Looking at
diferent classes of queries from CQs to FO queries, we provide a fairly complete picture of
complexity results. Nevertheless, numerous directions for future work exist, including:
Restricting the database. We primarily focused on restrictions on the queries. However,
restricting the database is also a viable option with far-reaching implications in related areas. Our full
paper contains some preliminary results1[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
      <p>
        Further parameterization. Exploring further parameterizations besides the size of the diversity
set seems interesting. For instance, choosing the diversity thresh oleldad to intriguing results
in [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
      </p>
      <p>Alternative distance measure. The Hamming distance might not a suitable distance measure
in all situation. It might thus be interesting to consider replacing it by more specific distance
measures derived from domain specific metrics.</p>
    </sec>
    <sec id="sec-5">
      <title>Acknowledgments</title>
      <p>This work has been funded by the Vienna Science and Technology Fund (WWTF) [10.47379/ICT2201,
10.47379/VRG18013, 10.47379/NXT22018]; and the Christian Doppler Research Association
(CDG) JRC LIVE.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>A.</given-names>
            <surname>Amarilli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Jachiet</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Muñoz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Riveros</surname>
          </string-name>
          ,
          <article-title>Eficient enumeration for annotated grammars</article-title>
          , in: PODS, ACM,
          <year>2022</year>
          , pp.
          <fpage>291</fpage>
          -
          <lpage>300</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Kobayashi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Kurita</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Wasa</surname>
          </string-name>
          ,
          <article-title>Linear-delay enumeration for minimal steiner problems</article-title>
          , in: PODS, ACM,
          <year>2022</year>
          , pp.
          <fpage>301</fpage>
          -
          <lpage>313</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>C.</given-names>
            <surname>Lutz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Przybylko</surname>
          </string-name>
          ,
          <article-title>Eficiently enumerating answers to ontology-mediated queries</article-title>
          , in: PODS, ACM,
          <year>2022</year>
          , pp.
          <fpage>277</fpage>
          -
          <lpage>289</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>D. S.</given-names>
            <surname>Johnson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. H.</given-names>
            <surname>Papadimitriou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Yannakakis</surname>
          </string-name>
          ,
          <article-title>On generating all maximal independent sets, Inf</article-title>
          . Process. Lett.
          <volume>27</volume>
          (
          <year>1988</year>
          )
          <fpage>119</fpage>
          -
          <lpage>123</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>E.</given-names>
            <surname>Hebrard</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Hnich</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. O</given-names>
            <surname>'Sullivan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Walsh</surname>
          </string-name>
          ,
          <article-title>Finding diverse and similar solutions in constraint programming</article-title>
          ,
          <source>in: AAAI</source>
          , AAAI Press / The MIT Press,
          <year>2005</year>
          , pp.
          <fpage>372</fpage>
          -
          <lpage>377</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>T.</given-names>
            <surname>Deng</surname>
          </string-name>
          , W. Fan,
          <article-title>On the complexity of query result diversification</article-title>
          ,
          <source>ACM Trans. Database Syst</source>
          .
          <volume>39</volume>
          (
          <year>2014</year>
          )
          <volume>15</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>15</lpage>
          :
          <fpage>46</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>K.</given-names>
            <surname>Zheng</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Qi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Gao</surname>
          </string-name>
          ,
          <article-title>A survey of query result diversification</article-title>
          ,
          <source>Knowl. Inf. Syst</source>
          .
          <volume>51</volume>
          (
          <year>2017</year>
          )
          <fpage>1</fpage>
          -
          <lpage>36</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>L.</given-names>
            <surname>Ingmar</surname>
          </string-name>
          ,
          <string-name>
            <surname>M. G. de la Banda</surname>
            ,
            <given-names>P. J.</given-names>
          </string-name>
          <string-name>
            <surname>Stuckey</surname>
          </string-name>
          , G. Tack,
          <article-title>Modelling diversity of solutions</article-title>
          , in: AAAI, AAAI Press,
          <year>2020</year>
          , pp.
          <fpage>1528</fpage>
          -
          <lpage>1535</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>A. K.</given-names>
            <surname>Chandra</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. M.</given-names>
            <surname>Merlin</surname>
          </string-name>
          ,
          <article-title>Optimal implementation of conjunctive queries in relational data bases</article-title>
          , in: STOC, ACM,
          <year>1977</year>
          , pp.
          <fpage>77</fpage>
          -
          <lpage>90</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>M.</given-names>
            <surname>Samer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Szeider</surname>
          </string-name>
          ,
          <article-title>Algorithms for propositional model counting</article-title>
          ,
          <source>J. Discrete Algorithms</source>
          <volume>8</volume>
          (
          <year>2010</year>
          )
          <fpage>50</fpage>
          -
          <lpage>64</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>T. C.</given-names>
            <surname>Merkl</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Pichler</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Skritek</surname>
          </string-name>
          ,
          <article-title>Diversity of answers to conjunctive queries</article-title>
          ,
          <source>in: ICDT</source>
          , volume
          <volume>255</volume>
          of LIPIcs,
          <year>2023</year>
          , pp.
          <volume>10</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>10</lpage>
          :
          <fpage>19</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>F. V.</given-names>
            <surname>Fomin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Golovach</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Jafke</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Philip</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Sagunov</surname>
          </string-name>
          ,
          <article-title>Diverse pairs of matchings</article-title>
          , in: ISAAC,
          <year>2020</year>
          , pp.
          <volume>26</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>26</lpage>
          :
          <fpage>12</fpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>