2.1 Semirings with monus
Here, we define the notion of a semiring with monus and give several examples.
A semiring is a structure K=(K,+,⋅,0,1), where addition + and multiplication ⋅ are binary operations on K, and 0, 1 are elements of K such that
-
(K,+,0) is a commutative monoid, (K,⋅,1) is a monoid, and 0=1;
-
for all a,b,c in K, we have that a⋅(b+c)=a⋅b+a⋅c and (b+c)⋅a=b⋅a+c⋅a;
-
for all a in K, we have that a⋅0=0⋅a=0.
Let K=(K,+,⋅,0,1) be a semiring.
-
K is commutative if the monoid (K,⋅,1) is commutative.
-
K is zero-sum-free if for all elements a,b∈K with a+b=0, we have that a=0 and b=0.
-
K has no zero divisors if for all elements a,b∈K with a⋅b=0, we have that a=0 or b=0.
-
K is a positive semiring if it is commutative, zero-sum-free, and has no zero divisors.
-
The natural preorder of K is the binary relation ⪯ on K, where a⪯b holds if and only if there is some c∈K such that a+c=b. Note that ⪯ is indeed a preorder on K, since it is clearly a reflexive and transitive relation on K.
-
We say that ⪯ is the natural order of K if ⪯ is a partial order on K, i.e., if a⪯b and b⪯a, then a=b. In this case, we also say that K is a naturally ordered semiring.
Fact 1. If a semiring K is naturally ordered, then K is zero-sum-free.
Indeed, if a+b=0, then we have that a⪯0; furthermore, since 0+a=a, we also have that 0⪯a; thus, a=0 because ⪯ is a partial order. A similar argument yields b=0.
Some, but not all, naturally ordered semirings can be expanded with a monus operation that shares some of the desirable properties of the difference operation on rings.
A semiring with monus is an algebraic structure K=(K,+,,−,0,1) such that:
-
(K,+,,⋅,0,1) is a naturally ordered commutative semiring;
-
For all elements a,b∈K, there is a smallest (in the sense of the natural order ⪯) element c in K, denoted by a−b, such that a⪯b+c.
The next proposition asserts that the monus operation can be characterized in terms of a set of four rather simple identities [Ame84]; a self-contained proof of this result can be found in [Suc24].
Proposition 1. Let K=(K,+,,⋅,0,1) be a naturally ordered semiring and let −′ be a binary operation on K. Then, the following statements are equivalent:
-
For all a,b∈K, we have a−′b=a−b, i.e., a−′b is the smallest element c such that a⪯b+c.
-
The following four identities hold for −′:
a−′a=0;0−′a=0;a+(b−′a)=b+(a−′b);a−′(b+c)=(a−′b)−′c.
We now give some examples of extensively studied positive semirings with monus.
Example 1. The two-element Boolean semiring B=({⊤,⊥},∧,∨,⊥,⊤) can be expanded to a semiring with monus in which a−b=a∧bˉ, where bˉ is the Boolean complement of b.
Example 2. The semiring N=(N,+,×,0,1) of the non-negative numbers, also known as the bag semiring, is a naturally ordered semiring in which the natural order coincides with the standard order ≤ on N. The bag semiring can be expanded to a semiring with monus in which the monus operation is the truncated subtraction x÷y, that is, x÷y=x−y if x≥y, and x÷y=0 if x<y.
Example 3. The tropical semiring T=(R∪{∞},min,+∞,0) of the real numbers is a naturally ordered semiring in which the natural order is the reverse standard order on the set R of all real numbers, i.e., x⪯y if and only if x≥y. It can be expanded to a semiring with monus by setting x−y=x if x<y, and x−y=∞ if x≥y, where < is the standard order of the reals.
Example 4. The fuzzy semiring F=[[0,1],max,min,0,1) is a naturally ordered semiring in which the natural order coincides with the standard order ≤ on the interval [0,1]. It can be expanded to a semiring with monus by setting x−y=x if x>y, and x−y=0 if x≤y.
Example 5. The provenance semiring N[X] is the semiring of all polynomials with variables from a set X={x1,…,xn,…} of variables and with coefficients from the set N of non-negative integers; the operations of N[X] are the standard addition and multiplication of polynomials.
The provenance semiring N[X] can be expanded to a semiring with monus as follows. For every tuple α=(α1,…,αn)∈Nn, let xα be the monomial x1α1x2α2…xnαn, where we set xi0=1. For a finite set I⊆Nn, let f[X]=∑α∈Ifαxα and g[X]=∑α∈Igαxα be two polynomials in N[X]. The monus operation is defined by letting f[X]−g[X]=∑α∈I(fα÷gα)xα, where ÷ is the truncated difference on N, that is, fα÷gα=fα−gα if fα≥gα, and fα÷gα=0 if fα<gα.
The semiring N[X] is called the provenance semiring because of its use in the study of database provenance, as initiated in [GKT07].
It should be pointed out that there are naturally ordered semiring that cannot be expanded to a semiring with monus; for a concrete example, see [Mon16].
2.2 Semiring-annotated relations, structures, and databases
Let D be a fixed denumerable set, which will serve as the domain of elements occurring in databases. For n≥1, we write Dn to denote the set of all n-tuples from D.
Let K=(K,+,,−,0,1) be a positive semiring with monus and let n≥1 be a non-negative integer.
-
A n-ary K-relation R is a function R:Dn⟶K of finite support, that is to say, the set supp(R):={(d1,…,dn)∈Dn:R(d1,…,dn)=0} is finite. We call n the arity of R.
-
A K-relation is a n-ary K-relation R, for some n≥1.
-
If A⊆D, then a n-ary K-relation on A is a n-ary K-relation R with supp(R)⊆An.
For example, if B is the Boolean semiring, then the B-relations are the standard relations in databases. Similarly, if N is the bag semiring, then the N-relations are the bags (or multisets), i.e., relations in which each tuple has a non-negative integer as its multiplicity.
A relational schema is a finite sequence τ=(R^1,…,R^p) of relation symbols, where each relation symbol R^i has a designated positive integer ri as its arity. We now consider the notions of a (finite) K-structure and a K-database over a relational schema τ.
-
A K-structure over τ is a tuple A=(A,R1,…,Rp), where A is a non-empty finite subset of D, called the universe of A, and each Ri is a K-relation on A whose arity matches the arity of the relation symbol R^i, 1≤i≤p.
-
A K-database over τ is a finite sequence I=(R1,…,Rp) of K-relations such that the arity of each K-relation Ri matches the arity of the relation symbol R^i, 1≤i≤p.
-
Let I=(R1,…,Rp) be a K-database. The active domain of I, denoted by adom(I), is the set of all elements of D that occur in the support of a relation Ri of I.
-
Every K-database I=(R1I,…,RmI) gives rise to a K-structure A(I) with universe the active domain adom(I) of I and with relations those of I, i.e., A(I)=(adom(I),R1I,…,RmI).
Clearly, B-structures are finite relational structures, B-databases are relational databases, while N-databases are bag databases.
Next, we define the fundamental notions of a query on K-structures and a query on K-databases.
-
Let n≥1. An n-ary query q on K-structures is a mapping defined on K-structures and such that if A=(A,R1,…,Rp) is a K-structures, then q(A) is a n-ary K-relation on A.
-
Let n≥1. An n-ary query q on K-databases is a mapping defined on K-databases and such that if I is a K-database, then q(I) is a n-ary K-relation on adom(I).
Clearly, a query q on K-structures gives rise to a query on K-databases obtained by restricting q to K-structures of the form A(I)=(adom(I),R1I,…,RmI), where I is a K-database.
A query language is a formalism for expressing queries. Codd [Cod70, Cod72] introduced relational algebra and relational calculus as formalisms for expressing queries on relational databases. Moreover, he showed that, in a precise sense, these two formalisms have the same expressive power. In [BKN25], basic relational algebra BRA and basic relational calculus BRC were introduced as formalisms for expressing queries on K-databases, where K is a positive semiring with monus.
Basic relational algebra BRA is a procedural query language in which queries are specified by expressions involving relations and operations on K-relations. The syntax of BRA-expressions over a relational schema τ=(R^1,…,R^p) is given by the context-free grammar
E:=R^i∣E∪E∣E×E∣E∖E∣πv(E)∣σθ(E)∣supp(E).
The semantics of a BRE-expression E on a K-database I is given by evaluating E on I and obtaining a K-relation EI whose arity matches that of E. This evaluation uses operations on K-relations (see [BKN25] for the precise definition). For example, ∪, ×, and ∖ are interpreted using the union, the cartesian product, and the difference of two K-relations, where these operations are defined as follows:
-
If R1 and R2 are two n-ary K-relations, then the union R1∪R2 is the n-ary K-relation defined by (R1∪R2)(t)=R1(t)+R2(t), for all t∈Dn.
-
If R1 is an m-ary K-relation and R2 is an n-ary K-relation, then the Cartesian product R1×R2 is the (m+n)-ary K-relation defined by
(R1×R2)(t)=R1(t1,…,tm)⋅R2(tm+1,…,tm+n),
for all t=(t1,…,tm+n)∈Dm+n.
- If R1 and R2 are two n-ary K-relations, then the difference R1∖R2 is the n-ary K-relation defined by (R1∖R2)(t)=R1(t)−R2(t), for all t∈Dn.
The basic relational calculus BRC is a declarative query language in which queries are specified by formulas in a variant of first-order logic FO with the connective ¬ ('but not') as a limited form of negation. The syntax of BRC-formulas is given by the context-free grammar
φ:=xi=xj∣R^i(x1,…,xri)∣φ∨φ∣φ∧φ∣φ¬φ∣∃xφ∣supp(φ).
As regards the semantics, with every BRC-formula φ, every K-structure A=(A,R1,…,Rp), and every assignment α mapping variables to elements of A, we associate a value ∥φ∥(A,α) in K that is defined recursively on the syntax of BRC-formulas and simultaneously for all assignments as follows:
-
∥xi=xj∥(A,α)=1, if α(xi)=α(xj); ∥xi=xj∥(A,α)=0, if α(xi)=α(xj).
-
∥R^i(xi1,…,xin)∥(A,α)=Ri(α(xi1),…α(xin)), for 1≤i≤p.
-
∥φ1∨φ2∥(A,α)=∥φ1∥(A,α)+∥φ2∥(A,α); ∥φ1∧φ2∥(A,α)=∥φ1∥(A,α)⋅∥φ2∥(A,α).
-
∣φ1¬φ2∣(A,α)=∥φ1∥(A,α)−∥φ2∥(A,α)
-
∥supp(φ)∥(A,α)=s(∥φ∥(A,α)), where s is the support function on K (i.e., for every c∈K, we have s(c)=0 if s(c)=0, and s(c)=1 if s(c)=0).
-
∥∃xφ∥(A,α)=∑b∈A∥φ∥(A,α[x/b]), where α[x/b] is the assignment obtained from α by assigning the value b to the variable x while keeping everything else the same.
It is not hard to show that the value ∣∥φ∥(A,α) depends only on the values a1,…,an of the assignment α on the free variables, say x1,…,xn, of φ. We write ∣∥φ∥(A,(a1,…,an)) to denote the value ∣∥φ∥(A,α), where α is any assignment such that α(x1)=a1,…,α(xn)=an. Therefore, with every K-structure A=(A,R1,…,Rp), we can associate a n-ary K-relation ∣∥φ∥A, where ∣∥φ∥A(a1,…,an)=∣∥φ∥(A,(a1,…,an)) if (a1,…,an)∈An, while φA(a1,…,an)=0 if (a1,…,an)∈/An. Note also that the syntax of BRC does not allow universal quantification, but it does allow a limited form of negation via the ¬ connective.
In [BKN25], the following version of Codd's theorem for K-relations was shown.
Theorem 1 ([BKN25]). Let K=(K,+,−,0,1) be a positive semiring with monus and let τ=(R^1,…,R^p) be a relational schema. If q is an n-ary query on K-databases, then the following statements are equivalent:
-
There is a BRA(τ)-expression E of arity n such that q(I)=EI, for every K-database I.
-
There is a BRC(τ)-formula φ(x1,…,xn) such that q(I)=∣∥φ∥A(I), for every K-database I, where A(I) is the K-structure A(I)=(adom(I),R1,…,Rp).
Thus, basic relational algebra and basic relational calculus can, in a precise sense, express the same queries on K-databases, where K is a positive semiring with monus. In particular, this holds true for bag semantics, which is the default semantics of SQL.
2.3 Semiring semantics via interpretations
Let FO(NNF) be the collection of all first-order formulas over τ in negation normal form. Grädel and Tannen [GT17, GT25] gave semiring semantics to FO(NNF)-formulas by using the notion of an interpretation.
In what follows, we assume that K=(K,+,×,0,1) is a positive semiring, τ=(R^1,…,R^p) is a relational schema, and A is a finite subset of D.
-
A literal from A is an atom or a negated atom involving elements of A, i.e., it is an expression of the form R^i(a) and ¬R^i(a), where a is a tuple of elements from A. We write LitA to denote the set of all literals from A.
-
An interpretation on A is a function π:LitA→K.
Let π be an interpretation. Grädel and Tannen [GT17, GT25], associate a value π[[φ]](α) to every FO(NNF)-formula φ and every assignment α mapping variables to elements of A; this value is defined by induction on the definition of FO(NNF)-formulas and simultaneously for all assignments as follows:
∙π[[xi=xj]](α)=1,if α(xi)=α(xj); π[[xi=xj]](α)=0,if α(xi)=α(xj).
∙π[[R^i(xi1,…,xin))]](α)=π(R^i(α(xi1),…α(xin))),for 1≤i≤p.
∙π[[¬R^i(xi1,…,xin))]](α)=π(¬R^i(α(xi1),…α(xin))),for 1≤i≤p.
∙π[[φ1∨φ2]](α)=π[[φ1]](α)+π[[φ2]](α); π[[φ1∧φ2]](α)=π[[φ1]](α)⋅π[φ2]](α).
∙π[[∃xφ]](α)=b∈A∑π[[φ]](α[x/b]); π[[∀xφ]](α)=b∈A∏π[[φ]](α[x/b])
Unlike the basic relational calculus, universal quantification is allowed here, but negation is limited to negated atoms only. A straightforward induction on the syntax of FO(NNF)-formulas shows that the value π[[φ]](α) depends only on the values a1,…,an of the assignment α on the free variables, say x1,…,xn, of φ. In what follows, we will write π[[φ]](x1/a1,…,xn/an) to denote the value π[[φ]](α), where α is any assignment such that α(x1)=a1,…,α(xn)=an. When the variables are understood from the context, we will simply write π[[φ]](a1,…,an).
Clearly, if ψ is a FO-sentence in negation normal form and π is an interpretation π, then the value π[[ψ]](α) is the same for all assignments α mapping variables to elements of A. We will write π[[ψ]] to denote this semiring value.
The following restricted notion of an interpretation was considered in [GT17, GT25].
- An interpretation π is model defining if for every atom R^i(a), exactly one of the values π(R^i(a)) and π(¬R^i(a)) is different from 0.
Every model-defining interpretation π on A gives rise to a structure Aπ=(A,R1Aπ,…,RpAπ) with universe A, where for every i≤p and for every tuple a from A, we have that a∈RiAπ if and only if π(Ri(a))=0. The following proposition (Proposition 5 in [GT25]) will be useful in the sequel.
Proposition 2. Let π be a model-defining interpretation on A. Then for every FO(NNF)-sentence ψ, we have that
π[[ψ]]=0if and only ifAπ⊨ψ.
3 Interpretation-based query languages
In this section, we address the following conceptual question: how can interpretation-based semantics be used to define languages for expressing queries over K-databases?
It should be noted that Grädel and Tannen [GT17, GT25] do not give interpretation-based semantics to FO(NNF)-formulas on K-structures. In particular, they do not define what it means for a K-structure A to satisfy a FO-sentence ψ in negation normal form. In [KPVW25], a definition of the latter concept was given in order to study repairs of K-databases. This was done by introducing the notions of compatible interpretation and canonical interpretation on a K-structure.
Definition 1. Let A=(A,R1A,…,RpA) be a K-structure over a relational schema τ.
An interpretation π on A is compatible with A if π is model-defining and for every i≤p and every tuple a with elements from A, we have that π(R^i(a))=RiA(a).
Note that if π is an interpretation that is compatible with a K-structure A, then, by definition, π has to agree with each relation RiA on the atomic facts R^i(a). For the negated atomic facts ¬R^i(a), we have that π(¬R^i(a))=0 if RiA(a)=0, because π is model defining. If, however, RiA(a)=0, then π(¬R^i(a)) can be any non-zero value from K. We now introduce a special compatible interpretation.
Definition 2. Let A=(A,R1A,…,RpA) be a K-structure over a relational schema τ.
The canonical interpretation on A is the interpretation πA such that for every i≤p and every tuple a of elements from A, we have that πA(R^i(a))=RiA(a) and
πA(¬R^i(a))={0,1,if RiA(a)=0if RiA(a)=0.
Clearly, the canonical interpretation πA is compatible with A; it is “canonical” in the sense that it assigns 1 as the default value to every literal ¬R^i(a) such that RiA(a)=0.
Let A be a K-structure and consider the canonical interpretation πA on A. Since πA is model-defining, it gives rise, as discussed earlier, to a relational structure AπA with universe A. From the definitions, it follows that AπA=Supp(A), where Supp(A)=(A,Supp(R1A),…,Supp(RmA)) is the relational structure with universe A and with relations the supports of the K-relations of A.
Proposition 3. Let A be a K-structure and let ψ be a FO(NNF)-sentence. Then the following hold:
-
If π1 and π2 are two interpretations that compatible with A, then π1[[ψ]]=0 if and only if π2[[ψ]]=0.
-
For every interpretation π that is compatible with A, the following statements are equivalent:
-
π(ψ)=0;
-
πA[[ψ]]=0;
-
Supp(A)⊨ψ.
Proof. The first part of the proposition is proved using a straightforward induction and the definition of compatibility. The second part of the proposition follows from the first part of the proposition together with Proposition 2 and the earlier fact that AπA=Supp(A). □
The preceding proposition motivated the authors of [KPVW25] to give the following definition of what it means for a K-structure to “satisfy” a FO(NNF)-sentence.
Definition 3. We say that a K-structure A satisfies a FO(NNF)-sentence ψ, denoted A⊨Kψ, if for some (equivalently, for every) interpretation π that is compatible with A, we have that π[[ψ]]=0.
Note that, by Proposition 3, we have that A⊨Kψ if and only if Supp(A)⊨ψ.
We now use canonical interpretations to give semantics to FO(NNF)-formulas over K-structures.
Definition 4. Let φ(x1,…,xn) be a FO(NNF)-formula. Given a K-structure A=(A,R1A,…,RpA), we write πA[[φ]] to denote the n-ary K-relation P such that for every n-tuple (a1,…,an), we have that
P(a1,…,an)={πA[[φ]](a1,…,an),0,if (a1,…,an)∈Anif (a1,…,an)∈/An.
where πA is the canonical interpretation on the K-structure A.
Next, we introduce the notion of a query being definable using canonical-interpretation semantics.
Definition 5. Let n be a positive integer.
-
Let q be a n-ary query on K-structures. We say that q is definable under canonical-interpretation semantics if there is a FO(NNF)-formula φ(x1,…,xn) such that q(A)=πA[[φ]] holds for every K-structure A.
-
Let q be a n-ary query on K-databases. We say that q is definable under canonical-interpretation semantics if there is a FO(NNF)-formula φ(x1,…,xn) such that q(I)=πA(I)[[φ]] holds for every K-database I=(R1,…,Rp), where A(I)=(adom(I),R1,…,Rp).
We also introduce the notion of a query being definable under a much more relaxed notion of interpretation-based semantics.
Definition 6. Let n be a positive integer.
- Let q be a n-ary query on K-structures. We say that q is definable under compatible-interpretation semantics if there is a FO(NNF)-formula φ(x1,…,xn) such that for every K-structure A=(A,R1,…,Rp), there is an interpretation π that is compatible with A and such that
q(A)(a1,…,an)={π[[φ]](a1,…,an),0,if (a1,…,an)∈Anif (a1,…,an)∈/An.
- Let q be a n-ary query on K-databases. We say that q is definable under compatible-interpretation semantics if there is a FO(NNF)-formula φ(x1,…,xn) such that for every K-database I=(R1,…,Rp), there is an interpretation π that is compatible with A(I) and such that
q(I)(a1,…,an)={π[[φ]](a1,…,an),0,if(a1,…,an)∈adom(I)nif(a1,…,an)∈/adom(I)n.
Thus, canonical-interpretation semantics use a special compatible interpretation, while compatible-interpretation semantics do not commit to a particular compatible interpretation. Clearly, if a query is definable under the canonical-interpretation semantics, then it is also definable under the compatible-interpretation semantics. The converse, however, need not be true. For example, consider a K-structure B=(B,R1B,…,RpB) and a compatible interpretation π on B that is different from the canonical interpretation on B. Let q∗ be the query such that, on the structure B, it returns the K-relation P that agrees with the compatible interpretation π on the values R^1(a) and ¬R^1(a) as a ranges over tuples of elements from A, while on every other K-structure A=(A,R1A,…,RpA), it returns the K-relation R1A. Then q∗ is definable under the compatible-interpretation semantics, but it is not definable under the canonical-interpretation semantics.
4 Limitations of interpretation-based query languages
We will show that the interpretation-based query languages introduced in the preceding section cannot express the monus operation on K-databases. We begin by considering the canonical-interpretation semantics.
Definition 7. Let K be a positive semiring with monus and let τ be a relational schema containing two n-ary relation symbols R^ and S^, for some n≥1.
The monus query on K-databases is the query qm=R^∖S^, i.e., for every K-database I, we have that qm(I)=RI−SI, where − is the monus operation on K.
We can now state the main result of this section.
Theorem 2. Assume that τ is a relational schema containing two unary relation symbols R^ and S^. Let K be one of the following three semirings with monus:
-
the bag semiring N=(N,+,×,0,1);
-
the tropical semiring T=(R∪{∞},min,+,∞,0);
-
the fuzzy semiring F=([0,1],max,min,0,1).
Then the monus query qm on K-databases is not definable by any FO(NNF)-formula under canonical-interpretation semantics.
Proof. We will prove each of the three parts separately.
PART I: Let K be the bag semiring N=(N,+,×,0,1). Recall that the monus operation on N is the operation ÷ defined as follows:
m÷n={m−n0if m>nif m<n.
Let a be an element in the domain D and let I=(RI,SI) be the N-database such that
-
RI(a)=3 and RI(b)=0, for all other elements b in D.
-
SI(a)=2 and SI(b)=0, for all other elements b in D.
Consider the relational algebra expression R^∖S^. Clearly, we have that (R^∖S^)I is the N-relation such that (R^∖S^)I(a)=RI(a)÷SI(a)=1 and (R^∖S^)I(b)=0, for all other elements b in D. Furthermore, we have that the following hold:
- A(I)=({a},RI,SI);
- The canonical interpretation πA(I) is the function on the atoms and negated atoms on {a} such that πA(I)(R^(a))=3, πA(I)(¬R^(a))=0, πA(I)(S^(a))=2, and πA(I)(¬S^(a))=0.
We will now establish the following claim.
CLAIM: Let φ(x1,…,xn) be a FO(NNF)-formula for some n≥1. Then either πA(I)[[[φ]]](a,…,a))=0 or πA(I)[[[φ]]](a,…,a))≥2, where (a,…,a) is a tuple of a's of length n.
The claim is proved by induction on the construction of FO(NNF)-formulas.
-
If φ is an atomic formula or a negated atomic formula, then the claim holds by the definition of the canonical interpretation πA(I).
-
Assume that φ(x1,…,xn) is of the form ψ1(x1,…,xn)∨ψ2(x1,…,xn) and that the claim holds for the formulas ψ1 and ψ2. If πA(I)[[[φ]]](x1/a,…,xn/a)=0, then
πA(I)[[ψ1]](x1/a,…,xn/a)=0orπA(I)[[ψ2]](x1/a,…,xn/a)=0.
The induction hypothesis implies that
πA(I)[[ψ1]](x1/a,…,xn/a)≥2orπA(I)[[ψ2]](x1/a,…,xn/a)≥2,
hence πA(I)[[[φ]]](x1/a,…,xn/a)≥2.
- Assume that φ(x1,…,xn) is the form ψ1(x1,…,xn)∧ψ2(x1,…,xn) and that the claim holds for the formulas ψ1 and ψ2. If πA(I)[[[φ]]](x1/a,…,xn/a)=0, then
πA(I)[[ψ1]](x1/a,…,xn/a)=0andπA(I)[[ψ2]](x1/a,…,xn/a)=0.
The induction hypothesis implies that
πA(I)[[ψ1]](x1/a,…,xn/a)≥2andπA(I)[[ψ2]](x1/a,…,xn/a)≥2,
hence πA(I)[[φ(x1/a,…,xn/a)]≥2.
-
Assume that φ(x1,…,xn) is of the form ∃xn+1χ(x1,…,xn,xn+1) and that the claim holds for the formula χ(x1,…,xn,xn+1). If πA(I)[[[φ]]](x1/a,…,xn/a)=0, then by induction hypothesis and the fact that adom(I)={a}, it must be the case that πA(I)[[[χ]]](x1/a,…,xn/a,xn+1/a)≥2, hence πA(I)[[[φ]]](x1/a,…,xn/a)=πA(I)[[χ]](x1/a,…,xn/a,xn+1/a)≥2.
-
Assume that φ(x1,…,xn) is of the form ∀xn+1χ(x1,…,xn,xn+1) and that the claim holds for the formula χ(x1,…,xn,xn+1). If πA(I)[[[φ]]](x1/a,…,xn/a)=0, then by induction hypothesis and the fact that adom(I)={a}, it must be the case that πA(I)[[[χ]]](x1/a,…,xn/a,xn+1/a)≥2. It follows that πA(I)[[[φ]]](x1/a,…,xn/a)=πA(I)[[[χ]]](x1/a,…,xn/a,xn+1/a)≥2.
The claim immediately implies Part I, since, as seen earlier, (R^∖S^)I(a)=1.
PART II: Let K be the tropical semiring T=(R∪{∞},min,+,∞,0). Recall that the monus operation on T is the operation – defined as follows:
x−y={∞xifx≥yifx<y.
Let a be an element in D and let I=(RI,SI) be the T-database such that
• RI(a)=3 and RI(b)=∞, for all other elements b in D.
• SI(a)=2 and SI(b)=∞, for all other elements b in dom(X).
Furthermore, let J=(RJ,SJ) be the T-database such that
• RJ(a)=2 and RJ(b)=∞, for all other elements b in D.
• SJ(a)=3 and SJ(b)=∞, for all other elements b in D.
Consider the relational algebra expression R^∖S^ and the T-relations (R^∖S^)I and (R^∖S^)J. Clearly, we have that (R^∖S^)I(a)=RI(a)−SI(a)=∞ and (R^∖S^)J(a)=RJ(a)−SJ(a)=2.
Furthermore, the following hold:
• A(I)=({a},RI,SI);
- The canonical interpretation πA(I) is the function on the atoms and negated atoms on {a} such that πA(I)(R^(a))=3, πA(I)(¬R^(a))=∞, πA(I)(S^(a))=2, and πA(I)(¬S^(a))=∞.
• A(J)=({a},RJ,SJ);
- The canonical interpretation πA(J) is the function on the atoms and negated atoms on {a} such that πA(J)(R^(a))=2, πA(J)(¬R^(a))=∞, πA(J)(S^(a))=3, and πA(J)(¬S^(a))=∞.
The following useful fact can be proved by a straightforward induction on the construction of FO(NNF)-formulas, using the properties of the operations min and + of the tropical semiring T.
FACT: For every FO(NNF)-formula φ(x1,…,xn), the possible values of πA(I)[[φ]](x1/a,…,xn/a) and of πA(J)[[φ]](x1/a,…,xn/a) are ∞ or a value of the form 2m+3n, where m+n>0.
We will now establish the following claim, which will immediately imply Part II.
CLAIM: Let φ(x1,…,xn) be a FO(NNF)-formula. Then
πA(I)(φ(x1/a,…,xn/a)=∞orπA(J)(φ(x1/a,…,xn/a)=2.
The claim is proved by induction on the construction of FO(NNF)-formulas.
-
If φ is an atomic formula or a negated atomic formula, then the claim holds by the definitions of the canonical interpretations πA(I) and πA(J).
-
Assume that φ(x1,…,xn) is of the form ψ1(x1,…,xn)∨ψ2(x1,…,xn) and that the claim holds for the formulas ψ1 and ψ2. We must show that if πA(I)[[φ]](x1/a,…,xn/a)=∞, then we have that πA(J)[[φ]](x1/a,…,xn/a)=2. If πA(I)[[φ]](x1/a,…,xn/a)=∞, then
min(πA(I)[[ψ1]](x1/a,…,xn/a),πA(I)[[ψ2]](x1/a,…,xn/a))=∞,
hence both πA(I)[[ψ1]](x1/a,…,xn/a)=∞ and πA(I)[[ψ2]](x1/a,…,xn/a)=∞. By induction hypothesis, we have that πA(J)[[ψ1]](x1/a,…,xn/a)=2 and πA(J)[[ψ2]](x1/a,…,xn/a)=2. We now distinguish three cases.
CASE 1: If πA(J)[[ψ1]](x1/a,…,xn/a)=∞, then
πA(J)[[φ]](x1/a,…,xn/a)=min(∞,πA(J)[[ψ2]](x1/a,…,xn/a))=πA(J)[[ψ2]](x1/a,…,xn/a))=2.
CASE 2: If πA(J)[[ψ2]](x1/a,…,xn/a)=∞, then
πA(J)[[φ]](x1/a,…,xn/a)=min(πA(J)[[ψ1]](x1/a,…,xn/a),∞)=πA(J)[[ψ1]](x1/a,…,xn/a))=2.
CASE 3: If πA(J)[[ψi]](x1/a,…,xn/a)=∞ for i=1,2, then the preceding fact about the possible values of FO(NNF)-formulas, implies that both
πA(J)[[ψ1]](x1/a,…,xn/a)≥3andπA(J)[[ψ2]](x1/a,…,xn/a)≥3,
hence
πA(J)[[φ]](x1/a,…,xn/a)=min(πA(J)[[ψ1]](x1/a,…,xn/a),πA(J)[[ψ2]](x1/a,…,xn/a))≥3=2.
- Assume that φ(x1,…,xn) is the form ψ1(x1,…,xn)∧ψ2(x1,…,xn) and that the claim holds for the formulas ψ1 and ψ2. We must show that if πA(I)[[φ]](x1/a,…,xn/a)=∞, then we have that πA(J)[[φ]](x1/a,…,xn/a)=2. If πA(I)[[φ]](x1/a,…,xn/a)=∞, then
πA(I)[[ψ1]](x1/a,…,xn/a))+πA(I)[[ψ2]](x1/a,…,xn/a)=∞,
hence πA(I)[[ψ1]](x1/a,…,xn/a)=∞ or πA(I)[[ψ2]](x1/a,…,xn/a)=∞. So, assume that πA(I)[[ψ1]](x1/a,…,xn/a)=∞. Hence, by induction hypothesis, we have that
πA(J)[[ψ1]](x1/a,…,xn/a)=2.
Therefore, by the preceding fact, we have that also
πA(J)[[φ]](x1/a,…,xn/a)=πA(J)[[ψ1]](x1/a,…,xn/a)+πA(J)[[ψ2]](x1/a,…,xn/a)=2.
- Assume that φ(x1,…,xn) is of the form Qxn+1χ(x1,…,xn,xn+1), where Q∈{∃,∀} and that the claim holds for χ(x1,…,xn,xn+1). We must show that if πA(I)[[φ]](x1/a,…,xn/a)=∞, then πA(J)[[φ]](x1/a,…,xn/a)=2. Since adom(I)=adom(J)={a}, the only possible instantiation of the quantified variable xn+1 is xn+1/a. Thus, if πA(I)[[φ]](x1/a,…,xn/a)=∞, then πA(I)[[χ(x1/a,…,xn/a,xn+1/a)]=∞, hence, by induction hypothesis, we have that πA(J)[[χ]](x1/a,…,xn/a,xn+1/a))=2, hence πA(J)(φ(x1/a,…,xn/a))=2.
This completes the proof of Part II.
PART III: Let K be the fuzzy semiring F=([0,1],max,min,0,1). Recall that the monus operation on F is the operation – defined as follows:
x−y={x0ifx>yifx≤y.
Let a be an element in D and let I=(RI,SI) be the F-database such that
• RI(a)=0.3 and RI(b)=0, for all other elements b in D.
• SI(a)=0.5 and SI(b)=0, for all other elements b in D.
Furthermore, let J=(RJ,SJ) be the F-database such that
• RJ(a)=0.5 and RJ(b)=0, for all other elements b in D.
• SJ(a)=0.3 and SJ(b)=0, for all other elements b in D.
Consider the relational algebra expression R^∖S^ and the F-relations (R^∖S^)I and (R^∖S^)J. Clearly, we have that (R^∖S^)I(a)=RI(a)−SI(a)=0 and (R^∖S^)J(a)=RJ(a)−SJ(a)=0.5.
Furthermore, we have that
• A(I)=({a},RI,SI);
- The canonical interpretation πA(I) is the function on the atoms and negated atoms on {a} such that πA(I)(R^(a))=0.3, πA(I)(¬R^(a))=0, πA(I)(S^(a))=0.5, and πA(I)(¬S^(a))=0.
• A(J)=({a},RJ,SJ);
- The canonical interpretation πA(J) is the function on the atoms and negated atoms on {a} such that πA(J)(R^(a))=0.5, πA(J)(¬R^(a))=0, πA(J)(S^(a))=0.3, and πA(J)(¬S^(a))=0.
The following useful fact can be proved by a straightforward induction on the construction of FO(NNF)-formulas, using the properties of the operations max and min of the fuzzy semiring T.
FACT: For every FO(NNF)-formula φ(x1,…,xn), the possible values of πA(I)[[φ]](x1/a,…,xn/a) and of πA(J)[[φ]](x1/a,…,xn/a) are 0, 0.3, and 0.5.
We will now establish the following claim, which will immediately imply Part III.
CLAIM: Let φ(x1,…,xn) be a FO(NNF)-formula. Then
πA(I)[[φ]](x1/a,…,xn/a)=0orπA(J)[[φ]](x1/a,…,xn/a)=0.5.
The claim is proved by induction on the construction of FO(NNF)-formulas.
-
If φ is an atomic formula or a negated atomic formula, then the claim holds by the definitions of the canonical interpretations πA(I) and πA(J).
-
Assume that φ(x1,…,xn) is of the form ψ1(x1,…,xn)∨ψ2(x1,…,xn) and that the claim holds for the formulas ψ1 and ψ2. We must show that if πA(I)[[φ(x1/a,…,xn/a)=0, then we have that πA(J)[[φ(x1/a,…,xn/a)]]=0.5. If πA(I)[[φ]](x1/a,…,xn/a)=0, then
max(πA(I)[[ψ1]](x1/a,…,xn/a),πA(I)[[ψ2]](x1/a,…,xn/a))=0,
hence both πA(I)[[ψ1]](x1/a,…,xn/a)=0 and πA(I)[[ψ2]](x1/a,…,xn/a)=0. By induction hypothesis, we have that πA(J)[[ψ1]](x1/a,…,xn/a)=0.5 and πA(J)[[ψ2]](x1/a,…,xn/a)=0.5. The preceding fact about the possible values of FO(NNF)-formulas, implies that both
πA(J)[[ψ1]](x1/a,…,xn/a)≤0.3andπA(J)[[ψ2]](x1/a,…,xn/a)≤0.3,
hence
πA(J)[[φ]](x1/a,…,xn/a)=
max(πA(J)[[ψ1]](x1/a,…,xn/a),πA(J)[[ψ2]](x1/a,…,xn/a))≤0.3=0.5.
- Assume that φ(x1,…,xn) is the form ψ1(x1,…,xn)∧ψ2(x1,…,xn) and that the claim holds for the formulas ψ1 and ψ2. We must show that if πA(I)[[φ]](x1/a,…,xn/a)=0, then we have that
πA(J)[[φ]](x1/a,…,xn/a)=0.5.
If πA(I)[[φ]](x1/a,…,xn/a)=0, then
min(πA(I)[[ψ1]](x1/a,…,xn/a),πA(I)[[ψ2]](x1/a,…,xn/a))=0,
hence πA(I)[[ψ1]](x1/a,…,xn/a)=0 or πA(I)[[ψ2]](x1/a,…,xn/a)=0. So, assume that
πA(I)[[ψ1]](x1/a,…,xn/a)=0.
Hence, by induction hypothesis, we have that
πA(J)[[ψ1]](x1/a,…,xn/a)=0.5.
Therefore, by the preceding fact, we have that
πA(J)[[ψ1]](x1/a,…,xn/a)=0orπA(J)[[ψ1]](x1/a,…,xn/a))=0.3,
hence
πA(J)[[φ]](x1/a,…,xn/a)=
min(πA(J)[[ψ1]](x1/a,…,xn/a),πA(J)[[ψ2]](x1/a,…,xn/a))=0.5.
- Assume that φ(x1,…,xn) is of the form Qxn+1χ(x1,…,xn,xn+1), where Q∈{∃,∀} and that the claim holds for χ(x1,…,xn,xn+1). We must show that if πA(I)[[φ]](x1/a,…,xn/a)=0, then we have that πA(J)[[φ]](x1/a,…,xn/a)=0.5. Since adom(I)=adom(J)={a}, the only possible instantiation of the quantified variable y is y/a. Therefore, if πA(I)[[φ]](x1/a,…,xn/a)=0, then πA(I)[[χ]](x1/a,…,xn/a,y/a)=0, hence, by induction hypothesis, we have that
πA(J)[[χ]](x1/a,…,xn/a,y/a)=0.5,
hence πA(J)[[φ]](x1/a,…,xn/a)=0.5.
This completes the proof of Part III and the proof of the theorem.
The preceding Theorem 2 reveals a limitation in the expressive power of the canonical-interpretation semantics. Moreover, the proof of this theorem actually shows that the same limitation holds true for the compatible-interpretation semantics. The reason is that the K-databases used in the proof have singleton sets as their active domains. If the active domain adom(I) of a K-database I is a singleton, then the only compatible interpretation on adom(I) is the canonical one. Therefore, the proof of Theorem 2 establishes the following stronger result.
Theorem 3. Assume that τ is a relational schema containing two unary relation symbols R^ and S^. Let K be one of the following three semirings with monus:
• the bag semiring N=(N,+,×,0,1);
• the tropical semiring T=(R∪{∞},min,+,∞,0);
- the fuzzy semiring F=([0,1],max,min,0,1).
Then the monus query qm on K-databases is not definable by any FO(NNF)-formula under compatible-interpretation semantics.
An immediate consequence of the first part of Theorem 3 is that the compatible-interpretation semantics suffer from the same limitation on every positive semiring with monus that contains an isomorphic copy of the bag semiring N. In particular, the following result holds.
Corollary 1. Assume that τ is a relational schema containing two unary relation symbols R^ and S^. Let N[X]=(N[X],+,⋅,0,1) be the provenance semiring of polynomials with variables from X and coefficients from N. Then the monus query qm on N[X]-databases is not definable by any FO(NNF)-formula under canonical-interpretation semantics.
Theorem 3 also implies that there is no version of Codd's theorem involving relational algebra with monus on the one side and compatible-based interpretations on the other side. In particular, since the monus operation on bags is used in the semantics of SQL, we have the following implication for SQL.
Corollary 2. The semantics of SQL cannot be captured using compatible-interpretation semantics; in particular, they cannot be captured using canonical-interpretation semantics.
It is an open problem to characterize the positive semirings K with monus for which FO(NNF)-formulas under canonical-interpretation semantics or under compatible-interpretation semantics have the same expressive power as basic relational algebra on K-databases, where the difference ∖ operation on K-relations is interpreted via the monus operation on K.
References
[Ame84] K. Amer. Equationally complete classes of commutative monoids with monus. Algebra Universalis, 18:129–131, 1984.
[BKN25] Guillermo Badia, Phokion G. Kolaitis, and Carles Noguera. Codd's theorem for databases over semirings. Proc. ACM Manag. Data, 3(5):277:1–277:26, 2025.
[Cod70] Edgar F. Codd. A relational model of data for large shared data banks. Communications of the ACM, 13(6):377–387, 1970.
[Cod72] Edgar F. Codd. Relational completeness of data base sublanguages. In R. Rustin, editor, Proceedings of 6th Courant Computer Science Symposium (May 24–25, 1971: New York, N.Y.), pages 65–98. Prentice-Hall, 1972.
[DGNT21] Katrin M. Dannert, Erich Grädel, Matthias Naaf, and Val Tannen. Semiring provenance for fixed-point logic. In Christel Baier and Jean Goubault-Larrecq, editors, 29th EACSL Annual Conference on Computer Science Logic, CSL 2021, January 25-28, 2021, Ljubljana, Slovenia (Virtual Conference), volume 183 of LIPIcs, pages 17:1–17:22. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2021.
[DMRT14] Daniel Deutch, Tova Milo, Sudeepa Roy, and Val Tannen. Circuits for datalog provenance. In Nicole Schweikardt, Vassilis Christophides, and Vincent Leroy, editors, Proc. 17th International Conference on Database Theory (ICDT), Athens, Greece, March 24-28, 2014, pages 201–212. OpenProceedings.org, 2014.
[GKT07] Todd J. Green, Grigoris Karvounarakis, and Val Tannen. Provenance semirings. In PODS 2007 Proceedings of the Twenty-sixth ACM SIGMOD-SIGACT-SIGART symposium on Principles of Database Systems, pages 31–40. ACM Press, 2007.
[GP10] Floris Geerts and Antonella Poggi. On database query languages for K-relations. Journal of Applied Logic, 8(2):173–185, 2010.
[GT17] Erich Grädel and Val Tannen. Semiring provenance for first-order model checking. CoRR, abs/1712.01980, 2017.
[GT25] Erich Grädel and Val Tannen. Provenance analysis and semiring semantics for first-order logic. In Model Theory, Computer Science, and Graph Polynomials, pages 351–401. Birkhäuser, 2025. Festschrift in Honor of János Makowsky.
[KPVW25] Phokion G. Kolaitis, Nina Pardal, Jonni Virtema, and Jef Wijsen. Rewriting consistent answers on annotated data. Proc. ACM Manag. Data, 3(2):110:1–110:26, 2025.
[Mon16] Mikaël Monet. Example of a naturally ordered semiring which is not an m-semiring. https://math.stackexchange.com/questions/1966858/example-of-a-naturally-ordered-semiring-which-is-not-an-m-semiring, 2016. StackExchange.
[Suc24] Dan Suciu. Different differences in semirings. In Antoine Amarilli and Alin Deutsch, editors, The Provenance of Elegance in Computation - Essays Dedicated to Val Tannen, Tannen's Festschrift, May 24-25, 2024, University of Pennsylvania, Philadelphia, PA, USA, volume 119 of OASIcs, pages 10:1–10:20. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2024.