Conjunctive Query Containment with Safe Negation and TGD One-Boundedness
Abstract
Query containment is a fundamental database problem which has been extensively studied for conjunctive queries (CQs). The most famous result is arguably the Homomorphism Theorem: a CQ is contained in a CQ iff there is a homomorphism from to . However, when extending conjunctive queries with safe base negation (CQ¬), this test becomes incomplete, hence, requiring significantly more expensive procedures due to its inherently harder complexity (-hard).
In this paper, we define and study the classes and : the classes of conjunctive queries extended with one or several safe negated atoms that satisfy the Homomorphism Theorem, and hence, whose containment check is in NP. To characterise them, we define what we call the dependency-version of a query, which is a dependency that, intuitively, models the databases in which the query is false. It turns out that, when the query contains one (several) negated atom(s), the query satisfies the Homomorphism Theorem iff its tgd(ded)-version is uniformly one-bounded. We also show that membership is EXPTIME-hard, but its complexity reduces to in the case, and to NP when bounding the number of positive atoms that can unify with the negated one.
Keywords and phrases:
conjunctive queries, query containment, safe negation, tgd, one-boundedness2012 ACM Subject Classification:
Theory of computation Logic and databases ; Theory of computation Database query processing and optimization (theory)Funding:
Supported by PID2021-127181OB-I00 (MCIN/AEI), and 2021-SGR-01252.Editors:
Balder ten Cate and Maurice FunkSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
Query containment stands as one of the most fundamental problems in databases. Given two queries, and , the query containment problem seeks to determine whether all the tuples retrieved by are also retrieved by , irrespective of the underlying data. This question finds applications across various domains, from information integration and query optimisation to materialised view maintenance and constraint checking [3]. Thus, extensive study has been devoted to this problem, particularly for conjunctive queries (CQ) under set semantics, which corresponds to the select-project-join subset of relational algebra. Indeed, in today’s database (DB) usage, CQs are the most prevalent kind of queries [17].
Given its significance, substantial algorithmic and theoretical research has tackled CQ containment. The most famous results, possibly, are that the problem is NP-complete and that it can be solved through a homomorphism test (aka Homomorphism Theorem) [5]. I.e., given two CQs and , we can check whether is contained in , noted as , by creating the canonical DB of (i.e. creating a DB by replacing every variable from with a new fresh constant), and querying over this canonical DB. From here, several refinements are possible. E.g., the problem becomes PTIME when the queries do not contain more than two atoms with the same predicate [19], or when we can bound its hypertree-width [10].
Yet, these results lose applicability when dealing with CQ extended with safe base negation (from now on ), i.e., queries containing negated atoms whose variables appear in positive atoms.
Example 1.
Consider the following boolean queries, which include safe negated atoms. retrieves whether there is some place that, despite having train connections to cities, is connected to some city by aeroplane but not by train. retrieves whether there is some place which, despite having some city connections, is not connected by train to some city:
qa() :- Connects(p,c1,Train), City(c1), Connects(p,c2,Aeroplane), City(c2), Connects(p,c2,Train). qb() :- Connects(p,c1,t), City(c1), City(c2), Connects(p,c2,Train).
Clearly, since there is a homomorphism from to (i.e., ). Indeed, the homomorphism test is always sound to check containment, even in [16]. From now on, we will write to indicate that there is a homomorphism from to .
However, the lack of homomorphism from to is not sufficient to assess that . Indeed, the homomorphism test is sound, but incomplete, in . Hence, a far more sophisticated technique is required. Indeed, under the presence of negated atoms, the problem is known to be -hard [7, 20]. Consequently, such techniques encompass generating and analysing an exponential number of different canonical versions of [8, 20].
To address this situation, in this paper we study the conjunctive queries extended with at most one negation (), and those extended with several negated atoms (), and characterise the classes and , i.e., their respective subclasses that satisfy the Homomorphism Theorem. That is, those boolean conjunctive queries with negation s.t., in essence, given any other boolean conjunctive query with negation , iff . This not only permits reducing the complexity to NP, but also exploiting the techniques given for checking homomorphisms faster [19, 10]. E.g., as we will see, both queries presented previously belong to . Thus, we can check containment via the homomorphism test, and, furthermore, since no predicate appears more than twice, we can do it in PTIME [19].
To identify whether a query belongs to or , we realise that it is equivalent to answering whether a full-dependency (a full-tgd in the case, and full-ded in the ), is uniformly one-bounded, or not, which is a property already studied in the context of logic programming [18, 13] and the chase algorithm [2]. A full-dependency is a rule of the form , where is a conjunction of atoms and is an atom s.t. . A full-dependency is a full-tgd when , and a full-ded when . Given a full-dependency , and a database , chasing with means, roughly speaking, creating the minimal necessary atoms to satisfy in . Do note that, if the predicate appears in , we might need to recursively chase . In essence, a full-dependency is said to be uniformly one-bounded if and only if, for any database , any fact obtained by the chase can be obtained in a single chase step (i.e., without recursion). Bounded (full-)tgds have been well-studied since they permit avoiding recursion, and allowing first-order rewritings [1]. In this paper, we naturally extend this notion to full-deds.
Our main result is that a CQ with safe base negation satisfies the Homomorphism Theorem iff its dependency-version is uniformly one-bounded, where the dependency-version of a query is the dependency obtained by placing the negated atoms of the query in the right-hand side of the dependency (resulting in a tgd, in the case, and in a ded, in the case).
Example 2.
The dependency-version of the queries from Example 1 are:
ta: Connects(p,c1,Train), City(c1),
Connects(p,c2,Aeroplane), City(c2) -> Connects(p,c2,Train)
tb: Connects(p,c1,t), City(c1), City(c2) -> Connects(p,c2,Train)
Both dependencies are uniformly one-bounded tgds (i.e., we can see that, when unfolding the first Connects predicate from the tgd , with the very same tgd , we obtain a new tgd s.t. ). Hence, and belong to .
We show this tight connection between the Homomorphism Theorem and dependency uniform one-boundedness by reducing containment over into an Ontology-Based Data Access (OBDA) consistency problem. In essence, given two boolean queries and , we build an ontology, using dependencies, that captures the DB counterexamples of ; thus, its unsatisfiability proves containment. It is worth mentioning that this idea of reducing query-containment into ontology consistency has already been explored in [4, 8] to deal with query containment under constraints.
In summary, our contributions are:
-
We define the classes and of boolean conjunctive queries extended with one or several negated atoms, that satisfy the Homomorphism Theorem.
-
We show that identifying whether a query belongs to is, in essence, the very same problem as identifying whether a full-tgd is uniformly one-bounded.
-
We extend the notion of uniform one-boundedness to full-deds, and show that identifying whether a query belongs to is, in essence, the very same problem as identifying whether a full-ded is uniformly one-bounded.
-
We demonstrate that deciding whether a query belongs to is EXPTIME-hard, but, in the case, its complexity lies between NP and , mirroring the currently observed complexity for the chase-firing problem [12], and it is in NP when bounding the number of positive atoms that can unify with the negated atom.
As subsidiary contributions, we also show how to build a datalog (disjunctive-datalog) program that checks whether there is a containment between two conjunctive queries with one (several) negated safe atoms.
2 Preliminaries
In the following, we introduce the basic logic notions we will use throughout the paper:
A term is either a variable, a constant, or a labelled null. We denote variables with lower case alphabetic characters (e.g., , , ), labelled nulls with strings starting with “#” (e.g., , , ), and constants with strings starting with upper case characters (e.g., Train, John). A vector of terms is denoted by .
A predicate is composed of a name and some arity (e.g. Connects is a -ary predicate). An atom is an -ary predicate with terms (e.g. Connects(x,y,Train)). A ground atom is an atom whose terms are labelled nulls or constants (e.g., Connects(#x,#y,Train)).
A substitution is a mapping from variables and labelled nulls to terms. Variables can be mapped to any term, whereas labelled nulls can only be mapped to other labelled nulls or constants. Applying a substitution to an atom (or conjunction of atoms) , denoted by , consists in simultaneously replacing each variable (labelled null) with in (in case is defined). We denote a substitution with where are different variables and labelled-nulls and are terms. If all the variables are mapped to labelled nulls or constants, we call the substitution ground.
A database is a finite set of ground atoms. Given a ground atom , is true in , denoted by , iff .
Next, we review the notions of conjunctive queries and query containment.
A boolean CQ is a formula composed of a 0-ary atom, called the head, and a conjunction of atoms, called the body. E.g., is a CQ, where is the head and is the body. Given a boolean CQ , and a database , we say that the query is true in , denoted by , iff there exists a ground substitution that makes all the atoms of the body of true w.r.t. . A boolean CQ is contained in another boolean CQ , denoted by , iff, for any database s.t. , we have .
Given two boolean queries and , a homomorphism from to , denoted by , is a substitution that makes the body of contained in the body of . Similarly, given a conjunction of positive atoms , a database , and a substitution s.t. , we say that is a homomorphism from to (shortly, satisfies ) and write, abusing notation, . We naturally extend the notion of homomorphism to databases as follows. Given two databases and , a homomorphism from to is a substitution s.t. .
Given a set of (possibly non-ground) atoms, its freeze is the DB obtained after applying a substitution that replaces each variable with a fresh labelled null. Given a boolean CQ , we define freeze(q) as the freeze of its body. E.g., the freeze of is the DB . Given two boolean CQ and , we can check whether by querying over freeze().
Next, we summarise the notions of tgds, deds, and OBDA techniques we require:
A (full-)dependency is a formula , where is a conjunction of atoms, called the left-hand side (LHS), and is a disjunction of atoms, called the right-hand side (RHS), with . We denote the LHS and RHS of a dependency by and , respectively. Do note that we do not consider existential variables (i.e. all the variables appearing in the RHS also appear in the LHS). Given a dependency and a database , we say that satisfies , noted as , iff for any homomorphism from to , we have for some . Otherwise, we say that violates . When the dependency only contains one atom in its RHS, we call it a tgd (tuple-generating dependency); when it contains several, we call it a ded (disjunctive-embedded dependency); and when it has none, we call it a denial. For brevity, we use the terms tgd/ded to refer to full-tgd/ded, and we omit the logic quantifiers.
An ontology is a pair , where is a set of dependencies, and is a database. A model of an ontology is a set of ground atoms s.t. 1) there is a homomorphism from to , and 2) every dependency is satisfied by . We might use to refer to all the models of an ontology . Given a boolean conjunctive query , we use the certain answer semantics. That is, querying over consists in answering whether is true in every possible model of , which we note as . Since we only work with full-dependencies, all models are finite.
Given an ontology , where is only composed of full-tgds, its universal model is a finite model s.t., for any other model , . Given an ontology and a (union of) conjunctive query(ies) , we can obtain the certain-answers of over by querying over its universal model [6]. More in general, if the ontology is composed of full-tgds, full-deds, and denials, its universal model set is a finite set of models , …, , s.t., 1) for any possible model , there is some s.t. , and 2) the set is minimal, i.e., there are no two models in the universal model set s.t. [6]. In this case, we can check by querying over all the models of the universal model set.
Given an ontology , s.t., there is a full-tgd that is violated in for some substitution , applying a chase step means adding into . In case is a ded violated in for some substitution , applying a chase step means adding some into , where . In case is a denial, the chase is considered to fail, and no solution exists. The chase algorithm consists in iteratively applying any possible chase step until reaching a new database where all dependencies are satisfied. If the ontology is composed solely of full-tgds, the result is unique and is the universal model of . If the ontology contains full-dependencies, and we use the chase to explore every possible solution, we can obtain its universal model set.
Given a tgd , we say that it is uniformly one-bounded (or one-bounded, for short) iff, given any database and ground atom , if we can obtain in, at most, one single chase step. That is, either , or there exists a substitution s.t. , and .
3 Problem definition
In this paper, we refer to the boolean CQ extended with base negated atoms as . As expected, a CQ with negation is true in a database , denoted as , iff there exists a ground substitution such that, for every positive atom in the body of , , and for every negated atom in the body of , . We only consider safe negation, i.e., queries where all variables appearing in a negated atom also appear in at least one positive atom of the same query.
We extend also the notion of homomorphism to queries with negation by requiring that the substitution maps every positive atom of to a positive atom in the body of , and every negated atom of to a negated atom in the body of .
To study which queries from satisfy the Homomorphism Theorem, we must first formalise this notion. In particular, to bring a meaningful definition, we must be careful with those queries containing a contradiction. E.g., is trivially contained in any other query, independently of having/not-having any homomorphism. Do note that such contradictions can be found by checking another homomorphism. I.e., we can find a contradiction by checking the existence of a homomorphism from (for every predicate ) to the body of our query.
Thus, we consider that a query satisfies the Homomorphism Theorem, in essence, if the containment w.r.t. another query can be determined by checking a homomorphism from to , and checking whether contains or not a contradiction:
Definition 3.
Given a boolean query , we say that satisfies the Homomorphism Theorem if and only if, , we have: iff ( or for some of the form ). We refer to the subset of queries from that satisfy the Homomorphism Theorem as .
The main purpose of this paper is to characterise the set . That is, bringing a way to identify whether a query belongs to . For our purposes, we will also study a slightly simplified case. That is, we will study the boolean conjunctive queries with at most one negated atom (from now on ), and study when they satisfy the Homomorphism Theorem. Formally:
Definition 4.
Given a boolean query , we say that satisfies the Homomorphism Theorem if and only if, for any other query , we have: iff ( or for some of the form ). We refer to the subset of queries from that satisfy the Homomorphism Theorem as
4 Identifying : the intuitions
In this section, we bring the intuitions about how to check whether a query from satisfies the Homomorphism Theorem, and thus, belongs to . As we are going to see, such a query belongs to iff its dependency-version is one-bounded. The formal theorems are left for the next section.
In particular, we reach such intuitions by reducing the problem of query containment of boolean queries to an OBDA consistency problem. That is, we build an ontology whose models represent the databases that witness the non-containment of the queries. As a result, if the ontology admits one (finite) model, there is a database counterexample for such containment. This reduction is already present in some other works, such as [4, 8].
In the following, we first discuss the reduction to an ontology finite satisfiability problem, then, we discuss why the queries whose dependency-version is one-bounded satisfy the Homomorphism Theorem, and finally, we discuss why the queries that satisfy the Homomorphism Theorem have one-bounded dependency-versions. From now on, abusing the language, we will call a query whose dependency-version is one-bounded a one-bounded query. In addition, we will only work with boolean queries with at most one negation (i.e., ) to explain the intuitions with the easiest case.
4.1 Checking query containment with ontology satisfiability
To illustrate how to check boolean query containment via ontology finite satisfiability, consider again the queries and from Example 1, and assume that we want to check .
The idea is to build an ontology whose models represent those databases that satisfy but falsify . With this ontology at hand, we can check query containment by means of checking whether the ontology is finitely satisfiable, which can be done by computing the universal model of the ontology through the chase algorithm.
Creating an ontology whose models falsify can be done by adding a simple dependency in the ontology. In particular, consider the tgd , from Example 2 obtained by placing, in its LHS, all the positive atoms of , and placing, in its RHS, the unique negated atom of . Clearly, any model that satisfies such tgd falsifies the query because, whenever there is a substitution of variables that makes the positive atoms of true in the model, the very same substitution must also make true the negated atom of , thus, falsifying the query.
Making the models of the ontology represent those databases that satisfy is more complicated due to its negated atom. In fact, if there were no negated atoms, this would be as easy as using, as the initial database for our ontology, the freeze of . The problem is that the notion of query freeze for queries including negated atoms is not defined.
To deal with negated atoms, our idea is to modify the query to transform negated atoms into new positive ones, and modify the ontology to add the semantics that such new atoms represent negated atoms. This idea already appears in [6]. Basically, in our example we have to 1) change the negated atom for a positive atom with a new fresh predicate , and 2) add, in the ontology, the denial .
In the following example, we show the ontology we would build to check whether .
Example 5.
Consider the ontology composed of the tgd (the dependency-version of ), together the freeze of after replacing its negated atom for a new notConnects atom, and a denial stating the semantics of notConnects:
database: Connects(#p,#c1,Train), City(#c1), Connects(#p,#c2,Airplane), City(c2), notConnects(#p,#c2,Train).dependencies: Connects(p,c1,t), City(c1), City(c2) -> Connects(p,c2,Train). Connects(x,y,z), notConnects(x,y,z) -> .
Now, we can check if this ontology is finitely satisfiable. We can do so by chasing our database with the tgd dependency, and check whether its result violates the denial dependency. In this case, the chase generates the new tuple . Thus, do note that we are violating the denial since, in the initial database, we already have . Hence, the ontology is unsatisfiable, which means that there is no database counterexample of the containment , and therefore, .
For brevity, from now on, given two boolean queries and , we refer to an ontology that captures the database counterexamples for as nonContainOnt(, ). We will later formally define such an ontology in Section 5.1.
4.2 One-bounded queries satisfy the Homomorphism Theorem
In the following, we illustrate, with an example, why queries whose dependency-version is one-bounded satisfy the Homomorphism Theorem. That is, given two boolean conjunctive queries with at most one negated atom and , where is one-bounded, we show that if and does not contain any contradiction, then .
We show this by exploiting the ontology we have defined in the previous section. That is, when is one-bounded, given any query , we show that if is unsatisfiable, then, (or contains a contradiction).
The first basic intuition is that, given the ontology , the chase generates, roughly speaking, the negated atoms of to falsify , and the negated atom of forbids generating some of such atoms. We illustrate this with the following example:
Example 6.
Consider the following query that checks if some place connects a city BCN through , but does not connect to a city LIS through .
qc :- Connects(p, BCN, t), City(BCN), City(LIS), not(Connects(p, LIS, t))
In addition, assume that we want to check whether , where is the query defined in Example 1. To do so, we can build the nonContainOnt(,) ontology:
database: Connects(#p, BCN, #t), City(BCN), City(LIS), notConnects(#p, LIS, #t).dependencies: Connects(p,c1,t), City(c1), City(c2) -> Connects(p,c2,Train). Connects(x,y,z), notConnects(x,y,z) -> .
Roughly speaking, when chasing the previous ontology, we will generate the necessary atoms of (the negated atom from ) to make the query false, and the denial forbids the generation of (the negated atom of ) to keep true. In other words, if the chase generates the atom , the ontology is unsatisfiable and therefore, there is a query containment.
Then, since the tgd is one-bounded, all the atoms that can be generated by the chase can be directly identified by the different homomorphisms from the LHS of the tgd to the database. Indeed, roughly speaking, since the tgd is one-bounded, the new atoms generated by the chase cannot generate new homomorphisms that trigger the chase recursively. Continuing the previous example, we can identify the following homomorphisms from the LHS of the tgd to the database: and .
Do note that generates the new atom , and generates the atom . Furthermore, do note that, since the tgd is one-bounded, such new atoms do not generate new atoms in the chase recursively.
Now, if the ontology turns out to be unsatisfiable (i.e., if there is a containment), we must have violated the denial. There are two options: either the denial is violated in the very initial database (which would point to a contradiction in the query being frozen, which is not the case in our example), or it has been violated due to some atom generated during the chase. In our example, roughly speaking, the homomorphism creates an atom , which causes the violation of the denial.
The key observation here is that the very same homomorphism that generates the atom that causes the denial violation is also a homomorphism from one query to the other.
In our example, generates the (forbidden) atom , and is also an homomorphism from . Why is that? In essence, maps each positive atom from to by construction (since we have obtained by looking for a homomorphism from the LHS of the dependency-version of to the freeze of ), and if it causes the denial violation, it also maps the negated atom from (the atom generated by the chase), to the negated atom of (the forbidden atom).
In summary, given two boolean queries and , when the query is one-bounded, testing whether there is a homomorphism from to checks whether any generated atom from chasing nonContainOnt(, ) violates its denial. In other words, checking the homomorphism permits checking the nonContainOnt(, ) satisfiability. This intuition will be later extended to the case of several negated atoms.
4.3 Queries satisfying the Homomorphism Theorem are one-bounded
In the following, we illustrate, with an example, why queries that satisfy the Homomorphism Theorem are, precisely, one-bounded queries. That is, given a boolean conjunctive query , we show that if is not one-bounded then we can build a new query s.t. but (where does not contain any contradiction).
To do so, let’s consider a non-bounded query such as the following:
Example 7.
Consider the following query, which, in essence, checks whether the Connects relationship is not transitive.
qd() :- Connects(p1, p2, t), Connects(p2, p3, t), not(Connects(p1, p3, t))
Do note that is not one-bounded. Indeed, we can build an ontology that proves so:
database: Connects(A, B, T), Connects(B, C, T), Connects(C,D,T) dependencies: Connects(p1, p2, t), Connects(p2, p3) -> Connects(p1, p3, t)
In essence, this ontology is formed by the dependency-version of , and several direct connections between , , and . It is easy to realise that chasing this ontology generates the atom , but this atom cannot be generated within a single chase step, which proves that the dependency is not one-bounded.
Now, our main observation is the following: given the database that proves that the query is not one-bounded, we can build a new query that is contained in , avoiding any homomorphism . The trick consists in creating a query whose positive atoms generate, when frozen, the database ; and adding in , as a negated atom, some atom that is obtained through several chase steps. That is, consider the new query :
qe() :- Connects(A,B,T),Connects(B,C,T),Connects(C,D,T),not(Connects(A,C,T))
This query is contained in , but it has no homomorphism with it. Why is that? The key idea lies in thinking again in terms of the ontology .
The ontology is, by construction, unsatisfiable (indeed, the chase will generate the forbidden atom at some point), and since cannot be obtained in a single chase step, there is no homomorphism between the queries. Indeed, if there was an homomorphism from to , then, such homomorphism would also show the triggering of the depdendency-version of , with the freeze of , to generate , which would mean that is obtained in a single chase step (contradiction!)
In summary, if some query is not one-bounded, we can build another query with some negated atom s.t. , when chased, generates after several chase steps, and such atom causes the violation of its denial (and therefore, ensures the containment ). Furthermore, since can only be generated after several chase steps, makes the existence of any homomorphism from to impossible. Roughly speaking, the homomorphism test only checks the inconsistencies that can occur in nonContainOnt(,) within a single chase step, and if is not one-bounded, we can create a query where the inconsistency is found after several chase steps.
5 Formalizing
Now we formalise the previous intuitions and generalise them to deal with boolean queries with several negated atoms.
In the following, we first define the notions relative to our ontology construction. In essence, we define the notions of dependency-version of a query, and its freeze, and formally prove that the ontology we build models the database counterexamples of the containment.
Then, we define, for our purposes, the notion of uniform one-boundedness for deds. Indeed, the notion of uniform one-boundedness is well defined for tgds, but, as far as we know, it has never been extended to deds. In our proposal, we define a ded as uniformly one-bounded if any atom from its universal model set can be obtained in at most one chase step, regardless of the original database.
Finally, we show that a query from belongs to iff its dependency-version is uniformly one-bounded using the previous reduction to ontology finite satisfiability.
5.1 Building the nonContainOnt ontology
Assume two boolean conjunctive queries and with an arbitrary number of safe negated atoms (which might be 0). Our goal now is to formally define the construction of the nonContainOnt(, ), that is, the ontology that models the counterexamples of the containment of . Recall that, in our intuitions, we have seen that the idea is to create a dependency-version of , and a freeze for , where the difficulty is that might have a negated atom. We continue by 1) defining the notion of dependency-version of a query, 2) the notion of query freeze, where the query might contain several negated atoms, and 3) proving that, using such definitions, we can build the ontology nonContainOnt(, ) which is (finitey) satisfiable iff .
Definition 8.
Given a boolean query of the form , we define its ded-version as the disjunctive-embedded dependency: . Fixed a query , we may refer to its ded-version as .
Example 9.
Given a query , its dependency-version is .
Do note that, by construction, the dependency-version of a query with several negated atoms gives rise to a ded, whereas the dependency-version of a query with one negated atom gives rise to a tgd, and a query with no negation gives rise to a denial.
The freeze of a given query is a set of atoms where variables have been replaced with new fresh labelled nulls, and negated atoms have been replaced with new fresh predicates. Formally:
Definition 10.
Given an atom , we define as the atom obtained by replacing the predicate with a new fresh predicate . I.e., .
Then, given a query we define as the query .
Finally, given a boolean query , we define its freeze, noted as freeze(q), as the freeze of its removeNegation, i.e., .
Example 11.
Given a query , its freeze is .
Do note that the previous definition is an extension of the traditional notion of freeze for a conjunctive query (without negation) since it brings the very same result when the query does not contain any negated atom.
Now, we lack defining the semantics of the newly generated predicates. In essence, we need to create a denial stating that we cannot have and at the same time.
Definition 12.
Given a query , let be the predicates that appear in its negated atoms. We define the nonContradictionAxioms of , noted as nonContradictionAxioms(q), to be the set of denials , where is a vector of different variables, and .
Example 13.
The nonContradictionAxioms of the query from Example 11 are: and .
Do note that the nonContradictionAxioms brings an empty-set when the query has no negation.
With all these, we can now define the nonContainOnt ontology of a couple of boolean queries and from .
Definition 14.
Given a couple of boolean queries , we define nonContainOnt to be the ontology .
Example 15.
database: P(#x, #y), notP(#x,#x), notP(#y, #y), notR(#x, #y).dependencies: P(x, y), Q(y, z) -> P(x, z) v P(y, z). P(x, y), notP(x, y) -> . R(x, y), notR(x, y) -> .
With all this machinery, we can state our first main result. In essence, we can check query containment between a couple of boolean conjunctive queries with safe base negation via ontology (finite) satisfiability.
Theorem 16.
Given two boolean queries , we have that if and only if is not finitely satisfiable.
Given two boolean conjunctive queries with safe negation and , this result tells how to use a chase algorithm dealing with deds (such as [6]) to check query containment with negation. In essence, we have to compute the universal model set and check whether there is some model in the universal model set that does not violate any denial present in the ontology. Furthermore, if only contains one negated atom, we can do so with a standard chase dealing with tgds (instead of deds).
Equivalently, we can check whether by checking whether , excluding its denials, entails the denials. To do so, consider the following definitions:
Definition 17.
Given two boolean queries , and its corresponding ontology , we define:
-
to be the ontology obtained after removing any denial from .
-
to be the query formed by the disjunction of all the bodies of all the denials from .
Example 18.
Consider the nonContainOnt(, ) ontology of Example 15. In this case, is the ontology:
database: P(#x, #y), notP(#x,#x), notP(#y, #y), notR(#x, #y).dependencies: P(x, y), Q(y, z) -> P(x, z) v P(y, z)and the is the query:
q() :- P(x,y), notP(x,y) V R(x,y), notR(x,y)
Exploiting current knowledge from the literature, given two boolean queries , from , we can check whether is finitely satisfiable by checking whether .
Moreover, exploiting the fact that we work with full-dependencies (i.e, there are no existential variables in the RHS of any dependency), we could use a disjunctive-datalog engine to check if In addition, if contains only one negated atom, the ontology would only contain one full-tgd, and thus, we could use a pure datalog engine to solve the query containment problem of . We summarise the previous observations in the following corollary:
Corollary 19.
Given two boolean queries with possibly some negated atoms.
-
If , we can check via disjunctive-datalog query answering.
-
If , we can check via datalog query answering.
Interestingly, in the special case where the queries and are pure conjunctive queries, we end up with an ontology with a single denial (stating, roughly speaking, that must be false), and with a database that is, precisely, the freeze of . Thus, checking the satisfiability of the ontology consists in checking that the denial is not violated in the database, which, in essence, is a homomorphism test from to .
5.2 Uniform one-boundedness of deds
For the case of full-deds, to the best of our knowledge, there is no similar notion of uniform one-boundedness as we have for full-tgds. For our purposes, we define that a full-ded is uniformly one bounded iff any atom that appears in its universal model set can be obtained in a single chase step. More formally:
Definition 20.
Given a full-ded , we say that is uniformly one-bounded iff for any database , and any from the universal model set of , we have that, for any atom , there is a substitution s.t. and .
Do realise that such a definition is a natural extension of the notion of uniform one-boundedness for full-tgds. Indeed, when applying the previous definition to the tgd case, we only have one universal model where each atom in must be obtained in a single chase step (which coincides with the classical definition of uniform one-boundedness for full-tgds).
5.3 Satisfying the Homomorphism Theorem
We now move to our main result, that is, a conjunctive query with negated atoms satisfies the Homomorphism Theorem iff its ded-version is uniformly one-bounded.
To achieve this result, we first show that, given two queries and , where is one-bounded, if there is a containment, we have that there is a homomorphism from (or is inconsistent). Then we show the opposite.
5.3.1 One-boundedness implies the Homomorphism Theorem
Assume a couple of queries where is one-bounded. We will now study whether via the nonContainOnt(, ), and we will conclude that there is a containment only if (or contains a contradiction). Equivalently, we will see that nonContainOnt+(, ) inconsistencyQuery(, ) only if (or contains a contradiction).
To study whether nonContainOnt+(, ) inconsistencyQuery(, ), we can compute its universal-model set, and check whether every model from the universal-model set satisfies inconsistencyQuery(, ). If we find some model that does not satisfy inconsistencyQuery(, ), this means that inconsistencyQuery(, ) is not entailed, and hence, nonContainOnt(, ) models a database counterexample for the containment .
If is uniformly one-bounded, that means that all the models of the universal model set can be obtained, loosely speaking, by first computing all the homomorphisms from to . Indeed, once we have all such homomorphisms, obtaining their universal models is a matter of selecting, for each , some atom in .
Taking a look on the , we should realize that, if we we want to avoid entailing inconsistencyQuery(, ), we should find some model in the universal model set that does not contain any if we have in .
Now, the intuitive idea is that when checking if , we are checking if all the homomorphisms from to that triggers the execution of the , permits the chase find some model that does not satisfy the inconsistencyQuery(, ), or on the contrary, all the possibilities (all the atom ins ) leads to an inconsistency since all atoms in appear in (in the form of atoms). To illustrate this, consider the following example:
Example 21.
Consider the following queries:
ql :- P(x,y,z), not(P(y,z,x)), not(P(z,x,y)) qm :- P(a,b,c), not(P(b,c,a)), not(P(a,a,a)) qm’ :- P(a,a,b), not(P(a,b,a)), not(P(b,a,a))
To check whether , we can build the following ontology and inconsistency query:
database: P(#a,#b,#c), notP(#b,#c,#a), notP(#a,#a,#a) dependencies: P(x,y,z) -> P(y,z,x) v P(z,x,y) inconsistencyQuery: P(x,y,z), notP(x,y,z)
The inconsistencyQuery is not entailed, which can be proved by the model , , , . In essence, the absence of a homomorphism from to permits instantiating the atom to satisfy the dependency without satisfying the inconsistencyQuery.
However, if we check whether we can build the following different ontology:
database: P(#a,#a,#b), notP(#a,#b,#a), notP(#b,#a,#a) dependencies: P(x,y,z) -> P(y,z,x) v P(z,x,y) inconsistencyQuery: P(x,y,z), notP(x,y,z)
The inconsistencyQuery is now entailed. Indeed, the current database violates the dependency through the homomorphism , and the chase forces to instantiate either or , but since is also an homomorphim from to , both options leads to satisfying the inconsistencyQuery.
5.3.2 Main result
Now we go to the main result, that is, we show that being one-bounded is not only a sufficient condition, but also a necessary one to satisfy the Homomorphism Theorem. In essence, if the ded-version of a query is not uniformly one-bounded, we can build a second query that is contained in , but without having any homomorphism .
To do so, we depart from the database that shows that is not one-bounded. In particular, since is not one-bounded, we have a database that, when chased using , generates a universal model set s.t., in some , there is some atom that cannot be obtained through a single chase step.
Now, create a new query by taking all the positive atoms of (so that, when chasing with we basically obtain the previous models . Now, for each , we pick some atom and include its negation in (so that, will include , making such model satisfy a contradiction ). The crucial point is that, for the case (the model that contained an atom that could not be obtained in a single chase step), we will include the atom (so that there is no homomorphism from to ). To illustrate this, consider the following example:
Example 22.
Suppose that we have the query:
qn() :- P(A, y), P(y, z), not(P(A, z)), not(P(A, A))
Do note that this query is not one-bounded. Its dependency-version is not one-bounded since the database makes this ded generate a universal-model set with two models:
model1: P(A, B), P(B, C), P(C, D), P(A, C), P(A, D) model2: P(A, B), P(B, C), P(C, D), P(A, A)
where, in the first model, the atom is obtained, necessarily, through two chase steps. Thanks to this database and models, we can build the following query that shows that does not satisfy the Homomorphism Theorem:
qo() :- P(A, B), P(B, C), P(C,D), not(P(A,D)), not(P(A,A))
In essence, the query is built by picking the atoms from the database counterexample and writing them as positive atoms in our query; picking the atom that was derived through two chase steps, and writing its negation in the query; and picking another atom from the other model, and writing its negation in the query. Do note that . Indeed, chasing with creates the two models we have previously seen, accompanied by the atoms and from the , so, each of this models entails a contradiction . Furthermore, there is no homomorphism since the negated atom is obtained through two chase steps.
Using the previous observation, we reach our main result (Theorem 23). In addition, by limiting our main result to the , we see that a query satisfies the Homomorphism Theorem iff the tgd corresponding to is one-bounded.
Theorem 23.
A boolean query is in iff ded is uniformly one-bounded.
Corollary 24.
A boolean query is in iff is a one-bounded tgd.
6 Complexity for deciding and membership
We now study the complexity of deciding whether belongs to . As we are going to see, the problem is EXPTIME-hard due to a reduction from full-tgd fact entailment [11]. To lower this result, we study the complexity of , and see that its complexity lies between NP and , which virtually mirrors the known complexity of the chase triggering problem [12], whose similarity with our problem is also discussed.
6.1 Complexity for deciding membership
We show that deciding whether belongs to is EXPTIME-hard. We do so through a reduction from full-tgd combined complexity fact entailment (aka sirup combined complexity) [11]. In particular, the problem of full-tgd combined complexity consists in deciding whether, given a full-tgd of the form , a database with contents , and some ground atom , we have .
To grasp the intuition of the reduction, suppose that tgd is not uniformly one-bounded, and the very same database generates a universal model set that proves so. Bearing this in mind, we build a new full-ded of the form . The idea is that, if , for any given database , the universal model set of is: when ; and when (and thus, the ded is uniformly one-bounded). On the contrary, if , the universal model set of is , and thus, it is not uniformly one-bounded.
Theorem 25.
Deciding whether a full-ded is uniformly one-bounded is EXPTIME-hard.
Corollary 26.
Deciding membership is EXPTIME-hard.
6.2 Complexity for deciding membership
We now show that membership complexity lies between NP and . The NP lower bound is clear due to previous literature results. Certainly, it is known that checking uniform one-boundedness for the case of linear full-tgds (full-tgds where the LHS only contains one atom whose predicate matches the predicate of the RHS atom) is NP-hard [13].
Theorem 27.
Deciding membership is NP-hard.
The upper bound comes from the fact that checking full-tgd not one-boundedness can be done in . The proof is based on applying unfoldings over full-tgds [8]. In essence, given a tgd with some atom in its RHS, unfolding the tgd consists in replacing some atom with the way it can be derived through the tgd itself. To illustrate this, consider the following example:
Example 28.
Consider the tgd . By unfolding the first atom we obtain ; by unfolding the second atom we obtain ; and by unfolding simultanously both atoms we obtain: .
Intuitively, an unfolded tgd shows the atoms it can generate by applying two chase steps. So, if all the unfolded tgds generate the same as the original tgd, we conclude that all the atoms that can be generated through two-chase steps can be generated within a single chase step, showing that the tgd is one-bounded.
To check whether some unfolded tgd generates the same atoms as the original tgd, it suffices to check if there is a homomorphism between the two (indeed, we can interpret the tgds as non-boolean conjunctive queries where the is the head of the query).
Thus, given some tgd , if we can nondeterministically find an unfolded tgd s.t., there is no homomorphism from , we can conclude that is not one-bounded, placing this problem in . Consequently, the one-boundedness problem lies in . Furthermore, if we bound the number of predicates in the LHS of that can be unfolded (i.e., if we bound the number of atoms whose predicate matches the predicate of the tgd’s RHS), the total amount of possible unfolded tgds is polynomial, making the problem -complete.
Theorem 29.
Deciding membership is in .
Theorem 30.
Given a boolean query , s.t. the number of positive atoms that can unify with the negated atoms is bounded by some , deciding whether is NP-complete.
This result (NP lower bound and upper bound) is quite similar to the chase triggering problem complexity. The chase triggering problem consists in deciding whether, given two (general) tgds, firing one tgd can trigger another tgd. That is, given two (general) tgds, deciding whether there is a database such that violates the first tgd, and when applying the chase to repair this violation, we end up violating the second tgd (which was satisfied in ). This problem is known to be NP-hard with an upper-bound to (in fact, the result is even tightened to ) [12]. Do note that our problem is quite similar to it, with small tricky differences. Roughly speaking, we are checking whether a (full)-tgd can trigger itself (do note that we do not have existential variables in the tgd, as they do, which makes our problem more restricted in this sense). Second, we are interested in checking whether the obtained tuple from the second triggered tgd could be obtained from the original tgd in a single chase step (which is not taken into account in the chase-triggering problem).
7 Related Work
Conjunctive query containment was shown to be NP-complete in [5], who also proposed the homomorphism test as a solution. To reduce the complexity, some researchers found some cases where the problem was in PTIME. For instance, Sarayian [19] showed that, if the queries do not contain more than two atoms with the same predicate, containment can be checked in PTIME. Gottlob et al [10] defined the notion of bounded hypertree width, which made conjunctive query containment checking in PTIME too.
Considering that we can reduce a homomorphism test from queries including negated atoms to a homomorphism test between queries with only positive atoms (e.g., replace any not(p) atom by a fresh predicate notP), this paper enlarges the application of the previous work to the case.
To check containment in , Levy and Sagiv [15] proposed building an exponential number of canonical databases and applying a homomorphism test for each one of them. Later on, while reviewing this method, Ullman stated that the query containment problem in was -complete [20]. It turns out, however, that the upper-bound seems only valid when the arity of the predicates is bounded since Geck et al. [9] showed that it is coNEXPTIME-complete when arities are unbounded.
The work of Wei and Lausen [22, 21] is an optimised version of the work of [15, 20]. In essence, it uses the different homomorphisms between the queries to create several simpler containment tests. However, in the worst case, their approach might create the same exponential number of canonical databases. Similarly, the work of Farré et al [8] is based on building such canonical databases at runtime. Hence, they also face the problem of searching for a counterexample over an exponential search space.
The most similar result to our work is one from Mugnier et al [14], where a sufficient condition to assess that a query belongs to is given. Basically, Mugnier et al state that if a query does not contain two unifiable atoms with opposite polarity, . Indeed, this is a case in which since, roughly speaking, the RHS of the cannot unify with the LHS of , which makes trivially uniformly one-bounded. Do note that this property is sufficient, but not necessary, as the queries provided in Example 1 can show. It is also worth mentioning that, in a different paper, Mugnier et al studied conditions that, when satisfied by , the query-containment complexity of can drop down to NP-complete [16]. Do note, however, that such conditions refer to both queries, whereas we have studied conditions over alone.
8 Conclusions
We have defined the classes and of CQs that satisfy the Homomorphism Theorem, having one or several safe negated atoms. We have seen that deciding () membership is, in essence, the same problem as deciding whether a full-tgd (full-ded) is uniformly one-bounded. We have also seen that the problem is EXPTIME-hard for the case, but in the case, and can be lowered down to NP when bounding the number of positive atoms that can unify with the negated atom. We have also shown how to solve query containment using datalog queries, when the query , and disjunctive datalog queries, when . Numerous interesting further work problems can be addressed, such as:
-
Extending this approach to non-boolean queries. Indeed, it is not immediately clear how to define the dependency-version of a non-boolean query.
-
Extending this approach for non-safe negation. In this case, do note that the dependency-version of a query might be a ded with existential variables in the RHS. Is the characterisation based on one-boundedness still sound and complete?
-
Regarding complexity, what is the upper bound of identifying membership? Can we provide tighter complexity bounds for the problem of identifying membership?
References
- [1] Miklós Ajtai and Yuri Gurevich. Datalog vs first-order logic. J. Comput. Syst. Sci., 1994. doi:10.1016/S0022-0000(05)80071-6.
- [2] Pierre Bourhis, Michel Leclère, Marie-Laure Mugnier, Sophie Tison, Federico Ulliana, and Lily Gallois. Oblivious and semi-oblivious boundedness for existential rules. In Proc. of the 28th IJCAI, 2019. doi:10.24963/IJCAI.2019/219.
- [3] Diego Calvanese, Giuseppe De Giacomo, and Maurizio Lenzerini. On the decidability of query containment under constraints. In Proc. of the 7th ACM PODS, 1998. doi:10.1145/275487.275504.
- [4] Diego Calvanese, Giuseppe De Giacomo, and Maurizio Lenzerini. Conjunctive query containment and answering under description logic constraints. ACM TOCL, 9(3), 2008. doi:10.1145/1352582.1352590.
- [5] Ashok K Chandra and Philip M Merlin. Optimal implementation of conjunctive queries in relational databases. In Proc. of the 9th ACM STOC, 1977. doi:10.1145/800105.803397.
- [6] Alin Deutsch, Alan Nash, and Jeff Remmel. The chase revisited. In Proc. of the 27th ACM PODS, 2008.
- [7] Carles Farré, Werner Nutt, Ernest Teniente, and Toni Urpí. Containment of conjunctive queries over databases with null values. In ICDT. Springer, 2007. doi:10.1007/11965893_27.
- [8] Carles Farré, Ernest Teniente, and Toni Urpí. Checking query containment with the cqc method. Data & Knowledge Engineering, 53(2), 2005. doi:10.1016/J.DATAK.2004.08.002.
- [9] Gaetano Geck, Bas Ketsman, Frank Neven, and Thomas Schwentick. Parallel-correctness and containment for conjunctive queries with union and negation. ACM TOCL, 20(3), 2019. doi:10.1145/3329120.
- [10] Georg Gottlob, Nicola Leone, and Francesco Scarcello. Hypertree decompositions and tractable queries. In Proc. of the 8th PODS, 1999. doi:10.1145/303976.303979.
- [11] Georg Gottlob and Christos Papadimitriou. On the complexity of single-rule datalog queries. Information and Computation, 183(1), 2003. doi:10.1016/S0890-5401(03)00012-9.
- [12] Gösta Grahne and Adrian Onet. Anatomy of the chase. Fundam. Inform., 157(3), 2018. doi:10.3233/FI-2018-1627.
- [13] Paris C Kanellakis. Logic programming and parallel complexity. In Foundations of Deductive Databases and Logic Programming. Elsevier, 1988. doi:10.1016/B978-0-934613-40-8.50018-X.
- [14] Michel Leclere and Marie-Laure Mugnier. Some algorithmic improvements for the containment problem of conjunctive queries with negation. In ICDT. Springer, 2007.
- [15] Alon Y Levy and Yehoshua Sagiv. Queries independent of updates. In VLDB, volume 93, 1993. URL: http://www.vldb.org/conf/1993/P171.PDF.
- [16] Marie-Laure Mugnier, Geneviève Simonet, and Michaël Thomazo. On the complexity of entailment in existential conjunctive first-order logic with atomic negation. Information and Computation, 215, 2012. doi:10.1016/J.IC.2012.03.001.
- [17] François Picalausa and Stijn Vansummeren. What are real sparql queries like? In Proc. of the Int. Workshop on Semantic Web Information Management, 2011.
- [18] Yatin P Saraiya. Polynomial-time program transformations in deductive databases. In Proc. of the 9th ACM PODS, 1990. doi:10.1145/298514.298551.
- [19] Yatin P Saraiya. Subtree-elimination algorithms in deductive databases. Stanford Univ., 1991.
- [20] Jeffrey D Ullman. Information integration using logical views. In ICDT. Springer, 1997. doi:10.1007/3-540-62222-5_34.
- [21] Fang Wei and Georg Lausen. Containment of conjunctive queries with safe negation. In ICDT. Springer, 2003.
- [22] Fang Wei and Georg Lausen. A unified apriori-like algorithm for conjunctive query containment. In Proc. of the Int. Symp. on Database engineering & applications, 2008. doi:10.1145/1451940.1451957.
Appendix A Proofs for Theorems
Remark.
The proof of Theorem 25 requires the following (technical) proposition whose proof, for space limitation, is published at https://doi.org/10.5281/zenodo.18010617.
Proposition 31.
Given a tgd , a database , and a ground atom , we can reduce, in polynomial time, the problem of deciding whether to deciding whether , where is a tgd, and shows that is not uniformly one-bounded.
Theorem 16. [Restated, see original statement.]
Given two boolean queries , we have that if and only if is not finitely satisfiable.
Proof.
We first prove that if then is finitely satisfiable. Then, we prove the other direction.
Assume that . Hence, there is a database s.t. but . We are now going to build a model of from . In particular, lets add all the atoms from into and, additionally, for each atom that can be built using the constants and labelled nulls from s.t. , lets include into . We are now going to prove that such satisfies all the dependencies of , and hence, it is a model.
satisfies , otherwise, the very same substitution that proves the violation of in would also prove . satisfies since, by construction, we avoid adding an atom and its negation at the same time. satisfies since the very same substitution that proves , also proves .
We continue proving the other direction. That is, we now show that the finite satisfiability of implies . Assume that is finitely satisfiable, and hence, we have a finite model for it. We are now going to build a database that proves .
In particular, we are going to build by means of simply removing any atom from . We now prove and .
because the very same homomorphism that proves also proves . Indeed, we have that . To realise so, consider any positive atom from the query . , because by construction of , for any atom (in exception of those of the form ) . Pick now any negated atom . , because, if , then, by construction, , and thus, we would have that proves the violation of the non-contradiction axiom .
because, if there was a homomorphism s.t. , then, would violate for .
Theorem 23. [Restated, see original statement.]
A boolean query is in iff ded is uniformly one-bounded.
Proof (Soundness).
Given two boolean queries and , we prove that, if is uniformly one-bounded, then, implies .
Assume that contains at least one negated atom, and thus, nonContainOnt+(, ) contains one tgd or ded. Do note that, in case has no negated atom, is a denial, nonContainOnt+(, ) is an ontology solely composed of the freeze of , and the inconsistencyQuery(, ) has the form . Thus, do observe that, in such case, checking whether nonContainOnt+(, ) inconsistencyQuery(, ) is the same as checking whether there is a homomorphism (and whether contains some contradiction), thus, satisfying our intended result.
We now chase with to obtain the universal model-set. To do so, we compute all the homomorphisms from the LHS of to . Then, for each one of these homomorphisms, we need to add, in the model, some atom where is an atom from the RHS of . Do note that, since is one-bounded, we do not need to look for new homomorphisms triggering the ded. Technically speaking, this procedure might yield a superset of the universal model set, but this is not a problem at all. Indeed, we can check whether nonContainOnt+(, ) inconsistencyQuery(, ) by checking whether inconsistencyQuery(, ) is satisfied in all the models of (a superset of) the universal model set of nonContainOnt+(, ). From now on, we refer to this set as .
We now check whether all the models from satisfy the inconsistencyQuery(, ). To do so, we first study the form of inconsistencyQuery(, ). Since we have assumed that contains, at least, one negated atom, the inconsistencyQuery(, ) is of the form , where each is a predicate that appears negated in . We continue assuming w.l.o.g. that contains at least some negated atom. In case has no negated atom, do note that nonContainOnt(, ) is trivially satisfiable since it does not contain any denial, and thus, .
We continue checking whether all the models from satisfy , where each is a predicate that appears negated in . We show that if (and does not contain a contradiction), there is some model in not satisfying any query of the form . Assume now that , and does not contain a contradiction.
We show that, when we were building the set of models , at each step, there was always some (partial) model that was not satisfying any . Indeed, recall that we have built by picking, for every homomorphism from the to freeze(), some atom in . Consider the list containing all of such homomorphisms. We now denote by the set of partial models obtained by picking, for each , some atom in . The proof continues by induction.
In the base case, we have a set of partial models which is composed solely of the initial database. Clearly, since does not contain a contradiction, this initial database does not satisfy any query of the form .
In the inductive case, we have a set of partial models which, by induction hypothesis, contains some partial model that does not satisfy any query of the form . Pick now the next homomorphism . We show that there is some atom that can be added in without violating any query of the form . We continue the proof by contradiction. Thus, assume that, for any , satisfies some . If this is the case, is, precisely, a homomorphism from (contradiction).
Proof (Completeness).
We prove that if the is not uniformly one-bounded, then . To do so, we build a counterexample query s.t. but where .
Assume that is not uniformly one-bounded. Hence, there is some finite database that proves so. I.e., there is some finite database , s.t. the universal model set of is , where contains at least one model that contains at least one atom that cannot be obtained, from , through a unique chase step.
The idea is to use to build the positive atoms of the query . That is, assuming we start building as :- . Do note that the query will be composed only of constants. We lack inserting some negated atoms in . To do so, assume, w.l.o.g., that the universal model set of is and that contains the atom that cannot be obtained in a single chase step. We add in the atom , and for each , , we add some atom where , and .
We now prove that , but . We start proving that by contradiction. Assume that is the substitution that proves . There are two cases: either maps some negated atom from to , or not. In the first case, can be obtained in a single chase step (contradiction). In the second case, maps every negated atom from to atoms (possibly a subset of them). In terms of deds, this means that is a violation of w.r.t. , and thus, every model of should contain some of such atoms to avoid this violation, but does not contain any (contradiction).
We conclude by proving . By construction, every model of entails a non-contradiction axiom. Thus, by Theorem 16, we know that .
Theorem 25. [Restated, see original statement.]
Deciding whether a full-ded is uniformly one-bounded is EXPTIME-hard.
Proof.
We apply a polynomial reduction from full-tgd combined complexity, which is EXPTIME-hard, to our problem. In particular, given a full-tgd with the form , a database with contents , and some ground atom , we reduce the problem of identifying whether to decide whether some ded is one-bounded. In virtue of Proposition 31, w.l.o.g., we assume that has a universal model that contains an atom that cannot be obtained in a single chase step from .
Now, we build the full-ded = and prove that is one-bounded iff . We start proving that implies is one-bounded. To see so, do realize that, for any database , has a universal model set composed of only one model which is either itself (when ), or (when ). Do note that, in both cases, all atoms can be obtained through at most 1 chase step.
We continue proving that implies is not one-bounded. In particular, do note that the universal model set for is , where is the universal model of . Indeed, similarly as before, we see that every potential minimal model of is and the model , where are, precisely, the violations that occur when chasing with . Thus, . Since , we see that , which makes a true minimal model of . Furthermore, by assumption, we have that contains some atom that cannot be obtained in a single chase step from , and thus, neither from . Thus, is not one-bounded.
Theorem 27. [Restated, see original statement.]
Deciding membership is NP-hard.
Proof.
Immediately from the NP-hardness of checking one-boundedness for linear full-tgds [13], and the possibility to check whether a linear full-tgd is one-bounded by checking whether its corresponding query (i.e., s.t. ) belongs to .
Theorem 29. [Restated, see original statement.]
Deciding membership is in .
Proof.
We prove that not membership is in . Recall that a query is not in iff is not uniformly one-bounded (Theorem 23). Let rewriting represent the set of all the that can be obtained after unfolding one or several atoms of the body of with . We can check that a full-tgd is not uniformly one-bounded by non-deterministically guessing a new tgd , s.t. . Since is of polynomial size, and checking is in NP, we can see that checking whether a full-tgd is not one-bounded is in .
Theorem 30. [Restated, see original statement.]
Given a boolean query , s.t. the number of positive atoms that can unify with the negated atoms is bounded by some , deciding whether is NP-complete.
Proof.
The problem is NP-hard since it is a generalisation of uniform one-boundedness of linear (full-)tgds, which is NP-complete [13]. The problem is in NP slightly modifying our proof for Theorem 29. In particular, our problem can be solved by first computing all the unfolded tgds . Do note that the number of is , so, if is bounded, the number of obtained is constant. Then we only need to check that , for each . In essence, we need to find a polynomial number of polynomial homomorphisms, making the problem in NP.
