Local loop lemma

We prove that an idempotent operation generates a loop from a strongly connected digraph containing directed cycles of all lengths under very mild (local) algebraic assumptions. Using the result, we reprove the existence of a weakest non-trivial idempotent equations, and that a strongly connected digraph with algebraic length 1 compatible with a Taylor term has a loop.


Introduction
Theorems that give a loop in a graph under certain algebraic and structural assumptions play an important role in universal algebra and constraint satisfaction problem. One example of such a "loop lemma" is the following one. • is smooth (has no sources and no sinks), • has algebraic length 1 (cannot be homomorphically mapped to a non-trivial directed cycle) and • is compatible with a Taylor term, then G contains a loop.
The consequences of this loop lemma include the following.
• [2] If a digraph G has no sources and no sinks, and G has a component that cannot be homomorphically mapped to a circle, then constraint satisfaction problem over G is NP-complete. This was a positive answer to an influential the Hell-Nešetřil conjecture [7] in the domain of computational complexity.
• [8] Every locally-finite Taylor algebra has a term operation s satisfying s(r, a, r, e) = s(a, r, e, a). Taylor varieties are essential in universal algebra, especially in tame congruence theory and Maltsev conditions. The fact that locally finite Taylor algebras can be characterized by such a simple condition was utterly unexpected in universal algebra, and a similar condition was later found for infinite Taylor algebras [10].
• [1] Every finite Taylor algebra A has cyclic terms of all prime number arities bigger than |A|. This, not so direct, application of loop lemma ranks among the strongest characterizations of finite Taylor algebras.
The modern proof [1] of the loop lemma above requires idempotency and is based on absorption. An operation f is said to be idempotent if f (x, x, . . . , x) = x for any x. The definition of absorption is slightly more complex. Let A be a set, X, Y subsets of A, and f be an n-ary operation on A. We say that X absorbs Y with respect to f if for any coordinate i = 0, . . . , n − 1 and any elements x 0 , x 1 , . . . , x i−1 , y, x i+1 , . . . , x n−1 ∈ A such that y ∈ Y and each x j ∈ X, we have t(x 0 , x 1 , . . . , x i−1 , y, x i+1 , . . . , x n−1 ) ∈ X.
Another loop lemma based on absorption, which was used for the proof that there are the weakest non-trivial idempotent equations [10] and which drops the finiteness assumption, has the following form.
Theorem 1.2. Let G be an undirected, not necessarily finite graph that contains an odd cycle and is compatible with an idempotent operation f . Assume that for every non-isolated node x ∈ G, the set of neighbors of x absorbs {x} with respect to f . Then G has a loop.
The absorption assumption in Theorem 1.2 is not particularly strong, it is weaker than compatibility with NU term, or absorption of a diagonal by the edges of G, see Proposition 4.5 in [10]. On the other hand, it still requires some form of homogeneity -it have to be satisfied for every non-isolated node x, and the definition of absorption hides another universal quantifiers inside. The idea that such level of homogeneity may not be necessary was expressed by the following question in [10] Question 1.3. Let G be an undirected graph, containing a cycle of odd length with an element a. Moreover let f be an idempotent operation compatible with G such that the neighborhood of the node a absorbs {a} with respect to f . Does G necessarily contain a loop?
A slight progress in this area was made before. L. Barto has found a proof for finite set A, and also a general proof in the case of cycle of length 3 was found. The main result of this paper is a version of loop lemma under even significantly weaker assumptions than the original question. That makes our "local loop lemma" one of the strongest, even among finite loop lemmata. Theorem 1.4 (local loop lemma). Consider a set A, operation t : A n → A a digraph G on A, and vertices α i,j ∈ G for i, j ∈ {0, . . . , n − 1} such that (1) t is idempotent, (2) G is compatible with t, (3) G is either a strongly connected digraph containing directed cycles of all lengths starting with two, or G is an undirected connected non-bipartite graph.
Proof of positive answer to Question 1.3. Consider an element x ∈ A in an odd cycle such that the neighborhood of x absorbs {x}. Then the component of x is closed under t (see Corollary 2.6 for detailed explanation), so we can restrict to that component. The item (4) is satisfied by putting α i,i = x and α i,j = y otherwise, where y is any element in the neighborhood of x. Then t(y, . . . , y, x, y, . . . , y) is in the neighborhood by absorption, so Note that the absorption approach is not the only one widely used to tackle loop lemmata. The oldest method is based on performing pp-definitions and ppinterpretations mostly on the graph side. This resulted in older, weaker versions of Theorem 1.1, see [5,7], but also provides a state-of-the-art version of loop lemma for oligomorphic structures [3]. The most recent technique is based on the correspondence of certain loop lemmata with Maltsev conditions, see [9,11,6]. However, none of the methods available are local enough for our purposes. Therefore, we have chosen a different approach, a blindly straightforward one. The only thing we actually do is that we define what exactly to plug into a star-power of the operation t to get a loop. Yet, such an approach appears to be among the most efficient ones.

Outline
In section 2 we give proper definitions of the used terms, alongside with our notation for finite sequences that will be used in the main proof. In section 3 we prove our main result, Theorem 1.4. In section 4, we prove a stronger local version of the existence of a weakest non-trivial equations, the main result from [10]. In section 5. we get further strengthening of Theorem 1.4 that yields a version of Theorem 1.1 with slightly stronger relational assumption (strongly connected digraph) but slightly weaker algebraic assumptions. In section 6, we discuss possible further generalizations of the main result.

Words, integer intervals
Consider a set A representing an alphabet. By a word, we mean a finite sequence of elements in A. The set of all words in the alphabet A of length n is denoted by A n . For manipulation with words, we use a Python-like syntax.
• x = [a 0 , a 1 , . . . , a n−1 ] represents a word of length n, The length of x is denoted by |x|.
• Elements of the word x can be extracted using an index in round brackets after the word, that is x[i] = a i . The first position is indexed by zero. By a position in a word we mean an integer that represents a valid index.
Notice that the interval includes i and does not include j.
• If i or j is omitted, the boundaries of the word are used. That is • Inspired by the subword notation, we use single [i : j] to represent an integer interval. That is [i : j] = {i, i + 1, . . . , j − 1}, where i, j can be arbitrary integers. Notice that i is included in that interval while j is not. If i is omitted, it is meant implicitly as zero, that is [: n] = {0, 1, . . . , n−1}.
The set of all integers is denoted by Z.
A word x is said to be periodic with a period k ≥ 1, or briefly k-periodic, if x[i] = x[i + k] whenever both i and i + k are valid indices. Alternatively speaking, x ∈ A n is k-periodic if k ≥ n or x[: n − k] = x[k :]. A 1-periodic word is also called a constant word. In our proof, we use the following well-known property of periodic words.

Operations, star powers
An n-ary operation t on a set A is a mapping t : A n → A. Instead of t([a 0 , . . . , a n−1 ]), we simply write t(a 0 , . . . , a n−1 ). An operation t on A is said to be idempotent if t(x, x, . . . , x) = x for every x ∈ A.
For a given n-ary operation t and a non-negative integer k we recursively define k-th star power of t, denoted t * k , to be n k -ary operation given by We perceive variables in star powers as being indexed by words in [: n] k , where the left-most letters corresponds to the outer-most position in the composition tree. More precisely, a substitution of variables in a star power t * k is represented by a function f :

Algebras, equations
A signature Σ is a set of symbols accompanied with their arities. An abstract algebra A = (A, t 0 , t 1 , . . .) in the signature Σ is a set A together with representations of symbols in Σ as actual basic operations on A of the corresponding arities. A term in a signature Σ is a syntactically valid expression using the term symbols of Σ and variables. A term operation in A is an operation on A that can be written as a term in Σ, represented by basic operations in A.
An equation in Σ is a pair of terms in Σ written as t 0 ≈ t 1 . An equational condition C is a system of equations in any signature, say ∆. An algebra A is said to satisfy an equational condition C if it is possible to assign some term operations in A to the symbols in ∆ so that all the equations in C hold for any choice of variables in A.
Equational conditions are thoroughly studied in universal algebra in the form of strong Maltsev conditions (equational conditions consisting of finitely many equations) and Maltsev conditions (infinite disjunction of strong Maltsev conditions). Of particular interest are the Taylor equations that represents the weakest non-trivial idempotent Maltsev condition. The signature consists of a single n-ary symbol t. The Taylor system of equations is any system of n equations of the form t( where each question mark stands for either x or y. A Taylor operation is any operation satisfying any Taylor system of equations. A quasi Taylor system of equations is a Taylor system of equations without the last one requiring idempotency. For the purposes of our proofs, we enumerate the first n (quasi) Taylor equations from top to bottom by integers from 0 to n − 1. For more background on universal algebra, we refer the reader to [4]. Note that it was recently proved [10] that the weakest non-trivial idempotent Maltsev condition can be written in a specific form of a strong Maltsev condition. We reprove this fact in Section 4.

Relations, digraphs
An n-ary relation on a set A is any subset of A n . A relation R is said to be compatible with an m-ary operation t, if for any tuple of words r 0 , r 1 , . . . , r m−1 ∈ R, the the result of t(r 0 , r 1 , . . . , r m−1 ) is in R as well, where the operation t is applied to r 0 , . . . r m−1 point-wise. A relation is said to be compatible with an algebra A if it is compatible with all basic operations of A, or algebraically said, if it is a subuniverse of an algebraic power A n . Notice that if a relation R is compatible with an algebra A, it is compatible with all term operations in A.
In particular, if R is compatible with an operation t, then R is compatible with any star power of t. A relational structure R = (A, R 0 , R 1 . . .) on A is the set A together with a collection of relations R 0 , R 1 . . . on A. An algebra A, or an operation t on A is compatible with a relational structure R on A, if A, or t, is compatible with all the relations in R.
A digraph G = (V, E) is a relational structure with a single binary relation. If the set E of edges is symmetric, we call the digraph an undirected graph. Given a digraph G = (V, E), we usually denote the edges by u → v instead of [u, v] ∈ E. By a n-walk from v 0 to v n , or simply a walk, we mean a sequence (word) of vertices in the digraph While we use most of the notation we have for words also for walks, we redefine a length of a walk to be n, that is one less than the length of the appropriate word of vertices. A cycle walk of length n, or n-cycle walk, is such an n-walk w that The n-th relational power G •n of a digraph G is a digraph with the same set of vertices, and u → v in G •n if and only if there is a n-walk in G from u to v. Notice that if a digraph G is compatible with an algebra A, any relational power of G is compatible with A as well.
A digraph is said to be strongly connected, if there is a walk from u to v for any pair of vertices u, v. We say that a digraph have an algebraic length 1, if it cannot be homomorphically mapped to a directed cycle of length greater than one.
We finish this chapter by proving basic combinatorial properties of strongly connected graphs of algebraic length 1. Proof. First observe that if all cycle walks in G are divisible by some n ≥ 2 and G is strongly connected, then G can be homomorphically mapped to the directed cycle of length n.
Therefore, since G is supposed to have has algebraic length 1, there are some cycle walks c 0 , . . . c k−1 such that the greatest common divisor of the lengths of the cycles equals one. Let w i denote a walk from u to There is a cycle walk starting in u of any length of the form where x 0 , x 1 , . . . , x k−1 stands for any non-negative integer coefficients. Since gcd(|c 0 |, . . . , |c k−1 |) = 1, this number can reach any large enough integer.
Proposition 2.4. If G is a finite strongly connected digraph with algebraic length 1, then there is an integer K such that there is a k-walk from v 0 to v 1 for any v 0 , v 1 ∈ G and k ≥ K.
Fix an element u ∈ G. By Proposition 2.3, there is such a length C that there is a c-cycle walk from u to u of any length c ≥ C. Thus the choice K = d + C + d works for any Proposition 2.5. Let t be an idempotent n-ary operation compatible with a graph G. Let H ⊂ G be a strongly connected component of G that have an algebraic length 1. Then H is closed under t.
Proof. Fix a vertex u ∈ H. By Proposition 2.3, there is such a length C that there are c-cycle walks from u to u of any length c ≥ C. Consider any v 0 , . . . , v n−1 ∈ H. We prove that there is a walk from u to t(v 0 , . . . , v n−1 ). Let w i denote a walk from u to v i . There are also walks from u to v i of a fixed length k = C + max(|w 0 |, |w 1 |, . . . , |w n |).
Corollary 2.6. Let H be a non-bipartite connected component of an undirected graph G compatible with an idempotent operation t. Then H is closed under the operation t.

Proof of the local loop lemma
We prove the local loop lemma in the following form.
(3) G is a strongly connected digraph containing cycle walks of all lengths greater that one, Then G contains a loop.
Theorem 3.1 differs from Theorem 1.4 in the item (3), where Theorem 1.4 allows also an undirected connected non-bipartite graph. We start by explaining how Theorem 1.4 follows from Theorem 3.1, Proof of Theorem 1.4. If G has cycle walks of all lengths greater than one, we get a loop directly by Theorem 3.1. Assume that it does not, thus G is an undirected connected non-bipartite graph. Therefore, there is a cycle of odd length in G, let us denote the smallest odd length of such a cycle by l. To obtain a contradiction, assume that there is no loop in G, hence l ≥ 3. Observe that G contains cycle walks of all lengths l ′ ≥ l − 1: there are cycle walks of any even length jumping around a single edge, and cycle walks of any odd length greater that l − 1 that first go around a cycle of length l and then jumps around a single edge.
Consider the graph G ′ = G •(l−2) . By minimality of l, G ′ does not have a loop. Since l−2 is an odd number and G is undirected, the edges of G •(l−2) form a superset of the edge set of G, hence G ′ satisfies the item (4) of Theorem 3.1 about α i,j . Compatibility of G ′ with t, that is item (2), follows from basic properties of relational powers. Since G contains a cycle walk of every length greater than l − 2, the digraph G ′ contains a cycle walk of any length greater than 1. Therefore, by Theorem 3.1, there is a loop in G ′ corresponding to a cycle walk of length l − 2 in G which contradicts the minimality of l.
The proof of Theorem 3.1 relies on the following technical proposition.
Proposition 3.2. Let n be a positive integer and A denote [: n]. Consider a strongly connected digraph G that contains cycle walks of all lengths, and let α i,j be any vertices of G. Then there is a positive integer N and a mapping f : A N → G (substitution to the star power) such that for any x ∈ A N one of the following cases happen: Proof of Theorem 3.1. Take the substitution function f : A N → G given by Proposition 3.2. Based on that, we define two functions f 0 , f 1 : By idempotency of t, the functions f ′ 0 and f are identical. Therefore . We verify the edge by checking an edge from f ′ 0 (x) to f ′ 1 (x) for any x ∈ A N . We analyze the two cases of the behavior of f on x.
(2) If there is an edge for every i ∈ A, then by compatibility of t and G, there is an edge Proposition 3.2 will be proved in the following two subsections. In Subsection 3.1 we explicitly define the function f , in Subsection 3.2 we prove that the function f satisfy the required properties. Before that we reduce the problem to a finite case. Lemma 3.3. Let G be a strongly digraph that contains a cycle walk of every length greater than one. Let A be a finite set of vertices in G. Then there is a finite subdigraph G ′ ⊂ G that is strongly connected and contains a cycle walk of every length greater than 1 and all elements of A, Proof. We start with a finite subdigraph G 0 ⊂ G with algebraic length oneit suffices to put any two coprime cycle walks of G into G 0 and connect them. Thus there is a length C such that G 0 contains a c-cycle walk for any c ≥ C. We construct G ′ by adding the following edges and nodes into G 0 : • one cycle walk of every length in the interval [2 : C], • all the vertices in A, • paths connecting the elements in previous items to a fixed node in G 0 and vice versa.
These are finitely many edges and vertices in total. The final G ′ is therefore finite while it meets the required criteria.

Construction of the substitution f
In this section, we construct a witness to the Proposition 3.2. In particular, we consider the digraph G, positive integer n and vertices α i,j and define an appropriate integer N and a function f : By Lemma 3.3, we can assume that G is finite. Consequently, we can use Proposition 2.4 and get K such that K ≥ 2 and there are k-walks from v 0 to v 1 for any v 0 , v 1 ∈ G and k ≥ K. For every v 0 , v 1 , k, we fix such a walk and denote it by walk(v 0 , v 1 , k). We define the length N as N = L + W + R (left, window, right), where • M = 2(K − 1) · n W + (K − 1).
The overall idea is to evaluate f (x) primarily by the "window" x[L : L + W ], or to investigate the neighborhood of this window, if necessary. We start with constructing a priority function π : A W → Z and a value function ν : A W → G of the following properties.
(2) If w is periodic with the shortest period k ∈ [2 : K], then π(w) = R and there is a k-cycle walk (3) If w[: W − 1] is constant but w is not, then π(w) = R.
(4) If w is not periodic with a period smaller than K and w[: W − 1] is not constant, then π(w) is negative.
The construction of such functions is straightforward. To satisfy the conditions 1, 3 we simply set the appropriate values of π and ν. The items 4 5 can be satisfied since there are infinitely many negative numbers and just finitely many possible words of length W . Finally, to meet the condition 2, for all k ∈ • Let q ∈ [p : N − W + 1] be the right-most position such that x[p : q + W ] is constant. We redefine π x (p) to be min(q − p, R − 1) instead of zero.
Based on the priority function π x : [: We are finally ready to construct the function f : A N → G. If L is a local maximum in x, we simply set f (x) = ν x (L). Otherwise, we find the closest local maxima to L from both sides. In particular let p < L be the right-most local maximum before L, and let q > L be the left-most local maximum after L. We claim that these positions exist and that q − p ≥ K, these claims are proved in the following subsection. In that case we set

Proofs
In this section, we fill the missing proofs in the construction. In particular, we prove the following.
• It is possible to find a local maximum on both sides of the position L in any x ∈ A N (Corollary 3.10).
• If L is not a local maximum and p, q are local maxima such that p < L < q, then q − p ≥ K (Corollary 3.5).
• The constructed mapping f meets the criteria given by Proposition 3.2 (Proposition 3.14).
Lemma 3.4. Let p < q be local maxima in x such that q − p < K. Then ν x (p) = ν x (q) ≥ R − 1 and the segment x[p : q + W ] is periodic with a period strictly less than K.
Proof. Since both p, q are local maxima, ν x (p) = ν x (q). First we prove that ν x (p) ≥ 0. To obtain a contradiction, suppose that ν x (p) < 0. Then x[p : p + W ] = x[q : q + W ] by injectivity of the function ν on negative values. Hence x[p : q + W ] is periodic with a period q − p < K. That contradicts the assumption that ν x (p) < 0. Therefore ν x (p) ≥ 0, and both subwords w 0 = x[p : p + W − 1] and w 1 = x[q : q+W −1] are periodic with periods less than K, let us denote their shortest periods k 0 , k 1 respectively. Their intersection w = x[q : p + W − 1] has length at least so it is gcd(k 0 , k 1 )-periodic by Proposition 2.1. Since |w| ≥ max(k 0 , k 1 ) and the subwords w 0 , w 1 are k 0 -periodic or k 1 -periodic, they are uniquely determined by w. Therefore, the whole subword x[p : q + W − 1] is gcd(k 0 , k 1 )-periodic and gcd(k 0 , k 1 ) = k 0 = k 1 .
If x[p : q + W − 1] is not constant, then k 0 ≥ 2, and w 1 is not constant. Since ν x (q) ≥ 0, the word x[q : q + W ] is then periodic with a period less that K. By the same reasoning as above, the shortest period of x[q : q + W ] is k 0 and the whole part Corollary 3.5. Let x ∈ A N be a word such that L is not a local maximum in x, and let p, q be local maxima such that p < L < q. Then q − p ≥ K.
Proof. Conversely suppose that q − p < K. By Lemma 3.4, x[p : q + W ] is periodic with a period strictly less than K and π x (p) = π x (q) ≥ R − 1. If x[p : q + W ] is constant, π x (L) = R − 1, else π x (L) = R. In both cases, L is a local maximum contrary to the assumption.
is constant. If p is not a local maximum, then one of the following scenarios happen.
Proof. Since p is not a local maximum, there is a position q such that |p−q| < K and ν x (q) > ν x (p) ≥ 0, hence x[q : q + W − 1] is periodic with a period smaller than K. The subword x[q : q + W − 1] has an intersection with the constant subword x[p : p + W ] of length at least (W − 1) − (K − 1) = 2K − 3 ≥ K − 1. Therefore by periodicity, x[q : q + W − 1] is constant as well. We analyze two cases by the position of q.
(2) If q > p, we show that x[q + W − 1] differs from the constant on x[q : q + W − 1], so the scenario (2) happens. If it did not, the whole segment x[p : q + W ] would be constant, and ν x (p) = min(R − 1, ν x (q) + q − p) would contradict v x (q) > ν x (p).
Then p is a local maximum. Proof. If there is no such a position q ∈ [p 0 : p 0 + 2(K − 1) · n W + 1] that x[q : q+W ] is constant, we find the local maximum by the following process. We start with the position q 0 = p 0 +(K −1)n W . While q i is not a local maximum, we find q i+1 such that |q i+1 − q i | ≤ K − 1 and π x (q i+1 ) > π x (q i ). Observe that the positions q 1 , q 2 , . . . , q n W cannot escape the interval [p 0 : p 0 + 2(K − 1) · n W + 1].
On the other hand, the process cannot have more than n W steps since the values π x (p i ) form an increasing sequence which is made of at most n W negative values and one non-negative value R. So we will get to the local maximum eventually. If there is a position q ∈ [p : p + 2(K − 1) · n W + 1] such that x[q : q + W ] is constant, we find q 0 , q 1 such that p 0 ≤ q 0 ≤ q ≤ q 1 ≤ p 1 and x[q 0 : q 1 + W ] is the largest possible constant segment containing the position q. If q 1 < p 1 , then π x (q 1 + 1) = R, hence q 1 + 1 is a local maximum in [p 0 :  Now, we are going to prove that the constructed mapping f satisfies given conditions. For that purpose, we investigate how functions π x , ν x relates to functions π y , ν y , where y = x[1 :] + [i] for some i. Proof. Clearly, x[p : To confirm the lemma, it remains to discuss the exceptional behavior of ν that assigns α i,j . Fix i, j ∈ A. We claim that with the exception of p = L + 1 and x[L : N ] being constant, the following items are satisfied if and only if the following items are satisfied The forward implication is clear. The only case in which the backward one could fail is when p − 1 ≤ L but p ≤ L, that is p = L + 1. In that case, since y[p − 2 : p − 2 + W + R] is constant, we get that is constant as well.
We first prove the forward implication by contradiction. Suppose that p is a local maximum in x but p − 1 is not a local maximum in y. We thus find a position q such that |p − q| < K, π x (p) ≥ π x (q) and π y (p − 1) < π y (q − 1). By Lemma 3.12, the priority can raise by at most one when shifting to the left. Since the inequality changed, it was an equality before, that is π x (p) = π x (q), and then the priority changed at q but not at p: π y (p − 1) = π x (p) and π y (q − 1) = π x (q) + 1. Moreover, since the priority changed at q, y[q − 1 : N ] must be constant. Since π y (p − 1) = π x (q) ∈ [0 : R], also y[p − 1 : p − 1 + W ] is constant, and consequently, y[p−1 : N ] is constant. Since π y (q −1) > π y (p−1), we get q < p. On the other hand, since the priority increased at q but not at p, we get p ≥ L + 1 > q by Lemma 3.12. Satisfying both is impossible. Now we prove the other part. Let us assume that p − 1 is a local maximum in y but p is not a local maximum in x. There are two possible reasons for p not being a local maximum in x. Either p > N − W − (K − 1), or there is a position q such that ν x (q) > ν x (p) and |p − q| < K. Now suppose that there is q such that ν x (q) > ν x (p), and |p − q| < K. Since p − 1 is a local maximum in y, ν y (q − 1) ≤ ν y (p − 1). Similarly as in the forward implication, we obtain the following identities from Lemma 3.12, Since ν x (q) = ν y (q − 1) = ν y (p − 1), x[q : q + W ] is constant and ν x (q) = R − 1. We compute On the other hand, q ≤ L + 1 since ν x (q) = ν y (q − 1). Therefore [L + 1 : N ] is constant and L + 1 is a local maximum in [L + 1 : p].
Proposition 3.14. The function f : A N → G, as constructed in subsection 3.1 is such that for any x ∈ A N , one of the following cases happen: In this case L − 1 and L are local maxima in y by Lemma 3.13. Also ν y (L) = ν x (L + 1) by Lemma 3.11. By Lemma 3.4, π x (L) = π x (L + 1) ≥ 0 and x[L : L + W + 1] is periodic with a period smaller than K. We show that x[L : L + W + 1] cannot be constant. Assume that the subword is constant to obtain a contradiction, then π x (L) = min(R − 1, π x (L + 1) + 1). Since π x (L) = π x (L + 1), we get π x (L+1) = R−1, so x[L+1 : (L+1)+W +(R−1)] is constant. That contradicts the assumption that x[L : N ] is not constant. Therefore x[L : L + W + 1] is periodic with a smallest period k such that 1 < k < K. Thus k is also the smallest period of words Now, let us assume that L or L + 1 is not a local maximum in x. Let p 0 be the right-most local maximum such that p 0 ≤ L, and let p 1 be the left-most local maximum such that p 1 > L. They both exist by Corollary 3.9, and p 1 − p 0 ≥ K by Corollary 3.5. By the choice of p 0 , p 1 , there is no local maximum strictly between p 0 , p 1 . Therefore by Lemma 3.13 p 0 − 1, p 0 − 1 are local maxima in y and there is no local maximum between them. Since x[L : N ] is not constant,

Double loop
The core of the paper describing the weakest nontrivial equations [10] is the proof that the existence of a Taylor term implies the existence of a double loop term, that is a term d satisfying the double loop equations: d(xx, xxxx, yyyy, yy) = d(xx, yyyy, xxxx, yy) d(xy, xxyy, xxyy, xy) = d(yx, xyxy, xyxy, yx) The variables are grouped together for better readability. The double loop equations can be obtained as follows. Consider a 4 × 12 matrix whose columns are all the four-tuples [a 0 , a 1 , b 0 , b 1 ] ∈ {x, y} 4 with a 0 = a 1 or b 0 = b 1 , and let r 0 , r 1 , r 2 , r 3 denote its rows. The double loop equations are then d(r 0 ) ≈ d(r 1 ) and d(r 2 ) ≈ d(r 3 ). If the columns are organized lexicographically with x < y, we get the equations above. The fact that a Taylor term implies a double loop term is proved in [10] by an intermediate step in a form of a double loop lemma. We provide a local version of that procedure. Not only the local loop lemma makes possible to get the double loop lemma in a more straightforward manner but also the implication Taylor term ⇒ double loop term gets a stronger, "local" notion: if an idempotent algebra satisfies Taylor equations locally on X, it satisfies the double loop equations locally on X. The notion of locally satisfied equational condition is defined below.
Definition 4.1. Let A be an algebra with a subset X ⊂ A. Let S be an equational condition. We say that A satisfies S locally on X if it is possible to assign term operations in A to the term symbols in S so that every equation is satisfied whenever the variables are chosen from the set X.
Note that if X is the universe of A, then A satisfying S locally on X just means that A satisfies S as an equational condition.  12 quadruples [a 0 , a 1 , b 0 Proof. We assume that x A = y A and x B = y B , otherwise the theorem is trivial. Let us define a graph G = (A, E) on A by Observe that since the generators of Q are symmetric in the first two coordinates, so is the Q itself, and consequently the graph G = (A, E) is undirected. Clearly [x, y] ∈ E. Our goal is to apply Theorem 1.4 to G. Claim 4.3. Consider elements a 0 , . . . , a n−1 , a ′ 0 , . . . , a ′ n−1 ∈ {x B , y B } such that there is exactly one i ∈ [: n] such that a i = a ′ i . Then there is a G-edge t A (a 0 , . . . , a n−1 ) → t A (a ′ 0 , . . . , a ′ n−1 ) To verify the claim, we use the Taylor equation number i, that is . Therefore t(a 0 , . . . , a n−1 ), t(a ′ 0 , . . . , a ′ n−1 ), which testify the claim.
Due to Claim 4.3, there is a cycle walk of length 2n − 1 in G containing x A : Proof. We construct a "local free algebra" F with the signature of A generated by two generators. The universe F of F consists of all the binary operations X 2 → A that can be expressed by a term in A. The operations on F are naturally inherited from the basic operations on A by the left composition. Thus F is an idempotent algebra generated by the binary projections. Let us denote the binary projections x, y respectively. Since A satisfies some Taylor equations locally on X and the images of the functions x, y equals to X, F satisfies the same Taylor equations locally on {x, y}. Let Q ⊂ F 4 be a 4-ary relation on F generated by all the quadruples [a 0 , a 1 , b 0 , b 1 ], where a 0 , a 1 , b 0 , b 1 ∈ {x, y} and a 0 = a 1 or b 0 = b 1 . By Theorem 4.2, there is a double loop [a, a, b, b] ∈ Q. Therefore, there is a term d in the signature of A that takes the generators of Q and returns [a, a, b, b]. In particular d(xx, xxxx, yyyy, yy) = a, d(xx, yyyy, xxxx, yy) = a, d(xy, xxyy, xxyy, xy) = b, d(yx, xyxy, xyxy, yx) = b.
Thus d satisfies the double loop equations if we plug in x, y in that order. However, whenever we choose a pair [z 0 , z 1 ] ∈ X 2 , then [x(z 0 , z 1 ), y(z 0 , z 1 )] = [z 0 , z 1 ], hence d satisfies the double loop equations on A if we plug in z 0 , z 1 in that order. Since z 0 , z 1 can be any pair of elements of X, A satisfies the double loop equations locally on X.

Strong local loop lemma
In this section, we find a certain upgrade of the local loop lemma by finding even weaker assumption (4) in Theorem 1.4. We then use the upgraded version for reproving a finite loop lemma for strongly connected digraphs, in particular Theorem 7.2 in [2] For a given n-ary term t : A n → A and a coordinate i ∈ [: n], we define a digraph P(t, i) on A by x i → t(x 0 , x 1 , . . . , x n−1 ) for all possible values x 0 , . . . , x n−1 ∈ A. Using digraphs P(t, i), the assumption (4) in Theorem 1.4 can be expressed as: "For every i ∈ [: n], the digraph P(t, i) has a common edge with G." Let P(t, i) denote the transitive closure of P(t, i), that is en edge u → v in P(t, i) indicates a walk from u to v in P(t, i). Using this notation, Theorem 1.4 has the following generalization.
(3) G is either a strongly connected digraph containing cycle walks of all lengths greater than one, or G is an undirected connected non-bipartite graph, (4) for every i ∈ [: n], there is a common edge a i → b i in G and P(t, i).
Then G contains a loop.
Proof. As in the proof of 3.1, we denote [: n] by A. By idempotency of t, the edges of P(t, i) form a reflexive relation. Therefore, there is a fixed k such that there is a P(t, i)-walk of length k from a i to b i for every i ∈ A. For every i ∈ A, fix a substitution f i : We verify the assumptions of Theorem 1.4 using the operation t * (k−1)n+1 . The operation t * (k−1)n+1 is idempotent, compatible with G, and G already satisfy the relational requirements. It remains to find the values α x,y , for every x, y ∈ A (k−1)n+1 to make the condition (4) satisfied. We perceive the matrix α as a sequence of functions in the second variable, that is α x,y = α x (y). We need to find such functions α x that there are a G-edges Take x ∈ A (k−1)n+1 . By pigeonhole principle, there is i ∈ A occuring at least k-times in x. Let p 0 , . . . , p k−1 ∈ [: (k − 1)n + 1] be an increasing sequence of positions in x such that x[p j ] = i for every j ∈ [: k]. We define α x by Thus Therefore the assumption (4) of Theorem 1.4 is satisfied by a i → b i , and G has a loop.
From Theorem 5.1 we obtain the following finite version.
Theorem 5.2. Let A be a finite set and t : A n → A be an idempotent operation. Assume that for every i ∈ [: n] and every pair u, v ∈ A, there is w ∈ A such that there are edges u → w and u → w in P(t, i). Then every digraph G that is strongly connected, compatible with t and has algebraic length 1, has a loop.
Proof. Fix i ∈ [: n]. We start by proving the following claim by induction on |X| Claim 5.3. For every X ⊂ A, there is an element b such that for every x ∈ X, there is an edge x → b in P(t, i).
If X is empty, it suffices to take any b ∈ A. Otherwise let X = X ′ ∪ {x}, where the claim is already proven for X ′ , so there is b ′ such that there is an edge x ′ → b for every x ′ ∈ X ′ . Using the assumption of the theorem and putting u = b ′ , v = x, we get a vertex w = b such that there are edges b ′ → b, x → b. By transitivity of P(t, i), there are edges x → b for every x ∈ X. This finishes the proof of the claim.
For every i ∈ [: n], we fix b i ∈ A such that there is an edge x → b i in P(t, i) for every x ∈ A. Consider a strongly connected digraph G with algebraic length 1 that is compatible with t. To obtain a contradiction, suppose that there is no cycle walk of length 1 (a loop) in G. Since G is a strongly connected digraph with algebraic length 1, it contains cycle walks of all enough large lengths. Let k denote the largest length such that there is no cycle walk of length k in G. The relational power G •k is compatible with t, strongly connected, and by the choice of k, G •k contains cycle walks of all lengths greater than 1 but no loop. Since G •k is strongly connected, we can find nodes a i such that there are edges a i → b i in G •k . Any such edge is also an edge in P(t, i) by the choice of b i . Therefore, the assumptions of Theorem 5.1 are satisfied, and we get a contradiction with the assumption that G •k has no loop.
The standard finite loop lemma for strongly connected digraphs, originally proved in [2], is a direct consequence.
Corollary 5.4. Let G be a strongly connected digraph with algebraic length 1 compatible with a Taylor operation. Then G has a loop.
Proof. Let us denote the Taylor operation as t, and the vertex set of G as A.
Since the digraph G is strongly connected and has algebraic length 1, it remains to verify the assumptions of Theorem 5.2. We take i ∈ [: n] and u, v ∈ A, and find w such that u → w and v → w in P(t, i). This is straightforward, it suffices to set w = t(x 0 , . . . , x i = u, . . . , x n−1 ) = t(y 0 , . . . , y i = v, . . . , y n−1 ), where x j , y j are set to u or v according to the Taylor equation number i.

Conclusion
Though perceiving positions of variables in a star power as words and applying a simple word combinatorics on them gives surprisingly strong results, further research is needed. In particular, we would like to see a proof that is able to separate the technical effort from the overall powerful machinery. This could lead not only to a nicer proof the local loop lemma in this article but also pave a way to various interesting generalizations.
A modest generalization would be replacing the item (3) in Theorem 1.4 by simply G being a strongly connected digraph with algebraic length 1. The fact that we were able to get around it whenever we needed suggests that it is really rather a technical issue in the proof rather than a real obstacle.
A bit bolder attempt would be replacing the assumption of a strongly connected graph by something weaker. While the finite loop lemma, Theorem 1.1, suggests that the assumption of a strongly connected digraph is not entirely necessary, the strong connectedness forms a solid barrier for loop conditions, see Chapter 6 in [9] for counterexamples.
However, to get a widely applicable and powerful tool, it is necessary to get beyond a single digraph. What are the necessary assumptions to get a loop shared by two digraphs? What about loops in hypergraphs (see [6])? A natural question comes from Section 4. While it is possible to prove that a local Taylor implies local double-loop term, there is a much simpler form of the (global) weakest non-trivial idempotent equational condition: Question 6.1. Let A be an idempotent algebra that satisfies Taylor identities locally on a set X. Does it necessarily has a term that satisfies t(x, y, y, y, x, x) = t(y, x, y, x, y, x) = t(y, y, x, x, x, y) locally on X?
And last but not least, is it possible to apply the ideas in this article to oligomorphic structures, and consequently, infinite constraint satisfaction problem (see [3,6])? Oligomorphic algebras are kind of the opposite of idempotent algebras -idempotent algebras have only the trivial unary term operation while oligomorphic algebras has a large group of them. On the other hand, notice that the proof of Theorem 1.4 uses the idempotency at just two position in a predictable manner, therefore there might be a way of using a variant of the local loop lemma in algebras that are not idempotent.