The local loop lemma

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


Introduction
Theorems that give a loop in a directed graph (digraph) under certain algebraic and structural assumptions play an important role in universal algebra and the constraint satisfaction problem. One example of such a "loop lemma" is the following one. Theorem 1.1 (loop lemma) [2,1]. If a finite digraph G • is weakly connected, • is smooth (has no sources and no sinks), • has algebraic length 1 (cannot be homomorphically mapped to a directed cycle of length at least 2) and • is compatible with a Taylor operation, then G contains a loop (a vertex adjacent to itself ).
The consequences of this loop lemma include the following. was found. The main result of this paper is a version of the loop lemma under significantly weaker assumptions than the original question. This 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 closed walks of all lengths starting with two, or G is an undirected connected nonbipartite graph, (4) for every i ∈ {0, . . . , n − 1}, there is a G-edge α i,i → t(α i,0 , α i,1 , . . . , α i,n−1 ).

Then G contains a loop.
Proof of the 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. 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 α i,i = x → t(y, . . . , y, x, y, . . . , y) = t(α i,0 , . . . , α i,n−1 ).
Note that the absorption approach is not the only existing one used to tackle loop lemmata. The oldest method is based mostly on performing ppdefinitions and pp-interpretations. This resulted in older, weaker versions of Theorem 1.1, see [6,8], but also provided a state-of-the-art version of loop lemma for oligomorphic clones [4]. The most recent technique is based on a correspondence of certain loop lemmata with Maltsev conditions, see [11,12,7]. However, none of the available methods are local enough for our purposes. We have chosen a different approach, a blindly straightforward one. We provide a description of 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 terms used, alongside with 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 obtain further strengthening of Theorem 1.4 that yields a version of Theorem 1.1 with a slightly stronger relational assumption (that G be a 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 square 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. • Words can be concatenated using symbol +, that is This syntax is known in Python as slice notation. Notice that the interval includes i and does not include j, so then 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, 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
For a given n-ary operation t and a non-negative integer k we recursively define the k-th star power of t, denoted t * k , to be n k -ary operation given by We consider 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 :

Equations
An equation in a signature Σ is a pair of terms in Σ written as t 0 ≈ t 1 . An equational condition C is a system of equations in a fixed signature Σ. An algebra A (in any signature) 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 (an infinite disjunction of strong Maltsev conditions). Of particular interest are Taylor equations since every idempotent algebra satisfying a non-trivial Maltsev condition also have a term satisfying some Taylor system of equations. A Taylor system of equations is any system of n equations using an n-ary symbol t of the following form. t where each question mark stands for either x or y. A Taylor operation is any operation satisfying some Taylor system of equations. A quasi Taylor system of equations is a Taylor system of equations without the last one requiring idempotency. For 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 [5]. Note that it was recently proved [10] that the property of an algebra having a Taylor term can be characterized by 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 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 component-wise. A relation is said to be compatible with an algebra A if it is compatible with all basic operations of A, or algebraically, 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 G an undirected graph. Given a digraph G = (V, E), we usually denote the edges by 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 closed walk of length n, or closed n-walk, is an n-walk w such 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 has an algebraic length 1 if it cannot be homomorphically mapped to a directed cycle of length greater than one.
We finish this section by proving some basic combinatorial properties of strongly connected digraphs of algebraic length 1. Proof. First, observe that if all closed 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 has algebraic length 1, there are some closed walks c 0 , . . . c k−1 such that the greatest common divisor of the lengths of the closed walks equals one. Let w i denote a walk from u to c i [0] and w i denote a walk Vol. 81 (2020) The local loop lemma Page 7 of 23 14 There is a closed walk starting in u of any length of the form . , x k−1 stands for any non-negative integer coefficients. Since gcd(|c 0 |, . . . , |c k−1 |) = 1, this number can reach every sufficiently large integer.

Proposition 2.5. Let t be an idempotent n-ary operation compatible with a digraph G. Let H ⊆ G be a strongly connected component of G that has an algebraic length 1. Then H is closed under t.
Proof. Fix a vertex u ∈ H. By Proposition 2.3, there is a length C such that there are closed c-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

Proof of the local loop lemma
We prove the local loop lemma in the following form. (3) G is a strongly connected digraph containing closed walks of all lengths greater that one, Then G contains a loop. Proof of Theorem 1.4. If G has closed 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 closed walks of all lengths l ≥ l − 1. There are closed walks of any even length-simply pick any edge [a, b], and construct the walk [a, b, a, b, . . . , a]. For constructing a closed walk of an odd length greater than l − 1, start with a closed walk of length l around a cycle of length l and append a walk from the even case.
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 item (4) of Theorem 3.1 about the α i,j . Compatibility of G with t, that is item (2), follows from basic properties of relational powers. Since G contains a closed walk of every length greater than l − 2, the digraph G contains a closed walk of any length greater than 1. Therefore, by Theorem 3.1, there is a loop in G corresponding to a closed 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.  Vol. 81 (2020) The local loop lemma Page 9 of 23 14 By the idempotency of t, the functions f 0 and f are identical. Therefore We claim that there is an edge from t * (N +1) (f 0 ) to t * (N +1) (f 1 ). We verify the edge by checking for 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.
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 Section 3.1 we explicitly define the function f , in Section 3.2 we prove that the function f satisfes the required properties. Before that, we reduce the problem to a finite case. Proof. We start with a finite subdigraph G 0 ⊆ G with algebraic length oneit suffices to put any two coprime closed walks of G into G 0 and connect them. Thus there is a length C such that G 0 contains a closed c-walk for any c ≥ C. We construct G by adding the following edges and nodes into G 0 : • one closed 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 : 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 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. (4) If w is not periodic with a period smaller than K and w[: W − 1] is not constant, then π(w) is negative. (5) π is "injective on negative values", that is, whenever π(w 0 ) = π(w 1 ) < 0, then w 0 = w 1 .
The construction of such functions is straightforward. To satisfy conditions 1 and 3 we simply set the appropriate values of π and ν. Items 4 and 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 ∈ [2 : K], we partition the words with the smallest period k into groups that differ by a cyclic shift. Any such group can be arranged as w either π x (p) = R, or p ∈ [K − 1 : N − W − (K − 1) + 1] and π x (p) ≥ π x (q) whenever |p − q| < K. 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 in 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.11). • If L is not a local maximum and p, q are local maxima such that p < L < q, then q − p ≥ K (Corollary 3.6). • The constructed mapping f meets the criteria given by Proposition 3.2 (Proposition 3.15).

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 subword 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. This contradicts the hypothesis 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 subword x[p : q + W ] is k 0 -periodic.
In both cases, p 0 + 1 is a local maximum in the interval [p 0 + 1 : p 1 ] contrary to the hypotheses.
Corollary 3.6. 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.
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 : Therefore by periodicity, x[q : q + W − 1] is constant as well. We analyze two cases by the position of q.
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 Vol. 81 (2020) The local loop lemma Page 13 of 23 14 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 subword. If q 1 < p 1 , then π x (q 1 + 1) = R, hence q 1 + 1 is a local maximum in [p 0 : p 1 + 1]. Assume otherwise that q 1 = p 1 . Since x[p 0 : p 1 + W ] is not constant, we have q 0 > p 0 . Since p 1 − q 0 ≥ M − 2(K − 1) · n W = K − 1, q 0 is the desired local maximum by Corollary 3.8.  To prove 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 is constant as well.  Proof. By Lemma 3.13, π x (p) = R if and only if π y (p − 1) = R, in that case both p and p − 1 are local maxima. Assume otherwise, that is π x (p) < R, and π y (p) < R. 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) − 1. From Lemma 3.13, we obtain π x (p − 1) ≥ π x (p) and π y (q) ≥ π y (q − 1) − 1. This leads to a cycle in inequalities so all the compared values must be equal.
Since π y (q) = π y (q−1), y[q−1 : N ] is constant. Since π y (p−1) = π x (q) ∈ [: 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.13. Satisfying both is impossible. Now we prove the second part of the lemma. 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.
Proposition 3.15. The function f : A N → G, as constructed in Section 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.14. Also ν y (L) = ν x (L+1) by Lemma 3.12. 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 hypothesis 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. Both p 0 and p 1 exist by Corollary 3.10, and p 1 − p 0 ≥ K by Corollary 3.5. By the choice of p 0 , p 1 , there is no local

Double loop
The core of the paper describing the weakest nontrivial equations [10] is the proof that the existence of a Taylor  (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 quadruples [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 intermediate steps in the form of the infinite loop lemma (Theorem 4.3 in [10]) followed by the double loop lemma (Theorem 5.2 in [10]). We provide a local version of that procedure by replacing the infinite loop lemma by the local loop lemma. Not only makes this change the proof of the double loop lemma more straightforward but we also prove a stronger, "local" version of the main theorem: If an idempotent algebra satisfies Taylor equations locally on X, it satisfies the double loop equations locally on X. The notion of a 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.