Abstract 1 Introduction 2 Existing results and our contributions 3 Main definitions 4 Main concepts and the linear algebra toolbox 5 Computing the rank in NC2 6 Time and space complexity 7 Conclusions and open problems References

Efficiently Computing the Minimum Rank of a Matrix in a Monoid of Zero-One Matrices

Stefan Kiefer ORCID Department of Computer Science, University of Oxford, UK Andrew Ryzhikov ORCID Department of Computer Science, University of Oxford, UK
Abstract

A zero-one matrix is a matrix with entries from {0,1}. We study monoids containing only such matrices. A finite set of zero-one matrices generating such a monoid can be seen as the matrix representation of an unambiguous finite automaton, an important generalisation of deterministic finite automata which shares many of their good properties.

Let 𝒜 be a finite set of n×n zero-one matrices generating a monoid of zero-one matrices, and m be the cardinality of 𝒜. We study the computational complexity of computing the minimum rank of a matrix in the monoid generated by 𝒜. By using linear-algebraic techniques, we show that this problem is in NC and can be solved in 𝒪(mn4) time. We also provide a combinatorial algorithm finding a matrix of minimum rank in 𝒪(n2+ω+mn4) time, where 2ω2.4 is the matrix multiplication exponent. As a byproduct, we show a very weak version of a generalisation of the Černý conjecture: there always exists a straight line program of size 𝒪(n2) describing a product resulting in a matrix of minimum rank.

For the special case corresponding to complete DFAs (that is, for the case where all matrices have exactly one 1 in each row), the minimum rank is the size of the smallest image of the set of states under the action of a word. Our combinatorial algorithm finds a matrix of minimum rank in time 𝒪(n3+mn2) in this case.

Keywords and phrases:
matrix monoids, minimum rank, unambiguous automata
Funding:
Andrew Ryzhikov: Supported by the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (Grant agreement No. 852769, ARiAT).
Copyright and License:
[Uncaptioned image] © Stefan Kiefer and Andrew Ryzhikov; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Formal languages and automata theory
; Computing methodologies Symbolic and algebraic manipulation
Acknowledgements:
We thank the anonymous reviewers for their helpful comments that improved the presentation of the paper.
Editors:
Olaf Beyersdorff, Michał Pilipczuk, Elaine Pimentel, and Nguyễn Kim Thắng

1 Introduction

Matrix monoids are a rich and versatile object used in formal verification, program analysis, dynamical systems and weighted automata. However, many of their properties are in general undecidable. One such example is the well-studied matrix mortality problem. Given a finite set 𝒜 of n×n matrices, it asks if the monoid generated by 𝒜 (that is, the set of all products of matrices from 𝒜) contains the zero matrix. This problem is undecidable already for 3×3 integer matrices [40], and was studied for several decidable special cases, see e.g. [16, 6, 47].

Even if 𝒜 is a set of zero-one matrices (that is, matrices with entries in {0,1}), matrix mortality is PSPACE-complete [47]. We thus restrict our attention to the case where the whole monoid generated by 𝒜 consists of zero-one matrices; in this case, matrix mortality becomes decidable in polynomial time [34]. We call such monoids zero-one matrix monoids. Intuitively, when multiplying any two matrices from such a monoid, we never get 1+1 as a subexpression. Zero-one matrix monoids have a rich structure while still admitting good algorithmic properties. They correspond precisely to unambiguous finite automata, and find applications in formal verification [3], variable-length codes [9] and symbolic dynamics [38]. They are also an interesting special case of finite monoids of rational matrices (studied in, e.g., [39, 28, 1, 13]), monoids of nonnegative matrices (studied in, e.g., [41, 10, 51, 22]), and, in the case where they do not contain the zero matrix, of matrix monoids with constant spectral radius [42].

In this paper, we consider a problem that can be seen as a natural generalisation of matrix mortality: given a finite set 𝒜 generating a zero-one monoid, find the minimum real rank of a matrix in this monoid. By the real rank of a matrix we mean the dimension of the subspace generated by its columns over the reals. Clearly, this rank is zero if and only if the monoid contains the zero matrix. The minimum real rank of a matrix in a zero-one matrix monoid is a much more tractable problem than deciding other similar properties: for example, checking if a zero-one matrix monoid contains a matrix of a given real rank was shown to be NP-hard111In fact, it is PSPACE-complete, which follows directly from [8, Theorem 3]: add a fresh state and define all yet undefined transitions to lead to this state. [24].

The goal of our paper is threefold. Firstly, we present efficient algorithms for analysing monoids of zero-one matrices and unambiguous finite automata. Secondly, to obtain these algorithms, we provide new structural properties of such monoids and automata that might be interesting on their own. Thirdly, we strengthen the connections between the areas of synchronising automata, weighted automata and matrix semigroups by transferring methods and tools between them. We also highlight open problems in the intersection of these areas.

2 Existing results and our contributions

Throughout the paper, we always assume that matrix monoids are defined by sets of generators, and all matrices are square zero-one unless stated otherwise.

Complete DFAs

An n×n zero-one matrix with exactly one 1 in every row can be equivalently seen as a transformation of a set Q of size n. A set of such matrices generates a zero-one matrix monoid, and can be seen as a complete deterministic finite (semi-)automaton222In this paper, all automata are semi-automata, meaning that they do not have any initial or accepting states, and do not recognise any languages. Following the usual conventions (as in, e.g., [9]), we omit “semi-”, in particular because it would make abbreviations like DFA less recognisable. (complete DFA) 𝒜=(Q,Σ,δ). Here, Σ is a finite alphabet whose letters correspond to the generating matrices, and δ:Q×ΣQ is the transition function defined in such a way that for each aΣ, δ(_,a) is the transformation of Q induced in the natural way by the matrix corresponding to a. Thus, words over Σ correspond to products of the generating matrices.

The rank of a word w in 𝒜 is the size of the image of Q under the transformation corresponding to w. Equivalently, it is the real rank of the matrix corresponding to w. The rank of a complete DFA is the minimum among the ranks of all its words. This concept was studied from the perspectives of automata theory [43, 30] and the theory of transformation semigroups [48, 31]. It is the subject of the rank conjecture (called the Černý-Pin conjecture in [43]), which states that every complete DFA of rank r admits a word of rank r having length at most (nr)2. The Černý conjecture, one of the oldest open problems in combinatorial automata theory [50], is a special case with r=1. We refer to surveys [49, 4, 30, 50] for the vast literature on the Černý conjecture. Underlying digraphs of complete DFAs of a given rank were studied in [12, 4] in the context of the road colouring problem.

The rank of an n-state complete DFA over an alphabet of size m can be found in 𝒪(m4n4) time [43, Theorem 1]. In contrast, for any fixed r2, the problem of checking if a complete DFA admits a word of rank r is NP-hard [24]. Checking if an n-state complete DFA over an alphabet of size m has rank one is NL-complete [26, 50], and can be done in 𝒪(mn2) time [20, 49]. For each complete DFAs of rank r, there exists a word of rank r of length at most (nr)36+𝒪((nr)2) [37], and if r=1, finding a word of rank one can be done in 𝒪(n3+mn2) time and 𝒪(n2) space [20].

Unambiguous finite automata

Generalising the case of complete DFAs, a set 𝒜 of n×n zero-one matrices generating a zero-one matrix monoid can be equivalently seen as an unambiguous nondeterministic finite (semi-)automaton (UFA). Let Q={q1,,qn} be its set of states. To each matrix in 𝒜 we again associate a letter in the alphabet Σ, and the transition relation ΔQ×Σ×Q is defined so that (qi,a,qj)Δ if and only if the entry (i,j) in the matrix corresponding to a is equal to one. Just as in the complete DFA case, words over Σ naturally correspond to products of matrices from 𝒜.

The obtained NFA then has the property that is sometimes called diamond-free: for every two states p,q and every word w, there is at most one path from p to q labelled by w. A simple reachability argument shows that the length of a shortest word labelling two such paths, if it exists, is at most quadratic in the dimension of the matrices. Hence, deciding whether an NFA is a UFA (and thus whether a set of zero-one matrices generates a zero-one monoid) is in coNL = NL. It is actually NL-complete as described in the next subsection.

A UFA is called complete if it does not admit a word whose matrix is the zero matrix. For an n-state UFA the length of such a word if it exists is at most n5 [34]. The best known lower bound is quadratic in n, and is achieved by a series of DFAs [44]. For UFAs, the quadratic upper bound was conjectured to be tight [43, Conjecture 2]. Checking if a UFA is complete can be done in NC2 [34].

The real rank of a UFA is the minimum among the real ranks of the matrices corresponding to words. It was shown in [14] that for an n-state UFA of real rank r1 there always exists a word of minimum rank of length 𝒪(rn3). For n-state strongly connected Eulerian UFAs of rank one, a subclass with remarkably nice properties, there always exists a word of length at most (n1)2 of rank one [15, Corollary 4]. All mentioned constructions also provide polynomial time algorithms that construct words with the required properties (in particular, with a length within the stated bounds).

Applications to variable-length codes

A variable-length code (or simply a code) is a set X of finite words over an alphabet Σ such that every finite word over Σ has at most one factorisation over X. In other words, a code is a basis of a free submonoid of Σ.

The definitions of both UFAs and codes rely, intuitively, on the uniqueness of certain representations. In fact, UFAs and codes are tightly related. Let us illustrate this relationship. If the cardinality of a code X is finite, one can construct its flower automaton, which is a UFA with a chosen state s such that, for each word from X, there is a separate cycle containing s and labelled by this word, see Figure 1 (left) for an example. More generally, codes that are regular languages correspond precisely to strongly connected UFAs in a similar way, see [9, Chapter 4] for the details.

Figure 1: The flower automaton of the code X={aa,aab,aba,abab} (left), two adjacent interpretations of ababa over X (top right), and two disjoint interpretations of bababaaba over X (bottom right). Note that this code is not complete, but still illustrates all the discussed properties.

A useful corollary of the construction of the flower automaton is the fact that deciding if a set of zero-one matrices generates a zero-one monoid is NL-hard. Indeed, a finite set of words is a code if and only if its flower automaton is unambiguous [9]. Deciding if a finite set of words is a code is NL-complete [45], and the flower automaton can be constructed in AC0.

A code X over Σ is called complete if every word over Σ is a factor of a concatenation of codewords, that is, for every word wΣ there exist u,vΣ with uwvX. A code that is a regular language is complete if and only if the corresponding UFA is complete [9]. For complete codes that are regular languages, the real rank of the corresponding UFA is equal to a natural and important parameter called the degree of a code [9, Proposition 9.6.1].

Let us explain the intuition behind the notion of degree, see [9, Chapter 9.6] for the formal definitions. For each word w we can consider all possible factorisations over X of all its extensions uwvX with u,vΣ, called interpretations of w. Two such interpretations either match in at least one position (as in Figure 1 (top right) between the second and the third letter), or do not match in any position (as in Figure 1 (bottom right)), in which case they are called disjoint. The degree of a word is the number of pairwise disjoint interpretations of this word. The degree of a code X is the minimum nonzero degree of all words wΣ.

A particularly important case is when a complete code has degree one. Then there exists a word wX (called a synchronising word) such that for any concatenation of codewords uwwvX with u,vΣ we have uw,wvX. Intuitively, this means that the two halves uw and wv can be decoded separately and independently.

Computational complexity classes

In this paper, we characterise the computational complexity of problems by showing that they belong to the classes NLNC2NCP, see [2, 23] for their formal definitions. NL is the class of problems solvable in nondeterministic logarithmic time. NCk is the class of problems solvable by 𝒪((logn)k)-depth polynomial-size bounded fan-in Boolean circuits, and NC is the union of these classes for all k1. The class NC represents problems that have efficient parallel algorithms, and is a subclass of problems solvable in polylogarithmic space [2]. Intuitively, NC is the class of problems that can be solved using local computations, as opposed to P-complete problems, which are inherently sequential and thus require storing the entire structure in the memory unless NC=P. Showing that a problem is in NC also allows to obtain a polynomial space algorithm for the case of exponential-size input computed by a PSPACE-transducer (as done, e.g., in [3]), which is not necessarily true for arbitrary problems solvable in polynomial time.

NC2 is an especially important class in computational algebra. To quote [23, page 468], “NC2 is the habitat of most natural problems in linear algebra”. Indeed, matrix multiplication, computing the determinant, inverse and rank of a matrix belong to NC2 [11, 18, 7, 19].

Our contributions

The known results about reachability properties of zero-one matrix monoids (including the special case of complete DFAs), such as [14, 20, 46, 34], mostly construct a product of minimum rank iteratively, with each iteration decreasing the number of different rows or the rank of a matrix. Such an approach is inherently sequential, since the matrix in the new iteration has to depend on the previous one, which thus has to be constructed explicitly. In particular, this requires matrix multiplication at every step, which heavily increases the time complexity. In this paper, we take a different direction by strongly relying on linear algebra. While linear-algebraic arguments are used widely in the synchronising automata literature, they mostly serve to decrease the number of iterations in the iterative scheme described above. Our approach is to instead relate the rank of a zero-one matrix monoid to efficiently computable linear-algebraic properties, without explicitly constructing a matrix of minimum rank.

Our first main result is that computing the rank of a zero-one matrix monoid provided in the input by a generating set of m matrices of dimension n (or, equivalently, by a UFA with n states and m letters) is in NC2 (Theorem 18) and can be done in time 𝒪(mn4) (Theorem 22). Previously, it was not known that this problem is in NC, not even for complete DFAs or finite complete codes. Moreover, the naive implementation of the polynomial time algorithm from the literature works in time 𝒪(n4+ω+mn4) [14].

These results rely on a new concept of weight of the matrices in a complete zero-one monoid. This theory of matrix weight, which we develop in Section 4, is our main technical contribution. Matrix weight is a natural generalisation of an existing notion of weight of columns of matrices in complete DFAs, which was used, e.g., in connection with the road colouring problem [21, 29, 25]. We show that all matrices in a zero-one matrix monoid have the same weight, and that this weight is tightly related to both the rank of the monoid and to the maximal weight of the columns and rows of its matrices (Section 4.3). This connection allows us to reduce the computation of the monoid rank to the computation of maximal column and row weight. Then we show that we can instead compute the weight of “maximal pseudo-columns” and “maximal pseudo-rows”, as they have the same weight as maximal columns and rows, respectively (Section 4.4). Finally, we transfer linear-algebraic techniques from the literature on weighted automata to compute those weights, and thus the rank of the monoid, efficiently (Section 5 and Section 6.2).

We complement the linear-algebraic algorithms with a combinatorial algorithm, our second main contribution. While the latter has higher time complexity of 𝒪(n2+ω+mn4) in the general case (Theorem 23), it also constructs a matrix of minimum rank in addition to computing the rank of the monoid. For complete DFAs, our combinatorial algorithm runs in time 𝒪(n3+mn2) (Theorem 24), thus outmatching the linear-algebraic counterpart and improving upon the 𝒪(m4n4) algorithm known before [43]. The two key technical ingredients of our combinatorial algorithm are explained in the beginnings of Section 6.3 and Section 6.4. Our results on the time complexity of computing the rank are summarised in the table below.

class previous best linear-algebraic algorithm combinatorial algorithm
UFA 𝒪(n4+ω+mn4) [14] 𝒪(mn4) (Theorem 22) 𝒪(n2+ω+mn4) (Theorem 23)
complete DFA 𝒪(m4n4) [43] 𝒪(mn3) (see Section 6.2) 𝒪(n3+mn2) (Theorem 24)

3 Main definitions

Let Q be a finite set, which we view as a set of states. For SQ we write [S] for the column vector x{0,1}Q such that x(q)=1 if and only if qS. We may write [q] for [{q}]. For a column vector x{0,1}Q we write xT for the transpose, a row vector. For two column vectors x1,x2Q we write x1x2 if the inequality holds component-wise. We view the elements of Q×Q (and similar sets) as matrices. Vector and matrix addition and multiplication are defined in the usual way (over ). We denote by X the span of a set X of vectors, i.e., the set of all linear combinations of X with real coefficients. The real rank of a matrix AQ×Q is, as usual, the dimension of the column space of A over the field of the reals (which equals the dimension of the row space); i.e., 𝗋𝖺𝗇𝗄(A)=dimA[q]qQ=dim[q]TAqQ.

Let 𝒜={A1,,Am} be a set of matrices from {0,1}Q×Q, and Σ={a1,,am} be a finite alphabet. We associate the letters with the matrices by setting M(ai)=Ai for 1im. Throughout this paper, when speaking about computational complexity, we assume that the input is the function M:Σ{0,1}Q×Q from letters to zero-one matrices. We can extend M:Σ{0,1}Q×Q naturally (and often implicitly) to M:Σ0Q×Q by defining M(a1ak)=M(a1)M(ak). Thus, M is a monoid homomorphism from Σ to the matrix monoid M(Σ) generated by 𝒜=M(Σ). Note that M(ε)=I, where ε denotes the empty word and I the Q×Q identity matrix. In this paper, we consider only monoid morphisms M:Σ0Q×Q that are unambiguous, i.e., M:Σ{0,1}Q×Q. If M is unambiguous, 𝒜=M(Σ) generates a finite matrix monoid M(Σ){0,1}Q×Q.

Viewing the matrices as transition matrices of an automaton, we obtain a nondeterministic finite (semi-)automaton (NFA) (Q,Σ,Δ) with transition relation Δ={(p,a,q)Q×Σ×Q[p]TM(a)[q]=1}. Recall that in this paper automata do not have dedicated initial or accepting states, see footnote 2 on page 2. We can extend Δ from letters to words in the usual way so that we have Δ={(p,w,q)Q×Σ×Q[p]TM(w)[q]1}. An NFA (Q,Σ,Δ) is unambiguous (or diamond-free) if for every two states p,q and for every two words w1,w2 there exists at most one tQ with (p,w1,t)Δ and (t,w2,q)Δ; see Figure 2 for an illustration of the forbidden configuration. We denote unambiguous NFAs as UFAs. Recall from the previous section that deciding if an NFA is unambiguous is NL-complete. In the following, we often identify M:Σ{0,1}Q×Q with the corresponding UFA (Q,Σ,Δ). In particular, a monoid homomorphism is unambiguous if and only if the corresponding NFA is unambiguous.

Figure 2: The configuration that is forbidden in a UFA.

When M (or, equivalently, Δ) is clear from the context, we may write pw={qQ(p,w,q)Δ}. Then [pw]T=[p]TM(w). Similarly, we may write wq={pQ(p,w,q)Δ}, so that [wq]=M(w)[q]. We call M strongly connected if for all p,qQ there is wΣ with pwq. We call M complete if 0M(Σ), where 0 is the zero matrix. The real rank of M (and of M(Σ)) is 𝗋𝖺𝗇𝗄(M):=min{𝗋𝖺𝗇𝗄(M(w))wΣ}. Note that M is complete if and only if 𝗋𝖺𝗇𝗄(M)0.

Suppose that |pa|=1 holds for every pQ and aΣ, or, equivalently, that every matrix in 𝒜 has exactly one 1 in each row. Then |pw|=1 holds for every pQ and wΣ. We call such UFAs complete deterministic finite (semi-)automata (complete DFAs) and we may write δ instead of Δ to highlight that it is a transition function δ:Q×ΣQ instead of a transition relation. A complete DFA (Q,Σ,δ) is complete in the sense defined above (i.e., 0M(Σ)), and for any wΣ we have that 𝗋𝖺𝗇𝗄(M(w)) is the number of nonzero columns in M(w).

4 Main concepts and the linear algebra toolbox

In this section, we introduce the main tools that we will use for both linear-algebraic and combinatorial algorithms in later sections. Until Section 4.5, we fix an unambiguous, complete, and strongly connected monoid morphism M. In Section 4.5 we will show that the case where M is not strongly connected can be easily reduced to the strongly connected case.

4.1 Columns, rows and the structure of minimum rank matrices

The concept of maximum columns and rows plays a crucial role in dealing with reachability problems in unambiguous monoid morphisms. Abusing language slightly in the following, by column we refer to column vectors of the form [wq]=M(w)[q]{0,1}Q where wΣ and qQ. Similarly, a row is of the form [qw]T=[q]TM(w). See Figure 3 for an example. In the case of complete DFAs, all rows are of the form [q]T. This fact makes complete DFAs significantly simpler to deal with than general complete UFAs.

M(a)=(1010101000000000)M(b)=(0000000001010101)
Figure 3: [a3]=M(a)[3]=[{1,2}] is a column; [2a]T=[2]TM(a)=[{1,3}]T is a row.

A column [C] is called maximal if there is no column [C] such that [C][C] and [C][C] (that is, CC). Maximal rows are defined in the same way. Recall that the inequalities are taken component-wise.

Let A{0,1}m×n be a zero-one matrix. One can view 𝗋𝖺𝗇𝗄(A) as the least number r such that there are matrices Cm×r and Rr×n with A=CR. Define the unambiguous rank 𝗋𝖺𝗇𝗄𝗎𝗇(A) as the least number r such that there are matrices C{0,1}m×r and R{0,1}r×n such that A=CR. Analogously to 𝗋𝖺𝗇𝗄(M), define also 𝗋𝖺𝗇𝗄𝗎𝗇(M):=min{𝗋𝖺𝗇𝗄𝗎𝗇(M(w))wΣ}. Clearly, 𝗋𝖺𝗇𝗄(A)𝗋𝖺𝗇𝗄𝗎𝗇(A), and the inequality can be strict, but in Corollary 2 below we show that 𝗋𝖺𝗇𝗄(M)=𝗋𝖺𝗇𝗄𝗎𝗇(M). The reason we are interested in the unambiguous rank is that Theorem 1 below implies that there is always a matrix with a very simple structure such that its unambiguous rank is equal to its real rank and both ranks are minimum.

In the following let us write r:=𝗋𝖺𝗇𝗄𝗎𝗇(M) when M is understood. A word uΣ is of minimum unambiguous rank if 𝗋𝖺𝗇𝗄𝗎𝗇(M(u))=r. If uΣ is of minimum unambiguous rank then so is vuw for all v,wΣ.

Words of unambiguous rank one, known as synchronising words, play an especially important role due to their applications in the theory of codes, as explained in Section 2. It is easy to see that a word w has unambiguous rank one if and only if there exist C,RQ such that w maps a state p to a state q if and only if pC and qR. For complete DFAs, we moreover have that C=Q and R has cardinality one.

Theorem 1 (Césari [17]).

Let uΣ be of minimum unambiguous rank. There are pairwise disjoint sets C1,,CrQ and pairwise disjoint sets R1,,RrQ such that

M(u)=i=1r[Ci][Ri]T.

Moreover, each [Ci] and [Ri]T is, respectively, a maximal column and a maximal row.

This theorem will play a central role. A proof can be found in [5, Proposition 4]. In the case of a complete DFA, R1 is a singleton and Theorem 1 is fairly obvious.

In Theorem 1, since the Ci are pairwise disjoint and the Ri are pairwise disjoint, each [Ci][Ri]T forms, intuitively, a “combinatorial rectangle”, and no such rectangle shares a row or a column with any other rectangle. The column vectors [Ci] are exactly the nonzero columns of M(u) and linearly independent, and the row vectors [Ri]T are exactly the nonzero rows of M(u) and linearly independent. Thus, r is the number of distinct nonzero columns and also the number of distinct nonzero rows in M(u). It follows that r=𝗋𝖺𝗇𝗄𝗎𝗇(M(u))=𝗋𝖺𝗇𝗄(M(u)). Thus we have:

Corollary 2.

We have r=𝗋𝖺𝗇𝗄𝗎𝗇(M)=𝗋𝖺𝗇𝗄(M).

We can thus define 𝗋𝖺𝗇𝗄(M) as 𝗋𝖺𝗇𝗄𝗎𝗇(M)=𝗋𝖺𝗇𝗄(M). For words wΣ that are not of minimum unambiguous rank, we may have 𝗋𝖺𝗇𝗄(M(w))<𝗋𝖺𝗇𝗄𝗎𝗇(M(w)), but the rank of such matrices will rarely play a role in the following. In what follows, we call words of minimum unambiguous rank simply words of minimum rank. Since we never refer to the real rank of words below, this will not lead to any confusion.

4.2 The weight of columns and rows

The results in this subsection, about the column and row vectors that appear in the matrices M(w), are mostly due to [17]; see also [5, Section 3]. Since a notion of column and row weight will be crucial for us in the later development, we phrase and prove the results around these concepts, but we do not view the lemmas of this subsection as novel.

Define A¯=1|Σ|aΣM(a)[0,1]Q×Q. Since M is strongly connected, A¯ is irreducible. Since M is unambiguous, the spectral radius of A¯ is at most 1, and since M is complete, it is at least 1. Thus, the spectral radius of A¯ equals 1. Since A¯ is irreducible, it follows from basic Perron-Frobenius theory that A¯ has an eigenvalue 1 and every right eigenvector with eigenvalue 1 is a multiple of a strictly positive vector, say β>0Q. Since A¯ has only rational entries, we can assume β>0Q. Similarly for left eigenvectors. Therefore, there are α,β>0Q with αTA¯=αT and A¯β=β. Without loss of generality, we assume that αTβ=1.

In the complete DFA case, since M(a)[Q]=[Q] for all aΣ, we have A¯[Q]=[Q] and so it is natural to take β=[Q]. In that case, αT[Q]=αTβ=1 means that αT=αTA¯ is the (unique) stationary distribution of the Markov chain whose transition probabilities are given by the row-stochastic matrix A¯; intuitively, in this Markov chain a letter aΣ is picked uniformly at random in every step.

Define the weight of a column y and of a row xT by αTy and xTβ, respectively. Denote the maximum column weight and the maximum row weight by 𝗆𝖼𝗐 and 𝗆𝗋𝗐, respectively, i.e.,

𝗆𝖼𝗐:=max{αTyy is a column} and 𝗆𝗋𝗐:=max{xTβxT is a row}.

A column y is called of maximum weight if αTy=𝗆𝖼𝗐, and analogously for rows. In the complete DFA case, every row is of the form [q]T for some qQ, hence every row is of maximum weight.

Lemma 3.

A column (respectively, row) is maximal if and only if it is of maximum weight.

An important property that we will need later is that the set of maximal columns is closed under left multiplication by matrices from the monoid, as stated in the following lemma. Note that this is no longer true without the completeness assumption, and is the key reason why the case of complete matrix monoids is easier to deal with.

Lemma 4.

Let vΣ and qQ be such that [vq] is a maximal column. Then [uvq] is a maximal column for all uΣ.

The following lemma will be useful later to construct minimum rank matrices from maximal columns and rows.

Lemma 5.

Let wΣ be such that all non-zero columns and rows in M(w) are maximal. Then ww is of minimum rank.

4.3 Weight preservation property and minimum rank

Every word w of minimum rank in a complete DFA induces a partition of the state set into subsets of states mapped by w to the same state (that is, into columns). It was observed by Friedman in [21] that all sets of such a partition have the same weight. This observation has many applications to variations of the road colouring problem [21, 29, 25, 30]. Moreover, it was proved in [25, Theorem 6], again in connection with road colouring, that for every w the weights of all columns in M(w) sum up to 1 (assuming β=[Q] as suggested previously). This can be seen as a weight preservation property: the total weight of columns in the matrix of a word is preserved under multiplication by any matrix from the monoid. As a result we get that 1=r𝗆𝖼𝗐, and hence r=1𝗆𝖼𝗐. The proof of the weight preservation property for complete DFAs is quite simple and relies on the fact that for a state q and a word w the set qw is always a singleton. For complete UFAs this is no longer true; in particular, qw can be the empty set, thus permanently “losing” some weight collected in q. Hence, a more refined property is required. The following result provides such a property. It also turns out that its proof requires more sophisticated techniques than in the complete DFA case.

Theorem 6.

For all wΣ we have 1=αTM(w)β=r𝗆𝖼𝗐𝗆𝗋𝗐.

Similarly to the complete DFA case, this result allows us to reduce computing r to computing 𝗆𝖼𝗐 and 𝗆𝗋𝗐, which we will use later in our algorithms. Recall that we have defined αT and β so that αTβ=1.

Towards a proof of Theorem 6 we first prove the following lemma.

Lemma 7.

Let uΣ be of minimum rank. Then αTM(u)β=r𝗆𝖼𝗐𝗆𝗋𝗐.

Proof.

Let M(u)=i=1r[Ci][Ri]T be as in Theorem 1. Each [Ci] and each [Ri] is of maximum weight. Thus,

αTM(u)β=i=1rαT[Ci][Ri]Tβ=i=1r𝗆𝖼𝗐𝗆𝗋𝗐=r𝗆𝖼𝗐𝗆𝗋𝗐.

We also need the following proposition.

Proposition 8.

Let xQ and c be such that xTM(u)β=c holds for all uΣ of minimum rank. Then xTM(w)β=c holds for all wΣ.

Proof.

Let wΣ. Let uΣ be of minimum rank. Recall that every word that contains u as a factor is of minimum rank. For every k0, partition Σk into sets W0(k) and W1(k) so that W0(k)=Σk(ΣuΣ) and W1(k)=Σk(ΣuΣ); i.e., W0(k),W1(k) are the sets of length-k words that do or do not contain u as a factor, respectively. For all vW0(k) both v and wv are of minimum rank. Thus, we have xTM(wv)β=c for all vW0(k). It follows that

vW0(k)xTM(wv)β|W0(k)|=cfor all k0. (1)

Let d>0 be such that |xTAβ|d for all A{0,1}Q×Q. Then we have

vW1(k)|xTM(wv)β||W1(k)|dfor all k0. (2)

Let m0. Define p1(m):=|W1(m|u|)||Σ|m|u|. We can view p1(m) as the probability of picking a word in W1(m|u|) when a word of length m|u| is picked uniformly at random. We have p1(m)(11|Σ||u|)m, as in order to avoid u as a factor, it has to be avoided in each of the m consecutive blocks of length |u|. Thus, limmp1(m)=0. We have

xTM(w)β =xTM(w)A¯β=xTM(w)A¯m|u|β=1|Σ|m|u|vΣm|u|xTM(wv)β
=|W0(m|u|)||Σ|m|u|vW0(m|u|)xTM(wv)β|W0(m|u|)|+|W1(m|u|)||Σ|m|u|vW1(m|u|)xTM(wv)β|W1(m|u|)|
=(1p1(m))c+p1(m)vW1(m|u|)xTM(wv)β|W1(m|u|)|(by Equation 1).

With Equation 2 it follows that |xTM(w)βc|p1(m)(|c|+d). Since this holds for all m0 and limmp1(m)=0, we conclude that xTM(w)β=c.

Now we prove Theorem 6.

Proof of Theorem 6.

It follows from Lemmas 7 and 8 that

αTM(w)β=r𝗆𝖼𝗐𝗆𝗋𝗐for all wΣ.

With w=ε we obtain 1=αTβ=αTM(ε)β=r𝗆𝖼𝗐𝗆𝗋𝗐, as required.

4.4 Maximal pseudo-columns

In this subsection, we define maximal pseudo-columns, which are vectors that can be seen as a relaxation of the notion of maximal columns. We show that the weight of a maximal pseudo-column is equal to the weight of a maximal column, and a maximal pseudo-column is a solution of a system of linear equations, and thus can be computed efficiently. By invoking Theorem 6, this will allow us to efficiently compute r.

Denote by 𝖬𝖢𝗈𝗅{0,1}Q the set of maximal columns. By Theorem 1 (bearing in mind also Corollary 2), the vector space spanned by all maximum columns, 𝖬𝖢𝗈𝗅, is at least r-dimensional:

Proposition 9.

We have rdim𝖬𝖢𝗈𝗅.

One might hypothesise that r=dim𝖬𝖢𝗈𝗅 or even that all minimum-rank matrices have the same r nonzero (hence, maximum) columns. The following example shows that neither is the case in general, not even for complete DFAs.

Example 10.

Consider the complete DFA with Σ={a,b} and

M(a)=(1000001000101000)M(b)=(0100010000010001)

By symmetry, we have αT=(14141414). Since no word maps states 1 and 3 to the same state, we have r=2; i.e., a and b are both minimum rank. Further, 𝖬𝖢𝗈𝗅 consists exactly of the four nonzero columns in M(a) and M(b). Their span 𝖬𝖢𝗈𝗅 is 3-dimensional, as (1111) is orthogonal to each maximum column. Thus, r=2<3=dim𝖬𝖢𝗈𝗅<4=|𝖬𝖢𝗈𝗅|.

Define the vector space U:=αTM(w)αTwΣ. Intuitively, it is the set of all differences of weight distributions over the states before and after a word is applied. Notice that for all w1,w2Σ we have αTM(w1)αTM(w2)U. Later (see the proof of Lemma 19 below) we show that U is closed under post-multiplication with M(a) for all aΣ. Such “forward spaces” play an important role in weighted automata; see, e.g., [32]. Denote the orthogonal complement of U by U; i.e., U={yQwΣ:αTM(w)y=αTy}. Intuitively, it is the set of vectors whose weight does not change under pre-multiplication with M(w) for any w (where by the weight of a vector y we understand αTy). Clearly, dimU+dimU=|Q|. The following proposition follows immediately from Lemma 4.

Proposition 11.

We have 𝖬𝖢𝗈𝗅U.

It follows that 𝖬𝖢𝗈𝗅 is a subspace of U. With Proposition 9, we have rdim𝖬𝖢𝗈𝗅dimU. One might hypothesise that 𝖬𝖢𝗈𝗅=U. The following example shows that this is not the case in general, not even for complete DFAs.

Example 12.

Consider the DFA with Σ={a,b,c} and

M(a)=(1000100000100010),M(b)=(0100010000010001),M(c)=(0010000110000100).

We have 𝖬𝖾𝗋(1)=𝖬𝖾𝗋(2)={1,2} and 𝖬𝖾𝗋(3)=𝖬𝖾𝗋(4)={3,4}. Thus, 𝖬𝖢𝗈𝗅={(1100)T,(0011)T}. Hence, dim𝖬𝖢𝗈𝗅=2.

On the other hand, by symmetry we have αT=(14141414). For any wΣ,

αTM(w)={(14141414)if w{c}(120120)if the last non-c letter in w is a(012012)if the last non-c letter in w is b .

It follows that U=(1111). Thus, dimU=41=3>2=dim𝖬𝖢𝗈𝗅, and 𝖬𝖢𝗈𝗅 is a strict subspace of U. For example, the vector (1001)T is in U but not in 𝖬𝖢𝗈𝗅.

Although the dimension of U does not generally equal r, the vector space U turns out useful for computing r. Recall that, by Theorem 6, we can obtain r by computing 𝗆𝖼𝗐 (and, symmetrically, 𝗆𝗋𝗐). For qQ define

𝖬𝖾𝗋(q):={qQS{q,q} such that [S] is a column}.

Intuitively, 𝖬𝖾𝗋(q) consists of the states that can “appear” in a column together with q, or, equivalently, the states that are “mergeable” with q (that is, can be mapped to the same state by a word). Note that q𝖬𝖾𝗋(q). We will need the following lemma which is easy to prove.

Lemma 13.

Let vΣ and qQ be such that [vq] is a maximal column. Then vq= holds for all q𝖬𝖾𝗋(q){q}.

We call a vector yU a maximal pseudo-column if there is qQ with y(q)=1 and y(q)=0 for all q𝖬𝖾𝗋(q). This notion, which is closely related to the “pseudo-cuts” from [35], can be seen as a relaxation of the notion of a maximal column: clearly, every maximal column is a maximal pseudo-column, but the converse is not true, since a maximal pseudo-column is not necessarily a vector over {0,1}, let alone a column in the strict sense, i.e., of the form [wp]. The following lemma however shows that the weight of a maximal pseudo-column is equal to the weight of a maximal column. We will later show that computing the former can be done in NC2.

Lemma 14.

Let y be a maximal pseudo-column. Then αTy=𝗆𝖼𝗐.

Proof.

Let qQ be such that y(q)=1 and y(q)=0 for all q𝖬𝖾𝗋(q). Let wΣ be such that [wq] is a maximal column. We have

αTy =αTM(w)y (yU)
=qQy(q)αT[wq]
=q𝖬𝖾𝗋(q)y(q)αT[wq] (y(q)=0 for q𝖬𝖾𝗋(q))
=αT[wq]+q𝖬𝖾𝗋(q){q}y(q)αT[wq] (y(q)=1)
=αT[wq] (Lemma 13)
=𝗆𝖼𝗐 (by the choice of w,q).

Example 15.

We continue Example 10. We have U=(1111) and 𝖬𝖾𝗋(2)={1,2,3}. Let y=(4/311/30)T. Then yU. Since y(2)=1 and y(4)=0, vector y is a maximal pseudo-column. Thus, by Lemma 14, 𝗆𝖼𝗐=αTy=(14141414)y=12.

Theorem 16.

Let Γ be a basis of U, and let qQ. Then the following linear system for yQ has a solution, and all its solutions are maximal pseudo-columns:

γTy = 0for all γTΓ
y(q) = 1
y(q) = 0for all q𝖬𝖾𝗋(q).
Proof.

By Proposition 11, any maximal column solves the linear system. Let yQ be a solution of the linear system. The equations on the first line guarantee that yU. Then, the equations on the second and third line guarantee that y is a maximal pseudo-column.

4.5 Dealing with the non-strongly connected case

The following lemma shows that in order to compute the minimum rank we can focus on the strongly connected case.

Proposition 17.

Let M:Σ{0,1}Q×Q be an unambiguous matrix monoid morphism. Suppose that Q1Q2=Q is a partition of Q such that for all wΣ it holds that [Q2]TM(w)[Q1]=0; i.e., for all wΣ matrix M(w) has the block form M(w)=(M1(w)M12(w)0M2(w)), where M1(w){0,1}Q1×Q1 and M12(w){0,1}Q1×Q2 and M2(w){0,1}Q2×Q2. We have 𝗋𝖺𝗇𝗄(M)=𝗋𝖺𝗇𝗄(M1)+𝗋𝖺𝗇𝗄(M2) and 𝗋𝖺𝗇𝗄𝗎𝗇(M)=𝗋𝖺𝗇𝗄𝗎𝗇(M1)+𝗋𝖺𝗇𝗄𝗎𝗇(M2).

By a straightforward induction it follows from Proposition 17 that the minimum rank of an unambiguous matrix monoid is the sum of the minimum ranks of its strongly connected components (where “incomplete” components count as having rank 0).

5 Computing the rank in NC2

In this section, we prove our first main result, which is as follows.

Theorem 18.

The problem of computing the (real) rank of an unambiguous matrix monoid is in NC2.

In order to use Theorem 16, we need the following lemma. We use the notation defined in the previous section. Recall that we defined U:=αTM(w)αTwΣ.

Lemma 19.

If M is strongly connected, one can compute a basis of U in NC2.

For each aΣ define M(a):=M(a)I{1,0,1}Q×Q and extend M to M:ΣQ×Q by defining M(a1ak)=M(a1)M(ak). Define U:=αTM(w)wΣ+. Note that here w ranges over Σ+, i.e., nonempty words, only. By definition, U is closed under right multiplication by M(a) for all aΣ. We first show the following lemma.

Lemma 20.

We have U=U.

Proof.

For the inclusion UU, we prove by induction on i0 that for all length-i words wΣi we have αT(M(w)I)U. Concerning the induction base, i=0, we have αT(M(ε)I)=0U. Concerning the induction step, let i0, and let wΣi and aΣ. We have

αT(M(wa)I) =αT(M(w)I)M(a)+αT(M(a)I)
=αT(M(w)I)(M(a)I)+αT(M(w)I)+αT(M(a)I)
=αT(M(w)I)M(a)+αT(M(w)I)+αTM(a).

It holds that αTM(a)U, and, by the induction hypothesis, αT(M(w)I)U. It follows that αT(M(wa)I)U.

For the converse, UU, we proceed similarly by induction. Concerning the induction base, i=1, for all aΣ we have αTM(a)=αT(M(a)I)U. Concerning the induction step, let i1, and let wΣi and aΣ. By the induction hypothesis there are n|Q| and w1,,wnΣ and λ1,,λn such that αTM(w)=i=1nλiαT(M(wi)I). Thus, we have

αTM(wa) =αTM(w)(M(a)I)=i=1nλiαT(M(wi)I)(M(a)I)
=i=1nλiαT((M(wia)I)(M(a)I)(M(wi)I))U,

as required.

Proof of Lemma 19.

For each aΣ define Ua:=αTM(a)M(w)wΣ. Using the technique from [33, Section 4.2] (see [32, Proposition 5.2] for a clearer explanation), for each aΣ one can compute333In [33, 32] only membership in NC is claimed, but the bottleneck computations are matrix powering and rank computation, which can in fact be done in DETNC2; see [18]. The computations in [32, Proposition 5.2] are on polynomially larger matrices, but this does not impact the membership in NC2, as log2(𝑝𝑜𝑙𝑦(n))=O(log2(n)). a basis of Ua in NC2. The union of these bases, say Γ={γ1T,,γnT} for some n|Σ||Q|, spans U, which equals U by Lemma 20. To shrink Γ to a basis of U, for each i{1,,n} include γiT in the basis if and only if dimγ1T,,γi1T<dimγ1T,,γiT. The latter (rank) computation can be done in NC2 [27].

Now we can prove Theorem 18.

Proof of Theorem 18.

Let M:Σ{0,1}Q×Q be an unambiguous monoid morphism. Its strongly connected components can be computed in NLNC2. It follows from the proof of [34, Proposition 3] that one can check each component for completeness in NC2, since a zero-one monoid contains the zero matrix if and only if the joint spectral radius of the set of its generators is strictly less than one [34]. Therefore, using Proposition 17, we can assume in the rest of the proof that M is complete and strongly connected.

We use the fact that one can compute a solution of a possibly singular linear system of equations in NC2 [11, Section 5]. First, compute in NC2 vectors α,β>0Q with αTA¯=αT and A¯β=β and αTβ=1. Using Lemma 19 compute in NC2 a basis of U. Choose an arbitrary qQ and compute 𝖬𝖾𝗋(q) in NLNC2 with a reachability analysis. Then, solve the linear system from Theorem 16 to compute in NC2 a maximal pseudo-column yQ. Hence, using Lemma 14, we can compute 𝗆𝖼𝗐=αTy in NC2. Symmetrically, we can compute 𝗆𝗋𝗐 in NC2. Finally, by Theorem 6, we can compute r=1𝗆𝖼𝗐𝗆𝗋𝗐 in NC2.

Example 21.

We continue Examples 10 and 15. Since M is a complete DFA, it is natural to take β=[Q]. Note that αTβ=1. Since every row is of the form [q]T for some q, we have 𝗆𝗋𝗐=1. Recall from Example 15 that 𝗆𝖼𝗐=12. With Theorem 6 we conclude that r=1𝗆𝖼𝗐𝗆𝗋𝗐=2, as observed in Example 10.

6 Time and space complexity

In this section, we study the time and space complexity of computing the rank of a zero-one matrix monoid and finding a matrix of minimum rank in it. We provide two approaches. The first one relies on the linear-algebraic tools developed in Section 4. It turns out to be faster than the second, combinatorial, approach, but is limited to only computing the rank. This is due to the fact that we never explicitly construct a maximal column in this approach, which is required in order to find a matrix of minimum rank by Theorem 1. Moreover, it is not known if one can find a maximal column in NC. In contrast, the combinatorial approach explicitly constructs a matrix of minimum rank step by step. In a way, this is exactly the reason why it is slower than the linear-algebraic approach, since this requires performing a large number of matrix multiplications. In the complete DFAs case, where direct matrix multiplication can be avoided due to the special shape of transformation matrices, it becomes much more efficient, and outmatches its linear-algebraic counterpart by a factor of the alphabet size.

The three main results of this section are as follows.

Theorem 22.

The (real) rank of an n-state UFA over an alphabet of size m can be computed in 𝒪(mn4) time and 𝒪(n2) space.

Theorem 23.

A matrix of minimum (real) rank in an n-state UFA over an alphabet of size m can be found in 𝒪(n2+ω+mn4) time and 𝒪(n3) space.

Theorem 24.

A matrix of minimum (real) rank in an n-state complete DFA over an alphabet of size m can be found in 𝒪(n3+mn2) time and 𝒪(n2) space.

Until the end of the section, fix a strongly connected complete UFA 𝒜=(Q,Σ,Δ). Denote n=|Q|, m=|Σ|. Section 4.5 shows that strong connectivity can be assumed without loss of generality.

6.1 Square automaton and square digraph

We will need the construction of the square automaton of an NFA. The square automaton 𝒜(2)=(Q(2),Σ,Δ(2)) of 𝒜 is defined as follows. Let Q(2)={(p,q)p,qQ}, and for p,qQ and aΣ, the transitions are defined component-wise, that is,

Δ(2)={((p,q),a,(p,q))Q(2)×Σ×Q(2)(p,a,p),(q,a,q)Δ}.

Note that the square automaton of a complete DFA is also a complete DFA.

We call states of the form (q,q) in 𝒜(2) singletons. Observe that the restriction of 𝒜(2) to singletons is equal to 𝒜. We denote by G(2)=(V(2),E(2)) the underlying digraph of 𝒜(2) obtained by forgetting the labels of the transitions. Note that |E(2)|=𝒪(mn4), and there exists an infinite series of complete UFAs over a two-letter alphabet with |E(2)|=Θ(n4) [36, Appendix A]. If 𝒜 is a complete DFA, then |E(2)|=mn2.

6.2 Minimum rank in 𝓞(𝒎𝒏𝟒) time

We now perform the steps of the linear-algebraic algorithm described in Section 5, but implement them efficiently in terms of time and space complexity.

Lemma 25.

For a state p, the set 𝖬𝖾𝗋(p) can be computed in 𝒪(mn4) time and 𝒪(n2) space.

Proof.

Perform a multi-source backwards digraph search starting from all singletons in G(2) and label all states qQ such that (p,q) or (q,p) is visited during this search. This search can be performed in time linear in the number of edges of |E(2)|, and |E(2)|=𝒪(mn4). Observe that only the vertices of this digraph have to be stored in the memory explicitly, since the edges can be computed on the fly from the input without increasing the time complexity, hence the space complexity of the algorithm is 𝒪(n2).

Lemma 26.

A maximal pseudo-column can be found in 𝒪(mn4) time and 𝒪(n2) space.

Proof.

To use Theorem 16 we first need to set up the linear system of equations described there. The average matrix A¯ can be computed in time 𝒪(mn2). The weight vectors α,βQ can then be computed in time 𝒪(n3) by solving a system of linear equations. Then, using Lemma 25, we compute in 𝒪(mn4) time the set 𝖬𝖾𝗋(p) for some state p. We also need to compute a basis of the vector space U defined in Section 4.4. As in the proof of Lemma 19, we compute a basis of U=U=αTM(w)wΣ+, which is the smallest vector space that contains αTM(a) for all aΣ and is closed under post-multiplication with M(a) for all aΣ. This can be done in 𝒪(mn3) time and 𝒪(n2) space using a worklist algorithm and keeping a basis in echelon form using Gaussian elimination, as described, e.g., in [32, Section 2]. Finally, we solve the system of linear equations from Theorem 16, which can be done in 𝒪(n3) time. Each step requires at most 𝒪(n2) space.

By Lemma 14, we thus get that 𝗆𝖼𝗐 and 𝗆𝗋𝗐 can be computed in 𝒪(mn4) time and 𝒪(n2) space, which together with Theorem 6 proves Theorem 22. We remark that for complete DFAs the proof of Lemma 26 gives 𝒪(mn3) time for computing the rank. The combinatorial algorithm provided below will improve it to 𝒪(n3+mn2) (see Section 6.5), while additionally finding a matrix of minimum rank.

6.3 Efficiently constructing a maximal column

We now consider a more general problem of finding a matrix of minimum rank in a zero-one matrix monoid. As mentioned above, by Theorem 1 we have to explicitly construct a maximal column for that, which turns out to be a more difficult task in terms of the time complexity. We will see in the next subsection that we only need one maximal column (together with a word constructing it) to get a matrix of minimum rank. The goal of this subsection is thus to show how to efficiently compute a short representation of a word constructing a maximal column, since the word itself may be longer than the time complexity we are aiming for. We do so by reusing repeating subwords in such a word, and describing their occurrences with a straight line program.

In [20, Section 5], an algorithm for constructing a word of rank one in complete DFAs in 𝒪(m3+mn2) time and 𝒪(n2) space was suggested. Our approach for finding a maximal column and a word constructing it follows a similar direction, with a few key differences. Firstly, we observe that it is enough to only compute words merging states with one chosen state p, instead of finding all pairs of mergeable states. This both simplifies the algorithm (in [20] an additional step is required to decrease the space complexity from 𝒪(n3) to 𝒪(n2), which we get for free) and allows to present our results in terms of straight line programs, giving a better insight into the regularities present in the constructed word of minimum rank.

We define set straight line programs (set-SLPs), which are just SLPs with multiple initial symbols, and thus encode a set of words instead of one word. Formally, a set-SLP is a tuple (𝒱,Σ,R,𝒮), where 𝒱 and Σ are disjoint finite sets of nonterminal and terminal symbols respectively, R:𝒱(𝒱Σ) is a function defining a derivation rule for each nonterminal symbol, and 𝒮𝒱 is a set of initial symbols. For v𝒱, we write R(v) as vw with w(𝒱Σ), and we call v and w the left- and right-hand sides of this derivation rule respectively. The length of a set-SLP is the total length of the right-hand sides of all the derivation rules. The semantics of a set-SLP is defined as follows. Given an initial symbol s𝒮, we recursively replace each symbol in R(s) with the right-hand side of its derivation rule until we obtain a word over Σ, which is called the word encoded by s. We require that each initial symbol produces a unique word over Σ as a result of such derivation. Namely, we require that there exists a total linear order on the set 𝒱 such that for all v with vw, w does not contain v𝒱 with vv. The (multi-)set of words encoded by all initial symbols is called the set of words encoded by a set-SLP.

Example 27.

Consider a set-SLP ({w1,w3,w5,u1,u2,u3},{a,b},R,{w1,w3,w5}) with

w1u1,w3u3u2,w5u2,u1aab,u2aab,u3aaba.

This set-SLP encodes the (multi-)set {aab,aabaaab,aab}, and illustrates the reason why we are using set-SLPs: they allow to construct sets of words out of smaller “pieces” without having to explicitly repeat these “pieces” multiple times (in our example, we are reusing u2). Note that the set-SLPs that we construct below only encode sets of words whose total length is polynomial in the size of the set-SLPs.

Lemma 28.

Given a state p, a set-SLP of length 𝒪(n2) defining a set {wqq𝖬𝖾𝗋(p)}, where wq is a word with ppwq and pqwq, can be computed in 𝒪(mn4) time and 𝒪(n2) space.

Proof sketch.

Call vertices (p,q) with q𝖬𝖾𝗋(p) merging. The idea is to construct, by a digraph search of G(2), a directed tree T rooted in (p,p) and containing a path from each merging vertex to the root, and then use the joint subpaths of these paths in the tree to obtain a short set-SLP describing these paths. See Figure 5 for an example.

Figure 5: An example of 𝒜 (left), and a part of the underlying digraph G(2) of its square automaton (right). Merging vertices are doubly circled. The edges of T for p=7 are represented by dotted edges, and these edges are labelled with one of the letters labelling the corresponding transition in 𝒜(2). Furthermore, we have ρ1=(7,1)(8,2)(1,3)(4,4), ρ2=(5,7)(6,8)(3,1)(4,4), ρ3=(7,3)(8,4)(1,5)(4,6)(5,7). A set-SLP encoding the labels of these path is presented in Example 27, with ui labelling the path ρi, i{1,2,3}.
Lemma 29.

For a given state p of 𝒜, an SLP of length 𝒪(n2) encoding a word w such that [wp] is a maximal column can be computed in 𝒪(n2+ω+mn4) time and 𝒪(n3) space.

Proof sketch.

Compute the matrices of the words encoded by the set-SLP from Lemma 28. We rely on the property, already used in some form in [14], that if for all q𝖬𝖾𝗋(p), qp, the vector [wq] is zero, then [wp] is a maximal column. To construct a word with this property, we iteratively concatenate the words wq depending on nonzero columns in the matrix in each iteration. The number of iterations is bounded by n.

6.4 Finding a matrix of minimum rank

We now use the results of the previous section to construct a matrix of minimum rank. The key idea is as follows: since the set of maximal columns is stable under left multiplication by matrices from the monoid, we can iteratively make each column of the matrix maximal or zero by, intuitively, applying the same word (together with a short “reachability” word) to a state in each column. This simple observation significantly decreases the time complexity of our algorithm compared to the naive implementation of the algorithm from [14] constructing a word of minimum rank. Indeed, in the approach of [14], the word is constructed letter by letter, and requires to know the result of applying the last letter at every step. Since the constructed word has length 𝒪(rn3)=𝒪(n4), where n is the number of states and r is the rank, this results in 𝒪(n4+ω) time complexity. By efficiently constructing only one maximal column (as described in the previous section) and reusing it for the whole set of states (as described in this section), we decrease the time complexity to 𝒪(n2+ω).

Proposition 30.

An SLP of length 𝒪(n2) encoding a word w of minimum rank can be computed in 𝒪(n2+ω+mn4) time and 𝒪(n3) space.

Proof sketch.

Compute the matrix of the word w encoded by the SLP from Lemma 29. Iteratively, for each qQ, concatenate w with a word of length at most n mapping p to a state corresponding to a nonzero element of the row in the current iteration. Denote by wn the resulting word, which has the property that all nonzero columns of M(wn) are maximal. Symmetrically compute wn for rows. Then by Lemma 5 the word wnwnwnwn matrix has minimum rank.

Given an SLP of length 𝒪(n2) encoding a word w, we can compute the matrix of w by computing the matrices of words occurring in the derivation of w from bottom to top in time 𝒪(n2+ω). Thus we prove Theorem 23. We also get the following result, which can be seen as a proof of a very weak version of the Černý conjecture generalised from rank one words in complete DFAs to minimum rank words in complete UFAs.

Theorem 31.

For every n-state complete UFA, there exists an SLP of length 𝒪(n2) encoding a word of minimum rank.

We remark that the length of the word encoded by the constructed SLP asymptotically matches the best known upper bound for words of minimum rank: 𝒪(n4) for complete UFAs [14] and 𝒪(n3) for complete DFAs [37]. In particular, one can efficiently compute words of minimum rank within these bounds.

6.5 Complete DFAs

For complete DFAs, we follow the same algorithms as in the proof of Theorem 23, but exploit the fact that elementary matrix operations can be performed more efficiently. Namely, if 𝒜 is a complete DFA, then each word defines a transformation on Q. By storing matrices of words as transformations, we get that matrix multiplication can be performed in 𝒪(n) time, and each matrix requires 𝒪(n) space. Moreover, we have |E(2)|=mn2. By taking these improvements into account, we get the proof of Theorem 24.

7 Conclusions and open problems

We list a few open questions that follow directly from our work.

  • In [20], it was asked if a word of rank one for a complete DFA can be found in NC. Similarly, can a matrix of minimum rank for a complete DFA be computed in NC?

  • Given an unambiguous morphism M:Σ{0,1}Q×Q and a vector α>0Q, can a basis of αTM(w)wΣ be computed faster than in 𝒪(|Q|3) time? This would improve algorithms for several fundamental problems for weighted automata [32]. Similarly, for complete DFAs, computing a basis of U from Section 4.4 in subcubic time (see the proof of Lemma 26) would allow to compute the minimum rank of a complete DFA faster than in cubic time.

  • The bottleneck in the time complexity in Theorem 22 is the very first step, computing 𝖬𝖾𝗋(q) via digraph search in the square digraph of 𝒜. The number of edges of this digraph can be quadratic in the number of its vertices [36, Appendix A], hence of order |Q|4. Can 𝖬𝖾𝗋(q) be computed faster than in time 𝒪(|Q|4)? Very little seems to be known about general properties of square automata of DFAs or UFAs.

  • One of the bottlenecks of the combinatorial algorithm is performing matrix multiplication. Can it be done faster for matrices from a zero-one matrix monoid? If not, are there any subclasses of UFAs (other than DFAs) where it can be done more efficiently?

References

  • [1] Jorge Almeida and Benjamin Steinberg. Matrix mortality and the Černý-Pin conjecture. In Volker Diekert and Dirk Nowotka, editors, Developments in Language Theory, pages 67–80, Berlin, Heidelberg, 2009. Springer Berlin Heidelberg. doi:10.1007/978-3-642-02737-6_5.
  • [2] Sanjeev Arora and Boaz Barak. Computational complexity: a modern approach. Cambridge University Press, 2009.
  • [3] Christel Baier, Stefan Kiefer, Joachim Klein, David Müller, and James Worrell. Markov chains and unambiguous automata. Journal of Computer and System Sciences, 136:113–134, 2023. doi:10.1016/J.JCSS.2023.03.005.
  • [4] M.-P. Béal and D. Perrin. Synchronised automata. In Valérie Berthé and Michel Rigo, editors, Combinatorics, Words and Symbolic Dynamics, Encyclopedia of Mathematics and its Applications, pages 213–240. Cambridge University Press, 2016. doi:10.1017/CBO9781139924733.008.
  • [5] Marie-Pierre Béal, Eugen Czeizler, Jarkko Kari, and Dominique Perrin. Unambiguous automata. Math. Comput. Sci., 1(4):625–638, 2008. doi:10.1007/S11786-007-0027-1.
  • [6] Paul C. Bell, Igor Potapov, and Pavel Semukhin. On the mortality problem: From multiplicative matrix equations to linear recurrence sequences and beyond. Information and Computation, 281:104736, 2021. doi:10.1016/J.IC.2021.104736.
  • [7] Stuart J. Berkowitz. On computing the determinant in small parallel time using a small number of processors. Information Processing Letters, 18(3):147–150, 1984. doi:10.1016/0020-0190(84)90018-8.
  • [8] Mikhail V. Berlinkov. On two algorithmic problems about synchronizing automata (short paper). In Arseny M. Shur and Mikhail V. Volkov, editors, Developments in Language Theory – 18th International Conference, DLT 2014, Ekaterinburg, Russia, August 26-29, 2014. Proceedings, volume 8633 of Lecture Notes in Computer Science, pages 61–67. Springer, 2014. doi:10.1007/978-3-319-09698-8_6.
  • [9] Jean Berstel, Dominique Perrin, and Christophe Reutenauer. Codes and automata, volume 129. Cambridge University Press, 2010.
  • [10] Vincent D. Blondel, Raphaël M. Jungers, and Alex Olshevsky. On primitivity of sets of matrices. Automatica, 61:80–88, 2015. doi:10.1016/J.AUTOMATICA.2015.07.026.
  • [11] Allan Borodin, Joachim von zur Gathen, and John E. Hopcroft. Fast parallel matrix and GCD computations. Information and Control, 52(3):241–256, 1982. doi:10.1016/S0019-9958(82)90766-5.
  • [12] Greg Budzban and Philip Feinsilver. The generalized road coloring problem and periodic digraphs. Applicable Algebra in Engineering, Communication and Computing, 22:21–35, 2011. doi:10.1007/S00200-010-0135-Z.
  • [13] Georgina Bumpus, Christoph Haase, Stefan Kiefer, Paul-Ioan Stoienescu, and Jonathan Tanner. On the size of finite rational matrix semigroups. In Artur Czumaj, Anuj Dawar, and Emanuela Merelli, editors, 47th International Colloquium on Automata, Languages, and Programming, ICALP 2020, July 8-11, 2020, Saarbrücken, Germany (Virtual Conference), volume 168 of LIPIcs, pages 115:1–115:13. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. doi:10.4230/LIPICS.ICALP.2020.115.
  • [14] Arturo Carpi. On synchronizing unambiguous automata. Theoretical Computer Science, 60:285–296, 1988. doi:10.1016/0304-3975(88)90114-4.
  • [15] Arturo Carpi and Flavio D’Alessandro. Strongly transitive automata and the Černý conjecture. Acta Informatica, 46(8):591–607, 2009. doi:10.1007/S00236-009-0106-7.
  • [16] Julien Cassaigne, Vesa Halava, Tero Harju, and François Nicolas. Tighter undecidability bounds for matrix mortality, zero-in-the-corner problems, and more. CoRR, abs/1404.0644, 2014. arXiv:1404.0644.
  • [17] Yves Césari. Sur l’application du théorème de Suschkewitsch à l’étude des codes rationnels complets. In Jacques Loeckx, editor, Automata, Languages and Programming, 2nd Colloquium, University of Saarbrücken, Germany, July 29 - August 2, 1974, Proceedings, volume 14 of Lecture Notes in Computer Science, pages 342–350. Springer, 1974. doi:10.1007/3-540-06841-4_73.
  • [18] Stephen A. Cook. A taxonomy of problems with fast parallel algorithms. Inf. Control., 64(1-3):2–21, 1985. doi:10.1016/S0019-9958(85)80041-3.
  • [19] Laszlo Csanky. Fast parallel matrix inversion algorithms. SIAM Journal on Computing, 5(4):618–623, 1976. doi:10.1137/0205040.
  • [20] David Eppstein. Reset sequences for monotonic automata. SIAM Journal on Computing, 19(3):500–510, 1990. doi:10.1137/0219033.
  • [21] Joel Friedman. On the road coloring problem. Proceedings of the American Mathematical Society, 110(4):1133–1135, 1990.
  • [22] Balázs Gerencsér, Vladimir V. Gusev, and Raphaël M. Jungers. Primitive sets of nonnegative matrices and synchronizing automata. SIAM Journal on Matrix Analysis and Applications, 39(1):83–98, 2018. doi:10.1137/16M1094099.
  • [23] Oded Goldreich. Computational Complexity: A Conceptual Perspective. Cambridge University Press, 2008. doi:10.1017/CBO9780511804106.
  • [24] Pavel Goralčík and Václav Koubek. Rank problems for composite transformations. International Journal of Algebra and Computation, 05(03):309–316, 1995. doi:10.1142/S0218196795000185.
  • [25] Vladimir V. Gusev and Elena V. Pribavkina. On synchronizing colorings and the eigenvectors of digraphs. In Piotr Faliszewski, Anca Muscholl, and Rolf Niedermeier, editors, 41st International Symposium on Mathematical Foundations of Computer Science, MFCS 2016, August 22-26, 2016 - Kraków, Poland, volume 58 of LIPIcs, pages 48:1–48:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2016. doi:10.4230/LIPICS.MFCS.2016.48.
  • [26] Markus Holzer and Sebastian Jakobi. On the computational complexity of problems related to distinguishability sets. Information and Computation, 259(2):225–236, 2018. doi:10.1016/J.IC.2017.09.003.
  • [27] Oscar H. Ibarra, Shlomo Moran, and Louis E. Rosier. A note on the parallel complexity of computing the rank of order n matrices. Information Processing Letters, 11(4/5):162, 1980. doi:10.1016/0020-0190(80)90042-3.
  • [28] Gérard Jacob. Un algorithme calculant le cardinal, fini ou infini, des demi-groupes de matrices. Theoretical Computer Science, 5(2):183–204, 1977. doi:10.1016/0304-3975(77)90006-8.
  • [29] Jarkko Kari. A counter example to a conjecture concerning synchronizing words in finite automata. Bulletin of the EATCS, 73:146, 2001.
  • [30] Jarkko Kari, Andrew Ryzhikov, and Anton Varonka. Words of minimum rank in deterministic finite automata. In Piotrek Hofman and Michal Skrzypczak, editors, Developments in Language Theory – 23rd International Conference, DLT 2019, Warsaw, Poland, August 5-9, 2019, Proceedings, volume 11647 of Lecture Notes in Computer Science, pages 74–87. Springer, 2019. doi:10.1007/978-3-030-24886-4_5.
  • [31] Nasim Karimi. Reaching the minimum ideal in a finite semigroup. Semigroup Forum, 94(2):390–425, 2017.
  • [32] Stefan Kiefer. Notes on equivalence and minimization of weighted automata. https://arxiv.org/abs/2009.01217, 2020. arXiv:arXiv:2009.01217.
  • [33] Stefan Kiefer, Ines Marusic, and James Worrell. Minimisation of multiplicity tree automata. Logical Methods in Computer Science, 13(1), 2017. doi:10.23638/LMCS-13(1:16)2017.
  • [34] Stefan Kiefer and Corto N. Mascle. On nonnegative integer matrices and short killing words. SIAM Journal on Discrete Mathematics, 35(2):1252–1267, 2021. doi:10.1137/19M1250893.
  • [35] Stefan Kiefer and Cas Widdershoven. Efficient analysis of unambiguous automata using matrix semigroup techniques. In Peter Rossmanith, Pinar Heggernes, and Joost-Pieter Katoen, editors, 44th International Symposium on Mathematical Foundations of Computer Science, MFCS 2019, August 26-30, 2019, Aachen, Germany, volume 138 of LIPIcs, pages 82:1–82:13. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2019. doi:10.4230/LIPICS.MFCS.2019.82.
  • [36] Stefan Kiefer and Cas Widdershoven. Efficient analysis of unambiguous automata using matrix semigroup techniques. CoRR, abs/1906.10093, 2019. arXiv:1906.10093.
  • [37] A.A. Klyachko, I.K. Rystsov, and M.A. Spivak. An extremal combinatorial problem associated with the bound on the length of a synchronizing word in an automaton. Cybernetics, 23(2):165–171, 1987.
  • [38] Douglas A. Lind and Brian Marcus. An introduction to symbolic dynamics and coding. Cambridge university press, 2021.
  • [39] Arnaldo Mandel and Imre Simon. On finite semigroups of matrices. Theoretical Computer Science, 5(2):101–111, 1977. doi:10.1016/0304-3975(77)90001-9.
  • [40] Mike Paterson. Unsolvability in 3×3 matrices. Studies in Applied Mathematics, 49:105–107, 1970.
  • [41] Vladimir Yu. Protasov. Analytic methods for reachability problems. Journal of Computer and System Sciences, 120:1–13, 2021. doi:10.1016/J.JCSS.2021.02.007.
  • [42] Vladimir Yu. Protasov and Andrey S. Voynov. Matrix semigroups with constant spectral radius. Linear Algebra and its Applications, 513:376–408, 2017.
  • [43] Igor Rystsov. Rank of a finite automaton. Cybernetics and Systems Analysis, 28(3):323–328, 1992.
  • [44] Igor K. Rystsov. Reset words for commutative and solvable automata. Theoretical Computer Science, 172(1-2):273–279, 1997. doi:10.1016/S0304-3975(96)00136-3.
  • [45] Wojciech Rytter. The space complexity of the unique decipherability problem. Information Processing Letters, 23(1):1–3, 1986. doi:10.1016/0020-0190(86)90121-3.
  • [46] Andrew Ryzhikov. Mortality and synchronization of unambiguous finite automata. In Robert Mercas and Daniel Reidenbach, editors, Combinatorics on Words – 12th International Conference, WORDS 2019, Loughborough, UK, September 9-13, 2019, Proceedings, volume 11682 of Lecture Notes in Computer Science, pages 299–311. Springer, 2019. doi:10.1007/978-3-030-28796-2_24.
  • [47] Andrew Ryzhikov. On shortest products for nonnegative matrix mortality. In Laura Kovács and Ana Sokolova, editors, Reachability Problems – 18th International Conference, RP 2024, Vienna, Austria, September 25-27, 2024, Proceedings, volume 15050 of Lecture Notes in Computer Science, pages 104–119. Springer, 2024. doi:10.1007/978-3-031-72621-7_8.
  • [48] Sujin Shin and Jisang Yoo. A note on the rank of semigroups. Semigroup Forum, 81(2):335–343, 2010.
  • [49] Mikhail V. Volkov. Synchronizing automata and the Černý conjecture. In Carlos Martín-Vide, Friedrich Otto, and Henning Fernau, editors, Language and Automata Theory and Applications, Second International Conference, LATA 2008, Tarragona, Spain, March 13-19, 2008. Revised Papers, volume 5196 of Lecture Notes in Computer Science, pages 11–27. Springer, 2008.
  • [50] Mikhail V. Volkov. Synchronization of finite automata. Russian Mathematical Surveys, 77(5):819–891, 2022. doi:10.4213/rm10005e.
  • [51] Yaokun Wu and Yinfeng Zhu. Primitivity and Hurwitz primitivity of nonnegative matrix tuples: A unified approach. SIAM Journal on Matrix Analysis and Applications, 44(1):196–211, 2023. doi:10.1137/22M1471535.