A finite algebra has few subalgebras of powers if and only if it has a cube term (equivalently, edge term or parallelogram term) of some dimension. See  and  for an introduction to these terms, and  for the application to the Constraint Satisfaction Problem.
How to efficiently decide if a given finite algebra has a cube term? This question has practical significance: When coming up with hypotheses about few subpowers, one might want to quickly know if a candidate for a counterexample actually has few subpowers. Deciding existence of various operations is also of interest in computational universal algebra (e.g. in the software package UAcalc ). Conveniently, deciding whether has a cube term goes a long way towards telling us whether also has a near unanimity operation, see Theorem 2.
Our goal in this paper is to explore the conditions for the existence of a cube term in the clone of operations of an algebra (with finitely many basic operations), or equivalently, in a finitely generated finite clone.
Before we begin, we would like to point out that the part of our paper devoted to clones of idempotent algebras (Section 4) has a significant overlap with the results in  by Keith Kearnes and Agnes Szendrei. To be specific, [10, Theorem 4.1] is a stronger version of our Theorem 4. While Theorem 4 requires finiteness, [10, Theorem 4.1] only requires that the algebras in question be idempotent and have finitely many basic operations. Also, this paper and  both give example algebras proving that the bound on cube term dimension from Theorem 4 (or [10, Theorem 4.1]) is tight; this is Theorem 4 here and Example 4.4 in . While the outcome is similar, our construction is novel in that it works for any (finite, greater than 2) size of the base set.
When constructing the proof of Theorem 4, we had heard the statement of Theorem 4.1 in , thus priority for the result belongs to Keith Kearnes and Agnes Szendrei. It also turns out that our methods for idempotent algebras resemble those of  (in particular, our “chipped cubes” are basically the same thing as “crosses” of Keith Kearnes and Agnes Szendrei). However, we produced the proof of Theorem 4 on our own as we only knew the statement, not the proof of [10, Theorem 4.1] when writing our proof.
We include a full proof of Theorem 4 in this paper because it illustrates the ideas we later develop for the non-idempotent case and also because Theorem 4 naturally leads to Theorem 4 which shows that the bounds on cube term arity of Theorem 4 are tight for all applicable sizes of the base set of the algebra in question, improving the state of the art.
We will spend much time and effort designing and examining tuples. A tuple on of arity (or -tuple on ) is a sequence of members of the set . If we want to emphasize that an object is a tuple we print it in bold: . The set of all -tuples on will be denoted by . If and , we denote the -th entry of by or sometimes by . On the other hand, indices without parentheses and in bold shall refer to a particular member of a sequence of tuples, so e.g. is the third tuple from some sequence, not the third entry of . If confusion is unlikely, we will write the tuple in a more compact form as .
When are tuples, we will denote by their concatenation, i.e. the tuple .
If are positive integers and is an tuple, then by we mean the -tuple .
If and then is the -tuple whose all entries are (the boldface signals that we are turning into a tuple), i.e. . If for some , we will call the interval the -th block of . The partition into blocks can be ambiguous if e.g. , but this will not be an issue as we will usually fix the partition in advance. A careful reader might have noticed that we have overloaded e.g. to mean both the second element and the -th element of . We did this to keep our notation short; when is broken into obvious blocks then always stands for the element forming up the second block of .
Finally, if is a (finite) set then is the -tuple that lists all elements of in a fixed order (for example, ). We will denote the set by .
The following way to combine tuples, introduced in , will be useful when talking about cube terms and blockers: Let , be two tuples. We then define for each the tuple
In particular, we will often consider the matrix . If , then is an matrix whose -th column is where is the -th nonempty subset of (ordered, say, lexicographically for some fixed linear order on )
An operation of arity on a set is a mapping . The table of the operation is the -tuple that lists all the values of in some agreed upon order. The -ary projection to the -th coordinate is the operation . If is an -ary operation and are -ary operations, then we can compose with getting the -ary operation
A clone on a set is any set of operations on that contains projections and is closed under composition of operations. A clone is finite if is finite. A clone is finitely generated if there is a finite list of operations inside such that every other operation of can be obtained by a sequence of compositions from and projections.
An algebra consists of a base set together with a set of operations where ranges over some index set . The operations are called basic operations of . The arities of operations form the signature of a given algebra.
An algebra is finite if is finite. A term operation of (or just operation of for short) is any operation we can get from the basic operations of and projection operations by a sequence of compositions. If is an algebra with finitely many basic operations and is finite, then the set of term operations of is finitely generated finite clone and, on the other hand, every finite finitely generated clone is the clone of operations of a finite algebra with finitely many basic operations. We will mostly talk about algebras in the rest of our paper, but this is only matter of taste – all our arguments easily translate into the language of clones.
A subuniverse of is any set that is closed under the (basic) operations of . We denote the statement that is a subuniverse of by .
We will often apply a term operation to a matrix. Let be an algebra and let be an -ary operation of . If is an matrix, then is the -tuple that we obtain by applying on the rows of .
If is an algebra and , then the -th power of , denoted by , is the algebra with universe and operations “inherited” from : If is an -ary operation of , then is also an -ary operation of . To evaluate , apply on the matrix with columns .
For , we will denote by the subuniverse of generated by . is the smallest subset of that contains and is closed under all (basic) operations of . If we want to emphasize the dimension and the algebra we are talking about, we will write . To simplify notation, we will often omit curly brackets in the argument of , writing e.g. instead of .
Given a set , we can find the subalgebra of generated by in time , where is the maximum arity of a basic operation of . The algorithm works by generating a sequence of subsets of that terminates with . We obtain from by applying all the basic operations of to tuples from that contain at least one element outside of (this last condition ensures that we handle each tuple at most once for each basic operation; in the step, we let ). We do not claim authorship of this algorithm; it was previously mentioned in .
The algebra or a clone is idempotent if for each of its operations and all the identity
holds (this is equivalent to demanding that the identity holds for each of ’s basic or generating operations, respectively).
A variety of algebras is a family of algebras of the same signature that is closed under taking powers, subalgebras and homomorphic images, or equivalently (by Birkhoff’s theorem) a family of algebras of the same signature that satisfy a fixed set of identities (see e.g.  for details).
Our situation in the rest of the paper is that we are given a finite algebra described by a list of its elements and the tables of its (finitely many) basic operations, and we want to decide if there is a cube term in the clone of . Occasionally, we shall need to distinguish the number of elements of , denoted by , from the total size of the input which includes the list of elements plus a table of size for each basic operation of of arity . We denote the total size of ’s description by .
Let be an algebra. A relation is compatible with for (also called -invariant or admissible in the literature) if is a subuniverse of . In other words, if for every -ary basic operation of the operation extended to maps into itself: For every we have where is the matrix whose -th column is .
The following proposition is easily proved from the definition of relations compatible with an algebra. We note that this proposition is part of a larger theory of Galois correspondence between clones of operations and relational clones (sets of relations closed under primitive positive definitions) [4, 7]. Let be relations compatible with . Then the following relations are also compatible with :
The unary relations and ,
the projection of to any subset of ,
the relation ,
if , the relation , and
the unary relation , where , if is idempotent.
One application of Proposition 2 that we will use is that if is an -ary relation compatible with an idempotent algebra and is an element of , then the relation we get from by “fixing the first coordinate to and projecting it out” is also compatible with .
An -ary operation on is called a cube operation of dimension if for all we have
The reason for this name is that if we view as a -dimensional cube, then the cube term will, given a cube with one missing vertex, fill in the empty spot.
A -ary term is called an edge operation of dimension (or just a -edge term) if for any we have
Finally, a -ary term is a -ary near unanimity operation (abbreviated to ) if for any we have
(This is not the usual way to write the NU equalities, but we chose it here to show the similarity between NUs and cube/edge terms.)
Note that since all three of the above definitions (cube, edge, and near unanimity operations) require that an equality holds for any , we could have also easily rewritten them as systems of equations in two variables. For example, NU operation is an operation satisfying the following identities for all :
It is easy to see that a -dimensional edge term implies the existence of a -dimensional cube term. It turns out that one can also prove the converse: [[3, Theorem 2.12]] Let be a finite algebra. Then has a -dimensional edge term operation if and only if admits a -dimensional cube term.
The situation with near unanimity is a bit more complicated since admitting an operation is a strictly stronger condition than admitting an edge or a cube term. However, it turns out that is equivalent to having a -edge term (or, by Theorem 2, -dimensional cube term) for congruence distributive algebras (for an earlier result of a similar flavor, see [13, Theorem 3.16]).
[[3, Theorem 4.4]] For each , a variety is congruence distributive and has a -edge term if and only if has a -ary near-unanimity term.
Thus any bound on the minimal arity of a cube term is also a bound on the minimal arity of a near unanimity operation.
Note that deciding the existence of near unanimity (NU) term reduces to deciding the existence of a cube term: By Theorem 2, an algebra has an NU term if and only if it has a cube term and lies in a congruence distributive variety. One can test whether generates a congruence distributive variety in time polynomial in for idempotent algebras (see ) and in time exponential in for general algebras (by taking the idempotent algorithm and adding the prefix to all tuples; see Lemma 3 below). In both of these cases, deciding congruence distributivity of the variety generated by is much easier than deciding the existence of a cube term.
To decide the existence of a cube term, we want to translate the problem from the language of operations into the language of relations. We have a good description of the shape of relations that, when compatible with an algebra , prevent from having cube terms:
We say that an -ary relation on is elusive if there exist tuples such that for all , but . In this situation, the tuple is called an elusive tuple for (this is a notion similar to, but stricter than, essential tuples used ; we note that elusive tuples were used, unnamed, already in ). Elusive relations prevent the existence of cube terms of low dimensions:
If is an idempotent algebra which admits an -ary elusive relation, then does not have any cube term of dimension or less.
Let be elusive and let be a pair of tuples that witness the elusiveness of .
Since we can trivially obtain an
dimensional cube term from a cube term of lower dimension by introducing dummy variables, we only consider the case thathas a cube term of arity . Then applying this cube term on would give us , a contradiction.
Let be an idempotent algebra. Then a pair is a cube term blocker (or just a “blocker” for short) if and are nonempty subuniverses of , and . The reason for the name “cube term blockers” comes from the following result: [] Let be a finite idempotent algebra. Then has a cube term if and only if it possesses no cube term blockers.
Viewed in -dimensional space, the relation looks like a hypercube with one corner chipped off (the missing corner prevents cube terms from working properly). The following proposition gives a logically equivalent way to describe cube term blockers (note that the original paper  actually used this as the definition of cube term blockers and showed equivalence with our Definition 2). [[12, Lemma 3.2]] Let be an idempotent algebra and let be two subuniverses of . Denote the arity of by . Then is a cube term blocker of if and only if for each there exists a coordinate between 1 and such that for each and all we have
Proposition 2 immediately gives us an algorithm (first described in ) that decides in polynomial time if is a blocker for an algebra given by its idempotent basic operations: First test if and , then for every basic operation try out all the coordinates and see if for some position of . If we can find such a coordinate for all basic operations, then we have a blocker; else is not a blocker. The testing of coordinates can be implemented in time , by passing through each table of each operation exactly once and keeping track of the coordinates that each tuple rules out (here is the maximum arity of a basic operation of ).
In the following, we will need a more general version of cube term blocker. Let and where . We then define the -ary relation which we call a chipped cube by
The coordinates of a chipped cube naturally break down into blocks: The -th block, which we will often denote by , consists of integers from to (inclusively).
We will sometimes omit unnecessary brackets as well as exponents equal to 1, so for example we have
The following two observations are immediate consequences of the definition of an elusive relation:
Let be an elusive tuple for some relation compatible with the algebra . Then there exist elements such that is an elusive tuple for the relation
Let be an algebra. Let
be a chipped cube where each is a subuniverse of and assume that the relation is not elusive. Then
3 General cube term results
Let be a finite algebra. Then the following are equivalent:
has a cube term of dimension ,
For all we have
If has a -dimensional cube term then consider the matrix that we obtain by prefixing each column of the matrix by . Since cube terms are idempotent, it is easy to see that all columns of are of the form for some and that .
It remains to prove Claim 3. We proceed by induction on . We already know that the statement is true for . Assume now that the statement is true whenever and consider with . Let us denote by the set of generators
We will view as a matrix whose columns are indexed by sets such that .
Without loss of generality let . Pick so that is the first entry of the last block of .
Considering the projection of to coordinates and applying the induction hypothesis (taking and instead of and ), we obtain that there exists an such that
Therefore, there is a term such that . Observe that is idempotent since it maps to . Our next goal is to go from blocks to blocks .
Consider the matrices , where . Given a , we obtain from by replacing, in each column, blocks of by corresponding blocks of as prescribed by . To be more precise, we let and replace each column of by . The columns of lie in and by idempotency of , we have for each
From this, it follows that contains all tuples of the form
where is a nonempty union of some of the blocks . Applying the induction hypothesis (with the sum of block sizes ), we get that contains the tuple
finishing the proof. (Here we used the fact that membership of tuples beginning with in is witnessed by idempotent terms, so the suffix is not changed by using the induction hypothesis).
The following lemma sheds some light on how minimal elusive relations look like. The additional assumption that we are dealing with a chipped cube is reasonable – see Lemma 4.
Let be an algebra, an inclusion minimal elusive relation compatible with . Assume moreover that is equal to the chipped cube
Let and be two tuples witnessing the elusiveness of . Then:
there is no subuniverse of such that for some ; in particular for each ,
if are such that , then ,
if for some and then either or .
Note that for each we have and .
The first point follows from the fact that is the smallest relation that contains all the tuples that witness the elusiveness of .
The proof of the second point is similar. Were there strictly between and , we could restrict the -th coordinate of to and obtain a smaller elusive relation, proving (b).
To see that (c) holds, take and such that and . Without loss of generality let . Then the set of generators of is invariant under the permutation that swaps -th and -th coordinates. Therefore, is invariant under such a permutation of coordinates as well. Consider now
Since is a chipped cube, it follows that and from the symmetry of , we get that is symmetric as a binary relation. It is straightforward to verify that this can only happen when and .
Finally, assume (without loss of generality) that and . Consider then the chipped cube we get from by switching the first two coordinates:
By symmetry, is a relation compatible with . Moreover, is the chipped cube
which is also an elusive relation (because ). From the assumption that is minimal, we get , proving (d). In the proof above, we took advantage of swapping two coordinates of . Later in the paper, we will be working with a general mapping that moves coordinates of tuples around.
4 Cube terms in idempotent algebras
Let be an idempotent algebra, an inclusion minimal elusive relation compatible with . Then is a chipped cube.
Given that is minimal, our strategy will be to fit a maximal chipped cube into and show that this chipped cube is equal to .
Let be an elusive tuple for . Let moreover
be an inclusion-maximal chipped cube such that (1) and (2) for each . (At least one such chipped cube exists by Observation 2.)
We prepare ground for our proof by exploring properties of the sets . From the maximality of , it follows that each of the sets is a subuniverse of : Were, say, then for some operation of and suitable . Take such that for each we have and for at least one we have . By definition of a chipped cube, for each we have and applying thus gives us . Therefore contains the chipped cube
a contradiction with the maximality of .
From the minimality of , we immediately get and what is more for each . The latter equality follows from the fact that is an elusive relation and we chose to be a minimal elusive relation. Since for each we have and the outer pair of sets is equal, it follows that actually for each .
We are now ready to show that . Assume otherwise and choose that agrees with on as many coordinates as possible. Up to reordering of coordinates, we thus have a tuple such that .
Since , we see that for all . We will show that contains the chipped cube
yielding a contradiction with the maximality of . To prove this, we need to show that .
Observe first that This follows from the inclusion and the idempotence of .
Let . Since , we obtain , making strictly smaller than .
Consider now the relation . From we see that is not elusive. However, contains the chipped cube
This is only possible if , which is exactly what we needed. We would like to remark that Lemma 4 does not hold for general algebras. As an example, consider the algebra on the set with one unary constant operation . For any let
This relation is compatible with and elusive. It is straightforward to verify that is also minimal such (-ary elusive relation needs to contain at least tuples; is just one tuple larger than this theoretical minimum, and a case consideration shows that we can’t discard any tuple from ). However, is not a chipped cube: The projections of to each coordinate are all equal to and contains the tuple . It is not hard to show that any chipped cube with these two properties contains at least tuples whose some entry is 2, which does not.
Let be a finite idempotent algebra, and let be an integer. Then has a cube term of dimension if and only if there is no -ary chipped cube relation compatible with . Cube terms are incompatible with chipped cubes, so the interesting implication is that the absence of a -dimensional cube term gives us a -ary compatible chipped cube.
Assume thus that has no -dimensional cube term. We claim that then is compatible with some -ary elusive relation. By Lemma 3, there exist such that . Since is idempotent, we can remove the prefix and have . This amounts to saying that is an elusive tuple for . To finish the proof, we take an inclusion minimal -ary elusive relation compatible with . By Lemma 4, this is a chipped cube.
The following Lemma is a nontrivial consequence of Proposition 2. Let be an idempotent algebra that admits a cube term. Denote by the arities of . Assume that the chipped cube
is compatible with . Let for each
where goes from 1 to (see Definition 2 for what a cube term blocker is). Then:
for each we have .
Note that we implicitly have for each from the definition of a chipped cube.
Since has a cube term, there is no cube term blocker in . In particular none of , , …, are blockers for . Were, say, a blocker for all algebras then each maps each relation into itself, making a blocker for the whole algebra . Therefore, for each there exists an so that , i.e. , giving us part (a).
It remains to show that for each we have . Assume for a contradiction that for some . Without loss of generality we can assume that in fact (we are free to reorder the ’s and ’s). We then consider the chipped cube
It is easy to see that can be obtained from by restricting all but the first coordinates to some singleton values from and projecting the result to the first coordinates (here we need that is idempotent). Therefore preserves .
However, are not blockers for . By Proposition 2, for each we then can find a tuple
such that and .
Arrange the above mentioned tuples into rows of an matrix . Since for all , each column of belongs to . Therefore, we should have as well. But applied to the -th row of the matrix gives us an element from for each , so fails to be in , a contradiction.
Since the sets in the above theorem depend only on and the sets , we can generalize the result to the case when appears multiple times in : Let be an idempotent algebra that admits a cube term. Denote by the arities of . Assume that the chipped cube
is compatible with . Then there exists a family of sets such that and for each we have .
We are now ready to give a lower bound on the arity of a cube term in finite idempotent algebras with cube terms. For a version of the following theorem that works for infinite idempotent algebras, see [10, Theorem 4.1] (we discuss the relationship between our paper and  in detail at the end of the Introduction). Let