Day's Theorem is sharp for $n$ even

We solve some problems about relative lengths of Maltsev conditions, in particular, we give an affirmative answer to a classical problem raised by A. Day more than fifty years ago. In detail, both congruence distributive and congruence modular varieties admit Maltsev characterizations by means of the existence of a finite but variable number of appropriate terms. A. Day showed that from J\'onsson terms $t_0, \dots, t_n$ witnessing congruence distributivity it is possible to construct terms $u_0, \dots, u _{2n-1} $ witnessing congruence modularity. We show that Day's result about the number of such terms is sharp when $n$ is even. We also deal with other kinds of terms, such as alvin, Gumm, Pixley, directed, specular, mixed and defective. All the results hold when restricted to locally finite varieties. We introduce some families of congruence distributive varieties and characterize many congruence identities they satisfy.


Introduction
A variety is a class of algebraic systems (henceforth, algebras, for short) of the same type and closed under taking products, subalgebras and homomorphic images. Groups and rings form a variety, fields do not. A congruence on an algebra is the equivalence relation associated to some homomorphism. Described internally, a congruence is an equivalence relation respecting all the operations. E. g., the laterals of a normal subgroup in a group, or the laterals of a bilateral ideal in a ring are the equivalence classes associated to a congruence. From the point of view of general algebra the case of groups and rings is very special; in general, a congruence cannot be described in terms of a single subset [24]. For example, just work out the congruences of a four-elements linearly ordered set, considered as a lattice with the operations of min and max.
Tight structure theorems have been proved for varieties all whose algebras have congruences satisfying appropriate properties [26,33]. Two congruences α and β of the same algebra are said to permute if α • β = β • α, where • is relational composition. Varieties consisting of algebras with permuting congruences, congruence permutable varieties, for short, share some properties in common with groups [60]. The set of all congruences of some algebra has a natural lattice structure. Varieties all whose algebras have a distributive congruence lattice share many properties in common with lattices [28] (notice that here lattices play a two-fold role). If both congruence permutability and distributivity are present, we get varieties sharing some good properties in common with Boolean algebras. Turning to weaker conditions, the modular identity is a lattice identity corresponding to the Dedekind law holding for normal subgroups of a group. All congruence permutable algebras and all congruence distributive algebras are congruence modular. Astonishingly, it has been discovered that virtually all the properties which hold both in congruence permutable and in congruence distributive varieties hold in congruence modular varieties, as well [18,23].
The key to many such results are characterizations obtained by means of the existence of certain terms (aka words, expressions, polynomials). The first and simplest such characterization is due to A. Maltsev [48]: a variety V is congruence permutable if and only if there is a term t in the language of V such that x = t(x, y, y) and t(x, x, y) = y are identities holding in all algebras in V. For groups t(x, y, z) = xy −1 z is such a term. For quasigroups (x/(y\y))(y\z) works. As an immediate consequence, varieties with additional operations are congruence permutable, too. This applies to rings, Boolean algebras, modules, groups and quasigroups with operators.
Similar characterizations have been discovered for congruence distributive [28] and congruence modular varieties [11], with a significant difference. Contrary to the case of congruence permutability, in these cases the characterization does not involve a single term, rather, it involves a sequence of terms, and the length of such a sequence should be allowed to vary in the set of natural numbers. See Section 2 for examples. Many other such Maltsev conditions have been subsequently discovered, characterizing many more properties [26,33].
In passing, let us notice that the mentioned conditions involving terms have been originally devised only in search for conditions implying "good algebraic structure". Quite unexpectedly, however, more recently the very same conditions, or small variations thereof, have come to prominence in the field of computational complexity, particularly in connection with aspects related to the algebraic constraint satisfaction problem. See, e. g., [2,4,27] for a survey.
Summarizing, a Maltsev condition is a condition asserting the existence of some sequence of terms satisfying appropriate sets of equations in some variety. In general, the above sequences have variable length, roughly, a Maltsev condition is a statement of the form there is some n ∈ N and there are terms t 0 , . . . , t n such that so and so.
Deep results are known connecting various distinct Maltsev conditions, both in abstract and in more specific settings. In fact, as we hinted above, there are many nontrivial results asserting that if all the algebras in some variety have some property, then all the algebras in that variety have some other property. In general, the proof is obtained by translating the relevant properties into appropriate Maltsev conditions. Notice that, generally, such results hold only at the "global" level of varieties, not at the "local" level of single algebras. Namely, if the first property holds in some algebra, it is not necessarily the case that the second property holds in that algebra. Usually only global properties holding within a variety do imply Maltsev conditions, this fact partially explains the reason for the usefulness of Maltsev conditions. For example, a 3-elements algebra A with no operation has a modular congruence lattice, hence it satisfies a comparatively strong local property, but the variety V generated by A is trivial, hence, in a sense, it satisfies no nontrivial global property. In any case, V satisfies no nontrivial Maltsev condition.
A significant specific example of applications of Maltsev conditions concerns congruence modularity. There is a bunch of really different-looking Maltsev conditions, all of them characterizing congruence modularity [11,12,13,17,22,23,30,52,62]. Hence all such Maltsev conditions are actually equivalent. Each condition has specific features leading to particular applications which are difficult or virtually impossible to obtain using the other conditions. Most proofs are highly nontrivial. Some conditions characterizing congruence modularity shall be explicitly recalled and studied here; see, in particular, Sections 2 and 7.
Other deep results connecting apparently distinct Maltsev conditions can be found in [26,33]. In passing, let us also mention an unexpected quite recent result: there is the weakest strong Maltsev condition among all the idempotent nontrivial Maltsev conditions [59,54]. A Maltsev condition is idempotent if all the terms defining it are idempotent, that is, they satisfy t(x, x, x, . . . ) = x. The product xy in a group is not idempotent, but the Maltsev term t(x, y, z) = xy −1 z witnessing congruence permutability is idempotent. Similarly, the majority of the interesting Maltsev conditions are indeed idempotent.
While, as we have just mentioned, many deep results are known about Maltsev conditions and their interplay, really little is known about the possible lengths of the corresponding sequences. In more detail, if M and M ′ are Maltsev conditions expressed in the standard formulation and M implies M ′ , then, for every n ∈ N, there is m ∈ N such that, whenever some variety V satisfies M, as witnessed by n terms, then V satisfies M ′ , as witnessed by m terms. See the following subsection for details, exemplified in the specific case of interest here. We are in the really strange situation that highly nontrivial results are known about different Maltsev conditions, while only a few facts are known about the relationship among the specific lengths of the corresponding sequences.
Among the few results known in this direction, a relatively easy argument by A. Day [11] shows that a variety with n Jónsson terms witnessing congruence distributivity has 2n − 1 Day terms witnessing congruence modularity. Shortly after the proof of his theorem, Day himself asked whether the result is optimal. To the best of our knowledge, the problem has not been solved before. We show that Day's Theorem is optimal when n is even. When n is odd, some arguments from Lampe, Taylor and Tschantz [36] show that Day's value can be improved by 1 and our results here imply that for n odd Day's value cannot be improved by 3, leaving open the possibility that it can be improved by 2.
The arguments from [36] use an assumption weaker than congruence distributivity; in particular [36] is mainly concerned with two distinct Maltsev conditions both characterizing congruence modularity, the already mentioned condition by Day and another condition discovered by Gumm. The arguments in the present note show also that the evaluation in [36] of the number of Day terms obtainable from a sequence of Gumm terms is optimal, for n even. The converse problem, already asked in [36], namely, the evaluation of the minimal number of Gumm terms obtainable from a sequence of Day's terms is still largely open. The relevance of this problem has been stressed by a recent result [43] in which we show that a congruence distributive variety with n Gumm terms has n + 1 Jónsson terms. Together with [36], the above result implies that in a congruence distributive variety the number of Day terms (for congruence modularity) directly influences the number of Jónsson terms (for congruence distributivity)! A solution of Lampe, Taylor and Tschantz' problem is necessary in order to evaluate exactly the effect of this influence. See Problem 10.10 for further comments and details.
A similar problem about lengths of sequences appears in [30], where the classical Maltsev condition by Jónsson for congruence distributivity is showed to be equivalent to another condition involving "directed" terms. In [30] directed Gumm terms are also introduced. Directed terms have proved to be very interesting and useful [64,30,41,32]. Again, we show that the evaluation of the number of "undirected" terms obtainable from a sequence of directed terms is optimal, the reverse direction being still open.
As the reader has surely already appreciated, the main emphasis in this introduction concerns how much is known about Maltsev conditions and how little is known about the lengths of the corresponding sequences of terms. Astonishingly, already the examples dealing with a single Maltsev condition turn out to be generally rather tricky. Let us explain the point in more detail. As we already mentioned, say, congruence distributivity can be characterized by sequences of Maltsev terms of length not prescribed in advance. This suggests that, for example, there is a congruence distributive variety whose congruence distributivity is witnessed by a sequence consisting of 5 terms, but cannot be witnessed by 4 terms or less. Similar examples necessarily can be found for any other Maltsev condition whose definition-in contrast, for example, with the Maltsev condition characterizing congruence permutabilitydepends on a sequence of variable length. While such examples can be worked out abstractly, essentially as some hard exercise on term-rewriting [14], until recently [19,35] no natural [29, p. 368] example was known. As a by-product of our techniques, we provide new examples for congruence distributivity and, possibly, the first explicit locally finite examples for congruence modularity. See Section 9, in particular, Corollaries 9.12, 9.13 and 9.14. The examples we present in Section 9 are locally finite congruence distributive varieties generated by 2-elements algebras. These examples have probably intrinsic interest for their own sake.
As hinted in the above paragraphs, our techniques are quite general and go far beyond the proof that Day's Theorem is sharp. Our basic constructions outlined in Section 3 work in a rather abstract context and have applications outside the theory of congruence modular varieties. In fact, we have results about much weaker congruence identities; see Remark 10.11. In Section 6 we notice that all the constructions we perform produce varieties with specular terms, a notion weaker than full symmetry and which probably deserve further study, as suggested also by [8]. In Section 8 we hint a connection with Maltsev conditions associated to certain directed paths and devised in [32]. Moreover, as a byproduct of our techniques, we evaluate exactly certain congruence identities satisfied by the variety of nearlattices, complementing some results from [45]. See Proposition 3.12 and Corollary 9. 15.
We now summarize the paper in more detail, touching upon a few significant technical issues, when convenient. We assume the reader is familiar with the basic notions of universal algebra. See, e. g., [23,26,29,33,49] for background.
The ways congruence modularity follows from distributivity. It is plain that every congruence distributive variety is congruence modular. Since both congruence distributivity and modularity admit Maltsev characterizations, it is theoretically possible to construct a sequence of terms witnessing congruence modularity from any sequence of terms witnessing congruence distributivity.
In more detail, a classical theorem by B. Jónsson [28] asserts that a variety is congruence distributive if and only if, for some natural number n, there are terms t 0 , . . . , t n satisfying an appropriate set of equations. A parallel result has been proved by A. Day [11] with respect to congruence modularity. See Section 2 for details and explicit definitions. If, for each n, we consider a variety V with exactly operations satisfying Jónsson equations, then V is congruence distributive, hence congruence modular, so finally, by Day's theorem, V has a certain number u 0 , . . . , u m of Day terms. Working in an appropriate free algebra, we can thus express Day terms in function of Jónsson terms. Since, by its very definition, V is interpretable in any variety having Jónsson terms t 0 , . . . , t n , we get that every variety W with Jónsson terms t 0 , . . . , t n has Day terms u 0 , . . . , u m for the same m as above, actually, the u k 's are expressed in the same way.
While the above general argument is useful in very complex situations, in the special case at hand the construction of Day terms from Jónsson terms can be obtained in a relatively simple way. We shall recall Day's argument in the proof of Corollary 4.3(i) below and variations on it appear in Theorem 5.1(ii) and Lemma 4.2. The latter merges the original Day's argument with some ideas from [36].
It is customary to say that a variety is n-distributive if it has Jónsson terms t 0 , . . . , t n ; the definition of an m-modular variety is similar. See Section 2 for details. The following theorem already appeared in [11], in the same paper where the Maltsev characterization of congruence modularity has been presented. Among other, in the present paper we show that Day's Theorem is the best possible result for n even. Theorem 1.2. If n > 0 and n is even, then there is a locally finite n-distributive variety which is not 2n−2-modular. Theorem 1.2 is a special case of Theorem 4.1(i) which shall be proved below. The reader interested only in a quick tour towards the proof of Theorem 1.2 might go directly to Section 3, turning back to Section 2 only if necessary to check notation and terminology. A large part of Section 3 is not necessary for the proof of Theorem 1.2, either. A quick route to the proof of Theorem 4.1(i) goes through Constructions 3.2, 3.4, 3.13, Lemma 3.6(i) and Theorems 3.3, 3.7 and 3.14(i)(ii). An explicit counterexample witnessing Theorem 1.2 is the variety V a n which shall be introduced in Definition 9.2(a). See Theorem 9.8.
However, in the author's humble opinion, the present paper contains some further results which might be of interest to scholars working on congruence distributive and congruence modular varieties. In particular, as a by-product of our proof of Theorem 1.2, we get the best evaluation for the modularity levels of varieties with Gumm terms, again in the case n even. See Proposition 7.4. Moreover, similar arguments can be used to show that a theorem by A. Mitschke [51], too, gives the best possible evaluation. See [47]. As we are going to explain soon, we get quite neat results about certain directed, reversed and specular conditions. Occasionally, we shall also deal with congruence identities which fail to imply congruence modularity. See Remark 10.11 below.
Concerning the case n odd in Day's Theorem 1.1, we mentioned in [46] that if n > 1 and n is odd, then Day's Theorem can be improved (at least) by 1. The improvement follows already from the arguments in the proof of [36, Theorem 1 (3) → (1)], actually, under a hypothesis weaker than congruence distributivity. See Lemma 4.2 and Section 7, in particular, Proposition 7.4(i). We do not know what is the best possible result for n odd. We shall briefly discuss the issue in Remark 10.3 below.
"Reversed" conditions and hints to the inductive proof that Day's result is sharp. Let us now comment a bit about the proof of Theorem 1.2. We shall recall Jónsson and Day terms in Section 2. In both cases, the terms are required to satisfy distinct conditions for even and odd indices. If we exchange odd and even in the condition for congruence distributivity, we get the so called alvin terms [49,Theorem 4.144]. While a variety is congruence distributive if and only if it has Jónsson terms, if and only if it has alvin terms, we get different conditions, in general, if we keep the number of terms fixed [19]. Similarly, let us say that a variety V is m-reversed-modular if V has terms u 0 , . . . , u m satisfying Day's conditions with odd and even exchanged. See Definitions 2.7 and 2.9 for precise details. We have results also for the reversed conditions. Actually, the use of the reversed conditions seems fundamental in our arguments; the proof of Theorem 1.2 proceeds through a simultaneous induction which deals alternatively with (a) distributivity in combination with reversed modularity, and (b) alvin in combination with modularity. In the next theorem we state our main results about the reversed conditions. Theorem 1.3. Suppose that n ≥ 4 and n is even.
(ii) There is a locally finite n-alvin variety which is not 2n−3-modular, Theorem 1.3 follows from Lemma 4.2(a) and Theorem 4.1(ii) which shall be proved below. Notice that the conclusions in Theorems 1.1 and 1.2 deal with 2n − 1 and 2n − 2, while Theorem 1.3 deals with the different parameter 2n − 3. The proof of Theorem 1.3(i) uses the methods from Day [11] with a small known variation "on the outer edges". An alternative proof using relation identities is presented in Section 8.
The bounds in Theorems 1.1 and 1.3 are shown to be optimal by constructing appropriate counterexamples by induction. In each case, the induction at step n uses the counterexample constructed for n − 2 in the parallel theorem. We shall prove a slight improvement of Theorem 1.2, to the effect that, for n ≥ 2 and n even, there is an n-distributive variety which is not 2n−1-reversed-modular. Then the induction goes as follows: from an n−2-alvin not 2n−7-modular variety we construct an n-distributive variety which is not 2n−1-reversed-modular. In the other case, from an n−2-distributive variety which is not 2n−5-reversed-modular we construct an n-alvin not 2n−3-modular variety. Notice that the shift in the modularity level is 6 in the former case and 2 in the latter case. On average, we get a shift by 8 each time n is increased by 4, in agreement with the statements of the results.
A more explicit description of varieties furnishing the counterexamples is presented in Section 9. The varieties introduced in Section 9 are described in a relatively simple way; however, as far as we can see, there is no direct proof that such varieties do the requested job. Any possible proof seems to use and mimic-more or less in disguise-the general constructions performed in Section 3 and the inductive arguments presented in Section 4. In fact, in a parallel situation, in [47,Section 4] we worked the explicit details: the resulting computations turned out to occupy almost the same space as the abstract general considerations, even though some details were only hinted. This is the reason why, in the present situation, we shall exhibit the more abstract constructions in Section 3. Such constructions have also the advantage of furnishing a uniform treatment for various different situations and have further applications to some extended settings, as we shall hint in Remarks 10.1 -10.2, 10.7 -10.9.
Directed and mixed conditions. We shall also deal with other conditions equivalent to congruence distributivity. Kazda, Kozik, McKenzie, Moore [30] have studied a "directed" variant of Jónsson condition and they proved that this directed Jónsson condition, too, is equivalent to congruence distributivity. For the directed variant there is no distinction between even and odd indices. We shall prove optimal results also for the modularity levels of varieties with such directed Jónsson terms. See Theorem 5.1. Furthermore, Kazda, Kozik, McKenzie and Moore noticed that every variety with directed Jónsson terms 1 d 0 , . . . , d n has Jónsson terms t 0 , . . . , t 2n−2 . We shall show in Theorem 5.2(ii) that the above observation from [30] cannot be sharpened, as far as the number of terms is concerned. In the other direction, a hard result from [30] shows that from some sequence of Jónsson terms one can construct a sequence of directed Jónsson terms. In Theorem 5.2(i) we show that, in general, the latter sequence cannot be taken to be shorter than the former sequence. However it would be really surprising if this turns out to be the best possible result. See Remark 5.3(b) and the comment after Proposition 5.4.
The idea of directed Jónsson terms suggests an even more general notion of mixed Jónsson terms; see Definition 8.1. Mixed terms have been first introduced in Kazda and Valeriote [32] using different notation and terminology. Roughly, a mixed condition involves, for each index, either the Jónsson or the directed or the specular directed equation, with no a priori prescribed pattern. We study some basic facts about this notion in Section 8, proving that any kind of mixed condition in this sense implies congruence distributivity. We roughly evaluate the modularity and distributivity levels which follow from such mixed conditions; in many special cases we know that we have found the optimal values; actually, all the previously mentioned results about modularity levels (on the positive side, not the counterexamples) can be seen as special cases of our main result about mixed conditions, Corollary 8.11.
Gumm terms as defective alvin terms. There is another observation suggesting that the notion of a mixed condition is interesting. In order to explain this in detail, we have to recall the notions of Gumm and of directed Gumm terms.
An astonishing characterization of congruence modularity has been found by H.-P. Gumm [22,23], using terms which "compose" the conditions for permutability and distributivity.
Gumm terms can be seen from another perspective. Observe that a Maltsev term for permutability can be considered as a Pixley term when the equation x = t(x, y, x) is not assumed (a Pixley term is the nontrivial term given by the alvin condition in the case n = 2. See Definition 2.1). In other words, a Maltsev term can be seen as a "defective" alvin term, for n = 2. Similarly, Gumm terms can be seen as defective alvin terms, for possibly larger values of n. See [46,Remark 4.2] for a hopefully complete discussion of this aspect. See also [32], [41, p. 12] and Remarks 7.2(c) and 8.13 below. The explicit definition of Gumm terms shall be given in Definition 7.1.
Directed Gumm terms as defective mixed terms. In [30] a directed variant of Gumm terms has been introduced, too. While, as we have just mentioned, it is possible to introduce Gumm terms as defective alvin terms, on the other hand, it is not possible to define directed Gumm terms as defective directed Jónsson terms. Actually, defective Jónsson (directed or not) terms generally provide a trivial condition. Cf. [32] and Remark 7.5(c). In order to get directed Gumm terms in the sense of [30] we need to consider a mixed distributivity condition in which the equations for directedness are considered "in the middle", while an alvin-like condition is taken into account on some "outer edge". Directed Gumm terms are then obtained by considering the defective version of such a mixed condition. We can also deal with a more symmetric condition in which an alvin-like condition is assumed on both outer edges and then take the defective variant on both edges. In this way we get terms which are "directed Gumm on both heads". See Definition 7.6. The above conditions appear interesting for themselves and we evaluate exactly the modularity level they imply in Theorem 7.7. The above discussion suggests the naturalness of the more general mixed conditions. See [32] and Section 8. Specular terms. As another generalization, our constructions can all be made more symmetrical, in the sense that the terms we construct can be always chosen in such a way that they satisfy the "specular" condition t i (x, y, z) = t n−i (z, y, x), for all indices i. Thus we get still other conditions implying congruence distributivity. We show in Section 6 that, for every form of distributivity under consideration, in the case when the index n is even our results turn out to be essentially the same if we impose the above condition of specularity.
A brief summary. In detail, the paper is divided as follows. In Section 2 we recall some basic notions about congruence distributive and congruence modular varieties; in particular, we recall Jónsson and Day terms, together with some variants. We stress the useful fact that many conditions can be translated in the form of a congruence identity. See Remarks 2.5, 2.6 and 2.10.
In Section 3 we present our main constructions. Roughly, starting from, say, an n-distributive algebra, we shift the Jónsson terms and add trivial projections both at the beginning and at the end. Since the original Jónsson terms are shifted by 1, the role of odd and even is exchanged, thus we obtain an n+2-alvin algebra; this is the trivial part of the argument. We then consider another n+2-alvin algebra by taking an appropriate reduct of some Boolean algebra (Construction 3.13). If the types of the above two algebras are arranged in such a way that they match, then their product is n+2-alvin, too. We also need a parallel construction which starts from an n-alvin algebra. Adding trivial projections, we get an n+2-distributive algebra, then we take the product with an appropriate reduct of a distributive lattice (Construction 3.4). Let us call E anyone of the above products. The most delicate part of the argument (Construction 3.2 and Theorem 3.3) allows us to find a subalgebra B of E in such a way that B witnesses the failure of m-modularity, for the desired m. We present general conditions ensuring that a certain subset B of some algebra E constructed as above is the universe for some substructure. Such conditions do not necessarily involve congruence distributivity and find applications in different contexts. In fact, we shall occasionally deal with congruence identities strictly weaker than congruence modularity. See, e. g., Theorems 4.5, 5.2(iii), Remarks 10.1, 10.11 and what we call the switch levels in Definition 9.7 and Theorem 9.8.
In Section 4 the constructions from Section 3 are put together in order to show that Day's result is optimal for n even. Essentially, we present the details for the induction we have hinted in the above subsection about reversed conditions. Sections 5, 6, 7 and 8 deal, respectively, with directed, specular, Gumm and mixed terms. Sections 5 -8 rely heavily on Sections 3 and 4, but are largely independent one from another. In Section 9 we present a more explicit description of the varieties furnishing our counterexamples, summing up most of our results, actually, adding a bit more. Finally, Section 10 is reserved for additional remarks and problems.

A review of congruence distributive and modular varieties
Aspects of congruence distributivity. For later use, we insert the definitions of Jónsson, alvin and directed Jónsson terms in a quite general context. Since our main concern are terms and equations, in what follows we shall be somewhat informal and say that a sequence of terms satisfies some set of equations to mean that some variety under consideration, or some algebra, have such a sequence of terms and the equations are satisfied in the variety or in the algebra. When no confusion is possible, we shall speak of, say, Jónsson terms, instead of using the more precise expression sequence of Jónsson terms. In case the terms are actually operations of the algebra or of the variety under consideration, we shall sometimes say that the algebra or the variety has Jónsson operations, to mean that the operations satisfy the corresponding equations.
Definition 2.1. Fix some natural number n and suppose that t 0 , . . . , t n is a sequence of 3-ary terms. In the present section, and for most of the paper, all the sequences of 3-ary terms under consideration will satisfy all the following basic equations as well as some appropriate equations from the following list We now define precisely the relevant conditions.

(Jónsson terms)
The sequence t 0 , . . . , t n is a sequence of Jónsson terms [28] for some variety, or even for a single algebra, if the sequence satisfies the equations (B) and If t 0 , t 1 , t 2 is a sequence of Jónsson terms, then t 1 is a majority term.
(Alvin terms) If we exchange the role of even and odd in the definition of Jónsson terms, we get a sequence of alvin terms. In detail, a sequence t 0 , . . . , t n is a sequence of alvin terms [49] if the sequence satisfies the equations (B) and If t 0 , t 1 , t 2 is a sequence of alvin terms, then t 1 is a Pixley term for arithmeticity. Cf. [55]. By the way, this suggests that, even for larger n, the alvin condition shares some aspects in common with congruence permutability. See Remarks 7.2(c) and 8.13 for further details.
(Directed Jónsson terms) Finally, if we always use (M → ), we get a sequence of directed Jónsson terms. In detail, a sequence of directed Jónsson terms [30,64] is a sequence which satisfies (B), as well as (M → ), for all h, 0 ≤ h < n. In the case of directed terms there is no distinction between even and odd h's.
A sequence t 0 , t 1 , t 2 is a sequence of directed Jónsson terms if and only if it is a sequence of Jónsson terms. On the other hand, we shall see that the notions are distinct for larger n's.
Notice that if some algebra A has, say, Jónsson terms t 0 , . . . , t n , then the variety V generated by A has Jónsson terms t 0 , . . . , t n . Thus the above notions are actually notions about varieties. However, in certain cases, as a matter of terminology, it will be convenient to deal with algebras.
Theorem 2.2. [28,30,49] For every variety V, the following conditions are equivalent. Jónsson terms. (iii) V has a sequence of alvin terms. (iv) V has a sequence of directed Jónsson terms.
The equivalence of (i) and (ii) is due to Jónsson [28]. The equivalence of (ii) and (iii) is easy and almost immediate (compare the proof of (ii) ⇔ (iii) in Theorem 2.8 below). Anyway, the equivalence of (i) and (iii) appears explicitly in [49]. The equivalence of (ii) and (iv) is proved in [30].
For a given congruence distributive variety, the lengths of the shortest sequences given by (ii) -(iv) above might be different. Henceforth it is interesting to classify varieties according to such lengths, both in the case of congruence distributivity, as well as in parallel situations. See, e. g., [11,19,21,28,30,35,36,43,46]. See also Theorem 9.8 below.
Definition 2.3. A variety or an algebra is n-distributive (n-alvin, n-directeddistributive) if it has a sequence t 0 , . . . , t n of Jónsson (alvin, directed Jónsson) terms.

Remark 2.4. (Counting conventions.)
Notice that each of the conditions in Definition 2.3 actually involves n + 1 terms, including the two projections t 0 and t n , so that the number of nontrivial terms is n − 1. This aspect might ingenerate terminological confusion and the present author apologizes for having sometimes contributed to the confusion. For example, an n-directed-distributive variety in the above sense has been called a variety with n + 1 directed Jónsson terms in [41], while in other works such as [42] we have called it a variety with n − 1 directed Jónsson terms, counting only the nontrivial terms. The latter is also the counting convention adopted in [30]. However, here it is extremely convenient to maintain a strict parallel with the universally adopted terminology concerning "undirected" n-distributivity.
Of course, the "outer" terms t 0 and t n are trivial projections, hence it makes no substantial difference whether they are listed or not in the above conditions. However, here it is notationally convenient to include them, since, otherwise, say in the case of the Jónsson condition, we should have divided the definition into two cases, asking for t n−1 (x, z, z) = z for n even, and for t n−1 (x, x, z) = z for n odd. Considering the trivial terms t 0 and t n , instead, we can fix equations (B) once and for all, independently of the kind of terms we are dealing with and, in particular, independently from the parity of n.
However, let us point out that, in a different context, it will be convenient not to include t 0 and t n . See Remark 8.6. We shall try to be consistent, and, in case we do not include the trivial projections, we shall list the terms as t 1 , . . . , t n−1 , so that the value of n will not change.
We have insisted on this otherwise marginal aspect since we shall have frequent occasion to shift the indices of the terms in use, hence particular care is needed in numbering and labeling. See Remark 3.1, Constructions 3.4, 3.5, 3.13, Lemma 3.6, Theorem 3.14(i), Definition 9.6 and the proofs of Theorems 2.8 and 9.8.
By the way, there is a deeper reason showing that the above counting terminology is necessarily conventional. Using arguments from [61] it can be shown that every idempotent Maltsev condition can be expressed by conditions involving a single term. In this situation, the varying quantity is the number of variables, not the number of terms.
Remark 2.5. It is frequently convenient to translate the above notions in terms of congruence identities. For β and γ congruences, let β • γ • k . . . denote the relation β • γ • β • γ • . . . with k factors, that is, k − 1 occurrences of •. If we know that, say, k is even, then, according to convenience, we write β • γ • k . . . • γ to make clear that γ is the last factor. It is also convenient to consider the extreme cases, so that where 0 is the minimal congruence in the algebra under consideration.
In congruence identities we use juxtaposition to denote intersection. Under the above notation, we have that, within a variety, each condition on the left in the following table is equivalent to the condition on the right.
The equivalence of the above conditions is now a standard fact [56,63]. In the specific case at hand, as well as in similar situations described below, the proof is quite simple and direct, see, e. g., [29,39,41,46,62] for examples and further comments. See also Remark 8.14(b) below. Notice that the conditions are equivalent only within a variety; indeed, the conditions on the right are locally weaker. If some algebra A satisfies one of the conditions on the right, it is not even necessarily the case that Con(A) is distributive, let alone the request that A generates a congruence distributive variety.
We have stated the above conditions in the form of inclusions, but notice that an inclusion X ⊆ Y is (set-theoretically) equivalent to the identity X = XY , hence we are free to use the expression "identity".
There seems to be no immediate directly provable condition equivalent to the existence of directed Jónsson terms and which can be expressed in terms of congruence identities. Nevertheless, directed terms are involved in the study of relation identities, see [41,Section 3] and [42,Section 3]. See also Section 8 below.
Remark 2.6. Expressing Maltsev conditions in terms of congruence identities as in Remark 2.5 is particularly useful.
(a) For example, from the above characterizations we immediately get the wellknown fact that, for n odd, n-distributive and n-alvin are equivalent conditions; just take converses and exchange β and γ. When dealing with the conditions involving terms, one obtains the equivalence by reversing both the order of variables and of terms [19, Proposition 7.1(1)], but this seems intuitively less clear.
(b) As another example, arguing in terms of congruence identities it is immediate to see that n-distributive implies n+1-alvin, and symmetrically that n-alvin implies n+1-distributive. In fact, to prove, say, the former statement, just notice that αβ • αγ • n . . . ⊆ αγ • αβ • n+1 . . . . See also Remarks 2.10, 4.4, 4.6, 7.5 and 10.12 for related observations. In fact, in our basic Theorems 3.7, 3.9, 3.14, and 4.5 we shall deal with congruence identities and then we shall use Remark 2.5 and the corresponding Remark 2.10 below about congruence modularity in order to translate the basic results in terms of distributivity and modularity levels. For example, this technique applies to Theorems 4.1, 5.1(i), 5.2 and 7.7(ii), as well as to the main results in [43,47].
Identities dealing with reflexive and admissible relations shall be heavily used in Section 8. See, in particular, Theorem 8.8 and its consequences.
Aspects of congruence modularity. Now for A. Day's characterization of congruence modularity.
Definition 2.7. A sequence of Day terms [11] for some variety, or even for a single algebra, is a sequence u 0 , . . . , u m , for some m, of 4-ary terms satisfying for even k, 0 ≤ k < m, u k (x, y, y, w) = u k+1 (x, y, y, w), If we exchange even and odd in (D2) we get a sequence of reversed Day terms. Proof. The equivalence of (i) and (ii) is due to Day [11]. If u 0 , . . . , u m is a sequence of Day terms (reversed Day terms), then we get a sequence u ′ 0 , . . . , u ′ m+1 of reversed Day terms (Day terms) by taking u ′ 0 to be the projection onto the first coordinate and u ′ k+1 = u k , for k ≥ 0. Hence (ii) and (iii) are equivalent. Otherwise, one can apply the second statement in Proposition 2.11 below.
We shall recall further conditions equivalent to congruence modularity in Theorem 7.3 below.
The above congruence identities explain the reason for our choice of the expression "reversed modularity".
Arguing as in Remark 2.6 we get the facts stated in the following proposition. As far as the second statement is concerned, compare also the proof of the equivalence of (ii) and (iii) in Theorem 2.8. For every m > 0, we have that m−1-modularity implies m-reversed-modularity and that m−1-reversed-modularity implies m-modularity.
In Corollary 9.13 we shall show that Proposition 2.11 cannot be improved for m ≥ 4.

The main constructions
Remark 3.1. If n ≥ 2 and some algebra D has alvin operations s 0 , . . . , s n−2 , then, by relabeling the operations as t 1 = s 0 , . . . , t n−1 = s n−2 and taking t 0 to be the projection onto the first coordinate, we get a sequence t 0 , . . . , t n−1 of Jónsson operations, since then the role of even and odd is exchanged. At the end, we can possibly add t n , taken to be the projection onto the third coordinate, getting a longer sequence t 0 , . . . , t n of Jónsson operations. Let A 4 denote the algebra with the relabeled operations (the labels and the ordering of the operations will be highly relevant in all the arguments below). If A is an algebra with Jónsson operations t 0 , . . . , t n , then also the product A × A 4 has Jónsson operations t 0 , . . . , t n , provided the types of the algebras are arranged in a such a way they match.
For short, we have showed that we can combine an n−2-alvin algebra with an n-distributive algebra, getting a new n-distributive algebra. Though the added operations are trivial, we shall see that the construction provides nontrivial results. In fact, all our counterexamples will be constructed in this way. Symmetrically, from an n−2-distributive algebra and an n-alvin algebra we can get another nalvin algebra.
Of course, in the general case, an alvin algebra D has alvin terms, not necessarily operations. However, for our purposes, it will be an inessential modification to consider the expansion of D in which the alvin terms are added as operations. Actually, it will be always no loss of generality to assume that D has no other operation. This assumption will simplify arguments and notation.
Constructing subalgebras. The relevant point in our constructions is to find some appropriate subalgebra B of an algebra like A × A 4 described in Remark 3.1. Actually, the algebra A will be constructed as the product of three algebras of the same type, but of course this makes no essential difference, as far as Remark 3.1 is concerned. The arguments showing that some B as above is indeed a subalgebra use really weak hypotheses, so we present them in generality. Here the main advantage of this abstract treatment is that the method works uniformly for Jónsson, directed and Gumm terms. As already mentioned, we shall subsequently hint to further applications.
Construction 3.2. Fix some natural number n ≥ 3. In what follows the number n will be always explicitly declared in all the relevant places, hence we shall not indicate it in the following notation. A similar remark applies to Constructions 3.4, 3.5 and 3.13 below.
(A) Premises. We suppose that A 1 , A 2 , A 3 and A 4 are algebras with only the ternary operations t Here and in similar situations we shall omit the j-indexed superscripts when there is no danger of confusion. We further suppose that the first three algebras have a special element 0 j ∈ A j , for j = 1, 2, 3. Again, we shall usually omit the subscripts. It is not necessary to assume that there is some constant symbol which is interpreted as the 0 j 's, it is enough to assume the existence of such elements.
We require that, for j = 1, 2, 3, the following equations hold in A j , for all x, y, z ∈ A j : for h = 1, . . . , n − 2, The algebra A 4 , instead, is supposed to satisfy: t 1 is the projection onto the first coordinate, (3.3) t n−1 is the projection onto the third coordinate, (3.4) for h = 2, . . . , n − 2 and all x, y ∈ A 4 . (3.5) (B) A useful subalgebra. We shall use the above equations in order to show that a certain subset B of E = A 1 × A 2 × A 3 × A 4 is a subalgebra. Let a, d be two arbitrary but fixed elements of where places denoted by can be filled with arbitrary elements from the appropriate algebra. Proof. The set B is closed under t 1 , since if x ∈ E has one of the types I -IV, then t 1 (x, y, z) has the same type, because of equation (3.1). In case of types I and III we need also (3.3).
Symmetrically, B is closed under t n−1 . In this case, t n−1 (x, y, z) has the same type of z and we are using (3.2) and (3.4). Now let h ∈ {2, . . . , n − 2} and x, y, z ∈ B. If x has type II or IV, then t h (x, y, z) has the same type of x, applying again (3.1).
Suppose that x has type I. We shall divide the argument into cases, considering the possible types of z. If z has type I, too, then t h (x, y, z) has type I, by (3.1) and (3.5). We need (3.5) to ensure that the fourth component is a. If z has type II or IV, then t h (x, y, z) has the same type of z, by (3.2). Finally, if z has type III, then t h (x, y, z) has type II. Indeed, the second component is 0 by (3.1), since x has type I, and the first component is 0 by (3.2), since z has type III.
The case in which x has type III is treated in a symmetrical way.
We have showed that B is closed with respect to t 1 , t 2 , . . . , t n−1 , hence B is the universe for a subalgebra of E. Notice that we have not used the assumption that y ∈ B.
Alvin in the middle. If k ≥ 1, we define the lattice C k to be the k-elements chain with underlying set C k = {0, . . . , k − 1}, with the standard ordering and the standard lattice operations min and max. Lattice operations shall be denoted by juxtaposition and +.
In particular, the above definition applies to the lattices C k . Limited to the present construction, we let A 1 = A 2 = C r 4 and A 3 = C r 2 . Suppose that D is an algebra with ternary operations s 0 , . . . , s n−2 . As in Remark 3.1, relabel the operations as t 1 = s 0 , . . . , t n−1 = s n−2 and let A 4 be the resulting algebra. Assume that A 4 satisfies Conditions Then the algebras A 1 , A 2 , A 3 and A 4 satisfy the assumptions in Construction 3.2, hence, by Theorem 3.3, for every choice of elements a, d ∈ A 4 , we have an algebra B = B(a, d) constructed as in 3.2(B).
We shall also use a small variation on Construction 3.4. This variation is not necessary in order to prove Theorem 1.2 and might be skipped at first reading.  Proof. It follows from a remark in Construction 3.4 that both in case (i) and in case (ii) the assumptions in Construction 3.2 are satisfied, hence it makes sense to talk of B, by Theorem 3.3.
(i) Letting t 0 be the projection onto the first coordinate and t n be the projection onto the third coordinate, it is immediate to see that, for every lattice L, the terms t 0 , t n and the operations of L r satisfy Jónsson conditions. In particular, this applies when L is C 2 , C 3 or C 4 . Here we are using the assumption that n is even, thus n − 1 is odd, hence t n−1 satisfies the desired equations t n−2 (x, x, z) = xz = t n−1 (x, x, z) and t n−1 (x, z, z) = z. Notice also that the assumptions imply n ≥ 4, thus t n−2 (x, y, z) is actually xz.
It follows that the terms t 0 , . . . , t n are Jónsson on A 1 , A 2 and A 3 . Since D has alvin operations, by the assumption in (i), and since the indices of the original alvin operations of D are shifted by 1, we have that the operations on A 4 satisfy Jónsson conditions, too, adding again the projections t 0 and t n . Hence the product , as well as any subalgebra, are n-distributive.
(ii) Considering again the projections t 0 and t n , the terms t 0 , t 1 , . . . , t n given by Constructions 3.4 or 3.5 are directed Jónsson terms in every lattice. Notice that this applies also in case n = 3. Adding the projection onto the first coordinate at the beginning does not affect the conditions defining directed Jónsson terms and the same holds adding the projection onto the third coordinate at the end. Hence t 0 , t 1 , . . . , t n are directed Jónsson terms for A 4 , as well, hence this applies to any product and subproduct.
Recall the notational conventions introduced in Remark 2.5, in particular, recall that in congruence identities juxtaposition denotes intersection. In what follows, an expression χ is a term in the language {•, ∩}. We shall mention in Remark 10.9 below that our results apply to a much more general context. In what follows, for simplicity, we shall deal with congruencesα, α, . . . , but, as we shall point out in Remark 10.8, many theorems below apply also to tolerances and to reflexive admissible relations.
Formally, the statements of Theorems 3.7, 3.9 and 3.14 below involve some natural number n, but notice that n makes no essential appearance in the results.
In order to prove (ii), letα,β andγ be congruences on A 4 as given by the assumption. Thus there are elements a, d ∈ A 4 such that (a, d) ∈α(β •αγ •β) and (a, d) ∈ χ(α,β,γ). Let B = B(a, d). It follows from the considerations in Construction 3.4 and from Theorem 3.3 that B is actually an algebra. We now consider two congruences on the factors A 1 = A 2 and then construct appropriate congruences on B. Let β * be the congruence on the lattice C 4 whose blocks are {0, 1} and {2, 3} and let γ * be the congruence on C 4 whose blocks are {0}, {1, 2} and {3}. Since β * and γ * are congruences on C 4 , they are also congruences on its term-reduct A 1 = A 2 . Let 0 and 1 denote, respectively, the smallest and the largest congruence on any algebra under consideration. The congruence Thus c 0 , c 1 , c 2 , c 3 ∈ B, since c 0 has type I, c 1 and c 2 have type IV and c 3 has type III. Moreover, c 0 α c 3 and c 0 β c 1 αγ c 2 β c 3 , thus (c 0 , c 3 ) ∈ α(β • αγ • β). Suppose by contradiction that (c 0 , c 3 ) belongs to the right-hand side of (3.6), thus there are elements g, h ∈ B such that (c 0 , g) ∈ γ • αβ • γ, (g, h) ∈ χ(α, β, γ) and (h, c 3 ) ∈ γ • αβ • γ. Then c 0 γ g 1 αβ g 2 γ g, for certain elements g 1 and g 2 . By the γ-equivalence of c 0 and g 1 , we have that the first component of g 1 is 3 and the third component of g 1 is 1. By the α-equivalence of g 1 and g 2 , the third component of g 2 is 1. By the β-equivalence of g 1 and g 2 , the first component of g 2 is either 3 or 2. Similarly, the third component of g is 1, hence g has not type IV. The first component of g ranges between 1 and 3, in particular it is not 0. Since the first component of g is not 0, g belongs to B and g has not type IV, then g has type I, hence the fourth component of g is a.
Remark 3.8. (a) Notice that the element g 1 from the proof of Theorem 3.7(ii) must have type I, hence the fourth component of g 1 is a, so we actually have c 0 = g 1 .
(b) Using similar arguments, we have that, under the assumptions in Theorem 3.7(ii), the following identities fail in B where each of φ and ψ can be taken to be either The next subsection is not necessary in order to prove Theorem 1.2.
Under the assumptions in (ii), there are a, d ∈ A 4 such that (a, d) ∈α(β •γ) and (a, d) ∈ χ(α,β,γ). Choose such a pair (a, d) and let B = B(a, d). Let β * be the congruence on C 3 whose blocks are {0} and {1, 2} and let γ * be the congruence on C 3 whose blocks are {0, 1} and {2}. Let β, γ and α be the congruences on B induced, respectively, by β * × γ * × 1 ×β, γ * × β * × 1 ×γ and 1 × 1 × 0 ×α. Notice a difference with respect to the proof of Theorem 3.7: here the first two components of β are distinct, and the same for γ. Consider the following elements of B: of types, respectively, I, IV and III, and where b is an element witnessing (a, d) . Thus c 0 α g and c 0 γ g 1 β g, for some g 1 in B. By γ-equivalence, the first component of g 1 is 2 and, by β-equivalence, the first component of g is either 1 or 2. By α-equivalence, the third component of g is 1 and since its first component is not 0, we get that g has type I, thus its fourth component is a.
Proposition 3.10. Under the assumptions and the notation from Theorem 3.9(ii) and its proof (in particular, Construction 3.5 is in charge), let B ′ be the subalgebra of B generated by c 0 , c 1 and c 2 . Then the identity α(β Proof. We first show that c 0 is the only element in B ′ having 2 as the first component. Any element of B ′ has the form t(c 0 , c 1 , c 2 ), for some ternary term t. Suppose by contradiction that in B ′ there is some element c * = c 0 such that the first component of c * is 2. Thus c * = t(c 0 , c 1 , c 2 ), for some term t. Choose c * and t in such a way that t has minimal complexity, hence t(x, y, z) = t i (r 1 (x, y, z), r 2 (x, y, z), r 3 (x, y, z)), for some i < n and ternary terms r 1 , r 2 and r 3 such that each of r 1 (c 0 , c 1 , c 2 ), r 2 (c 0 , c 1 , c 2 ) and r 3 (c 0 , c 1 , c 2 ) is either equal to c 0 , or has the first component different from 2.
, then 2 is the first component of both r 1 (c 0 , c 1 , c 2 ) and r 3 (c 0 , c 1 , c 2 ). By minimality of t, then c 0 = r 1 (c 0 , c 1 , c 2 ) and c 0 = r 3 (c 0 , c 1 , c 2 ), hence c * and c 0 coincide on the first three components. But then c * , being in B, must have type I, so c * and c 0 coincide also on the fourth component, hence c * = c 0 .
If i = 1, then t 1 (x, y, z) = x(y + z) on the first three components. Since 2 is the , then 2 is the first component of r 1 (c 0 , c 1 , c 2 ) and of at least one between r 2 (c 0 , c 1 , c 2 ) and r 3 (c 0 , c 1 , c 2 ). Again by minimality of t, we get that c 0 = r 1 (c 0 , c 1 , c 2 ) and either c 0 = r 2 (c 0 , c 1 , c 2 ) or c 0 = r 3 (c 0 , c 1 , c 2 ). In both cases, c * and c 0 coincide on the first three components and, arguing as above, c * = c 0 . The case i = n − 1 is similar.
In each case we get c * = c 0 , a contradiction, thus c 0 is the only element in B ′ having 2 as the first component.
Suppose that the assumptions in Condition 3.9(ii) hold and let α, β and γ be the congruences induced on B ′ by the congruences with the same name in the proof of Theorem 3.9. If g is an element of B ′ such that (c 0 , g) ∈ γ • αβ, then c 0 γ g 1 αβ g, for some g 1 ∈ B ′ , but γ-equivalence implies that the first component of g 1 is 2, thus c 0 = g 1 , by the above paragraphs. By β-equivalence, the first component of g is not 0 and, by α-equivalence, the third component of g is 1, hence g gas type I. Now the final argument in the proof of Theorem 3.9 applies. Definition 3.11. Baker [1] introduced and studied the variety generated by termreducts of lattices in which the only basic operation is t B (x, y, z) = x(y + z). We shall denote Baker's variety by B.
Strictly speaking, Baker studied the varieties generated by reducts of a single lattice. See Cornish [9] for further details and for the relationships between Baker's variety and nearlattices. In any case, what we call B here can be obtained by considering the variety generated by the reduct of the free lattice over ω generators, or just the reduct of the free lattice over 3 generators, since the former is embeddable in the latter, by a well-known result by Whitman. See, e. g., Freese, Ježek, Nation [16].
The variety B d is defined like Baker's, but considering only reducts of distributive lattices. Notice that in the distributive case the correspondence with nearlattices is exact, since in distributive lattices x(y + z) = xy + xz and (dual) nearlattices admit an equivalent definition as the variety generated by reducts of lattices in which only the operation given by xy + xz is considered. See, e. g., Chajda, Halaš, Kühr [7] for further informations about nearlattices. In particular, since we shall always deal with distributive lattices, our results about B d apply to the variety of distributive nearlattices, provided we consider nearlattices as ternary algebras. Of course, the above remark applies to most results from [45], as well.
Notice that, for each n ≥ 3, Baker's variety is term-equivalent to the variety generated by the algebras L r from Construction 3.4. Indeed, if t i (x, y, z) = xz in 3.4, then t i can be expressed as t i (x, y, z) = t B (x, z, z) = x(z + z). However, the exact types of algebras will be highly relevant in our arguments.
Congruence identities valid in Baker's variety have been intensively studied in [45]. Complementing the results from [45], we shall now see that the arguments from the proof of Theorems 3.7 and 3.9 show the failure of still another congruence identity in B.
In particular, neither B, nor B d nor N L are 4-alvin.
Proof. Let n = 3. Consider only the first three components in Constructions 3.2, 3.4, 3.5 and in the proofs of Theorems 3.3, 3.7 and 3.9. Or, more formally, rather than reformulating everything, take A 4 and D as 1-element algebras everywhere. By the comment shortly after Definition 3.11, all the mentioned constructions furnish algebras which are term-equivalent to algebras in B d , hence satisfying the same congruence identities. Construct an algebra B and elements c 0 , . . . , c 3 as in the proof of Theorem 3.7(ii), either disregarding the fourth component, or taking some fixed element (the only element in A 4 ) at the fourth place. With the corresponding definitions of α, β and γ from the proof of 3.7(ii), in the present situation we need no further assumption to get (c 0 , c 3 ) ∈ α(β • αγ • β). Or, put in another way, since here we are assuming a = d, we automatically get (a, d) ∈α(β •αγ •β). We shall show that B is not 5-reversed-modular. If, by contradiction, B is 5-reversed-modular, then The proof of Theorem 3.7 shows that the first component of g is not 0 and that g has type I. The symmetric argument shows that g has type III, a contradiction, since the first component of any element of type III is 0. Notice that here g plays at the same time the role of both g and h from the proof of Theorem 3.7. The fact that B d is not 5-reversed-modular is also a consequence of the last equation in [45, Proposition 2.3], taking n = 3 there.
The proof that the identities in the second statement fail is obtained by a similar variation on the proofs of Theorem 3.9(ii) and of Proposition 3.10. Another proof The final statement is then immediate from the fact that αγ • αβ ⊆ α(γ • β).
Jónsson distributivity in the middle. Operations of Boolean algebras will be denoted by juxtaposition, + and ′ . Let 2 = {0, 1} be the 2-elements Boolean algebra with largest element 1 and smallest element 0. Let 4 = {0, 1, 1 ′ , 2} be the 4-elements Boolean algebra with largest element 2 and smallest element 0. We have chosen such a labeling to maintain the analogy with the preceding subsections; thus, for example, C 3 = {0, 1, 2} is a sublattice of the lattice-reduct of 4.
Construction 3.13. Fix some natural number n ≥ 3.
For a Boolean algebra A, let A r denote the term-reduct with operations Suppose that D is an algebra with ternary operations s 0 , . . . , s n−2 , relabel the operations as t 1 = s 0 , . . . , t n−1 = s n−2 and let A 4 be the resulting algebra. Suppose that A 4 satisfies the assumptions in Construction 3.2. As in the preceding subsection, the algebras A 1 , A 2 , A 3 and A 4 satisfy the assumptions in Construction 3.2, hence, by Theorem 3.3, for every choice of elements a, d ∈ A 4 , we have an algebra Recall that an expression is a term in the language {•, ∩}.
Moreover, for every expression χ and every choice of δ = β or δ = γ and of ε = β or ε = γ, the following hold.
As in the proof of Theorem 3.7, c 0 has type I, c 1 and c 2 have type IV and c 3 has type III, thus they belong to B. Moreover, c 0 α c 3 and c 0 β c 1 αγ c 2 β c 3 , hence Whatever the choice of δ and ε, assume by contradiction that and h αε c 3 , for certain elements g, h of B.
Since the first component of c 0 is 2 and c 0 δ g, then, whatever the choice of δ, be it β or γ, the first component of g is not 0. By α-connection of c 0 and g, the third component of g is 1, hence g has type I, so the fourth component of g is a.
Remark 3.15. In the notation from the proof of Theorem 3.14, both in case (iii) and in case (iv), if we let e 1 = (1, 0, 1, a), e * 1 = (1 ′ , 0, 1, a), we see that {c 0 , e 1 } is an αβ-block in B and {c 0 , e * 1 } is an αγ-block in B. This might be useful in different situations.
4. Day's Theorem is optimal for n even Theorem 4.1. Suppose that n ≥ 2 and n is even.
(ii) There is a locally finite n-alvin variety which is not 2n−3-modular.
Proof. If some variety V is not 2n−1-reversed-modular, then V is not 2n−2-modular, by Proposition 2.11. The proof of the hard parts of the theorem goes by simultaneous induction on n. We first consider the base cases.
The variety of lattices is 2-distributive and not 3-reversed-modular. Indeed, under the equivalence given by Remark 2.10, 3-reversed-modularity reads α(β • αγ • β) ⊆ αγ • αβ • αγ and this identity implies 3-permutability: just take α = 1, the largest congruence. The variety of lattices is not 3-permutable, hence it is not 3-reversed-modular. The above arguments apply to the variety of distributive lattices, as well, and the variety of distributive lattices is locally finite.
The variety of Boolean algebras is locally finite, 2-alvin and not 1-modular. Notice that a 1-modular variety is a trivial variety. Thus the basis of the induction is true. Notice that, in place of lattices and of Boolean algebras we can just consider the varieties of their term-reducts with just a majority or a Pixley operation.
Suppose that n ≥ 4 and that the theorem is true for n − 2. By the inductive hypothesis and Remark 2.10, there exist an n−2-alvin variety V and an algebra D ∈ V with congruences α, β and γ such that the congruence identity Since D belongs to an n−2-alvin variety, D has n − 2 alvin terms.
It is no loss of generality to assume that these terms are actually operations of D. We can also assume that D has no other operation, since α, β and γ remain congruences on the reduct; moreover, intersection and composition do not depend on the algebraic structure of the algebra under consideration. Thus the identity α(β •αγ •β) ⊆ αβ •αγ • 2n−7 . . . •αβ fails in D, even if we consider D as an algebra with only the alvin operations. Otherwise, as we mentioned, the basis of the theorem can be proved for algebras having only alvin or Jónsson operations and it is easy to check that in the induction we are going to perform we construct algebras with such operations only. This fact will appear evident in the course of the proof of Theorem 9.8 below. Whatever the argument, we can suppose that D has only alvin operations.
Apply Construction 3.4 to the algebra D. By Lemma 3.6(i) and Theorem 3.7(i) with r = 2n − 7, there is an n-distributive algebra B (which henceforth generates an n-distributive variety) in which 2n−1-reversed-modularity fails.
In the parallel situation, again by the inductive hypothesis and Remark 2.10, there exist an n−2-distributive variety V and an algebra D ∈ V such that the Arguing as above, we can suppose that D has only the Jónsson operations. Apply Construction 3.13 to the algebra D. By Theorem 3.14(i)(ii) with r = 2n−5, there is an n-alvin algebra B (which henceforth generates an n-alvin variety) in which 2n−3-modularity fails.
The induction step is thus complete. In order to conclude the proof of the theorem it is enough to show that the above varieties can be taken to be locally finite. First notice that we have used distributive lattices in all of our constructions, and the variety of distributive lattices is locally finite. The variety of Boolean algebras is locally finite, as well. By induction, if D belongs to some locally finite variety, then A 4 , too, belongs to some locally finite variety, since A 4 is termequivalent to D. By the above remarks, at each induction step, B can be taken to belong to the join of two locally finite varieties, hence to a locally finite variety.
A somewhat simpler description of varieties furnishing a proof of Theorem 4.1 shall be presented in Section 9. However, as remarked in the introduction, the proof seems to necessarily rely on the methods in the present and in the former section.
The next lemma applies not only to n-alvin varieties, but also to varieties which satisfy the weaker form of the n-alvin condition in which the identities x = t 1 (x, y, x) and t n−1 (x, y, x) = x are not assumed. We shall state a reformulation of this observation in Proposition 7.4(i) below. Actually, the result applies to a condition weaker than n-alvin: it is not necessary to assume the "outer" equations x = t 1 (x, y, x) and t n−1 (x, y, x) = x. (b) If n ≥ 2, then every n-alvin variety is 2n−2-modular. In particular, if n is odd, then every n-distributive variety is 2n−2-modular.  (1)] "at both ends". We report the details below for the reader's convenience. Given alvin terms t 0 , . . . , t n , we obtain the following terms u 0 , . . . , u 2n−3 satisfying the reversed form of the conditions in Definition 2.7. The terms u 0 , . . . , u 2n−3 below are considered as 4-ary terms depending on the variables x, y, z, w in that order. The term u 0 is constantly x and the term u 2n−3 is constantly w. The remaining terms are defined in the following table, where we omit commas for lack of space.
Notice the different arguments of t 1 and of t n−1 with respect to the other terms in the corresponding columns. If n = 4, we consider only the first line, taking Notice that the indices in the last two lines follow the same pattern of the preceding lines, taking, respectively, i = n−6 2 and i = n−4 2 . We can do this since n is assumed to be even.
The fact that u 0 , . . . , u 2n satisfy the conditions in Definition 2.7 with even and odd exchanged is easy and is proved as in [11, p. 172-173]. The only different computations are u 0 (x, y, y, w) = x = t 0 (x, y, y) = t 1 (x, y, y) = u 1 (x, y, y, w) and . Notice that, in order to perform the above computations, it is fundamental to deal with the alvin and the reversed Day conditions! Symmetrically, at the other end, u 2n−5 (x, x, w, w) = t n−2 (x, w, w) = t n−1 (x, w, w) = u 2n−4 (x, x, w, w) and u 2n−4 (x, y, y, w) = t n−1 (y, y, w) = t n (y, y, w) = w = u 2n−3 (x, y, y, w). Notice that in this case it is fundamental to have n even! Finally, notice that we have not used the equations x = t 1 (x, y, x) and t n−1 (x, y, x) = x in the above computations.
Part (b) is proved in a similar way, with no "special trick" at the final end. We get that every n-alvin variety is 2n−2-reversed modular, but this is equivalent to 2n−2-modular, by Proposition 2.11. The last statement follows from the fact that if n is odd, then n-alvin and n-distributive are equivalent conditions, by Remark 2.6(a). (i) Every n-distributive variety is 2n−1-modular.
(iii) Every 2-alvin variety is 2-reversed-modular. If n ≥ 4, then every n-alvin variety is 2n−3-reversed-modular. (iv) All the above results are sharp: for every even n ≥ 2 there are an n-distributive variety which is not 2n−2-modular and an n-alvin variety which is not 2n−3modular, in particular, by Proposition 2.11, not 2n−4-reversed-modular. The variety of Boolean algebras is 2-alvin and not 1-reversed-modular.
Proof. As already mentioned, (i) is due to Day [11] and the assumption that n is even is not necessary in (i). The proof is slightly simpler than the proof of Lemma 4.2. This time the chain of terms is given by and there are no special variations on the outer edges. The proof of a fact more general than (i) using different methods shall be presented in Corollary 8.11(i).
(ii) is a special case of Lemma 4.2(b).
The nontrivial parts in (iv) are given by Theorem 4.1.
for all indices k.
The above equations are stronger than equations (D0), and correspondingly Day's proof actually shows that if n > 0, then every n-distributive variety satisfies the congruence identity In the same way it can be proved that n-alvin varieties, as well, satisfy the identity (4.2). Compare also Proposition 8.15 below (take i = 2, S 0 = S 2 = β and S 1 = γ there). Further elaborations and comments about these generalizations can be found in [41,46]. Notice that, on the other hand, the terms u 1 and u 2n−4 constructed in the proof of Lemma 4.2(a) do not necessarily satisfy the equations in (4.1), though the terms u 2 , u 3 , . . . , u 2n−5 do satisfy (4.1). From the point of view of congruence identities the above observation shows that if n ≥ 4 and n is even, then every n-alvin variety satisfies the congruence identity and, as in Lemma 4.2(a), the "outer" equations x = t 1 (x, y, x) and t n−1 (x, y, x) = x are not necessary for the proof. If we take αγ in place of γ in identity (4.3), we have α(αγ • β) = αγ • αβ and similarly on the other end, hence we get αγ • αβ • 2n−3 . . . on the right-hand side, thus (4.3) is stronger than Lemma 4.2(a), via Remark 2.10. However, we do not know whether there is a common improvement of (4.2) and (4.3) holding in every n-alvin variety. See, e. g., Problem 10.4(d) below.
The arguments in the proof of Theorem 4.1, together with Theorems 3.9(ii), 3.14 and Proposition 3.10, allow us to present other congruence identities which are not always satisfied in n-distributive and n-alvin varieties. Let ℓ . . .
Theorem 4.5. Suppose that n ≥ 2, n is even and let ℓ = n 2 .
(i) There is a locally finite n-distributive variety in which the following congruence identities fail: (ii) If n ≥ 4, then there is a locally finite n-alvin variety in which the following congruence identities fail: Proof. The case n = 2 in (i) is witnessed by the variety of distributive lattices. Recall that, by convention, γ • αβ • 1 . . . = γ. The case n = 4 in (i) is witnessed by Baker's variety B, as proved in Proposition 3.12. To get an example which is locally finite, consider B d , instead.
The rest of the proof proceeds by simultaneous induction as in the proof of Theorem 4.1. Notice that here we necessarily skip the case n = 2 in (ii). This is the reason why we need consider the case n = 4 in (i) in the basis of the induction.
Since αγ • αβ ⊆ α(γ • β), then the variety constructed in Theorem 4.5(i) is ndistributive and not n-alvin. Similarly, the variety constructed in Theorem 4.5(ii) is n-alvin and not n-distributive. Thus we get another proof of some results from [19]. We shall discuss this aspect in more detail in Section 9, where we shall present many other related results. See, in particular, Corollaries 9.12 and 9.14.

Optimal bounds for varieties with directed terms
The assumption that n is even is not necessary in the following theorem. Recall that our counting conventions are different from [30], as far as directed Jónsson terms are concerned. Cf. Remark 2.4. (ii) In the other direction, every n-directed-distributive variety is 2n−1-modular. Actually, every n-directed-distributive variety satisfies α(β Proof. (i) We first consider the cases n = 2 and n = 3.
A counterexample in the case n = 2 is given by the variety of distributive lattices. Indeed, a ternary majority term t 1 provides a sequence t 0 , t 1 , t 2 of directed Jónsson terms, where t 0 and t 2 are projections. As we have remarked in the proof of Theorem 4.1, the variety of distributive lattices is not 3-reversed-modular.
To deal with the case n = 3, consider Baker's variety B recalled in Definition 3.11. As noticed in [41, p. 11], Baker's variety has a sequence d 0 , d 1 , d 2 , d 3 of directed Jónsson terms (including the two projections), that is, Baker's variety is 3-directeddistributive in the present terminology. In fact, directed Jónsson terms for B are given by the two projections together with the terms t 1 and t 2 from Construction 3.4 in the case n = 3.
By Proposition 3.12, Baker's variety is not 5-reversed-modular. Thus the example of Baker's variety takes care of the case n = 3 in (i). Baker's variety is not locally finite; however, all the above arguments work in case we consider B d , the variety defined like Baker's, but considering only reducts of distributive lattices. The variety B d is indeed locally finite.
The rest of the proof of (i) proceeds by induction on n. Suppose that n ≥ 4 and that the theorem holds for n − 2. By the inductive hypothesis, there is an n−2-directed-distributive variety W in which 2n−5-reversed-modularity fails. By Remark 2.10, there is some algebra D ∈ W such that the congruence identity α(β • αγ • β) ⊆ αγ • αβ • 2n−5 . . . • αγ fails in D. Arguing as in the proof of Theorem 4.1, we can assume that D has only directed Jónsson operations.
(ii) The first statement is the special case n = k, ℓ = 3, T = αγ in the last displayed identity in [41,Proposition 3.1]. The stronger statement is obtained by taking T = γ, instead. Otherwise, (ii) can be proved in a way similar to Day's Theorem (see the proofs of Lemma 4.2 and of Corollary 4.3(i)), using the terms Still another proof can be obtained from Corollary 8.11(i) below in the case of the first statement and from Proposition 8.15 below (taking i = 2, S 0 = S 2 = β and S 1 = γ) in the case of the second statement. (ii) For every n ≥ 2, there is a locally finite n-directed-distributive variety which is not 2n−2-alvin, hence not 2n−3-distributive.
So far, we have proved the cases n = 2 and n = 3 of (iii). The rest of the proof is by induction on n. Suppose that n ≥ 4 and that (iii) is true for n − 2, thus there exists some n−2-directed-distributive variety V in which α(β • γ) ⊆ (α(γ • β)) n−3 fails. In particular, there is some algebra D ∈ V with elements a, d ∈ D and congruencesα,β,γ of D such that (a, d) ∈α(β •γ) but (a, d) / ∈ (α(γ •β)) n−3 . Arguing as in the proof of Theorem 4.1, we can assume that D has only the directed operations. Applying Construction 3.5, we get an n-directed-distributive algebra B, by Lemma 3.6(ii). Applying Theorem 3.9(ii) with χ = (α(γ • β)) n−3 , we get that the identity α(β • γ) ⊆ (α(γ • β)) n−1 fails in B. Again, the arguments from the proof of Theorem 4.1 show that we can get a counterexample belonging to a locally finite variety. [30,Observation 1.2] it is shown that, in the present terminology, every n-directed-distributive variety is 2n−2-distributive. Recall from Remark 2.4 that our counting convention is slightly different in comparison with [30]. Theorem 5.2(ii) shows that the result is optimal. In this respect, see also Theorems 8.8,9.8 and Remark 8.14 below.
(b) In the other direction, in [30] it is shown that every n-distributive variety is k(n)-directed-distributive, for some k(n). The k(n) obtained from the proof in [30] depends only on n, not on the variety, but is quite large. On the other hand, the only inferior bound we know is given by Theorem 5.2(i), namely, k(n) ≥ n, for n even. Concerning small values of n, it is obvious that a variety is 2-distributive if and only if it is 2-directed-distributive. A direct proof that every 3-distributive variety is 3-directed-distributive appears in [42, p. 10]. In the next proposition we prove the corresponding result for n = 4. It is likely that these results follow already from the arguments in [30].
Notice that, on the other hand, by Theorem 5.2(ii), there is a 3-directed-distributive not 3-distributive variety and there is a 4-directed-distributive not 5distributive variety. Proof. From terms t 0 , . . . , t 4 satisfying Jónsson's equations we get directed Jónsson terms s 0 , . . . , s 4 as follows: taking, of course, s 0 and s 4 to be the suitable projections.
Hence, so far, we cannot exclude the possibility that, for every n, every ndistributive variety is n-directed-distributive, though this would be a quite astonishing result.

Specular Maltsev conditions
The constructions in the previous sections suggest the following definition.
Definition 6.1. Let n be a natural number. An algebra or a variety is specular n-distributive (specular n-alvin, specular n-directed-distributive) if it has a sequence t 0 , . . . , t n of terms satisfying the Jónsson (alvin, directed Jónsson) equations, as well as equivalently, for all indices i with 0 ≤ i ≤ n.
Remark 6.2. In all the preceding arguments and in each case the algebras and the varieties we have constructed have terms (or can be chosen to have terms) t 0 , . . . , t n which satisfy the equations (S). In fact, the varieties providing the basis of the induction in Theorem 4.1 can be chosen to be varieties with a specular ternary operation, e. g., the classical majority term t(x, y, z) = xy + xz + yz in the case of lattices, and the Pixley term t(x, y, z) = xy ′ + xz + y ′ z in the case of Boolean algebras. Here n = 2, hence the specularity condition reads t 1 (x, y, z) = t 1 (z, y, x). The algebras L r and A r from Constructions 3.4 and 3.13 are defined by means of specular terms, too. Thus the induction step in the proof of Theorem 4.1 provides varieties with terms satisfying (S).
In the proofs of Theorems 4.5, 5.1 and 5.2, too, we use specular sequences of operations; in fact, the standard terms witnessing that Baker's variety is 4-distributive are t 1 (x, y, z) = x(y + z), t 2 (x, y, z) = xz and t 3 (x, y, z) = z(y + x) and the outer terms in the above sequence witness that B is 3-directed distributive. Since all the algebras in our constructions have specular terms and the constructions themselves proceed in a specular way, all the outcomes turn out to be specular.
We shall elaborate further on the above observations in Section 9. On the other hand, by Remark 6.2, for every n there is a nontrivial specular n-directed-distributive variety.
More generally, one can consider several kinds of specular "mixed" conditions. See Definition 8.1. For example, if n is odd and ℓ = n−1 2 , we can consider terms satisfying (B) and (a) the Jónsson (alvin) conditions for h < ℓ, (b) the alvin (Jónsson) conditions for ℓ < h, as well as (c) t ℓ (x, z, z) = t ℓ+1 (x, x, z) or, according to convenience, t ℓ (x, x, z) = t ℓ+1 (x, z, z). In each case we get a condition which implies congruence distributivity and is compatible with the specularity condition (S). Examples of varieties satisfying the above conditions can be constructed using Remark 9.17(a). See Section 8 for a general form of such "mixed" conditions, some compatible and some not compatible with specularity. In a parallel situation, Chicco [8] has studied specular conditions connected with n-permutability, again showing that the examples of specular varieties abound in that context, too. The above comments suggest that specular Maltsev conditions in general deserve further study.
For example, it is probably interesting to study specular sequences of Day terms, namely, terms satisfying equations (D0) -(D3) from Definition 2.7, as well as u k (x, y, z, w) = u m−k (w, z, y, x), for all k ≤ m. We get specular reversed Day terms if we exchange parity in (D2). In most cases, the Day or reversed Day terms whose existence follows from congruence distributivity turn out to be specular in the above sense, provided one starts with specular distributive terms. When n is even, this is the case for Day's original construction recalled in the proof of Corollary 4.3, and for the terms constructed in the proof of Lemma 4.2(a). For arbitrary n, the proof of Theorem 5.1(ii) provides 2n specular Day terms, too.
(b) Notice that, when dealing with ternary terms witnessing congruence distributivity, and with the only exception we shall mention below, we necessarily deal with specularity, not with (full) symmetry. An m-ary term w is symmetric if it satisfies the equations for all permutations σ of m. The mathematical literature about symmetric operations is so vast that it cannot be reported here. We just mention that recent results connected with universal algebra can be found in [6] and that the near-unanimity terms constructed in [47] are symmetric. Recent research deals also with terms and operations satisfying partial versions of symmetry. See, e. g., [3]. The above list is not intended to be exhaustive; moreover, further references can be found in the quoted works. It is possible that there are connections among the above-mentioned studies about symmetrical terms and the present notion of specular terms, but this has still to be analyzed in detail.
We just mention that, when dealing with the conditions introduced in Definition 2.1, full symmetry can occur only in the case of a ternary majority term, that is, 2-distributivity, equivalently, 2-directed-distributivity. In fact, as soon as some ternary term t is symmetric and satisfies t(x, y, x) = x, then t must be a majority term.
Another set of equations which can be satisfied by a symmetric ternary term is the following minority condition: x = t(x, y, y), x = t(y, x, y), x = t(y, y, x).
The above equations partially resemble the 2-alvin condition, but are satisfied, for example, by the term x + y + z in a group of exponent 2; hence the equations (6.2) do not imply congruence distributivity, though they do imply congruence permutability. Minority terms have been extensively studied in Kazda, Opršal, Valeriote, Zhuk [31]. See also Remarks 6.6(b) and 8.19 for a few further comments.
On the other hand, there are indeed full symmetric terms whose existence implies congruence distributivity. In [47] a variety N m has been constructed such that N m has an m-ary symmetrical near-unanimity term, is not 2m−4-alvin, hence not 2m−5-distributive and is not 2m−3-reversed-modular, hence not 2m−4-modular.
We now notice that, for even n, our constructions show that specularity does not influence distributivity levels. We shall prove stronger results in Section 9; however, we present the proof of the following corollary, since it is particularly simple. Corollary 6.5. If n ≥ 2 and n is even, then there are a specular n-distributive locally finite variety and a specular n-alvin locally finite variety which are not n−1distributive.
If n ≥ 2, then there is a specular n-directed-distributive locally finite variety which is not n−1-directed-distributive.
Proof. By Remark 6.2, the proof of Theorem 4.1 produces a specular n-distributive variety V which is not 2n−2-modular. By Day's Theorem 1.1, every n−1-distributive variety is 2n−3-modular, hence 2n−2-modular. Thus V is not n−1-distributive. Again by Theorem 4.1 and Remark 6.2 we get a specular n-alvin variety which is not 2n−3-modular and the same argument as above applies.
If n ≥ 2, then, by Theorem 5.1(i) and Remark 6.2, we have a specular ndirected-distributive variety W which is not 2n−2-modular. However, by Theorem 5.1(ii), every n−1-directed-distributive variety is 2n−3-modular, in particular, 2n−2-modular. Hence W is not n−1-directed-distributive. Remark 6.6. (a) For n even, an n-distributive variety is not necessarily specular n-distributive. For example, just consider the 2-distributive variety V with one ternary majority operation t = t 1 satisfying no further equation. We shall show that V is not specular 2-distributive, actually, V has no ternary specular term, except for the projection p 2 onto the second coordinate.
Every term in V has a normal form, obtained by applying the majority rule whenever possible. Suppose by contradiction that there exists a specular term s(x, y, z) in V distinct from p 2 . Choose such an s in normal form of minimal complexity. Since s is specular and distinct from p 2 , then s cannot be a variable. hence it is written as s(x, y, z) = t(u 1 (x, y, z), u 2 (x, y, z), u 3 (x, y, z)), for certain terms u 1 , u 2 and u 3 . We have t(u 1 (x, y, z), u 2 (x, y, z), u 3 (x, y, z)) = t(u 1 (z, y, x), u 2 (z, y, x), u 3 (z, y, x)), since s is specular, hence u 1 (x, y, z) = u 1 (z, y, x), u 2 (x, y, z) = u 2 (z, y, x), u 3 (x, y, z) = u 3 (z, y, x), since we are dealing with normal forms.
Since we have supposed that s is specular, distinct from the second projection and of minimal complexity, we have u 1 (x, y, z) = u 2 (x, y, z) = u 3 (x, y, z) = y, hence s(x, y, z) = t(y, y, y) = y, a contradiction.
(b) Similarly, the variety with a 2-alvin operation satisfying no further equation has no specular term distinct from the second projection, in particular, no specular 2-alvin term. The variety with a Maltsev operation (for permutability) satisfying no further equation has no specular Maltsev term. The variety with a minority operation satisfying no further equation has no specular minority term.
(c) It is likely that examples similar to (a) -(b) above can be worked out for every even n > 2. On the other hand, we do not know examples of locally finite n-distributive varieties which are not specular n-distributive.
(d) Suppose that some variety V has an idempotent term s such that s(x, y) = s(y, x) holds. If V is n-directed-distributive (n is even and V is n-distributive, nalvin), then V is specular n-directed-distributive (specular n-distributive, specular n-alvin). Indeed, if t 0 , . . . , t n is a sequence of terms witnessing the assumption, then t ′ i (x, y, z) = s(t i (x, y, z), t n−i (z, y, x)) are terms witnessing the conclusion. This is essentially an argument from [8].
(e) The same argument as in (a) above applies also to near-unanimity terms. If m ≥ 3 and V is the variety with only one m-ary operation w satisfying exactly the near-unanimity identities, then, for every j ≥ 2, V has no j-ary term which is symmetric in the sense of equation (6.1). In fact, the argument is slightly simpler.

Gumm, directed Gumm and defective alvin terms
Gumm and defective terms. Most results of the present paper apply to Gumm terms, too. This is quite surprising, since the existence of Gumm terms does not imply congruence distributivity; actually, a variety V has Gumm terms if and only if V is congruence modular. More generally, our results apply to the weaker notion of defective Gumm terms; as introduced in part (b) of the following definition.
As we have briefly discussed in the introduction, it is unusual-but much more convenient for our purposes here-to introduce Gumm terms as defective alvin terms. Again, we refer to [46, Remark 4.2] for a more complete discussion. A more general study of "defective" conditions appears in Kazda and Valeriote [32]. See also Section 8 below. Defective conditions in the present terminology correspond to dashed lines in paths in the terminology from [32]. See Remark 8.7(b) below for more details.
Definition 7.1. (a) We get a sequence of Gumm terms [22,23] if in Definition 2.1 the condition x = t 1 (x, y, x) from (B) is not assumed in the definition of alvin terms. More formally, for ℓ ≤ n, it is convenient to consider the following reduced set (B ℓ ) of equations: x = t 0 (x, y, z), t n (x, y, z) = z, In the above situation we shall say that the sequence of terms t 0 , . . . , t n is defective at place ℓ. Under the above notation, a sequence of Gumm terms is a sequence satisfying (B 1 ), as well as (A) from Definition 2.1.
With the above definition, if t 0 , t 1 , t 2 is a sequence of Gumm terms, then t 1 is a Maltsev term for permutability [48]. Recall that we are not exactly assuming Jónsson Condition (J), but the alvin variant (A) in which even and odd are exchanged. This is fundamental: see Remark 7.5(c) below. Notice also that many authors, including Gumm himself, define Gumm terms in a slightly different fashion. See Remark 7.2(b) below.
(b) If in the definition of Gumm terms we discard also the equation x = t n−1 (x, y, x) we get a sequence of doubly defective alvin terms, or defective Gumm terms [13,46]. More formally, and with the obvious extension of the above convention, a sequence of defective Gumm terms is a sequence satisfying (B 1, n−1 ) and (A). We shall soon see that the the parity of n and the places at which the missing equation(s) occur are highly relevant. See Remarks 7.5(b)(c) and 10.11.
(c) As in Definition 2.3, a variety or an algebra is said to be n-Gumm (defective n-Gumm) if it has a sequence t 0 , . . . , t n of Gumm (defective Gumm) terms. Notice that, on the contrary, when n is odd the definitions are not equivalent, actually, the conjunction of (B n−1 ) and (A) turns out to be a trivial condition, if n is odd. This is proved arguing as in Remark 7.5(c) below.
(b) On the other hand, when n is odd, we get a definition equivalent to 7.1(a) if we ask that (B n−1 ) and (J) are satisfied. Notice that here we are considering (J) rather than (A).
At first glance this equivalence might appear strange and counterintuitive. However it is enough to observe that, when n is odd, if we reverse the order of terms and of variables, condition (J) transforms into (A) and, obviously, (B n−1 ) transforms into (B 1 ). The above equivalence explains the reason why the convention in the literature is not uniform. Some authors define Gumm terms by taking the "permutability part", namely, the defective part, at the end, while others take it at the beginning.
For our purposes, it is convenient to define Gumm terms by taking the "permutability part" at the beginning, rather than at the end. In this way, we have no need to shift from the Jónsson and the alvin conditions, according to the parity of n. The definition we have adopted has also the advantage of providing a finer way of counting the number of terms: compare [41, p. 12]. To the best of our knowledge, this formulation of the Gumm condition is due to [36,62].
(c) As we mentioned, 2-alvin is equivalent to arithmeticity, that is, to the conjunction of congruence distributivity and permutability. Moreover, defective 2-alvin is equivalent to congruence permutability. The above observations suggest that the alvin conditions share some aspects in common with congruence permutability. This is indeed the case: we have discussed this matter in more detail in [42, Remark 2.2] for the case n = 3, and in [46,Remark 4.2] for the general case. Another exploitation of this fact is presented here in the proof of Theorem 8.8(iii) below. Compare also Remark 8.13 and [43].
The definition of directed Gumm terms [30] shall be recalled in Definition 7.6(a) below. The definition of two-headed directed Gumm terms shall be given in Definition 7.6(b) below. In order for the reader to appreciate the exact power of the notions involved, we state the following theorem even if we have not yet given all the definitions; in fact, we shall not actually need the theorem in what follows. (i) V is congruence modular.
(ii) V has a sequence of Gumm terms. (iii) V has a sequence t 1 , . . . , t n of defective Gumm terms, for some even n.
(iv) V has a sequence of directed Gumm terms.
(v) V has a sequence of two-headed directed Gumm terms.
The equivalence of (i) and (ii) is due to H.-P. Gumm [22,23]. The equivalence of (i) and (iii) appears in [13] under different notation and terminology. See [46, Proposition 6.4] for further details. In any case, (ii) ⇒ (iii) is obvious, and it follows from Lemma 4.2(a) or Corollary 8.11(ii)(c) below that (iii) implies congruence modularity (the case n = 2 is obvious). The equivalence of (ii) and (iv) is proved in [30]. By adding one more term, a trivial projection at the beginning, and shifting the indices, it is obvious that (iv) implies (v). Compare the proof of Theorem 2.8. If n = 2 in Definition 7.6(a), just add the projection two times. It follows from Corollary 8.11(ii)(c), to be proved below, that (v) implies congruence modularity. (ii) The result is optimal: for every even n ≥ 2 there is a defective n-Gumm locally finite variety, in particular, n-Gumm, which is not 2n−3-modular.
Proof. An n-Gumm variety is, in particular, defective n-Gumm. The fact that if n is even, then a defective n-Gumm variety is 2n−3-reversed-modular is simply a reformulation of the second statement in Lemma 4.2(a).
In order to prove (ii), recall that in Theorem 4.1(ii) an n-alvin not 2n−3-modular variety V has been constructed. In particular, V is a defective n-Gumm variety.
Remark 7.5. (a) As in Remark 2.5, within a variety, each condition on the left in the following table is equivalent to the condition on the right.
where in the first line we are assuming n ≥ 2 and in the second line we are assuming n even and n ≥ 4.
(b) As another example of applications of congruence identities one sees immediately, arguing as in (a), that, for n odd and n > 1, being defective n-Gumm is a trivial condition. Indeed, the condition is equivalent to the trivially true identities α(β •γ) ⊆ α(γ •β •γ), for n = 3, and α(β •γ) ⊆ α(γ •β)•(αγ •αβ • n−4 . . . •αγ)•α(β •γ), for larger n's. It requires a bit of ingenuity to see that the conditions are trivial, when expressed in function of terms. Take t n−1 to be the projection onto the second coordinate and all the terms before t n−1 as the projection onto the first coordinate. Recall that here n is odd and that we are considering a defective alvin condition, namely, we are assuming (A) from Definition 2.1, rather than (J).
(c) Expanding on an observation from [30], we get a trivial condition also by considering defective Jónsson or defective directed Jónsson terms, namely, discarding the equation x = t 1 (x, y, x) from each set of conditions. The existence of defective Jónsson terms is equivalent to the trivial congruence identity α(β • γ) ⊆ α(β • γ)• αβ . . . . In both cases, take t 1 as the projection onto the second coordinate and all the terms after t 1 as the projection onto the third coordinate, to show that the conditions are satisfied by every variety. This is essentially a remark on [30, p. 205], where it is used under the assumption that all the equations x = t h (x, y, x) (0 ≤ h ≤ n) are discarded. However, the argument works if we just discard only x = t 1 (x, y, x).
An even more general fact is presented in [32, Subsection 3.3.1].
(d) Anyway, there is a useful and interesting notion of directed Gumm terms [30]. The remarks in (c) above show that directed Gumm terms cannot be plainly obtained as defective directed Jónsson terms, as we did for "undirected" Gumm terms. However, notice that there is the possibility of considering various kinds of mixed Jónsson terms, in which, for each index, we choose some condition among (M0), (M1), (M → ). Details shall be presented in Definition 8.1 below, where a condition parallel to (M → ) shall be also taken into account.
Then directed Gumm terms, as introduced by [30], are actually defective mixed Jónsson terms, when (M → ) is assumed for all indices, with the exceptions of n − 2, for which (M1) is assumed, and of n − 1, for which (M0) is assumed. The definition applies both to the case n even and to the case n odd. See Definition 7.6(a) below for formal details and Remarks 8.2 and 8.7(b) for the connection with the idea of mixed Jónsson terms.

Directed Gumm terms.
Definition 7.6. (a) [30] If n ≥ 2, a sequence t 0 , t 1 , . . . , t n−2 , q of ternary terms is a sequence of directed Gumm terms if the following equations are satisfied: Notice that if n = 2 in the above definition, then q is a Maltsev term for permutability. Thus, for n = 2, the existence of directed Gumm terms is equivalent to the existence of Gumm terms (and equivalent to congruence permutability). Notice the parallel situation with respect to Jónsson terms and directed Jónsson terms, which give equivalent conditions in the case n = 2, as we mentioned in Definition 2.1.
(b) If n ≥ 4, a sequence p, t 2 , . . . , t n−2 , q of ternary terms is a sequence of twoheaded directed Gumm terms if the following equations are satisfied: (c) If in (b) above we also require that the terms p and q satisfy the equations x = p(x, y, x) and x = q(x, y, x) we get a sequence of directed terms with two alvin heads. If an algebra or a variety has a sequence of such terms, we say that it is n-directed with alvin heads. Of course, in the situation described here in (c), the terms p and q can be safely relabeled as t 1 and t n−1 .
Notice that being 4-directed with alvin heads is the same as being 4-alvin.
The indexing of terms in the above definitions has been chosen in order to match with the more general notions we shall introduce in Definition 8.1, and to get corresponding results, as far as modularity levels are concerned.
In the formalism from [32], two-headed directed Gumm terms correspond to a pattern path with forward solid edges everywhere, except for two dashed backwards edges on the outer ends. The case of directed terms with alvin heads is similar, but in this case all the edges are solid. More details shall be given in Remark 8.7(b).
(i) If some variety V has two-headed directed Gumm terms p, t 2 , . . . , t n−2 , q, then V is 2n−3-reversed-modular, hence 2n−2-modular. In particular, this applies to any variety which is n-directed with alvin heads. (ii) There is some locally finite variety V which has two-headed directed Gumm terms p, t 2 , . . . , t n−2 , q, but is not 2n−3-modular, hence (i) is the best possible result. A variety V as above can be chosen to be n-directed with alvin heads.
Proof. The proof of (i) is obtained by merging the arguments in the proofs of Lemma 4.2 and of Theorem 5.1(ii), namely, considering a sequence of terms which behaves as in the proof of Theorem 5.1(ii) on the inside and which on the outer edges is defined as in the proof of Lemma 4.2. In detail, define u 1 = p(x, y, z), u 2 = t 2 (x, y, w), u 3 = t 2 (x, z, w), u 4 = t 3 (x, y, w), . . . and symmetrically at the other end. A more general result shall be proved in Corollary 8.11(ii)(c) below.
(ii) By Theorem 5.1(i), there is an n−2-directed-distributive variety W which is not 2n−5-reversed-modular. By Remark 2.10, there is some algebra D ∈ W such that the congruence identity α(β • αγ • β) ⊆ αγ • αβ • 2n−5 . . . • αγ fails in D. As in the proof of Theorem 4.1, we can suppose that D has only directed Jónsson operations. If we perform Construction 3.13 by considering such an algebra D, then, arguing as in the proofs of Lemma 3.6(i)(ii) and Theorem 3.14(i), we get some algebra B belonging to a variety V with two-headed directed Gumm terms p, t 2 , . . . , t n−2 , q. Actually, the equations x = p(x, y, x) and x = q(x, y, x) hold in V, hence we get a variety which is n-directed with alvin heads. By Theorem 3.14(ii), the identity α(β • αγ • β) ⊆ αβ • αγ • 2n−3 . . . • αβ fails in B, thus V is not 2n−3-modular, again by Remark 2.10. The arguments showing that V can be chosen to be locally finite are from Theorem 4.1.

Mixed Jónsson terms and congruence modularity
Mixed terms and a way to describe them. We need a companion equation to (M0), (M1), (M → ) from Definition 2.1.
As clearly explained in [30,32], the symmetry between (M → ) from Definition 2.1 and (M ← ) above is only apparent. The two equations are significantly different, under the additional assumptions x = t 0 (x, y, z) and t n (x, y, z) = z. Suppose for the rest of the paragraph that we are not assuming the equations on the second line of (B) but, for each index, one of (M0), (M1), (M → ), (M ← ) is satisfied. If we assume (M → ) so much as for one index, we get a trivial condition, as in Remark 7.5(c). On the other hand, if we assume (M ← ) for all indices, we get a condition equivalent to n-permutability [25]. See [30,32] for further comments and details.
Remark 7.5(d) and Definition 7.6 suggest the following definition. If in the above definition we only assume (B ℓ ) instead of (B), we say that the sequence is defective at place ℓ. Compare Definition 7.1. Sequences defective at two or more places are defined similarly. We shall see that sequences defective at one or both "ends" 1 and n − 1 are particularly interesting and enjoy special properties. Compare also Lemma 4.2 and Theorem 7.7(i). Sequences defective at "internal places" are less well-behaved. See Remark 10.11 in conjunction with Remark 4.6.
In a different context and with different terminology mixed and defective mixed conditions appeared in Kazda and Valeriote [32] as Maltsev conditions associated to pattern paths. See [32, Subsection 3.2] and Remark 8.7(b) below. Mixed conditions deserve a more attentive study, but, of course, the present paper is already long enough and it is not possible to include a detailed study of such conditions. We just present a few remarks. In particular, we shall use the notion of a mixed condition in order to present alternative proofs, in a uniform way, for Theorems 1.3(i), 5.1(ii), 7.7(i), Lemma 4.2, Corollary 4.3(i)-(iii), Proposition 7.4(i) and for the statements in Remark 4.4. In a sense, the main point in the present section is just to introduce an appropriate notation and then we repeat some classical proofs in a greater generality. However, let us remark that the notational issue is not that trivial. As we are going to see soon, in order to provide a good way to generalize the classical methods, we need to describe mixed conditions by means of the way "variables are moved", rather than by listing the equations which are satisfied. See, in particular, Definition 8.5, Remarks 8.6, 8.7(a), as well as Theorem 8.8, together with its proof.
As we mentioned, though the terminology adopted here is different, there is a strong correspondence with some parts of [32]. See Remark 8.7(b). If we always choose equation (M ← ), we get a sequence t 1 , . . . , t n−1 of Pixley terms, in the terminology from [30, p. 205]. See also [38]. To be consistent with the notation in Definition 2.1, it is convenient to add the two trivial terms at the outer edges. In detail, under our convention, a sequence of Pixley terms is a sequence t 0 , . . . , t n of ternary terms such that the following equations are satisfied: the equations (B) from Definition 2.1, as well as (M ← ), for h = 0, . . . , n − 1.
A less standard example is the notion of directed terms with alvin heads, as introduced in Definition 7.6(c). In this case the first two equations are chosen to be (M1) and (M0), the last two equations are chosen to be (M1) and (M0), in that order, and all the remaining middle equations, if any, are (M → ).
The above examples are nondefective. All the various kinds of Gumm terms introduced in Section 7 are examples of defective mixed conditions. Proposition 8.3. If n ≥ 1, then every variety with mixed Jónsson terms t 0 , . . . , t n is congruence distributive, actually (at least) 2n−2-distributive. Proposition 8.3 can be proved using the arguments from [30]. We shall prove a more refined result in Theorem 8.8 below. See Remark 8.9.
Of course, according to the form of the mixed condition, a variety as in Proposition 8.3 might be m-distributive, for some m < 2n − 2. Indeed, n-distributivity itself is a special case of a mixed condition, hence it might already happen that m = n. On the other hand, Theorem 5.2(ii) shows that, in general, 2n − 2 is the best possible bound in Proposition 8.3.
We shall now prove a more explicit version of Proposition 8.3. More importantly for our purposes, and a generalization of Lemma 4.2, we are going to show that there are cases in which defective conditions imply congruence modularity. In order to accomplish this, we need a way to describe each specific mixed condition. While, in the case of the more usual examples, it appears natural to list the various kinds of equations which are satisfied, it turns out that, in the general case of an arbitrary mixed condition, it is more convenient to deal with the variables which are moved relative to each single term. See, in particular, Remark 8.7(a). We first need a formal notational remark about how to treat the initial and final equations.
Remark 8.4. Let V be a variety with mixed Jónsson terms as in Definition 8.1. It might happen that, for some h < n, V satisfies two or more equations among (M0), (M1), (M → ), (M ← ). In our definition of a mixed condition it is convenient to require that, for each h, exactly one of the above equations is selected. The "edge cases" h = 0 and h = n − 1 are an exception. As we shall see, in the present section it will be convenient to deal only with the terms t 1 , . . . , t n−1 . Hence, for h = 0, we shall not distinguish between (M0) and (M → ), which both entail x = t 1 (x, x, z), and we shall not distinguish between (M1) and (M ← ), both entailing x = t 1 (x, z, z). A symmetrical consideration applies to t n−1 .
t h (x, r(h), z) = t h+1 (x, l(h + 1), z), for 1 ≤ h < n − 1, and t n−1 (x, r(n − 1), z) = z. Remark 8.6. Clearly, every pair of functions l and r as above actually determines a mixed condition in the sense of Definition 8.1 and Remark 8.4. In passing, we notice that, by Remark 8.4, here it is more practical to write, say, x = t 1 (x, l(1), z) in place of something like t 0 (x, r(0), z) = t 1 (x, l(1), z), since x = t 0 (x, , ), no matter the second and the third arguments in the range of t 0 , hence there is no use in specifying some value for r(0). In other words, we do not need the outer (trivial) terms t 0 and t n when we present the definition of a mixed condition as determined by certain functions 2 l and r.
Conversely, every mixed condition requires that, for each h, one equation of the following form is satisfied, where each one of v h and w h+1 is either x or z. Hence if we set r(h) = v h and l(h + 1) = w h+1 , for all appropriate values of h, the given mixed condition is determined by l and r. Thus we get that every mixed condition is determined by some pair l and r.
In particular, the Jónsson (alvin) condition is obtained by setting l(h) = x and r(h) = z, for h odd (even), and l(h) = z and r(h) = x, for h even (odd). The directed Jónsson condition is obtained by putting l(h) = x and r(h) = z, for every h. Letting l(h) = z and r(h) = x, for every h, we obtain the generalized Pixley condition in the sense of [30], as recalled in Remark 8.2. If n ≥ 4, l(1) = l(n−1) = z, r(1) = r(n − 1) = x, and, in all the other cases, l(h) = x and r(h) = z, then we get directed terms with alvin heads, as in Definition 7.6(c), of course, suitably relabeling the terms p and q. See Remark 8.7(b) below for a diagram (inspired by [32]) representing the situation.
Gumm and defective Gumm terms are defective cases of the alvin condition. Directed Gumm terms are a defective case of the mixed condition determined by the positions l(n − 1) = z, r(n − 1) = x, and l(h) = x and r(h) = z, for all the other h's. Two-headed directed Gumm terms are defective cases of what we have called directed terms with alvin heads.
The identities (4.4) and (4.6) in the statement of Theorem 4.5 correspond to defective mixed conditions, too, via Remark 4.6. The conditions are defective versions of, respectively, the alvin and the Jónsson conditions; in this case the terms are defective at all odd (even) indices. In the statement of Theorem 4.5 n is assumed to be even; if n is odd, we set ℓ = n−1 2 and consider variations of (4.4) and (4.6) in which an αγ factor is added or deleted on the right. See Definition 9.7 below for exact details. The above conditions shall be called the switch and the J-switch condition.
The next remark shows that the description given by Definition 8.5 can be somewhat simplified.
Remark 8.7. (a) The l-r-convention introduced in Definition 8.5 is particularly useful in order to detect redundant conditions. Indeed, if, under the assumptions in Definition 8.5, we have l(h) = r(h), for some h, then thus in this case the term t h is redundant and can be discarded, getting a shorter sequence of mixed Jónsson terms. Indeed, given terms t 0 , . . . , t h−1 , t h+1 , . . . , t n satisfying (8.2) and all the other appropriate equations, we get terms t 0 , . . . , t h−1 , t h , t h+1 , . . . , t n satisfying the equations (8.1) by setting t h (x, y, z) = t h−1 (x, r(h−1), z). Notice that, with this position, t h does not depend on its second place.
In particular, it is no loss of generality to assume that l(h) = r(h), for every h. Under this assumption, a mixed condition is determined either by l alone, or by r alone, since l(h) and r(h) may assume only two values, hence, if l(h) = r(h), the value of l(h) determines the value of r(h) and conversely.
(b) Following [32], still assuming that l(h) = r(h), for every h, we can represent a mixed condition by a path with directed edges. The path P goes from 0 to n − 1 and touches all the intermediate natural numbers, in their order. If 1 ≤ i < n, l(i) = x and r(i) = z, then the edge in P connecting i − 1 and i is directed from i − 1 to i (forward directed ). On the other hand, if l(i) = z and r(i) = x, then the edge in P connecting i−1 and i is directed from i to i−1 (backward directed ). With the above conventions, the functions l and r determine the same Maltsev condition M (P ) as defined in [32,Subsection 3.2], provided all the edges of P are considered as solid, modulo the relabeling of the variables y in [32] to z here. Notice that there is an extra term in [32,Subsection 3.2], namely, we should have taken n + 1 in place of n here to get an exact correspondence.
One can describe defective mixed conditions in a similar way, considering P as an edge-labeled path, where edges are labeled as either solid or dashed. If the condition is defective at some place i, we consider the edge connecting i − 1 and i as dashed, otherwise, as above, the edge is solid. In this more general case, too, the (possibly defective) mixed condition turns out to be M (P ), as defined in [32].
In the following table we represent the conditions we study by means of paths.
where in the line representing defective Gumm terms we assume that n is even. We refer to [32] for further details, diagrams, results and variations. (c) In (b) above it would probably be more natural, though notationally clumsier, to assume that the vertices of P are labeled as 1 2 , 1 + 1 2 , . . . , n − 1 2 , namely, the indexing of the vertices is shifted by 1 2 . The above conditions turn out then to be more symmetric, for example, with the above shifted indices, if l(i) = x and r(i) = z, then the edge in P connecting i − 1 2 and i + 1 2 is directed from i − 1 2 to i + 1 2 ; it is dashed if the condition is defective at i, otherwise, it is solid. Relation identities. Now we turn our attention to relation identities which are consequences of mixed conditions. The study of relation identities seems to be interesting for itself, see [15,23,25,29,39,40,42,43,45,46,62] and Remarks 10.8 and 10.12. However, in this subsection we deal with relation identities only because they provide a quite easy and, at least in our opinion, natural way to congruence identities.
We let R, S and T denote binary reflexive and admissible relations on some algebra. We let R denote the converse of R and S ∪ T denote the smallest admissible relation containing both S and T . In the following formulae, when dealing with relation identities, juxtaposition denotes intersection of binary relations. Recall that in this context 0 denotes the identical relation. (iii) (a) If, in addition, l(1) = z, that is, V satisfies x = t 1 (x, z, z), then B 1 in identity (8.3) can be replaced by α(S ∪ T ), and this holds also in case the sequence of terms is defective at 1. (b) Symmetrically, if r(n−1) = x, that is, t n−1 (x, x, z) = z holds, then B n−1 in identity (8.3) can be replaced by α(S ∪ T ), and this applies also if the sequence of terms is defective at n − 1.

(c) If n ≥ 3 and both the additional assumptions in (a) and (b) hold, we can
perform both replacements, also if the sequence is defective both at 1 and at n − 1.
Proof of Theorem 8.8. In many particular instances the proof of 8.8 is standard, using or modifying the arguments from [28]. See, e. g., [46,Lemma 4.3], [22,23,36,41,42,45,62]  To prove the theorem in general, first notice that (i) is a special case of (ii), since if B = 0, then trivially B ⊆ αS • αT . In any case, by Remark 8.7(a), it is no loss of generality to assume that the case l(h) = r(h) never occurs.
So let us prove (ii). Suppose that V has mixed Jónsson terms t 0 , . . . , t n , with equations determined by l and r. If A ∈ V, a, c ∈ A and (a, c) ∈ α(S • T ), then a α c and there is some b ∈ A such that a S b T c. For h = 1, . . . , n − 1, let l * (h) = a if l(h) = x and l * (h) = c if l(h) = z and define r * similarly. Consider the elements e 0 = a = t 1 (a, l * (1), c), where the equalities follow from the equations (8.1). In conclusion, a = e 0 B 1 e 1 . . . e n−2 B n−1 e n−1 = c, hence (a, c) ∈ B 1 • B 2 • · · · • B n−1 and (ii) is proved.
(iii)(a) If r(1) = z, then by (ii) we can take B = 0 and we are done. Notice that no special equation involving t h is needed in the proof of the case l(h) = r(h).
Otherwise, r(1) = x. Suppose that a α c and a S b T c, as in the proof of (ii) above. Then, under the additional assumption, we have and this holds also when t 1 is defective, since the equation x = t 1 (x, y, x) has not been used in the proof of (8.4). Furthermore, e 0 = a = t 1 (a, a, a) α t 1 (a, a, c) = e 1 , so we do not need x = t 1 (x, y, x), either, in order to prove the α-relation.
(b) is proved in a symmetrical way.
(c) If n ≥ 3, the two arguments at 1 and n − 1 do not interfere, hence we can perform both replacements.
Notice that the argument applies when n = 3, in which case all the terms can be taken as defective! We thus get that a 3-permutable variety satisfies α(S • T ) ⊆ α(S ∪ T ) • α(S ∪ T ). This is a strong way to say that 3-permutable varieties are congruence modular: just take S = β and T = αγ • β in the above identity. Indeed, we have got a direct proof that 3-permutable varieties are 3-reversed-modular.
Remark 8.10. If n ≥ 4 and V is n-directed with alvin heads, then V is 2n−4-alvin.
This fact follows immediately from 8.8(ii) taking S = β and T = γ, thus Corollary 8.11. Suppose that n ≥ 2 and that the variety V has mixed Jónsson terms t 0 , . . . , t n in the sense of Definition 8.1. Then the following hold.
The result holds also if the mixed terms are defective at 1.
The result holds also if the mixed terms are defective at n − 1. (ii)(a) Choose S and T as above. By Theorem 8.8(iii)(a) we can take B 1 = α(S ∪ T ) = αT = αγ •αβ, hence we can save an occurrence of αβ at the beginning in the computation of B 1 • B 2 • · · · • B n−1 . That is, we have 2n−2-reversedmodularity, which is equivalent to 2n−2-modularity, by Proposition 2.11, since 2n − 2 is even.
(c) If both the assumptions in (a) and (b) hold, we can save the occurrences of αβ both at the beginning and at the end. Thus we get 2n−3-reversed-modularity. In passing, notice that either Theorem 4.1(ii) or Theorem 7.7(ii) show that we cannot get 2n−3-modularity.
Notice that the argument in (c) does not work if n = 2, since in that case we cannot perform at the same time both the replacements allowed by Theorem 8.8(iii)(c). Indeed, in the present terminology, any arithmetical variety V has mixed Jónsson terms t 0 , t 1 , t 2 with l(1) = z and r(1) = r(2 − 1) = x, but if n = 2, then 2n − 3 = 1, while only trivial varieties are 1-reversed-modular.
Additional remarks on mixed terms. Remark 8.12. Corollary 8.11(i) immediately implies Day's result that every n-distributive variety is 2n−1-modular.
Item (ii)(a) implies that every n-alvin and every n-Gumm variety is 2n−2modular. This holds for every n and, as we mentioned, is implicit in [36]. If n is odd, we get that every n-distributive variety is 2n−2-modular, by Remark 2.6(a). Otherwise, apply item (ii)(b) directly. In particular, we get another proof for Lemma 4.2(b).
Item (ii)(c) implies that if n ≥ 4 and n is even, then every n-alvin (actually, every defective n-Gumm, in particular, every n-Gumm) variety is 2n−3-reversedmodular. This gives another proof of Lemma 4.2(a). Item (ii)(c) also implies that every variety with a sequence p, t 2 , . . . , t n−2 , q of two-headed directed Gumm terms, as introduced in Definition 7.6(b), is 2n−3-reversed-modular.
It is important to notice that, in all the above situations, in order get congruence modularity it is fundamental that the conditions are defective at the outer places 1 or n − 1. In fact, mixed conditions defective at some "internal" place usually do not imply congruence modularity. See Remark 10.11(a).
Remark 8.13. What's so special at the ends? We have seen that special situations occur at the outer "edges" t 1 and t n−1 . Namely, if the equation x = t 1 (x, z, z) holds, then we get congruence modularity even without assuming x = t 1 (x, y, x). Actually, we get 2n−2-modularity rather than 2n−1-modularity, thus we have the rather remarkable result that, in this special case, we get a stronger conclusion using a weaker hypothesis! As we hinted in Remark 7.2(c), this can be seen as a consequence of the fact that alvin-like conditions share some aspects in common with congruence permutability.
It is essential to assume that x = t 1 (x, z, z). If x = t 1 (x, x, z), instead, and t 1 is defective, then we get a trivial condition, by Remark 7.5(c).
While our arguments here depend crucially on the form x = t 1 (x, z, z) of the first nontrivial equation, it should be mentioned that there are always some special kinds of shortcuts which can be taken "at the outer edges". See [39,Remark 17]. However, there are various reasons suggesting that identities like (8.3) are particularly interesting and useful.
First, the original proof [28] that Jónsson terms imply congruence distributivity, or, equivalently, that, within a variety, the identities displayed in Remark 2.5 imply congruence distributivity, essentially uses (the Jónsson-terms particular version of) identity (8.3). The point is that, in principle, in order to prove congruence distributivity, it is not enough to find bounds for α(β • γ), one needs bounds for α(β • γ • k . . .) for arbitrarily large k. See [41] for further elaborations on this aspect. Second, identity (8.3) provides a uniform way to prove some quite disparate facts. While, of course, once we have proved congruence distributivity, we surely have congruence modularity as a consequence, on the other hand, identity (8.3) is useful in establishing the exact distributivity or modularity levels. See Remarks 8.9, 8.12, Corollary 8.11 and Theorem 9.8. Compare also some parallel results in [22,23,36,41,42,46,62]. Indeed, it is almost immediately clear from (8.3) that the existence of Jónsson terms t 0 , . . . t n implies the corresponding displayed identity in Remark 2.5. Just take S = β and T = γ; then, due to Theorem 8.8(ii), we get n − 2 adjacent pairs of congruences, either αβ or αγ, so these congruences mutually absorb and we end up with a total of n factors. On the other hand, if we deal with directed Jónsson terms, then Theorem 8.8(ii) always gives B h = αβ • αγ, so we get no adjacent pair of identical congruences and we are left with 2n − 2 factors. In fact, in general, we can do no better, as shown in Theorem 5.2(ii).
Of course, a proof is needed, since the above informal argument using identity (8.3) is not a proof and in principle we might find out different tricks leading to a better result. In fact, this is the case, for example, for varieties with Pixley terms (cf. [30, p. 205] and Remark 8.2) which are congruence distributive and n-permutable, hence n-distributive [38]. In this case we always have B h = αγ • αβ, hence no pair of congruences absorb in (8.3), but we can get n-distributivity nesting terms. Apart from such exceptions, the argument based on identity (8.3) seems generally a quite clear guide to intuition.
(c) Identity (8.3) appears to be generally a good guide to intuition also when dealing with congruence modularity. In this case, the best bounds for modularity levels of varieties with the same number of Jónsson, alvin and directed Jónsson terms terms are essentially always the same, at most differing by 1 or 2, depending on the form of the identities "at the outer edges" t 1 and t n−1 . The intuitive reason for the above "stationarity" of the modularity levels is that whenever we try to have the left side α(S • T ) of (8.3) equal to α(β • αγ • β), we always end up with each B h having the form αβ • αγ • αβ, except possibly for the outer edges B 1 and B n−1 . Hence in this case there is no sensible difference between the cases of, say, Jónsson and directed Jónsson terms. Again, the above intuitive argument generally leads to the correct results, as we have showed in Corollary 4.3, Theorems 5.1, 7.7 and Proposition 7.4. Notice that here we are dealing with the minimal number of mixed terms, not with the distributivity level, namely, the minimal number of Jónsson terms. In fact, while n-distributivity implies 2n−1-modularity, and generally this result cannot be improved, there are varieties in which the distributivity and the modularity levels differ only by 1. Compare the results about the varieties V c n , V d n and V f n in Theorem 9.8 below. The following generalization of Theorem 8.8 is proved in the same way. The generalization is used only marginally in this paper. Proposition 8.15. If n ≥ 2, i ≥ 1 and V has mixed Jónsson terms t 0 , . . . , t n satisfying a condition determined by l and r, then V satisfies Notice that item (iii) from Theorem 8.8, as it stands, cannot be immediately generalized in the context of Proposition 8.15. In this connection, see however Lemma 4.3, Propositions 4.4 and 4.10 in [46] and Section 2 in [41]. Remark 8.16. It is also possible to introduce a notion of mixed Day terms. Let a modular quadruplet be anyone of the following quadruplets of variables: A sequence u 0 , . . . , u m of 4-ary terms is a sequence of mixed Day terms if the equations (D0), (D1) and (D3) from Definition 2.7 are satisfied and, moreover, for each k with 0 ≤ k < m, at least one of the following equations is satisfied: where both (x 1 , x 2 , x 3 , x 4 ) and (y 1 , y 2 , y 3 , y 4 ) are modular quadruplets. Of course, it is redundant to include (x, y, y, z) in the set of modular quadruplets, since we can take y = x or y = z, still getting an equation which is satisfied. However, it is convenient to maintain (x, y, y, z) in order to have Day's conditions as a special case. Moreover, if some equation in (8.6) involves (x, y, y, z), then we generally get a smaller modularity level. As we are going to show, the existence of mixed Day terms implies congruence modularity. This extends [13,Corollary 3.5].
Proposition 8.17. Every variety V with a sequence of mixed Day terms is congruence modular.
Proof. If, in some algebra in V, (a, d) ∈ α(β • αγ • β) with a β b αγ c β d and (a 1 , a 2 , a 3 , a 4 ) is (the interpretation of) a modular quadruplet (under the assignment x → a, y → b, z → d), then it is easy to see that, in any case, u k (a 1 , a 2 , a 3 , a 4 ) αβ+αγ u k (a, b, c, d). . In general, we get new conditions. For example, consider the following set of equations: It is easy to see that, for n ≥ 2, an abelian group G has terms t 1 , . . . , t n−1 satisfying equations (8.7) if and only if G has exponent dividing n.

Some more explicit descriptions and summing up everything
Constructing some algebras and varieties. The observations in Remark 6.2 and an analysis of the proofs of Theorems 4.1, 5.1(i), 5.2 and 7.7(ii) can be used in order to provide a relatively simple description of varieties furnishing the corresponding counterexamples. While the description of these varieties is quite simple, the proofs that they indeed furnish the desired counterexamples rely heavily on the constructions and arguments from Sections 3 and 4. In the present section we also make some additional remarks summing up exactly what our counterexamples show.
Recall that lattice operations are denoted by juxtaposition and +, that Boolean complement is denoted by ′ . if n is odd. For every lattice L and 0 < i < n 2 , let L i,n be the algebra with base set L and with ternary operations t 1 , . . . , t n−1 defined as follows Notice that all the algebras of the form, say, L i,n as above are term-equivalent (with L fixed and n, i subject to the condition 0 < i < n 2 ). A similar remark applies to various classes of the above algebras. The point is that we shall combine various algebras of the above form in order to generate appropriate varieties. Some particular care is needed, since the exact labeling of the operations will turn out to be relevant. Notice also that L ℓ,n and A ℓ,n are defined both in the case n even and in the case n odd.
We now introduce some families of varieties.
Definition 9.2. As in Definition 9.1, assume n ≥ 2 and set ℓ = n 2 if n is even and ℓ = n−1 2 if n is odd. Notice that, for each algebra introduced in 9.1, the second superscript determines the type of the algebra, hence the following definitions are well-posed. Recall that 2 denotes the two-elements Boolean algebra and let C = C 2 be the two-elements lattice.
The above definition is intended in the sense that if, say, ℓ = 1, then V a n is generated by the algebra C 1,n . Similar conventions apply to the definitions below.
In particular, V b 2 is generated by A 1,2 , hence V a 2 is the term-reduct of the variety of Boolean algebras, with the term xz + xy ′ + y ′ z. (c) Let V c n be the variety generated by the algebras C 1,n , C 2,n , . . . , C ℓ−1,n , C ℓ,n .
In particular, V c 2 and V a 2 are the same variety. Moreover, V c 3 is equal to V a 3 , being the variety generated by C 1,3 , hence V c 3 is term-equivalent to the variety of distributive nearlattices, by a remark in Definition 3.11. (d) If n ≥ 4, let V d n be the variety generated by the algebras 2 1,n , C 2,n , C 3,n , . . . , C ℓ−1,n , C ℓ,n .
(e) Let V e n be the non-indexed product [29,53,61] of V a n and V b n . We shall not need the exact definition of the non-indexed product of two varieties; we shall only use the result that the non-indexed product of two varieties satisfies exactly all the Maltsev conditions satisfied by both varieties. (f) If n ≥ 3, let V f n be the non-indexed product of V c n and V d n+1 . (g) Let V g n be the variety generated by the algebras 2 1,n , 2 2,n , . . . , 2 ℓ−1,n , 2 ℓ,n .
Remark 9.3. Since both the variety of distributive lattices and the variety of Boolean algebras are generated by their 2-elements members, we get that if, say, C i,n belongs to the set of generators of some variety V as defined in 9.2 (a) -(d), then, for every distributive lattice L, the algebra L i,n , with the same superscripts, belongs to V. A similar observation applies to Boolean algebras. In other words, we could have defined V a n -V g n by considering a larger set of generators, namely, all the algebras of the form L i,n and A i,n , for the corresponding values of the indices and letting L and A vary among all distributive lattices and all Boolean algebras. The definitions make sense and all the results hold even if we let L vary among all lattices, except that in this case the varieties are not necessarily locally finite. If we let L be any lattice in place of C = C 2 in Definition 9.2, we shall call the corresponding varieties the extended V a n -V f n .
Remark 9.4. With the above definitions, if n is even, then the operations t 1 , . . . , t n−1 , together with the projections t 0 and t n , are Jónsson terms in the cases of L i,n , for i odd, and of A i,n , for i even, possibly with i = ℓ. Hence if n is even, then V a n is n-distributive. Similarly, if n is even, the operations t 1 , . . . , t n−1 provide alvin terms in the cases of L i,n , for i even, and of A i,n , for i odd. Hence if n is even, then V b n is n-alvin. For every n and i, in the case of L i,n , possibly i = ℓ, the operations provide directed Jónsson terms, thus, for every n ≥ 2, V c n is n-directed-distributive. Similarly, if n ≥ 4, then V d n is n-directed with alvin heads. Hence, adding the two projections as usual, we get a specular sequence (namely, a sequence satisfying (S) in Definition 6.1) of mixed Jónsson terms (in the sense of Definition 8.1). Notice that if n even, then t ℓ (x, y, z) = t ℓ (z, y, x) in each case. In view of (9.1), we could have introduced the algebras L i,n , L ℓ,n , A i,n , A ℓ,n and the varieties V a n -V d n and V g n by just defining the operations t 1 , . . . , t ℓ and then considering t ℓ+1 , . . . , t n−1 as defined terms. For all practical purposes the two possible approaches are equivalent. For the sake of uniformity, here it is notationally convenient to consider t 1 , . . . , t n−1 to be operations. Everything we shall prove will hold also for the term-equivalent algebras and varieties defined by considering only the operations t 1 , . . . , t ℓ . Definition 9.6. It will be convenient to introduce a special notation for algebras and varieties defined as in 9.1 and 9.2 when also the two trivial projections t 0 and t n are considered as operations. Of course, this is an unessential expansion and, moreover, t 0 and t n can be introduced anyway as terms. However, as already mentioned, it is important for our purposes to keep track of the exact number of operations.
If L is a lattice and A is a Boolean algebra, let L i,n,+ , L ℓ,n,+ , A i,n,+ and A ℓ,n,+ be constructed as in Definition 9.1, but adding also the two ternary operations t 0 and t n defined by t 0 (x, y, z) = x and t n (x, y, z) = z. We let V a,+ n , . . . , V d,+ n be the varieties defined correspondingly, as in Definition 9.2.
Computing exact levels.
Definition 9.7. If V is a congruence distributive variety, the distributive level of V is the smallest natural number n such that V is n-distributive, namely, the smallest n such that V has Jónsson terms t 0 , . . . , t n . The alvin, modular, etc., levels are defined in a similar way.
In the case of two-headed terms it is necessary to explicitly specify the convention. If some variety V has two-headed directed Gumm terms (directed terms with alvin heads) p, t 2 , . . . , t n−2 , q in the sense of Definitions 7.6(b)(c), we say that V is two-headed n-directed Gumm (n-directed with alvin heads). The counting convention is motivated by a remark in Definition 7.6(c) and, more generally, by the definitions and the results from Section 8. The two-headed directed Gumm level of a congruence modular variety V is the smallest n such that V is two-headed n-directed Gumm. The n-directed with alvin heads level is defined correspondingly.
Again, let ℓ = n 2 if n is even and ℓ = n−1 The switch level of some variety V is the smallest n (if such an n exists) such that either n is even and V satisfies the congruence identity α(β • γ) ⊆ (α(γ • β)) ℓ , or n is odd and V satisfies the congruence identity α(β • γ) ⊆ (α(γ • β)) ℓ • αγ. Notice that every congruence distributive variety has a switch level, since it has an alvin level; however, there are varieties with a switch level and which are not congruence distributive. See Remark 10.11(a).
The J-switch level of some variety V is the smallest n (if such an n exists) such that either n ≥ 2 is even and V satisfies the congruence identity α(β • γ) ⊆ αβ • (α(γ • β)) ℓ−1 • αγ, or n ≥ 3 is odd and V satisfies the congruence identity α(β • γ) ⊆ αβ • (α(γ • β)) ℓ . By definiteness, a trivial variety is considered to have all levels equal to 0. By Remark 4.6, for every n, the statement that some variety has switch level (J-switch level) ≤ n is equivalent to the existence of terms satisfying certain identities, namely, it is a strong Maltsev condition.
In passing, Proposition 3.10 and Theorem 4.5 suggest that it is interesting to study the levels determined by identities like α(β . . . We shall postpone the study of such levels. Some related results appear in [44]. Notice that the congruence identity The following theorem essentially sums up all the results of the present paper and adds some more.
Theorem 9.8. Under the above Definitions 9.2 and 9.7, the following table describes the levels of the varieties V a n -V f n , where n ≥ 2 is always assumed and in the starred entries n ≥ 4 is assumed.
n even n even n ≥ 4 n even n ≥ 3 distributive, J-switch n n+1 * 2n−2 2n−3 n+1 * 2n−1 alvin, Gumm Proof. Preliminary observations. (i) Assume that n is even. Following the proof of Theorem 4.1, we see that V a n is not 2n−1-reversed-modular and not 2n−2-modular. Correspondingly, V b n is not 2n−3-modular. Indeed, the examples constructed in the proof of Theorem 4.1 can be taken to be members of V a n and V b n . This is checked by induction on n. One base case in the proof of Theorem 4.1 can be taken to be the variety V a 2 , namely, the variety generated by C 1,2 . In fact, the proof of 4.1 uses the observation that lattices are not 3-permutable; then V a 2 is not 3-permutable, either, being a term-reduct of the variety of distributive lattices. Moreover, the existence of a majority term is enough to prove 2-distributivity. Similarly, the other base case can be taken to be V b 2 , the variety generated by 2 1,2 , noticing that V b 2 is 2-alvin and nontrivial. Now suppose that n ≥ 4, n is even, D belongs to V b n−2 and witnesses that condition (ii) in Theorem 4.1 fails with n − 2 in place of n, that is, D is not 2n−7modular. It is no loss of generality to assume that D has also the operations t 0 and t n , the projections onto the first and the third coordinate. Namely, we can assume that D belongs to V b,+ n−2 , as introduced in Definition 9.6. By Remark 9.4, D has alvin operations s 0 , . . . , s n−2 . Recall that V b,+ n−2 is generated by the algebras 2 1,n−2,+ , C 2,n−2,+ , 2 3,n−2,+ , . . . from Definitions 9.1 and 9.6. By Birkhoff's Theorem, D can be constructed from 2 1,n−2,+ , C 2,n−2,+ , 2 3,n−2,+ , . . . by means of the usual operators of taking products, subalgebras and homomorphic images. Now recall the definitions, notation and procedures in Construction 3.4. When we pass from D to A 4 there, we shift all the indices of the operations by 1. Hence A 4 can be constructed using the corresponding "shifts" of the generators, namely, A 4 belongs to the variety generated by 2 2,n , C 3,n , 2 4,n , . . . . Notice that, say, 2 1,n−2,+ and 2 2,n have the same number of operations, since 2 1,n−2,+ is obtained from 2 1,n−2 by adding the two trivial projections, hence the number of operations is augmented by 2. Moreover, say, the index i at which we take the equation t i (x, y, z) = x(y ′ + z) is shifted by 1; this justifies the shift by 1 of the indices in the first upper position.
On the other hand, each of the algebras A 1 , A 2 and A 3 from Construction 3.4 has the form L 1,n , for an appropriate distributive lattice L (as we have mentioned at the beginning of Construction 3.2, the number n is not explicitly indicated in the notations in Section 3). Hence A 1 , A 2 and A 3 belong to the variety generated by C 1,n , by Remark 9.3. In conclusion, under the above assumptions, the algebra E = A 1 × A 2 × A 3 × A 4 from Construction 3.4 belongs to the variety generated by C 1,n , 2 2,n , C 3,n , 2 4,n , . . . , namely, to V a n . Thus also the substructure B = B(a, d) of A 1 × A 2 × A 3 × A 4 belongs to V a n , for appropriate a, d ∈ A 4 . By Theorem 3.7(i) we have that V a n is not 2n−1-reversed-modular. The parallel step of the induction is similar, starting with an algebra D in V a not n-distributive, otherwise this would contradict (4.6) in Theorem 4.5; in particular, V b n is not n−1-alvin, by Remark 2.6(b). For n = 2, V b 2 is a non trivial arithmetical variety, hence all the levels of V b 2 are equal to 2, except for the twoheaded directed Gumm and the directed with alvin heads levels which are defined only for n ≥ 4. By setting s 1 (x, y, z) = t 1 (x, y, z), s n−1 (x, y, z) = t n−1 (x, y, z) and s h (x, y, z) = t h (x, t h (x, y, z), z), for 1 < h < n − 1 we get terms witnessing the directed with alvin heads level. All the rest is similar to (a).
(c) Concerning V c n , notice that, arguing as in the above preliminary observation (i), the counterexamples both in Theorem 5.1(i) and in Theorem 5.2(ii)(iii) can be taken to be members of V c n . Thus V c n is n-directed-distributive, not 2n−1reversed-modular, not 2n−2-alvin, has switch level > 2n−2 and J-switch level > 2n−3. Moreover, V c n is 2n−2-distributive by [30,Observation 1.2] or Proposition 8.3. In particular, V c n has J-switch level ≤ 2n−2, hence switch level ≤ 2n−1. The variety V c n is 2n−1-modular by Corollary 8.11(i). Were V c n two-headed n+1-directed Gumm, or n+1-directed with alvin heads, it would be 2n−1-reversed-modular by Corollary 8.11(ii)(c), a contradiction. On the other hand, as we mentioned in (a), every n-directed-distributive variety is trivially n+2-directed with alvin heads, in particular, two-headed n+2-directed Gumm: just take trivial projections "at the heads".
(d) A large part of the fourth column follows from Theorem 7.7. Arguing as in the preliminary observation (i), we see that we can take V d n to be a counterexample as constructed in the proof of Theorem 7.7(ii), in particular, V d n is n-directed with alvin heads, 2n−3-reversed modular and not 2n−3-modular. As far as the first two lines in the table are concerned, apply Construction 3.13 to some appropriate algebra D in V c,+ n−2 . Since V c,+ n−2 is not 2n−7-distributive and not 2n−6-alvin, we get that V d n is not 2n−5-alvin and not 2n−4-distributive, again by the preliminary observation (i) and Theorem 3.14(iv). Hence V d n is not n−1-mixed Jónsson, since otherwise it would be 2n−4-distributive, by Proposition 8.3. By (c), V c,+ n−2 has switch level 2n−5, hence, by Theorem 3.14(iv), as above we get that the J-switch level of V d n is > 2n−4, hence the switch level is > 2n−5. Finally, V d n is 2n−4-alvin (hence 2n−3-distributive) by Remark 8.10.
(e) It is almost obvious that, except for the mixed level, each entry in the fifth column is the maximum of the corresponding entries in the first two columns. To prove the result formally, recall that, as we mentioned, the non-indexed product of two varieties W and W ′ satisfies exactly the same Maltsev conditions satisfied both by W and W ′ [29,53,61]. Each assertion that some level (except for the mixed level) of a variety is ≤ k is a strong Maltsev condition, thus we get the levels for V e n . The mixed Jónsson level is an exception, since it is a disjunction of Maltsev conditions: the equations to be satisfied vary and are not fixed in advance. However, by Corollary 8.11(i), the mixed level of V e n is > n−1, since V e n is not 2n−3-modular. Obviously, the mixed level of V e n is ≤ n, since V e n is n-directed distributive. (f) The levels of V f n are computed in the same way as (e).
Proof. It is trivial to see that V g n has Pixley terms t 0 , . . . , t n . The definition of Pixley terms has been recalled in Remark 8.2. Thus V g n is both n-permutable and congruence distributive [30,38]. All the other conditions in the first sentence follow immediately by Remarks 2.5 and 2.10.
If n = 2, then all the conditions in the second sentence fail for V g 2 , since if n = 2 the conditions are satisfied only in trivial varieties. The variety V g 3 is a termreduct of the variety I of implication algebras. See, e. g., [42, p. 17]. Mitschke [50] shows that I is neither congruence permutable, nor 2-distributive. All the other conditions in the second sentence, for n = 3, imply congruence permutability, hence they fail in I, a fortiori, they fail in the reduct V g 3 . Then, by induction and arguing as in the proof of Theorem 9.8, we get that, for every n ≥ 2, V g n is neither n−1modular, nor n−1-reversed-modular, by using Theorem 3.14(iii). We get that V g n is neither n−1-distributive, nor n−1-alvin, by using Theorem 3.14(iv). All the above conditions would be provable from n−1-permutability (together with congruence distributivity), hence V g n is not n−1-permutable, either. Problem 9.10. Determine the directed distributive and the mixed levels of V g n . Remark 9.11. (a) If some variety V has specular Jónsson, alvin, etc. terms, we can define the corresponding specular levels. It seems that there is no meaningful definition of specular levels for the Gumm and the directed Gumm conditions.
As we shall explicitly point out below in some special cases, the table in the statement of Theorem 9.8 generally provides the specular levels of the varieties under consideration. Essentially, the values in the table give the specular levels for odd values of the indices in the case of the modular and reversed modular levels, for indices of arbitrary parity in the case of directed levels and for even values of the indices in the remaining meaningful cases. Cf. Remark 6.3. Generally, for other values of the indices, the specular level is given by the next natural number.
(b) The table in the statement of Theorem 9.8 provides also the levels for the extended varieties V a n -V f n in the sense of Remark 9.3. Indeed, we have not used lattice distributivity in order to prove, say, n-distributivity, n-directed distributivity etc. On the other hand, the original (not extended) varieties are subvarieties of the corresponding extended varieties, hence the levels of the latter are ≥ than the levels of the former.
Some consequences. It is well-known that, for every n ≥ 2, there is an ndistributive (n-modular) not n−1-distributive (not n−1-modular) variety; see [11,14,19,28,29,34,35,37], among others. As we mentioned, n-distributive and n-alvin are equivalent if n is odd; moreover, 2-alvin implies 2-distributive and there is a 2-distributive not 2-alvin variety. Freese and Valeriote [19] showed, among many other things, that no more nontrivial relation holds about the two notions, namely they showed that, for every even n ≥ 4, there is an n-distributive (n-alvin) variety which is not n-alvin (n-distributive). The present paper provides another proof of the above results; we shall then obtain analogue results for modularity and reversed modularity. Our constructions might share some aspects in common with the above-mentioned works; we have not fully checked this. Other papers which might contain constructions bearing some resemblance with the present ones are [5,10].
(ii) For every even n ≥ 4, there is an n-alvin not n-distributive variety. (iii) For every n ≥ 2, there is a variety which is both n-distributive and n-alvin, but neither n−1-distributive nor n−1-alvin.
All the above varieties can be taken to be locally finite. For n even, all the above varieties can be taken to satisfy the specular conditions from Definition 6.1.
Proof. (i) is given by V a n or by V c ℓ with ℓ = 1 + n 2 . (ii) is given by V b n or by V d ℓ with ℓ = 2 + n 2 . Notice that every 2-alvin variety is congruence permutable, hence 2-distributive, so that the assumption n ≥ 4 in (ii) is necessary.
(iii) The result appears on [19, p. 71]. We can also use Proposition 9.9 and the variety V g n . It is not clear whether the two counterexamples are really distinct. For n ≥ 5 and n odd the varieties V e n−1 and V f ℓ for ℓ = n+1 2 furnish other counterexamples.
The varieties V a n and V b n satisfy the specular conditions by construction. The variety V g n , too, is constructed in a specular way, but the terms defining V g n are Pixley, not necessarily Jónsson or alvin. When n is even, in order to get a sequence of specular Jónsson (resp. alvin) terms for V g n , let us define, for 0 < h < n, for h odd (resp. even), and s h (x, y, z) = t h (x, y, z), for h even (resp. odd). and (ii) is witnessed by V d n with n = m+3 2 . Notice that every 3-reversed-modular variety is 3-permutable, hence 3-modular. This shows that the assumption m ≥ 5 is necessary in (ii).
(iii) follows from Proposition 9.9. When m is even and m ≥ 6, V f n furnishes another counterexample.
The sequences of the operations in the algebras generating V c n and V d n are specular. If we apply the proofs of Theorems 5.1(ii) and 7.7(i) we get specular Day (reversed Day) terms. See Remark 6.4(a).
For every n ≥ 4, there is a two-headed n-directed Gumm (n-directed with alvin heads) locally finite variety which is not two-headed n−1-directed Gumm (not n−1directed with alvin heads).
Proof. The counterexamples are given by V b n and V a n , according to the parity of n, in the Gumm case, by V c n in the directed distributive case and by V d n in the remaining cases.
Recall that the variety N L of nearlattices is the term-reduct of the variety of lattices obtained by considering the term t N L (x, y, z) = xy + xz. Many authors use the dual term, but for our purposes the two choices are equivalent. The variety B d of distributive nearlattices is defined similarly, considering only reducts of distributive lattices. See Definition 3.11 and [7,9] for further details. Since, as we mentioned after its definition, V c 3 is term-equivalent to B d , then the two varieties share the same levels. Arguing as in Remark 9.11(b), it is easy to see that N L shares the same levels, too. Proof. Since V c 3 and B d are term-equivalent, they share the same levels; moreover, the levels of N L are not strictly lower than the levels of B d , since B d is a subvariety of N L. On the positive side, as well-known, the terms t 1 = t N L (x, y, z) = xy + xz, t 2 = t N L (x, z, z) = xz and t 3 = t N L (z, y, x) witness that N L is 4-distributive. Moreover, s 1 = t 1 and s 2 = t 3 witness that N L is 3-directed-distributive. All the rest follows from Remark 2.6(b) and Theorem 5.1(ii).
Of course, we do not need the full power of Theorem 9.8 to get the present corollary; essentially, the only main result we need is Proposition 3.12.
Remark 9.16. Of course, it is interesting to take non-indexed products of other pairs, triplets, etc. of varieties from Definition 9.2, possibly, together with other known varieties. In any case, each level (except possibly for the mixed Jónsson level) of such a product is the maximum of the levels of the factors, as explained in the proof of 9.8. We leave the computations to the interested reader.
Remark 9.17. (a) Definition 9.2 can be obviously modified in order to construct varieties satisfying arbitrary mixed conditions which are also specular, in the sense of Definition 6.1. Here we require only specularity, we are not assuming that l(i) from Definition 8.5 satisfies any rule prescribed in advance. Thus we are not assuming that, say, l(i) has a constant value, as in the directed or in the Pixley conditions, or an alternating value, as in the Jónsson and the alvin conditions.
To construct a variety satisfying some specular mixed condition, just merge the algebras C i,n and 2 i,n , for fixed n, using different and appropriate patterns, in comparison with the varieties constructed in Definition 9.2. Use Remark 8.7(a).
On the other hand, in the case of mixed conditions which are not specular, the algebras from Remark 10.5 below can be used. Of course, the simple fact that we can construct some variety satisfying a desired Maltsev condition M does not necessarily entail that such a variety is sufficiently "generic" to furnish a counterexample to other Maltsev conditions which are not implied by M. In this respect, we have been rather lucky, as far as the results presented in this paper are concerned, since we have generally obtained the best possible values for distributivity and modularity levels. Concerning the general case, we expect that the case of specular conditions is simpler in comparison with the case of possibly non specular conditions.
(b) The above comment explains the reason why presently we are not able to get optimal values for levels of varieties with directed Gumm terms, since this is not a specular condition. Of course, every n−1-directed-distributive variety is ndirected Gumm, hence we get intervals for the best possible values. For example, by Corollary 8.11(ii)(b), every n-directed Gumm variety is 2n−2-modular. On the other hand, V c n−1 is n-directed Gumm and not 2n−4-modular. (c) The situation depicted in (b) might appear similar with respect to (undirected) Gumm terms, whose defining condition is not specular. However, the Gumm condition is a defective version of the alvin condition, which is indeed specular, for n even. Together with the study of switch levels, the above fact has permitted us to compute exactly optimal Gumm levels.
With hindsight, this also follows from the main result in [43], asserting that in a congruence distributive variety the alvin and the Gumm levels coincide.
(d) Accordingly, in all the examples presented in this paper we get varieties with the same alvin and Gumm levels, as exemplified in the second line in the table in Theorem 9.8. Since the alvin condition is equivalent to congruence distributivity, while the Gumm condition is equivalent to congruence modularity, there are varieties with a Gumm level and for which the alvin level is not even defined. However, as we mentioned, and quite surprisingly, in a congruence distributive variety the two levels always coincide [43]. In this respect, compare also Problem 10.10

Further remarks
Generalizations and problems.
Moreover, if n, q ≥ 2, then the congruence identity fails in V n c , where n is possibly odd, β • = β, γ • = γ if q is even and β • = γ, γ • = β if q is odd. Thus identity (5) generally fails in an n-directed-distributive variety. The failure of (5) is obtained as in the proofs of Theorems 5.1(i) and 5.2(iii). Compare [47] for similar arguments and for a parallel result. The special case q = 2 in (5) is Theorem 5.2(iii) and the case q = 3 in (5) implies Theorem 5.1(i) (b) The remarks in (a) will be probably useful in order to check whether some results from [41] are optimal.
In this respect, notice that it follows from [11] that every n-distributive variety satisfies the congruence identity α(β • γ • β) ⊆ αβ • αγ • 2n−1 . . . . See Remark 4.4. The assertion follows also from Theorem 8.8(ii), by taking S = β and T = γ. See [41] for still another proof and for more general results. Theorem 4.1 and, in particular, the variety V a n show that, for n even, the result is the best possible; actually, it cannot be improved under the additional assumption that γ ⊆ α. We do not know exactly what happens for n odd; see Problem 10.4 below. We do not know what happens if we consider longer chains of compositions on the left-hand side, namely, which are the best bounds for α(β • γ • k . . .)? Notice that in (a) we have considered expressions of the form α(β • αγ • αβ • · · · • αγ • β) or α(β • αγ • αβ • · · · • αβ • γ), instead. See again Remark 4.4 for possible differences between the two cases.
Remark 10.2. A. Mitschke [51] proved that every variety V with a near-unanimity term is congruence distributive, actually, that a variety with an m+2-ary nearunanimity term is 2m-distributive. In particular, any such variety is congruence modular and, by Day's Theorem, 4m−1-modular. Actually, L. Sequeira [58,Theorem 3.19] showed that a variety with an m+2-ary near-unanimity term is 2m+1modular. See also [45] for related results.
It can be shown that Mitschke's and Sequeira's results are optimal by combining various reducts of lattices using near-unanimity terms of the form, say, |{i,j,k}|=3 (x i +x j +x k ), more generally, |I|=k i∈I x i . We have presented details in [47]. Remark 10.3. In the case n odd we noticed in [46, Proposition 6.1] that Day's Theorem can be improved (at least) by 1, namely that if n > 1 and n is odd, then every n-distributive variety is 2n−2-modular. As we mentioned, this fact is implicit in [36] and can be also obtained as a consequence of Corollary 8.11(ii)(b).
While we do not know what is the best possible result, Theorem 1.2 implies that in the case n odd Day's Theorem can be improved at most by 2. Indeed, it is trivial that every n−1-distributive variety is n-distributive. Hence, if n is odd, thus n − 1 is even, then Theorem 1.2 provides an n−1-distributive variety (thus also n-distributive) which is not 2n−4-modular. Alternatively, for odd n ≥ 5, V e n−1 is n-distributive and not 2n−4-modular, by Theorem 9.8.
We are not claiming that the problems below are difficult; apparently, they are not solved by the present work. In connection with problems (a) and (b) below, observe that many congruence and relation identities valid in 3-distributive varieties have been described in [41,42]. In connection with (c), see Remark 10.3. In connection with (d), notice that, by Lemma 4.2(a) or Corollary 8.11(ii)(c), 4-alvin varieties satisfy α(β • αγ • β) ⊆ αγ • αβ • αγ • αβ • αγ. the assumption that, say,α is a congruence, in order to get that α is a congruence. Apart from this, the assumption that the relations at hand are congruences is not used in the proofs. Hence Theorems 3.7, 3.9 and 3.14 hold even in the case whenα, β andγ, or just some of them, are assumed to be, say, tolerances or reflexive and admissible relations, provided the corresponding assumptions are made relative to α, β or γ.
The above observation might be of interest, since there are deep problems involving relation identities in congruence distributive varieties. See, e. g., [42,45]. See also Remark 10.12 below. No matter how interesting the subject, in the present work we have limited ourselves to congruences. Remark 10.9. For practical purposes, we have defined an expression χ to be a term in the language {•, ∩}. See the convention introduced right before Theorem 3.7. Anyway, we have used only a very weak property of such terms. The statements of Theorems 3.7, 3.9 and 3.14 apply to any expression in the following more extensive sense.
(E) Whenever A 1 , A 2 are algebras of the same type, B ⊆ A 1 × A 2 , α 1 , β 1 , . . . holds, for every algebra A, for every m-uple of congruences on A and for every morphism ϕ with domain A. However, at first sight, the condition (H) seems slightly stronger than (E). Let us mention that condition (H) is useful also in different contexts. See [40, Section 3] and further references there. As in Remark 10.8, we can replace the word "congruence" in the above definitions with "reflexive and admissible relation".
From a wider perspective. Problem 10.10. In this paper we have considered only one side of the problem of the relationships among the modularity and the distributivity levels of congruence distributive varieties. As mentioned at the beginning of the introduction, it follows abstractly just from the theory of Maltsev conditions that, for every n, there is some m(n) such that every n-distributive variety is m(n)-modular. We have evaluated the best possible value, namely, m(n) = 2n − 1, in the case n even, and showed that if n is odd, the only possibilities for the best value are m(n) = 2n − 2 or m(n) = 2n − 3. See Remark 10.3.
At first sight, the other direction looks completely and vacuously trivial, since there are congruence modular varieties (actually, congruence permutable, namely, 2-modular varieties) which are not congruence distributive. However, the problem is completely nontrivial if we study the relationship among the modularity and distributivity levels of some variety V, assuming that V is congruence distributive.
As we mentioned, we have showed in [43] that in a congruence distributive variety the alvin level and the Gumm levels coincide. In particular, we get from [36] that To check (10.2), assume that a β b γ c β d γ e and a α c α e. Then a = s 1 (a, b, b) αγ s 1 (a, b, c) β s 1 (b, b, c) = t 2 (b, c, c) β t 2 (b, c, d) γ t 2 (c, c, d) = s 3 (c, d, d) γ s 3 (c, d, e) αβ s 3 (d, d, e) = e.
Remark 10.12. Define an equivalence relation ∼ CL between varieties as follows: V ∼ CL W if congruence lattices of algebras in V and W satisfy exactly the same identities.
In passing, notice that the relation ∼ CL arises by means of a Galois connection from the more frequently considered relation |= Con between lattice identities. The relation ε |= Con ε ′ means that, for every variety V, if V |= Con ε, then V |= Con ε ′ . As usual, V |= Con ε means that every congruence lattice of algebras in V satisfies ε. See [29] for a survey about the notion.
The relation ∼ CL is rather rough, for example, all nontrivial congruence distributive varieties form a single equivalence class. As already implicit in [28], it is interesting to study a finer relation ∼ Co defined by V ∼ Co W if the set of congruence relations of algebras in V and W satisfy the same identities expressed in the language with +, · and • (for two relations R and S it is convenient to interpret R + S as the transitive closure of R • S).
Theorem 9.8 and Proposition 9.9 show that the varieties V a n -V g n are pairwise not ∼ Co -equivalent, say, for all even n > 4. Notice that some assumption on n is necessary, since there are some trivial initial cases, e. g., V a 2 and V c 2 are the same variety.
A finer relation can be considered: write V ∼ Rel W to mean that the set of reflexive and admissible relations of algebras in V and W satisfy the same identities expressed in the language with +, · and •. Results from [42,45] show that ∼ Rel is strictly finer than ∼ Co .
In conclusion, there are viable intermediate alternatives strictly between congruence identities and the lattice of interpretability types [20,53].
In order to keep the following list within a reasonable length, we have sometimes quoted survey works rather than original sources. The reader is advised to consult the quoted works for credits to the original studies.