Primitive sets of nonnegative matrices and synchronizing automata

A set of nonnegative matrices $\mathcal{M}=\{M_1, M_2, \ldots, M_k\}$ is called primitive if there exist indices $i_1, i_2, \ldots, i_m$ such that $M_{i_1} M_{i_2} \ldots M_{i_m}$ is positive (i.e. has all its entries $>0$). The length of the shortest such product is called the exponent of $\mathcal{M}$. The concept of primitive sets of matrices comes up in a number of problems within control theory, non-homogeneous Markov chains, automata theory etc. Recently, connections between synchronizing automata and primitive sets of matrices were established. In the present paper, we significantly strengthen these links by providing equivalence results, both in terms of combinatorial characterization, and computational aspects. We study the maximal exponent among all primitive sets of $n \times n$ matrices, which we denote by $\exp(n)$. We prove that $\lim_{n\rightarrow\infty} \tfrac{\log \exp(n)}{n} = \tfrac{\log 3}{3}$, and moreover, we establish that this bound leads to a resolution of the \v{C}ern\'{y} problem for carefully synchronizing automata. We also study the set of matrices with no zero rows and columns, denoted by $\mathcal{NZ}$, due to its intriguing connections to the \v{C}ern\'{y} conjecture and the recent generalization of Perron-Frobenius theory for this class. We characterize computational complexity of different problems related to the exponent of $\mathcal{NZ}$ matrix sets, and present a quadratic bound on the exponents of sets belonging to a special subclass. Namely, we show that the exponent of a set of matrices having total support is bounded by $2n^2 -5n +5$.


Introduction
A nonnegative matrix M of size n × n is called primitive if M k is positive (i.e. has all its entries larger than zero) for a positive integer k.This notion was introduced by Frobenius in 1912 during the development of so-called Perron-Frobenius theory.This theory has found numerous applications since then: in the theory of Markov chains, economics, population modelling, centrality measures in networks, see [21,Chapter 8] for an introduction to the topic.Motivated by various applications Protasov and Voynov introduced the following generalization of this notion to sets of matrices [26]: a finite set of (entrywise) nonnegative matrices M = {M 1 , M 2 , . . ., M k } is called primitive if M i1 M i2 . . .M im is (entrywise) positive for some indices i 1 , i 2 , . . ., i m ∈ [1, k].The length of the shortest such product is called the exponent exp (M) of M. We will denote the value of the largest exponent among all sets of n × n matrices by exp(n).For example, the matrix set M in Fig 1 is primitive, since the product M 1 M 2 M 1 M 2 is entrywise positive, and its exponent is equal to 4. Since the actual values of positive entries of matrices in M do not influence the exponent, in the rest of our paper we will implicitly assume that entries of all matrices are equal to 0 or 1.Moreover, we assume that the product AB of two matrices of size n × n is also a (0, 1)-matrix that is defined as follows 1 : AB[i, j] = 1 if k A[i, k]B[k, j] > 0, and AB[i, j] = 0 otherwise.Primitive sets of matrices received a lot of attention for different reasons.We refer the reader to the introduction in [4] for the account of applications of primitive matrix sets to stochastic control theory and to the consensus problem.The connections to contractive matrix families and scrambling matrices are given in detail in [26, Section 5].Primitive sets of matrices further arise in the study of time-inhomogeneous Markov chains [14], and are of importance in mathematical ecology [19].Furthermore, primitive sets of matrices are tightly related to boolean networks, which are widely used in biology to model gene regulatory networks.A special class of boolean networks -disjunctive networks, can be seen as a set matrices over the Boolean semiring.While researchers in theoretical biology are mostly interested in the attractors and the limit cycles for different types of update schedules, see for example [12], we are mainly interested whether it is possible and how fast one can achieve the all-one state.The subfamily of nonnegative matrices that have no zero rows and columns, denoted by NZ, will be of major interest to us for the following reasons.A matrix M is called irreducible if for every i, j there exists a positive integer m such that As usual, we will denote by e i the ith vector of the canonical basis in R n , the ith entry of e i is one, all the others are zeros.We say that a matrix M acts as a permutation on a partition V 1 , V 2 , . . ., V m of the vectors of the canonical basis if there exists a permutation σ such that for all i, V i M belongs to the subspace spanned by V σ(i) .A classical theorem of Perron-Frobenius theory states that an irreducible matrix M is primitive if and only if there is no partition V 1 , . . ., V m of the canonical basis vectors for m > 1 such that M acts as a permutation on V 1 , . . ., V m .Protasov and Voynov generalized this theorem to sets of matrices belonging to NZ [26]: an irreducible set of matrices belonging to NZ is primitive if and only if there is no partition V 1 , . . ., V m for m > 1 such that every M ∈ M acts as a permutation on V 1 , . . ., V m .Thus, the class of primitive matrices belonging to NZ can be viewed as the right class for Perron-Frobenius-type theory of matrix sets.This characterization also leads to an efficient algorithm that decides whether a set of matrices belonging to NZ is primitive.

Synchronizing automata
A deterministic finite state automaton A is a triple 2 Q, Σ, δ , where Q is a finite set of states, Σ is a finite set of input symbols called the alphabet, and δ is a transition function δ : Q × Σ → Q.The image of a state q under the action of a word w is denoted by q • w.An automaton A is called synchronizing if there exist a word w and a state f such that for every state q we have q • w = f .Any such word is called a synchronizing or reset word.The length of the shortest such word is called the reset threshold rt(A ) of A .Synchronizing automata naturally appear in different areas of research.For example, they were used to model sensorless parts orienting problems: given a part and a set of available actions that can change its spatial orientation, find a sequence of actions that would bring the part to a desired orientation independently of the initial position [22].Clearly, if we consider an automaton A with the set of spatial orientations as the set of states, and the available actions as letters, then the "orienting sequence" corresponds to a synchronizing word of A .We refer the reader to [28] for the survey of main results and other applications.A recent account of applications of synchronizing automata in group theory can be found in [2].Persisting interest of the research community to the topic is also driven by one of the most famous open problems in automata theory.Namely, the Černý conjecture states that the reset threshold of an n-state automaton is at most (n − 1) 2 [6,7].This bound is reached by the n-state Černý automaton C n , see [28, p. 18], but despite intensive efforts of researchers, the best upper bound n 3 −n 6 was obtained more than 30 years ago in [9,25] and independently in [18].The notion of a synchronizing automaton can be generalized in three different ways to nondeterministic automata [16].We will focus our attention on the most relevant for us.An automaton A is a partial automaton if the transition function δ is partial, i.e. there might be undefined transitions for some pairs of states and letters.A partial automaton is carefully synchronizing if there exist a word w and a state f such that q • w is defined and equal to f for every state q.Any such word is called a carefully synchronizing word.The length of the shortest such word we will denote by car(A ).We will denote by car(n) the maximum of car(A ) among all n-state partial automata.Essentially, carefully synchronizing automata model the problem of bringing a simple finite-state device to a known state with a single input sequence, while avoiding undefined transitions, which are undesirable or can break the device.In matrix terms, it amounts to consider a set of matrices with at most one 1-entry per row, and to ask for a product with one (entrywise) positive column.

Our contributions
Our results can be informally arranged into three different groups.The contributions of the first group significantly improve the understanding of the relationships between primitive sets of matrices and synchronizing automata.The work within this framework started in [1], where well-known examples of primitive matrices with large exponent were used to construct series of automata with relatively large reset thresholds, so-called "slowly synchronizing automata".In [4] it was shown that a f (n) bound on the reset threshold of n-state automata implies a 2f (n) + n − 1 bound on the exponent of NZ matrix sets.We significantly improve these results.We show that the growth rate of exp(n) is equal to Θ(car(n)).Thus, in a certain sense, the study of the exponents of sets of matrices is equivalent to the study of carefully synchronizing automata.We also formulate an analogous result for primitive NZ matrix sets.Namely, we introduce a special class of automata C such that the growth rate of the reset thresholds of automata in this class is equivalent to the growth rate of the exponents of NZ matrix sets.We propose and formalize a new open question of whether a quadratic bound on exp NZ (n) leads to a breakthrough on the Černý conjecture.
The contributions of the second group are of combinatorial nature.Our main result states that lim n→∞ log exp(n) n = log 3 3 , and equivalently, lim n→∞ log car(n) n = log 3 3 .From the automata theory point of view our contribution can be seen as the resolution of the Černý-like problem for the carefully synchronizing automata.From the point view of matrix theory, our result is a generalization of the classical theorem by Wielandt that the exponent of a single matrix is at most (n − 1) 2 + 1, see for example [15,Corollary 8.5.9].It also answers the question of establishing the growth rate of exp(n) posed in [4].Another contribution in this group is a partial result for NZ matrix sets.Recall that a matrix M has total support if every non-zero element m i,j of M lies on a positive diagonal, i.e. for every i, j ∈ [1, n] such that m i,j > 0 there exists a permutation σ with the following properties: σ(i) = j and for every k ∈ [1, n] we have m k,σ(k) > 0. We prove that the exponent of a set of matrices having total support is bounded by 2n 2 − 5n + 5.In the proof we utilize the well-known theorem by Kari that the reset threshold of an Eulerian automaton is bounded by n 2 − 3n + 3.This result suggests that the bounds for other classes of synchronizing automata might be used to obtain upper bounds on the exponent in the special classes of NZ matrix sets.
The contributions of the last group are related to the computational complexity of finding the exponent of an NZ matrix set.Given a set of two matrices belonging to NZ and possibly an integer k encoded in binary, we establish the exact computational complexity of the following problems: 1. the problem of deciding whether exp(M) ≤ k is N P -complete; 2. the problem of deciding whether exp(M) = k is DP -complete; 3. the problem of computing exp(M) is F P N P [log] -complete.Furthermore, we show that unless P = N P , for every positive ε there is no polynomial-time algorithm that computes the exponent of an NZ matrix set with the approximation ratio n 1−ε , even in the case of only three matrices in the set.These results are based on a single relatively simple reduction from automata with a sink state to sets of matrices belonging to NZ.
The paper is organized as follows.Section 2 deals with the primitive sets of matrices in the general case.We show that exp(n) = Θ(car(n)) and prove that lim n→∞ log exp(n) n = log 3 3 .Section 3 is devoted to the NZ matrix sets.In subsection 3.1 we introduce the class C such that exp NZ (n) = Θ(rt C (n)).We also present a quadratic bound on the exponent of a set of matrices having total support.In subsection 3.2 we deal with the complexity issues related to the computation of the exponent of NZ matrix sets.

2
The general case Recall that we denote the value of the largest exponent among all n × n matrices by exp(n).
The growth rate of exp(n) is one of the most basic questions one can ask about the sets of primitive matrices.Furthermore, an upper bound on exp(n) gives a bound on the running time of the straightforward algorithm that decides whether a given set of matrices is primitive: we iterate through all the possible products of length up to exp(n) and check, whether they contain a positive matrix.Since the problem is N P -hard [4, Theorem 6], such a simple algorithm might be the best we can hope for.The best known bounds on exp(n) were presented in [4, Theorem 10]: Recall that we denote the maximum of car(A ) among all n-state automata A by car(n).In the upcoming theorem we are going to show that exp(n) grows asymptotically as car(n).Thus, we can utilize the known bounds on car(n) to infer the bounds on exp(n).Furthermore, in the next subsection we will be able to significantly improve the known upper bound on car(n), and equivalently, on exp(n).Before stating the theorem we require one last definition.Given a (partial or complete) automaton A , an adjacency matrix M of a letter is defined as follows: M [i, j] = 1 if i • = j, and M [i, j] = 0 otherwise.In Fig. 1 the matrix M 1 is an adjacency matrix of the letter m 1 .
The matrix set M and the corresponding non-deterministic automaton M .
Theorem 2. Let exp(n) be the maximum value of the exponent among all sets of n × n matrices.Let car(n) be the maximum value of car(A ) among all n-state partial automata A , then exp(n) = Θ(car(n)).
Proof.The proof of the first part of the theorem is inspired by [4,Theorem 16].While, in [4], the result was restricted to NZ matrices, we extend it here to all primitive sets of matrices.Furthermore, we make it deterministic, which will be crucial for Theorem 8. Let us consider an arbitrary primitive set of matrices M = {M 1 , . . ., M k }.We are going to show now that exp(M) ≤ 2 car(n) + n − 1, which implies exp(n) = O(car(n)).We will achieve this by presenting products P, Q, R of matrices in M with the following properties: 1. the ith column of P is positive for some i and the length of P is at most car(n); 2. the jth row of R is positive for some j and the length of R is at most car(n); 3. Q[i, j] > 0 and the length of Q is at most n − 1.These properties clearly imply that P QR is positive and the length of P QR is at most 2 car(n) + n − 1.Thus, exp(M) ≤ 2 car(n) + n − 1.
We will construct the product P by utilizing a partial automaton A defined as follows: a partial function ϕ : [1, n] → [1, n] is a letter of A if and only if there is a matrix M ∈ M with the properties: for all i, if ϕ(i) is defined, M [i, ϕ(i)] > 0, otherwise the ith row has no positive entries.First, we are going to show that A is carefully synchronizing, then we will use the shortest carefully synchronizing word of A to obtain the matrix product P .
We construct a carefully synchronizing word of A with the help of an auxiliary nondeterministic automaton M defined in the following manner: the set of states of M is equal to [1, n]; for each matrix M i ∈ M we add a letter m i such that M i is the adjacency matrix of m i , see Fig. 1.It is straightforward to verify that for every s, t, p 1 , . . ., p we have M p1 M p2 . . .M p [s, t] > 0 if and only if there is a path from s to t in M labelled by the word m p1 m p2 . . .m p .Since M is primitive, there exists a positive product of matrices in M. Therefore, there exists a word w such that for every pair of states of M there is a path between them labelled by w.
It remains to show that the word w can be transformed to a carefully synchronizing word of A .Let us fix a state t ∈ [1, n].There are paths π 1 , . . ., π n in M labelled by w and for every s the path π s goes from the state s to the state t.Furthermore, we can impose an additional property on these paths.Namely, if at a step h paths π x and π y are in the same state, then their continuations coincide.Indeed, let π x = π x vπ x and π y = π y vπ y .Then we can substitute the path π y with the path π y vπ x , which still goes from y to t and it is labelled by w.Observe now, that the paths π 1 , . . ., π n can be easily treated as paths leading to the state t in the partial automaton A : by construction for each letter m of M and states v i1 , v i2 , . . .v ip with a property v ix ∈ δ M (i x , m) for x ∈ [1, p], there exists a letter of A such that δ A (i x , ) = v ix for each x ∈ [1, p]; due to this fact and the unique continuation property of the paths, we conclude that there exists a word w over the alphabet of A that labels the paths from every state to the state t in A .Thus, A is carefully synchronizing.
Let w = w 1 w 2 . . .w h be the shortest carefully synchronizing word of A .It is easy to see that a product W 1 W 2 . . .W h contains a column of ones, where W x is the adjacency matrix of w x for x ∈ [1, h].Since for every x ∈ [1, h] there is matrix A x ∈ M such that W x ≤ A x we obtain a product P = A 1 A 2 . . .A f with the properties: P has a column of ones and its length is bounded by car(n).
The product R is constructed in the same manner by applying the reasoning of the previous paragraphs to a matrix set M T = {M T | M ∈ M}.The resulting product R T has a column of ones and the length at most car(n).The existence of the product Q easily follows from the fact that M is strongly connected (otherwise the set of matrices M is not primitive).Thus, for every pair of states i, j there exists a path of length at most n − 1 that bring i to j.Now, given a carefully synchronizing n-state automaton A with the reset threshold equal to car(n) we will construct a primitive set of matrices M such that car(A ) ≤ exp(M).It will imply exp(n) = Ω(car(n)).Let e be a row vector of 1's, and e k be a row vector with the only non-zero entry equal to 1 at position k.
The set of matrices M is defined as a union M ∪ E, where M is a set of the adjacency matrices of letters of the partial automaton A .Since A is carefully synchronizing, there is a product P of matrices in M such that the ith column is positive for some i.If we multiply P by the matrix e T k e ∈ E on the right, we obtain a positive matrix product.Thus, M is primitive.
It remains to show that car(A ) ≤ exp(M).Let W be the shortest positive product of matrices in M. Note, that W contains at least one matrix from E, since every product of matrices in M contains at most one 1 in each row.Let W = U EV , where the product U doesn't contain matrices from E and E ∈ E. Observe that U contains a positive column.Otherwise, W will have a zero row due to the presence of a zero row in U E. Therefore, the length of the product U is at least car(A ) and we obtain the desired inequality.).The second part follows from the result of Martyugin [20].He constructed a series of carefully synchronizing automata with the length of the shortest carefully synchronizing word equal to Ω(3 n 3 ).Thus, exp(n) = Ω(3 n 3 ).

Improving the upper bound on the exponent
The goal of this section is to significantly improve the bound on exp(n) and, equivalently, on car(n).We will present a new upper bound on the length of the shortest carefully synchronizing word by modifying constructions from [11].
Recall that a partition of a set Let Q be an n-element set and P be an arbitrary partition.We will denote by T(P) the number of different transversals with respect to P and by T (P) the number of different partial transversals of size .Let T k (n) be the largest value of T(P) among all partitions P of Q into k parts.Similarly, let T k (n) be the largest value of T (P) among all partitions P of Q into k parts.If the value of n is clear from the context, then we will often write T k and T k to simplify notation.We will make use of the following bounds on T k (n) and T k (n): Proof. 1.It is the statement of Proposition 5 in [11].

2.
Let P be a partition of Q into k parts such that Observe that for any i, j we have d j − d i < 2. Otherwise, by moving an element from the jth part to the ith part of the partition P, we will increase the number of transversals: Therefore, for a given range of values k, every d i is equal to 2 or 3. Let x be the number of d i 's equal to 2, then k − x is the number of d i 's equal to 3. Since 2x + 3(k − x) = n, we derive that x = 3k − n, and the desired bound follows.

3.
Let P be a partition of Q into k parts such that T(P) = T k (n), where k ≤ n 3 .If d i is the size of the ith part of P, then by the inequality of arithmetic and geometric means we have Let us bound the right hand side.Note that ∂ ∂k

4.
Let P be a partition of Q into k parts such that T k−j (P) = T k−j k (n) and let d i be the size of the ith part of P. Proof.We will show that car(n) is at most ) by [20], the statement lim n→∞ log car(n) n = log 3 3 will clearly follow.Due to Theorem 2 we will have the same statement for exp(n).
Let A be a carefully synchronizing n-state partial automaton with the set of states Q.We will construct a carefully synchronizing word u 1 of A via the following iterative procedure: (a) Let u n−1 be a letter that is defined on every state q ∈ Q and satisfies where | • | denotes the cardinality of a set.Since A is carefully synchronizing, there exists at least one such letter.
(b) Choose a positive integer < k.Let u k− be a word of the form where the words t k−s+1 k are defined iteratively for s ∈ [1, ]: Note, that the word u k− is well-defined, since at every step the set of possible words for t k−s+1 k contains carefully synchronizing words of A .Our procedure further ensures that |Q • u k | ≤ k for every k.Thus, u 1 is indeed a carefully synchronizing word.Our goal now is to bound the length of u 1 .The bound on car(n) presented in [11] was obtained using the presented procedure with the parameter ultimately fixed to 1.By choosing for every ε > 0 a sufficiently large satisfying certain conditions, we get a significant improvement.We proceed by bounding the length of intermediate words u k .To simplify the presentation and without loss of generality, we will further assume that n is divisible by 6 .
For these values of k we uniformly put = 1.The proof of this case is presented in [11,Proposition 7], which we repeat here for convenience.We are going to show that The word u k gives rise to a partition P of Q into k parts as follows: a pair of states p, q belongs to the same part of . Indeed, if it is not the case for some i , then the word u k x 1 . . .x i u k satisfy the conditions (b) of our procedure and it is shorter than u k−1 , which is impossible.Therefore, the length of t k k is bounded by T(P).By lemma 5 we conclude For each ε > 0 we will choose the value of at the end of the proof, independent of n and k.As before, the word u k gives rise to a partition P of Q into k parts as follows: a pair of states p, q belongs to the same part of Furthermore, S i is a partial transversal with respect to P. Indeed, if it is not the case, then Using this bound for all s ∈ [1, ] and part 4 of lemma 5 we obtain for some polynomial p(n) of degree − 1. Note, that part 3 of lemma 5 can be rewritten as . Applying this inequality and the inequality for |u k− | n 6 times we derive: Theorem 8. Let exp NZ (n) be the maximum value of the exponent among all sets of NZ matrices of size n × n.Let rt C (n) be the largest reset threshold among n-state automata in C, then exp NZ (n) = Θ(rt C (n)).
Proof.In order to show that exp NZ (n) is O(rt C (n)) we will reuse the reduction from primitive sets of matrices to partial automata presented in the first part of theorem 2. Let M be a primitive set of NZ matrices.It can be reduced to partial automata A and B such that exp(M) ≤ car(A ) + car(B) + n − 1.Since M is an NZ matrix set, we conclude that the automata A and B are complete.Thus, their carefully synchronizing words are ordinary synchronizing words.Furthermore, the automata A and B belong to C. Indeed, every letter of these automata was obtained from a matrix in M or M T .In order to obtain the desired partition, we group a pair of letters together if and only if they were derived from the same matrix.It is a straightforward check that both conditions on the partition are satisfied.
For the other direction, given an automaton A ∈ C we will construct a set of NZ matrices M such that rt(A ) ≤ exp(M).It will imply that exp NZ (n) = Ω(rt C (n)).Let Σ 1 , . . ., Σ k be the partition of the letters of A .A set of matrices M consists of matrices M i = ∈Σi A , where A is the adjacency matrix of the letter .Clearly, each M i is an NZ matrix due to the first property of the partition and the fact that A is complete.The second property ensures that rt(A ) ≤ exp(M), since every primitive word of M can be transformed into a synchronizing word of A as in the proof of theorem 2. Problem 9. Improve the bounds O(n 3 ) and Ω(n 2 ) on the growth rate of rt C (n) and, equivalently, exp NZ (n).In particular, is there a constant K such that rt C (n) < Kn 2 ?This problem can be settled in different ways.On one hand, one can show that problem 9 is as hard as the Černý conjecture.There are not many natural problems equivalent to it and the problem of bounding exp NZ (n) is a good candidate for this purpose.On the other hand, a quadratic bound for exp NZ (n) is clearly of interest by itself.
In the remainder of this subsection we will present an upper bound on the exponent of a set of matrices from a special class.A matrix M has total support if every non-zero element m i,j of M lies on a positive diagonal, i.e. for every i, j ∈ [1, n] such that m i,j > 0 there exists a permutation σ with the following properties: σ(i) = j and for every k ∈ [1, n] we have m k,σ(k) > 0. The class of matrices with total support received a lot of attention in the past.For example, it appears in the necessary and sufficient condition for the convergence of the classical Sinkhorn-Knopp method for matrix scaling, see [27].Another characterization is related to a class of doubly stochastic matrices.A square matrix M is called doubly stochastic if the entries are nonnegative and the sum of elements in each row and column is equal to 1.A matrix M is said to have a doubly stochastic pattern if there exists a doubly stochastic matrix D such that for all i, j it holds D[i, j] > 0 if and only if M [i, j] > 0. A famous result of Perfect and Mirsky [24] states that a matrix M has total support if and only if M has a doubly stochastic pattern, see [5, Theorem 9.2.1] for a modern and much more general treatment of the problem.Now we are ready to state our result.Theorem 10.If each matrix of a primitive set M has total support, then the exponent of M is at most 2n 2 − 5n + 5, where n × n is the size of matrices in M.
Proof.We will modify the reduction presented in the first part of theorem 2 from a primitive set of matrices M to partial automata A , B in order to prove the statement.By the aforementioned result of Perfect and Mirsky we conclude that for every matrix M ∈ M there exists a doubly stochastic matrix D 1 such that for every i, j we have M [i, j] > 0 if and only if D 1 [i, j] > 0. It is not hard to see that we can further assume that D 1 has only rational entries.Therefore, there exists h and a matrix D M with nonnegative integer elements such that the sum of entries in each row and column is equal to h, and M [i, j] > 0 if and only if D M [i, j] > 0 for all i, j.We will define the automaton A as follows.For each matrix M ∈ M we add a function ϕ : [1, n] → [1, n] as a letter of A multiple times.Namely, we treat ϕ(•) as n i=1 D M [i, ϕ(i)] different letters of the automaton A .Let B be an automaton obtained from a matrix set M T in the same manner.Similarly to the proofs of theorems 2 and 8 we can conclude that the automata A and B are complete and synchronizing, moreover, exp(M) ≤ rt(A ) + rt(B) + n − 1.Now we are going to show that the automaton A is Eulerian, i.e. the in-degree of each state is equal to its out-degree.Let Σ M be the set of letters generated from a matrix M ∈ M and h be the row (and column) sum of D M .It is not hard to see that by the definition of A the size of Σ M is h n .Furthermore, the number of letters from Σ M that move a state i to a state j is equal to D M [i, j]h n−1 .Thus, the number of incoming edges to j labelled by a letter from Σ M is equal to i D M [i, j]h n−1 = h n , which is equal to the size of Σ M .Since the alphabet of A is ∪ M ∈M Σ M and for every Σ M the number of incoming and outgoing edges labelled by Σ M coincide, we conclude that the automaton A is Eulerian.The same reasoning allow us to conclude that the automaton B is also Eulerian.By the famous result of Kari about the reset thresholds of Eulerian automata [17] we have rt(A ), rt(B) ≤ n 2 − 3n + 3. Thus, the exponent of the matrix set M is at most 2(n 2 − 3n + 3) + n − 1 = 2n 2 − 5n + 5.

Computation and approximation of the exponent
In this subsection we will focus on the problem of computing the exponent of a set of NZ matrices.Our results rely on the following lemma: Lemma 11.For every synchronizing automaton A with a sink state there exists a set of NZ matrices M constructible in polynomial time such that exp(M) = rt(A ) + 1.
Proof.If the number of states of A is equal to 1, then M can be an arbitrary set of matrices with the exponent equal to 2. For example, M = {( 1 1 1 0 )}.In all the other cases we construct the matrix set M as follows.Since A is synchronizing, it has a unique sink state, which we denote by s.Let M be the set of adjacency matrices of letters of A .The matrix set M consists of matrices in M modified in such a way that the sth row of every matrix is positive, i.e.M = {M + e T s e | M ∈ M }, where e stands for a row vector of 1's, and e s stands for a row vector with the only non-zero entry equal to 1 at position s.Since the automaton A is complete, we conclude that every matrix M ∈ M has no zero rows.Furthermore, each column of M has a positive element at position s.Thus, the set of matrices M belongs to NZ.Now we will demonstrate that the set M is primitive.Since the automaton A is synchronizing there exists a product P of matrices from M with a positive column.Due to the fact that for every letter of A one has s • = s, we conclude that the only positive entry in the sth row of P is located at position s.Thus, the sth column of P is positive.Altering each matrix M of the product P to a matrix M ∈ M with the property M ≤ M we obtain a product P of matrices from M with the positive sth column.Now multiply by any matrix M ∈ M to get a positive product P M .Thus, the set M is primitive and exp(M) ≤ rt(A ) + 1.
It remains to show that exp(M) ≥ rt(A ) + 1.Let P = M 1 M 2 . . .M m be the shortest positive product of matrices in M. Let P = M 1 M 2 . . .M m be the corresponding product of matrices in M , where M i and M i differ only in the sth row.For each row i = s there exists the largest h i such that the ith row of P hi = M 1 M 2 . . .M hi contains a unique positive entry.Due to the fact that the ith row of P hi+1 has several positive entries and the structure of 3. The algorithm from F P N P [log] that computes exp(M) is a simple binary search algorithm that uses logarithmic number of queries to the oracle for the N P -complete problem exp(M) ≤ k.Recall that the exponent of M is bounded by a polynomial p(n) = n 3 +2n−3 3 .Thus, in log p(n) iterations we can establish precise value of exp(M).

Conclusion
The goal of our work was to emphasize, and leverage, the fact that several problems about primitive sets of matrices are in some sense equivalent to problems about synchronizing automata.More precisely, we related the bounds on the exponents and the lengths of the shortest carefully synchronizing words in the general case, and the exponents and reset thresholds in the case of matrices without zero rows and columns.Furthermore, we utilized these connections to easily establish the exact complexity classes of different problems concerning the computation of the exponent of a set of matrices belonging to NZ.Thus, we believe that the joint research effort on both topics at the same time can lead to substantial progress on some of the most desperate problems in both fields at the same time.We left a quadratic upper bound on the exponent of an NZ matrix set as an open problem, and whether its existence brings any implication for the Černý conjecture.Our future work includes the search for matrix counterparts of special classes of automata, which have quadratically bounded reset threshold.These statements will be analogous to our result on primitive sets of matrices having total support.

Theorem 6 .
Let exp(n) be the maximum value of the exponent among all sets of n × n matrices.Let car(n) be the maximum value of car(A ) among all n-state partial automata A , then lim n→∞ log exp(n) n = log 3 3 , and equivalently lim n→∞ log car(n) n = log 3 3 .
where x 1 , . . ., x m are letters.By construction, for every i ∈ [1, m − 1] the cardinality of the set