<!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>Counting Database Repairs Entailing a Query: The Case of Functional Dependencies</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>(Discussion Paper)</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Marco Calautti</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ester Livshits</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Andreas Pieris</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Markus Schneider</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>DISI, University of Trento</institution>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Cyprus</institution>
          ,
          <country country="CY">Cyprus</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>University of Edinburgh</institution>
          ,
          <country country="UK">UK</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>A key task in the context of consistent query answering is to count the number of repairs that entail the query, with the ultimate goal being a precise data complexity classification. This has been achieved in the case of primary keys and self-join-free conjunctive queries (CQs) via an FP/♯P-complete dichotomy. We lift this result to the more general case of functional dependencies (FDs). Another important task in this context is whenever the counting problem in question is intractable, to classify it as approximable, i.e., the target value can be eficiently approximated with error guarantees via a fully polynomial-time randomized approximation scheme (FPRAS), or as inapproximable. Although for primary keys and CQs (even with self-joins) the problem is always approximable, we prove that this is not the case for FDs. We show, however, that the class of FDs with a left-hand side chain forms an island of approximability. We see these results, apart from being interesting in their own right, as crucial steps towards a complete classification of approximate counting of repairs in the case of FDs and self-join-free CQs.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        A database is inconsistent if it does not satisfy its integrity constraints. There is a consensus
that inconsistency is a real-life phenomenon that arises due to many reasons such as integration
of conflicting sources. With the aim of obtaining conceptually meaningful answers to queries
posed over inconsistent databases, Arenas, Bertossi, and Chomicki introduced in the late 1990s
the notion of Consistent Query Answering (CQA) [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. The key elements underlying CQA are
(i) the notion of (database) repair of an inconsistent database , that is, a consistent database
whose diference with  is somehow minimal, and (ii) the notion of query answering based on
certain answers, that is, answers that are entailed by every repair.
      </p>
      <p>
        Example 1. Consider the relation name Employee(id, name, dept) that comes with the constraint
that the attribute id functionally determines name and dept. Consider also the database 
consisting of the tuples: (1, Bob, HR), (1, Bob, IT), (2, Alice, IT), (2, Tim, IT). It is easy to see that
 is inconsistent since we are uncertain about Bob’s department, and the name of the employee
with id 2. To devise a repair, we need to keep one tuple from each conflicting pair, which leads to a
maximal subset of  that is consistent. Observe now that the query that asks whether employees 1
and 2 work in the same department is true only in two out of four repairs, and thus, not entailed.
Counting Repairs Entailing a Query. A key task in this context is to count the number of
repairs of an inconsistent database  w.r.t. a set Σ of constraints that entail a given query ;
for clarity, we base our discussion on Boolean queries. Given a set Σ of constraints and a query
, the problem ♯Repairs(Σ , ) that takes as input a database , and asks for the number of
repairs of  w.r.t. Σ that entail , can be tractable or intractable depending on the shape of Σ
and . This leads to the natural question whether we can establish a complete classification,
i.e., for every Σ and , classify ♯Repairs(Σ , ) as tractable or intractable by simply inspecting
Σ and . We already know from [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] that for a set Σ of primary keys, and a self-join-free
conjunctive queries (SJFCQs) query , ♯Repairs(Σ , ) is either in FP or ♯P-complete, and we
can determine in polynomial time, by simply analyzing Σ and , which complexity statement
holds. However, the dichotomy result in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] does not apply when we consider the more general
class of functional dependencies (FDs). This brings us to the following question:
Question 1: Can we lift the dichotomy result for primary keys and SJFCQs to the more general
case of functional dependencies?
      </p>
      <p>
        The closest known result related to Question 1 is for the problem ♯Repairs(Σ) , where Σ is
a set of FDs, that given a database , asks for the number of repairs of  w.r.t. Σ (without
considering a query). In particular, we know from [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] that whenever Σ has a so-called left-hand
side (LHS, for short) chain (up to equivalence), ♯Repairs(Σ) is in FP; otherwise, it is ♯P-complete.
Approximate Counting. Another key task is to classify ♯Repairs(Σ , ), whenever it is
intractable, as approximable via a so-called fully polynomial-time randomized approximation
scheme (FPRAS), or as inapproximable.
      </p>
      <p>
        For a set Σ of primary keys, and a CQ  (even with self-joins), ♯Repairs(Σ , ) is always
approximable [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. The next question is whether we can obtain a full classification for FDs:
Question 2: For a set Σ of FDs, and an SJFCQ , can we determine whether ♯Repairs(Σ , )
admits an FPRAS by inspecting Σ and ?
Summary of Contributions. Concerning Question (1), we lift the dichotomy of [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] for primary
keys and SJFCQs to the general case of FDs (Theorem 4). Concerning Question (2), although we
do not establish a complete classification (which would resolve a challenging open problem), we
show that, for every set Σ of FDs with an LHS chain (up to equivalence) and a CQ  (even with
self-joins), ♯Repairs(Σ , ) admits an FPRAS. On the other hand, we show that there is a very
simple set Σ of FDs such that, for every SJFCQ , ♯Repairs(Σ , ) does not admit an FPRAS
(under a standard complexity assumption).
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Preliminaries</title>
      <p>We consider the disjoint countably infinite sets C and V of constants and variables, respectively.
For  &gt; 0, let [] be the set {1, . . . , }, and for a finite set , let ♯ be the cardinality of .
Relational Databases. A schema S is a finite set of relation names with associated arity; we
write / to denote that  has arity  &gt; 0. Each relation name / is associated with a tuple
of distinct attribute names (1, . . . , ); we write att() for the set {1, . . . , }. A position
of S is a pair (, ), where  ∈ S and  ∈ att(), that essentially identifies the attribute  of
. A atom  over S is an expression of the form (1, . . . , ), where / ∈ S, and  ∈ C ∪ V
for each  ∈ []. A fact is an atom mentioning only constants; we may say -atom/fact to
indicate that the relation name is . For an atom  = (1, . . . , ), with (1, . . . , ) being
the tuple of attribute names of , we write  [] for the term . A database  over S is a finite
set of facts over S. We write , for  ∈ S, for the database {(¯) | (¯) ∈ }. The active
domain of , denoted dom(), is the set of constants occurring in .</p>
      <p>Functional Dependencies. A functional dependency (FD)  over a schema S is an expression
of the form  :  →  , where / ∈ S and ,  ⊆ att(); we say -FD to indicate that
the relation name is . We call  a key if  ∪  = att(). Given a set Σ of FDs over S, we
write Σ , for  ∈ S, for the set { ∈ Σ |  is an -FD}. We call Σ a set of primary keys if it
consists only of keys, and |Σ | ≤ 1 for each  ∈ S. A database  over S satisfies an FD 
over S, denoted  |= , if, for every two -facts ,  ∈  the following holds:  [] = []
for every  ∈  implies  [] = [] for every  ∈  . We say that  is consistent w.r.t. a set
Σ of FDs, written  |= Σ , if  |=  for every  ∈ Σ ; otherwise,  is inconsistent w.r.t. Σ . Two
sets of FDs Σ , Σ ′ are equivalent if, for every database ,  |= Σ if  |= Σ ′.
Conjunctive Queries. A (Boolean) conjunctive query (CQ)  over S is an expression of the
form ∃¯1, . . . , ∃¯ 1(¯1) ∧ · · · ∧ (¯), where each (¯), for  ∈ [], is an atom over S.
With abuse of notation we may treat  as the set of its atoms. The query  is a self-join-free
CQ (SJFCQ) if it mentions every relation name of S at most once. Let var() and const() be
the set of variables and constants in , respectively. A homomorphism from  to a database
 is a function ℎ : var() ∪ const() → dom(), which is the identity over C, such that
(ℎ(¯)) ∈  for  ∈ []. We say that  entails , and write  |=  if there exists a
homomorphism from  to . We point out that in this paper we are only dealing with Boolean
queries, but all the presented results can be generalized to non-Boolean CQs.
Database Repairs. Given a database  and a set Σ of FDs, both over a schema S, a repair of
 w.r.t. Σ is a maximal subset ′ of  such that ′ |= Σ . Let repΣ() be the set of repairs
of  w.r.t Σ . Given a CQ  over S, we write repΣ,() for {′ ∈ repΣ() | ′ |= }. The
following is a useful observation that we will exploit later in the paper:
Lemma 2. Consider a database , a set Σ of FDs, and a Boolean SJFCQ . We can compute in
polynomial time a database ′ such that ♯repΣ() = ♯repΣ,(′).</p>
      <p>Problem Definition. For each set Σ of FDs and CQ , we focus on the problem ♯Repairs(Σ , ),
which takes as input a database , and asks for the number ♯repΣ,(). The goal is to classify
it as tractable (place it in FP) or as intractable (show that is ♯P-complete).</p>
      <p>
        Another important task is whenever ♯Repairs(Σ , ) is intractable to classify it as
approximable via a so-called fully polynomial-time randomized approximation scheme (FPRAS, for
short), or as inapproximable. Formally, an FPRAS for ♯Repairs(Σ , ) is a randomized algorithm
A that takes as input a database , and numbers  &gt; 0 and 0 &lt;  &lt; 1, runs in
polynomial time in ||||, 1/ and log(1/ ), and produces a random variable A(, ,  ) such that
Pr (︀ |A(, ,  ) − ♯repΣ,()| ≤  · ♯repΣ,())︀ ≥ 1 − .
LHS Chain FDs. Consider a set Σ of FDs over S, and a relation name  ∈ S. We say that
Σ  has a left-hand side chain (LHS chain) if the FDs of Σ  can be arranged in a sequence
 : 1 → 1, . . . ,  :  →  such that 1 ⊆ 2 ⊆ · · · ⊆  [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. We call such a sequence
an LHS chain of Σ , and say that Σ has an LHS chain if, for every  ∈ S, Σ  has an LHS chain.
We know that for sets of FDs with an LHS chain, counting the number of repairs is tractable:
Proposition 3 ([
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]). Given a database , and a set Σ of FDs with an LHS chain (up to
equivalence), ♯repΣ() is computable in polynomial time in ||||.
      </p>
    </sec>
    <sec id="sec-3">
      <title>3. Exact Counting</title>
      <p>The goal of this section is to discuss the key ideas behind our main result on exact counting:
Theorem 4. For a set Σ of FDs, and an SJFCQ , ♯Repairs(Σ , ) is either in FP or ♯P-complete,
and we can decide in polynomial time in ||Σ || + |||| which of the two cases hold.</p>
      <p>
        We observe that for every set Σ of FDs, and an SJFCQ , ♯Repairs(Σ , ) is in ♯P: simply guess
(in polynomial time) a subset ′ of the given database , and verify (again in polynomial time)
that ′ is a repair of  w.r.t. Σ that entails . We also note that the non-existence of an LHS
chain (up to equivalence) is a preliminary boundary for the hard side of the target dichotomy,
regardless of the CQ. We know from [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] that, for a set Σ of FDs, the problem ♯Repairs(Σ) ,
which given a database , asks for ♯repΣ(), is ♯P-hard whenever Σ does not have an LHS
chain (up to equivalence). From the above discussion, and Lemma 2, we get the following result:
Proposition 5. Consider a set Σ of FDs without an LHS chain (up to equivalence), and an SJFCQ
. ♯Repairs(Σ , ) is ♯P-complete.
      </p>
      <p>
        From Proposition 5, and the fact that checking whether a set Σ of FDs has an LHS chain (up
to equivalence) is feasible in polynomial time [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], to obtain Theorem 4, it sufices to provide an
analogous result for FDs with an LHS chain (up to equivalence). To this end, following what
was done for primary keys in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], we are going to concentrate on the problem of computing
the relative frequency of the query. The relative frequency of a CQ  w.r.t. a database  and a
set Σ of FDs is defined as the ratio rfreq,Σ() = ♯r♯erpepΣΣ,(()) that computes the percentage of
repairs that entail the query . We then define the problem RelFreq(Σ , ) that takes as input a
database , and asks for rfreq,Σ(). We can indeed focus on RelFreq(Σ , ) since we know
from Proposition 3 that ♯Repairs(Σ) is in FP whenever Σ has an LHS chain (up to equivalence),
which implies that ♯Repairs(Σ , ) and RelFreq(Σ , ) have the same complexity, that is, both
are either in FP or ♯P-hard. Consequently, to obtain Theorem 4 it sufices to show the following:
Theorem 6. For a set Σ of FDs with an LHS chain (up to equivalence), and an SJFCQ ,
RelFreq(Σ , ) is either in FP or ♯P-hard, and we can decide in polynomial time in ||Σ || + ||||
which of the two cases hold.
      </p>
      <p>
        In the rest, we give some hints on the proof of Theorem 6; we first need some new notions.
Canonical Covers. If Σ has an LHS chain (up to equivalence), we know that it has a single
canonical cover1 Σ ′, and Σ ′ has an LHS chain [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Furthermore, it can be verified that, for every
1That is, (i) the FDs in Σ are not redundant and have no redundant attributes, and (ii) for a relation name  and
 ⊆ att(), there is at most one FD in Σ of the form  :  →  .
relation name  occurring in Σ ′, there exists a unique sequence  : 1 → 1, . . . ,  :  →
 of the FDs of Σ ′, which we call the LHS chain of Σ ′, such that (i)  ⊊ +1 for each
 ∈ [ − 1], (ii)  ∩  = ∅ for each ,  ∈ [], and (iii)  ∩  = ∅ for each ,  ∈ [] with
 ̸= . Since a canonical cover of a set of FDs can be computed in polynomial time, to establish
Theorem 6 it sufices to show it for sets of FDs with an LHS chain that are canonical. Therefore,
in the rest of the section, we assume that sets of FDs are canonical.
      </p>
      <p>Primary FDs and Positions. Consider now an SJFCQ . Let   be the -atom in , and let
Λ  =  : 1 → 1, . . . ,  :  →  be the LHS chain of Σ . We call an FD  :  → , for
some  ∈ [], the primary FD of Σ  w.r.t.  if  ∪ contains an attribute  such that at position
(, ) in   we have a variable, whereas at each position of {(, ) |  ∈  ∪  for  &lt; }
in   we have a constant. Note that there is no guarantee that the primary FD of Σ  w.r.t. 
exists. If the primary FD  :  →  of Σ  w.r.t.  exists, for some  ∈ [], then the
primarylhs positions of   (w.r.t. Σ ) are the positions {(, ) |  ∈ }, while the non-primary-lhs
positions of   (w.r.t. Σ ) are the positions {(, ) |  ∈ att() ∖ }. We further call the
sequence of FDs  : 1 → 1, . . . ,  : − 1 → − 1 the primary prefix of Σ  w.r.t. . If the
primary FD of Σ  w.r.t.  does not exist, then, by convention, the primary-lhs positions of  
are the positions {(, ) |  ∈ att()}, i.e., all the positions in   are primary-lhs, which
in turn implies that   has no non-primary-lhs positions. Moreover, the primary prefix of
Σ  w.r.t.  is defined as the sequence Λ  itself. We denote by pvarΣ( ) the set of variables
occurring in   at primary-lhs positions of  .</p>
      <p>Query Complex Part. A variable  ∈ var() is a liaison variable (of ) if it occurs more than
once in . The complex part of  w.r.t. Σ , denoted compΣ(), is the set of atoms  of  in
which we have a constant or a liaison variable at a non-primary-lhs position (, ), with 
being the -atom of , such that, for every FD  :  →  in the primary prefix of Σ  w.r.t. ,
 ̸∈  ∪  . We observe that when compΣ() = ∅, the number of repairs of  w.r.t. Σ that
entail  coincides with the number of repairs (without any query) of the subset cΣo,nf of 
obtained after removing the facts of  that are somehow in a conflict with , and thus, they
cannot appear in a repair that entails . Since cΣo,nf can be computed in polynomial time in
||||, by Proposition 3 we obtain the following:
Proposition 7. Given a database , a set Σ of FDs with an LHS chain, and an SJFCQ  with
compΣ() = ∅, it holds that rfreq,Σ() is computable in polynomial time in ||||.</p>
      <sec id="sec-3-1">
        <title>3.1. The Tractable Side</title>
        <p>We start by defining some properties that, when satisfied by a SJFCQ, allow to restate its relative
frequency in terms of the relative frequency of simpler queries.</p>
        <p>We write 1 ⊎ 2 for the CQ consisting of the atoms of two non-empty CQs 1, 2 that
share no atoms and variables, i.e., 1 ∩ 2 = ∅ and var(1) ∩ var(2) = ∅. We also write
↦→, where  ∈ var() and  ∈ C, for the CQ obtained from  after replacing  with .
Theorem 8. Consider a set Σ of FDs with an LHS chain, and a SJFCQ . For every database ,
the following hold:
1. If  = 1 ⊎ 2, then rfreq,Σ() = rfreq,Σ(1) × rfreq,Σ(2).
2. If compΣ() ̸= ∅, and there exists a variable  ∈ var() such that  ∈ pvarΣ( ) for every
 ∈ compΣ(), then there is * ⊆</p>
        <p>, computable in polynomial time in ||||, such that
⎛
⎝1 −</p>
        <p>∏︁
∈dom()</p>
        <p>︀( 1
rfreq,Σ()
=
− rfreq* ,Σ(↦→) ⎠ ×
︀)
⎞
♯repΣ
︁(</p>
        <p>∖ cΣo,nf)︁
♯repΣ()
.
3. If compΣ() ̸= ∅, and there exists an atom  = (¯) ∈ compΣ() such that pvarΣ( ) =
∅, and a variable  occurs in  at a position of {(, ) |  ∈  }, where  :  →  is the
primary FD of Σ  w.r.t. , then rfreq,Σ() = ∑︀
∈dom() rfreq,Σ(↦→).</p>
        <p>
          Item (1) of Theorem 8 is straightforward, and implies that when  = 1 ⊎ 2, one can
compute the relative frequency of  in polynomial time, if the same can be done for the relative
frequencies of 1 and 2. Items (2) and (3) are much more involved, and we refer the reader
to the full version of the paper [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ]. The main message is that when a SJFCQ  satisfies the
conditions of item (2), then its relative frequency is polynomial-time computable if so is for the
relative frequency of ↦→, for each constant  of the database, over a certain easily computable
subset * of , where  is as defined in item (2). Similarly, when
 satisfies the conditions
of item (3), then its relative frequency is polynomial-time computable, if so is for the relative
frequency of ↦→, for each constant  of the database, where  is as defined in item (3).
        </p>
        <p>For a set Σ of FDs with an LHS chain and an SJFCQ , we say that  is Σ -safe if either its
complex part is empty, i.e., compΣ() = ∅, or after recursively applying the conditions of items
(1)-(3) of Theorem 8 to , we are only left with queries having an empty complex part.2 By
definition of Σ -safe queries, and by Proposition 7 and Theorem 8, we obtain the following:
Theorem 9. Consider a set Σ of FDs with an LHS chain, and an SJFCQ . If  is Σ -safe, then
RelFreq(Σ , ) is in FP.</p>
        <p>Interestingly, safety exhausts the tractable side of the dichotomy stated in Theorem 6. That
establishes the second part of Theorem 6.
is, if  is not Σ -safe, then RelFreq(Σ , ) is ♯P-hard, as we discuss in the next section. Let us
stress that checking whether  is Σ -safe is feasible in polynomial time in ||Σ || + ||||, which</p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. The Hard Side</title>
        <p>
          We conclude this section by briefly discussing how the intractable side of the dichotomy stated
in Theorem 6 is obtained. We know from [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ] that, for every set Σ of primary keys, and an
SJFCQ  that is not Σ -safe, RelFreq(Σ , ) is ♯P-hard. Hence, with Theorem 9 in place, stating
that query safety ensures tractability, we can obtain the hard side of the dichotomy by showing:
Theorem 10. There is a set Σ ′ of primary keys, and a non Σ ′-safe SJFCQ ′ such that, for each set
Σ of FDs with an LHS chain and non Σ -safe SJFCQ , RelFreq(Σ ′, ′) reduces to RelFreq(Σ , ).
only one arbitrarily chosen constant from C, and thus the notion of Σ-safety is database independent.
        </p>
        <p>
          2We remark that for items (2) and (3), it is enough to recursively apply the conditions of Theorem 8 to ↦→ for
Theorem 10 is shown in two main steps. We first prove that there exists a set Σ * of FDs, and
an SJFCQ * such that RelFreq(Σ * , * ) can be reduced to RelFreq(Σ , ) by means of a set of
rewriting rules that extend the ones of [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ]. Second, we show that there is a set Σ ′ of primary
keys, and an SJFCQ ′ that is not Σ ′-safe such that, for every database , rfreq,Σ* (* ) =
rfreq,Σ′ (′), which then implies that RelFreq(Σ ′, ′) reduces to RelFreq(Σ * , * ), as needed.
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Approximate Counting</title>
      <p>
        We now briefly discuss our results on approximate counting. The main contribution of this
section is the following theorem; BPP is the class of decision problems that are eficiently
solvable via a randomized algorithm with a bounded two-sided error [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
      </p>
      <p>
        Theorem 11. For every set Σ of FDs with an LHS chain (up to equivalence), and a CQ ,
♯Repairs(Σ , ) admits an FPRAS. Moreover, for Σ ℎ = { : 1 → 2,  : 3 → 4}, where
att() = { |  ∈ [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]}, ♯Repairs(Σ ℎ, ) admits no FPRAS, for every SJFCQ , unless NP ⊆ BPP.
      </p>
      <p>
        To prove the approximability result we observe that ♯Repairs(Σ , ) can be seen as an
instantiation of the so-called union of sets problem [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], which given a succinct representation
of  ≥ 1 sets 1, . . . , , asks for the number | ⋃︀∈[] |. Indeed, given a database , let
hom,Σ() be the set of all homomorphic images of  in  that are consistent w.r.t. Σ .
Formally, hom,Σ() = {ℎ() | ℎ is a homomorphism from  to  such that ℎ() |= Σ }.
Hence, ♯repΣ,() = ⃒⃒⃒ ⋃︀∈[] repΣ, ()⃒⃒⃒ , assuming that hom,Σ() = {1, . . . , }.3
      </p>
      <p>
        From the above discussion, and the results of [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] on the approximability of the union of sets
problem, showing the existence of an FPRAS for ♯Repairs(Σ , ) boils down to showing that
for each  ∈ hom,Σ() we can (i) compute ♯repΣ, (), (ii) sample elements of repΣ, ()
uniformly at random, and (iii) check whether a database is in repΣ, (), all in polynomial time
in ||||. We prove that the above properties hold when Σ has an LHS chain (up to equivalence),
and the first part of Theorem 11 follows.
      </p>
      <p>
        The proof of the inapproximability of ♯Repairs(Σ ℎ, ), for every SJFCQ , employs a
socalled gap preserving reduction from the promise problem Gap3SAT , for some fixed  ∈ (0, 18 ),
i.e., the problem that given a Boolean formula  in 3CNF, asks whether  is satisfiable. The
promise is that if  is unsatisfiable, then every truth assignment makes at most 78 +  of the
clauses of  true. For every  ∈ (0, 81 ), Gap3SAT is NP-complete [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <p>For a fixed  ∈ (0, 18 ), the reduction maps each formula  to a database db( ) such that the
following holds: for any yes instance   of Gap3SAT , and any no instance   of Gap3SAT ,
the “gap” (i.e., the ratio) between the numbers ♯repΣℎ,(db(  )) and ♯repΣℎ,(db(  )) is so
large that an FPRAS for ♯Repairs(Σ ℎ, ) could be used, by employing a small enough error
 , to distinguish between yes and no instances of Gap3SAT with high probability, and thus,
placing the NP-complete problem Gap3SAT in BPP.</p>
      <p>
        The Dificulty Underlying a Dichotomy. Despite our eforts, we could not get a complete
approximability/inapproximability classification. However, in the full version of the paper [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
3By abuse of terminology, we treat each  as a CQ consisting of facts.
we show that obtaining such a classification is as hard as solving the challenging open question
whether ♯MaxMatch admits an FPRAS, i.e., the problem that given a bipartite graph , asks for
the number of maximal matchings in ; please refer to the full version for more details.
      </p>
    </sec>
    <sec id="sec-5">
      <title>5. Conclusion</title>
      <p>The obvious problems that remain open are the following: (1) lift the dichotomy of
Theorem 4 for FDs and self-join-free CQs to arbitrary CQs with self-joins, and (2) establish an
approximability/inapproximability dichotomy for FDs and SJFCQs.</p>
      <p>
        We point out that approximate versions of CQA have already been considered, both in
the database and ontological setting. In the database setting, to the best of our knowledge
[
        <xref ref-type="bibr" rid="ref10 ref4 ref9">4, 9, 10</xref>
        ] are the only works that focus on approximations in CQA. In particular, [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] studies
approximation algorithms for the relative frequency under primary keys only, which have also
been experimentally evaluated in [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. In [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], FDs are considered, but the notion of repair is
based on value updates, rather than tuple deletions, as we do. In the ontological setting, diferent
approximations have been considered. However, in this setting, approximations are understood
as subsets (i.e., sound but not complete) of the standard consistent answers (e.g., see [
        <xref ref-type="bibr" rid="ref11 ref12">11, 12</xref>
        ]).
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M.</given-names>
            <surname>Arenas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. E.</given-names>
            <surname>Bertossi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Chomicki</surname>
          </string-name>
          ,
          <article-title>Consistent query answers in inconsistent databases</article-title>
          ,
          <source>in: PODS</source>
          ,
          <year>1999</year>
          , pp.
          <fpage>68</fpage>
          -
          <lpage>79</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>D.</given-names>
            <surname>Maslowski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Wijsen</surname>
          </string-name>
          ,
          <article-title>A dichotomy in the complexity of counting database repairs</article-title>
          ,
          <source>J. Comput. Syst. Sci</source>
          .
          <volume>79</volume>
          (
          <year>2013</year>
          )
          <fpage>958</fpage>
          -
          <lpage>983</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>E.</given-names>
            <surname>Livshits</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Kimelfeld</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Wijsen</surname>
          </string-name>
          ,
          <article-title>Counting subset repairs with functional dependencies</article-title>
          ,
          <source>J. Comput. Syst. Sci</source>
          .
          <volume>117</volume>
          (
          <year>2021</year>
          )
          <fpage>154</fpage>
          -
          <lpage>164</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Console</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          ,
          <article-title>Counting database repairs under primary keys revisited</article-title>
          ,
          <source>in: PODS</source>
          ,
          <year>2019</year>
          , pp.
          <fpage>104</fpage>
          -
          <lpage>118</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Livshits</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Schneider</surname>
          </string-name>
          ,
          <article-title>Counting database repairs entailing a query: The case of functional dependencies</article-title>
          , in: PODS (to appear),
          <year>2022</year>
          , pp.
          <fpage>91</fpage>
          -
          <lpage>103</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>S.</given-names>
            <surname>Arora</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Barak</surname>
          </string-name>
          ,
          <string-name>
            <surname>Computational Complexity - A Modern Approach</surname>
          </string-name>
          , Cambridge University Press,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>R. M.</given-names>
            <surname>Karp</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Luby</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Madras</surname>
          </string-name>
          ,
          <article-title>Monte-carlo approximation algorithms for enumeration problems</article-title>
          ,
          <source>J. Algorithms</source>
          <volume>10</volume>
          (
          <year>1989</year>
          )
          <fpage>429</fpage>
          -
          <lpage>448</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>J.</given-names>
            <surname>Håstad</surname>
          </string-name>
          ,
          <article-title>Some optimal inapproximability results</article-title>
          ,
          <source>J. ACM</source>
          <volume>48</volume>
          (
          <year>2001</year>
          )
          <fpage>798</fpage>
          -
          <lpage>859</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Console</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          ,
          <article-title>Benchmarking approximate consistent query answering</article-title>
          ,
          <source>in: PODS</source>
          ,
          <year>2021</year>
          , pp.
          <fpage>233</fpage>
          -
          <lpage>246</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>S.</given-names>
            <surname>Greco</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Molinaro</surname>
          </string-name>
          ,
          <article-title>Probabilistic query answering over inconsistent databases</article-title>
          , Ann. Math. Artif. Intell.
          <volume>64</volume>
          (
          <year>2012</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>S.</given-names>
            <surname>Greco</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Molinaro</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Trubitsyna</surname>
          </string-name>
          ,
          <article-title>Computing approximate query answers over inconsistent knowledge bases</article-title>
          ,
          <source>in: IJCAI</source>
          ,
          <year>2018</year>
          , pp.
          <fpage>1838</fpage>
          -
          <lpage>1846</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>T.</given-names>
            <surname>Lukasiewicz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Malizia</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Molinaro</surname>
          </string-name>
          ,
          <article-title>Complexity of approximate query answering under inconsistency in datalog+/-</article-title>
          , in: IJCAI,
          <year>2018</year>
          , pp.
          <fpage>1921</fpage>
          -
          <lpage>1927</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>