Revisiting Finiteness of Matrix Monoids
Abstract
This paper concerns decision problems related to finite monoids of rational matrices. We show that determining finiteness of a given finitely presented monoid is in PSpace, improving the known bound. We also show that the membership problem for finite matrix monoids is PSpace-complete, improving the known NExp-upper bound. Our two complexity results are corollaries of a new polynomial bit-size bound on matrix entries in finite monoids. This is obtained by reduction to the case of matrix groups, using the structure theory of noncommutative algebras and of matrix monoids. Our techniques also give us a polynomial-time algorithm for deciding whether a monoid of rational matrices is conjugate to a monoid of integer matrices.
Keywords and phrases:
Matrix Semigroups, Finiteness, Integrality, Bitsize BoundCategory:
Track B: Automata, Logic, Semantics, and Theory of ProgrammingFunding:
Rida Ait El Manssour: Supported by the EPSRC Fellowship (EP/X033813/1).Copyright and License:
and James Ben Worrell; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Automata over infinite objectsEditors:
Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele PuppisSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
1.1 Main Results
The study of decision problems for matrix monoids – and their connections with automata theory – has a long history, spanning more than sixty years; see [13, 3] for a comprehensive survey. The connection between automata and monoids arises from the fact that the transition maps of automata give rise to matrix monoids with entries in a semiring. A particularly important instance is weighted automata over the field of rational numbers. In this setting, questions about the support and the growth of the formal series recognised by weighted automata reduce to questions about finitely generated matrix monoids over . In this paper we revisit several classical decision problems for monoids of rational matrices and obtain new complexity results.
We consider the following three problems, in which the input monoid is specified with a positive integer and a finite set of matrices generating a monoid .
-
1.
Finiteness Problem: given , determine whether is finite.
-
2.
Finite Membership Problem: given and a target matrix , determine whether , under the promise that is finite.
-
3.
Integrality Problem: given , determine whether is conjugate to a matrix monoid with integer entries.
Our first main result shows that the Finiteness Problem is in PSpace, improving the upper bound of [4, Theorem 13]. Our second main result establishes that the Finite Membership Problem is PSpace-complete. The PSpace upper bound improves the NExp bound of [4, Theorem 14], and we provide a matching PSpace lower bound. A key technical ingredient underlying both upper bounds is a polynomial bound (in the input size of the generators) on the bitsize of matrix entries appearing in finite monoids. Using tools developed for these two results, we further show that both the decision and function versions of the Integrality Problem can be solved in polynomial time.
1.2 Context and Related Work
Finiteness is decidable in polynomial time for subgroups of the group of invertible matrices in . If a finite subgroup has generators with integer entries of absolute value at most , the entries of every matrix in the group have absolute value at most [2, Theorem 1.1]. Finiteness is also decidable in polynomial time for finitely generated submonoids of . If such a monoid is finite then it consists of matrices whose entries are at most [18, Theorem A.2], where is the maximum entry of a generator of the monoid.
The decidability of the Finiteness Problem for matrix monoids over the rationals was first shown by McNaughton and Zalcstein [12], who proved that a finitely generated matrix monoid is infinite if and only if it contains an element of infinite order. This characterization implies that infiniteness is recursively enumerable and hence that finiteness is decidable (since finiteness is also recursively enumerable). Subsequently, Mandel and Simon [11] and Jacob [8] gave effective, albeit non-elementary, bounds on the cardinality of a finitely generated submonoid of in terms of the dimension and the number of generators.
The first elementary bound was obtained only recently, in [4], which shows that the cardinality is bounded by , where is the dimension and is the number of generators. This cardinality bound was obtained from a diameter bound [4, Theorem 1]: every element of a finite monoid can be expressed as a product of generators of length at most , where is the maximum order of a finite subgroup of . This bound is obtained using multilinear algebra and a graph construction, previously used to compute the Zariski closure of a finitely generated matrix monoid [7]. In this paper we reformulate the main technical result of [4] in terms of factorisation forests, from which the diameter bound follows directly.
On the other hand, the non-elementary cardinality bounds of [8, 11] proceed by reducing the general case to that of irreducible monoids. Recall that a matrix monoid is irreducible if the only subspaces of invariant under all matrices in are and . Schützenberger showed that such a monoid, if finite, has cardinality at most [15]. This bound has very recently been improved to , with an almost matching lower bound of [10, 17]. To lift bounds from irreducible monoids to general monoids, Berstel and Reutenauer use a change of basis that simultaneously puts all matrices in upper block triangular form, with square diagonal blocks, such that the monoid generated by the matrices appearing in each diagonal block is irreducible [3, Chapter 9, Theorem 1.1]. This lifting argument depends only on the existence of such a change of basis, not on its effective computation. Indeed, Berstel and Reutenauer [3] posed as an open problem the decidability of irreducibility, i.e. whether the above normal form consists of a single block. In fact, a procedure for determining irreducibility had already been given by [14]. Nevertheless, determining irreducibility and computing the above-mentioned upper block triangular form is still not known to be doable in polynomial time.
The improved cardinality bounds and complexity results in this paper exploit a combination of a suitable variant of the approach of [3] with the diameter bound of [4]. We observe that the explicit bounds for irreducible finite matrix monoids extend to the broader class of monoids whose enveloping algebra is semisimple. We then lift these bounds to general matrix monoids by combining (i) an upper block triangular form based on the Wedderburn–Malcev decomposition of the enveloping algebra as a direct sum of a semisimple algebra and a nilpotent ideal with (ii) the diameter bound of [4]. In contrast to the reduction to upper block triangular form with irreducible blocks on the diagonal, as used in [3], the polynomial-time computability of the Wedderburn–Malcev decomposition is straightforward. For our approach it is essential that this decomposition admit a polynomial-size representation.
2 Preliminaries
We write for the set of matrices with entries in a ring and denote by the set of square matrices of dimension . We denote the identity matrix by . Given , we write for the element-wise product and, for , we write for the -fold product of with itself. Note that . We also write and . The submonoid of generated by is , while the subsemigroup generated by is .
For an invertible matrix , we denote by the cofactor matrix of , that is, the -entry of is where denotes the matrix obtained from by deleting row and column . Then Cramer’s rule gives .
2.1 Height of Matrices
Given a finite set of matrices , and an integer , we say that is a common denominator of if . The height of is defined as:
where is the least common denominator of and is the maximum absolute value of entries of elements of .
In particular, for a reduced fraction seen as an element of we have . The main idea is that the log of the height corresponds to (an upper bound of) the number of bits needed to represent entries of a matrix.
The height is submultiplicative with respect to matrix multiplication and satisfies a form of triangle inequality. Let and be finite sets of matrices. Then:
| (1) |
Indeed, observe that given , the least common denominator of divides the one of . The triangle inequality for then gives the property.
We relate below the height of a matrix with its inverse, which will prove useful:
Claim 1.
Let and let , then .
Proof.
Let be the least common denominator of and let be the maximum absolute value of entries of . By Cramer’s rule, . From the Hadamard bound, . For the same reason, we have . Thus
Finally since , we have by the scalar submultiplicative property that
2.2 Semisimplicity and the Jacobson Radical
A vector space containing is called an algebra if is closed under matrix multiplication. Given , the vector space spanned by , or equivalently the smallest algebra containing is called the enveloping algebra . For example, let
Recall that denotes the submonoid generated by , which contains the identity matrix . Direct computation gives
Hence . Moreover, , and therefore
A key notion when studying algebras is that of (nilpotent) ideals. A vector subspace is called an ideal if . An ideal is called nilpotent if there exists such that ; the smallest such exponent is called the nilpotency index of . In the above example, the sets
are ideals, with being a nilpotent ideal of nilpotency index . Nilpotent ideals are a cause of complexity, but thankfully sets of strictly upper block triangular matrices like are (up to conjugation) the only examples of nilpotent ideals. In the following we repeat a proof of this fact, as it will be crucial in our size bounds for finite monoids, but we require some development first.
The trace of is the sum of the diagonal entries of . An algebra is called semisimple if is its only nilpotent ideal. We define and have the following classical theorem of Dickson [6].
Theorem 2.
The set is a nilpotent ideal and the quotient is semisimple.
Theorem 2 implies that is the largest nilpotent ideal, that is, is identical to the Jacobson radical of . In Section 2.3 and Section 3.1 we will recall a proof of the fact that can be effectively conjugated to strictly upper block triangular matrices, hence establishing that indeed nilpotent ideals are strictly upper block triangular. To this end, we have to compute a basis of as follows. Let , with , be a basis of . Define the -linear trace map by
With respect to the basis on this map is represented by the trace matrix
| (2) |
We have : Indeed, since the trace is a linear map, implies for all that
2.3 Block Decompositions of Matrices
A filtration of the vector space is a strictly increasing sequence of subspaces
| (3) |
We say that a basis of is adapted to the filtration (3) if it arises as the disjoint union of bases of subspaces such that for . Such an adapted basis can be constructed by first choosing a basis of , and then successively extending a basis of to a basis of , for . An algebra is said to preserve the filtration (3) if for all . In such a case, let be the matrix whose columns are given by . Then for all the matrix has the upper block triangular form
where has dimension for , where and . Here we say that is the signature of the block decomposition of .
Note that if is the enveloping algebra of a set of matrices , then for an invertible matrix , the conjugated algebra is in upper block triangular form if and only if is upper block triangular.
3 Structure Theory of Matrix Monoids and Algebras
In this section we give convenient formulations of known results concerning, respectively, the structure of matrix monoids and their enveloping algebras, that are key ingredients of the main results of this paper.
3.1 Wedderburn–Malcev Form
We say that an algebra is in Wedderburn–Malcev form if, with respect to some signature, consists of upper block triangular matrices and the Jacobson radical consists of strictly upper block triangular matrices. In this case we have that is semisimple, where is the projection onto the set of block diagonal matrices.
Proposition 3.
Let be a sub-algebra of and let be a nilpotent ideal in . Given a basis of , one can compute in polynomial time an invertible matrix such that
-
(i)
the conjugated algebra and conjugated ideal consist of upper block triangular and strictly upper block triangular matrices, respectively;
-
(ii)
and .
Proof.
We first show Item (i). Let be the nilpotency index of and write . Then we obtain the following filtration:
| (4) |
The above chain of inclusions is strict. Indeed, if the sequence were not strict then we would have for some . But this contradicts the fact that and by minimality of . Note, moreover, that preserves the filtration (4). Indeed, since is an ideal, we have .
Let be a basis adapted to the filtration in (4), as defined in Section 2.3, and let be the matrix whose -th column is , for . Since preserves the filtration, it follows that the conjugated algebra consists of upper block triangular matrices. We claim furthermore that the conjugated ideal consists of strictly upper block triangular matrices. To see this, let and . Then the inclusion holds, meaning that multiplication by strictly lowers the index in the filtration. This implies that is strictly upper block triangular in the adapted basis.
Height analysis: We next establish Item (ii). We start by computing bases of the . We take to be the canonical basis of . For , spans . By submultiplicativity of the height we obtain bases such that for any . From these bases we can select a basis adapted to the filtration in (4): first select a basis of . Then for , given a basis adapted to the filtration , we can extend it to a basis adapted to by adding vectors from .
Let be the change of basis matrix obtained from these vectors, then . Using Claim 1, above, we obtain .
Theorem 4.
There is a polynomial-time algorithm that, given a basis of an algebra , determines an invertible matrix such that is in Wedderburn–Malcev form. Moreover we have .
Proof.
By bilinearity of the trace, the Jacobson radical is defined by the following system of linear equations:
Thus we can compute a basis of from in polynomial time.
Applying Proposition 3 to and , given in terms of the basis , we can compute in polynomial time an invertible matrix such that is upper block triangular and is strictly upper block triangular.
Height analysis. Using the Bareiss algorithm, the Hadamard bound gives us a bound on the height of elements of . This is similar to the result of Claim 1, except that here the dimension is bounded by : .
Applying Proposition 3, we obtain .
3.2 Diameter Bound for Finite Monoids via Factorisation Forests
Recall that a finitely generated monoid has diameter if every element of the monoid can be written as the product of a list of generators of length at most . The diameter bound for finitely generated matrix monoids in [4] is proved using a graph construction that was introduced in [7] for computing the Zariski closure of matrix monoids. Below, we reformulate their main technical contribution in terms of factorisation forests, extracting a result that we think is of independent interest.
Given a morphism , a Ramseyan factorisation forest of a word is a finite unranked plane tree whose nodes are labelled with elements of . The root is labelled , the children have labels in , and an internal node with label whose children are labelled , satisfies
- (i)
-
, and
- (ii)
-
if then generate a subgroup of .
The height of such a tree is the maximum number of non-leaves on a root-to-leaf path and the reduced height is the maximum number of nodes of arity at least 3 on a root-to-leaf path.
The above notion of factorisation forest differs from the classical notion, due to Simon [16], which involves the stronger condition that for every node with 3 or more children, that node and all its children should be the same idempotent element of the monoid. The payoff is that we obtain a factorisation forest whose height depends only on the dimension of the matrices, not the cardinality of the monoid (as is the case for the classical formulation).
Theorem 5.
If has finite image then every word has a Ramseyan factorisation forest of height at most and reduced height at most .
We first show that Theorem 5 implies the claimed diameter bound, before proceeding to its proof.
Corollary 6 ([4, Theorem 1]).
Let be a positive integer and let . If is finite, then its diameter is at most , where is the maximum cardinality of a subgroup of .
Proof.
Let be a morphism such that . With respect to , every word has a Ramseyan factorisation forest of height at most and reduced height at most . We can moreover assume that the non-binary nodes of such a tree have arity at most . Such a tree thus has at most leaves. The result follows.
The starting point for proving Theorem 5 is a factorisation forest theorem for general matrix monoids (both finite and infinite) in [1, Proposition 2]. We then transform such a factorisation forest into a Ramseyan factorisation forest, using a construction similar to [4, Lemma 11]. Given a morphism , a weak factorisation forest of a word is a finite unranked plane tree whose nodes are labelled with elements of . The root is labelled , the children have labels in , and a node with label whose children are labelled , satisfies
- (i)
-
, and
- (ii)
-
if then .
The height and reduced height of a weak factorisation forest are defined exactly as in the Ramseyan case. The following result gives bounds on the height and reduced height of weak factorisation forests in arbitrary matrix monoids.
Theorem 7 ([1], Proposition 3).
Let be a semigroup morphism. Then every word has a weak factorisation forest of height and reduced height .
Recall that the notion of Ramseyan factorisation forest strengthens Condition (ii) to the requirement that generate a subgroup of We next show how to transform a weak factorisation forest to a Ramseyan factorisation forest in case the morphism has finite image. To this end, we use the following result, a direct consequence of [7, Proposition 9] and [4, Lemma 7].
Lemma 8.
Let and . Assume that
| (5) |
Then there exist , where , such that and .
The following is a version of [4, Lemma 11].
Proposition 9.
Assume has a finite image. Let and such that:
-
,
-
.
Then there exist such that and, moreover, generate a subgroup of
Proof.
For , we apply Lemma 8 to and respectively to obtain such that
-
.
-
From the rank condition we obtain that , which implies that
Let be the smallest integer such that for all . Such an integer exists since has a finite image. Moreover, acts as the identity on . We then rewrite as
Let be the finite sequence obtained by listing the factors
Then each belongs to and .
Let . Note that for every , has one of the forms . Therefore, for every , , , and moreover, . Since the all have the same kernel and image such that moreover , is isomorphic to a finite monoid of invertible linear endomorphisms of , i.e. is a group.
Proof of Theorem 5.
We will show that every has a Ramseyan factorisation forest of height at most , and reduced height at most . Fix . The construction of the Ramseyan factorisation forest of relies on the weak factorisation forest given in Theorem 7. Let be the weak factorisation forest of , with height at most and reduced height at most . We modify as follows. Process the nodes with more than two children level by level, starting from the leaves and moving upward. Whenever a node labelled by has more than two children labelled , apply Proposition 9 to that node, and replace that node by the corresponding subtree as in Figure 1.
Each application of Proposition 9 increases the height below that node by at most , and does not increase the reduced height. Since, for each path from the root to leaf we can pass through at most nodes that have more than two children, on every such path we can apply Proposition 9 at most times. Therefore, the total height increases by at most and the reduced height remains unchanged. Hence, the resulting tree has height at most , reduced height at most , and satisfies the Ramseyan factorisation forest conditions.
4 Height Bound for Finite Monoids
In this section we prove a bound on the bitsize of the matrices in a finite matrix monoid that is polynomial in the bitsize of the generators and the dimension . We first obtain a bitsize bound in the case that the enveloping algebra of the monoid is semisimple. This bound combines the fact that an element of such a monoid is determined by its image under the trace map (see Section 2.2) together with the fact that the image of the trace map is confined to a small range, due to the monoid being finite. We then lift the bitsize bound from the semisimple case to the general case using the Wedderburn–Malcev-form computation in Theorem 4 and the diameter bound in Corollary 6. We remark that similar arguments are used in [2] in the group case.
Lemma 10.
Let be a finite monoid. Then for all .
Proof.
Consider a matrix . Since is finite, there exists such that . It follows that the minimal polynomial of divides , i.e. every eigenvalue of is either or a root of unity. In particular, for all eigenvalues of and hence . As a sum of algebraic integers, is itself an algebraic integer. Since is moreover rational and integrally closed in , we obtain . The lemma immediately follows.
Theorem 11.
Let be a finite monoid such that is semisimple, with a basis . Then .
Proof.
Let be such that is finite and semisimple. One can choose a basis of within since has dimension at most (and . From Equation (1), .
By Lemma 10, the matrix , defined in Equation (2), is an integer matrix with entries in . We have by Claim 1 that .
Let and let be such that . Then for any , . By Lemma 10, the vector has entries in , and thus has height at most . We write . Let and let be the set of entries of elements of . Then . Then since , we have by triangle inequality that:
Proposition 12.
Let be a finite monoid such that is in Wedderburn–Malcev form, with a basis . Then .
Proof.
By assumption we can write the set of generators of as , where each is block diagonal and each strictly upper triangular on blocks. Write , and .
We first obtain a bound on the height of . By definition of Wedderburn–Malcev normal form, is semisimple. Hence, by Theorem 11, . Moreover, since any matrix in is zero, we get that a non-zero matrix in contains at most occurrences of elements of . Hence .
Let . By Corollary 6, can be written as a product of at most
matrices from the generating set . By the distributive law we can write as the sum of elements of . Since any matrix in is zero, most of these summands are zero, and the number of non-zero summands is bounded by . By Equation (1), summing elements of a set can at most multiply the height by . Thus
Relationship between height and bitsize. Before stating our main result on the height of a finite matrix monoid, we define the bitsize of a finite set of matrices: is defined as the maximal number of bits necessary to write (the absolute values of) numerators and denominators of entries of elements of . Thus any element of can be represented with many bits. Observe that the least common denominator of is smaller than . In particular, if , then the following relationships hold:
| (6) | ||||
| (7) | ||||
Theorem 13.
Let such that is finite, then , where the constant in the big-oh notation is absolute111By an absolute constant we mean a fixed number, independent of any parameters. As a consequence . Note that if , then .
Proof.
The first step is to compute a basis of . Since has dimension at most , one can find a basis within , which gives . We then put the matrices in Wedderburn–Malcev normal form. Applying Theorem 4, we obtain a change of basis matrix such that . Finally, by applying Proposition 12, we obtain that
Combining this with Equation (6), we obtain the polynomial size bound. If contains only integer matrices then using Equation (7), we obtain the result.
5 Finiteness and Membership
In this section, we derive complexity results for the Finiteness and Finite Membership Problems as corollaries of the polynomial bit-size bound on matrix entries in finite monoids, established in Theorem 13.
Proposition 14.
The Finiteness Problem is decidable in PSpace.
Proof.
PSpace membership is a consequence of the following nondeterministic polynomial-space algorithm for deciding infiniteness. The algorithm maintains a matrix , that is initially the identity. At each step, the algorithm nondeterministically chooses and makes the assignment . If the algorithm reaches a matrix whose bitsize exceeds the bound given by Theorem 13, it accepts. (We note that the constant in the big-oh notation in Theorem 13 is absolute.)
Proposition 15.
The Finite Membership Problem is PSpace-complete.
Proof.
PSpace membership is a consequence of the following nondeterministic polynomial-space algorithm. The algorithm maintains a matrix , that is initially the identity. At each step, it nondeterministically guesses a generator and performs the update . By Theorem 13, the bitsize of remains polynomially bounded throughout the computation. The algorithm accepts if it reaches the target matrix .
Hardness is shown by a reduction from the intersection emptiness problem for DFA. More precisely, we prove that the Finite Membership problem over is PSpace-hard in Section 6. We also extend PSpace-hardness to matrices over any semiring and to irreducible monoids.
6 PSPACE-hardness in Proposition 15
Recall that the DFA intersection emptiness problem asks, given and DFAs over a common alphabet , whether the intersection of their languages is nonempty.
For simplicity, we think of each DFA as a weighted -automaton with states, where is the initial row vector, is the transition matrix of and is the final column vector. By construction, the weighted automaton counts the number of runs of on a given word. Since each is deterministic, the value of the weighted automaton on a word is 1 if accepts and 0 otherwise.
The reduction constructs matrices of dimension , namely , and for each . The matrix is the target matrix, and the question is to check whether lies in the monoid generated by the other matrices. Below, for simplicity of notation, we extend the map to a monoid homomorphism in a natural way (where for the empty word the matrix is the identity matrix for appropriate size). Analogously, we extend the maps to . The idea is to simulate the computation of all weighted automata over words , that is by definition , simultaneously by the matrix product .
To this end, we define the matrix which initializes all weighted automata simultaneously, and similarly the matrix which accounts for the final column vectors:
For , the matrix simulates simultaneously applying the transition matrices , relying on the block multiplication:
The target matrix is zero everywhere except in its top-right entry, where it is .
We argue the correctness of the reduction as follows. Let . By the block matrix multiplication, and . Hence we can restrict ourselves to products with . Moreover, we can assume the form , otherwise the top-right entry is instead of .
By a simple induction, we can see that , with , is in the following form:
| (8) |
where the base of induction () holds by the definition of , and the induction step follows by block multiplication. Given the form in (8), it follows that is a zero matrix, except in its top-right entry, where it stores . The latter is if and only if is accepted by all . To conclude the proof, we note that entries of matrices in the monoid range over , hence the monoid is finite.
Extension to semirings.
The proof extends for matrices over any semiring and irreducible monoids as follows. To extend to a semiring , we have to prevent addition from occurring, as its value would depend on the semiring. To this end, we adapt the above construction as follows: We set , where the extra dimensions are used as additional target states. The idea is that instead of accumulating all runs on the same target state, for every DFA we have a separate target state which checks whether the corresponding DFA accepts. Formally, we still use matrices and for every . The matrices and are as defined above, extended with additional zero columns at the right. The matrices and are now defined as follows, the left matrix being and the right matrix is .
We argue correctness similarly to the above. Let . Again, and . Hence we can restrict ourselves to products with . Again, we can assume , as otherwise the top-right entries are instead of . With a similar induction as before, we observe that is a zero matrix, except in the top-right entries, where the -th entry stores , i.e. is equal to if and only if the DFA accepts . Hence all these entries are equal to as in if and only if is accepted by all . Moreover, observe that every fulfills , because the only operations performed are , , and which hold in every semiring .
Extension to Irreducible Finite Monoids.
A monoid is called irreducible if there is no vector space such that 222Defining irreducible with left or right multiplication gives the same definition, but right multiplication is more natural in automata theory, i.e. no vector space stable under multiplication by . We will show that membership is PSpace-hard also for irreducible finite monoids .
Proposition 16.
Membership is PSpace-hard even under the promise that is an irreducible finite matrix monoid.
Proof.
We again use and base this construction on the semiring reduction. As opposed to the above reductions though, we now use many matrices. The first matrices are and for every as before, they even have exactly the same definition as in the semiring reduction. Again, is the target matrix. The new matrices are and , where is the Kronecker delta, i.e. the matrix with every entry except a at the intersection of the -th row and -th column. These matrices are added purely to ensure irreducibility. Namely resets the -th state to the initial state, and is otherwise . The matrix on the other hand is a type of initialization matrix which only initializes one DFA. None of these matrices will be useful for reaching the target, but they will ensure that no vector space can be stable under the monoid.
Correctness.
First, observe that the monoid is still finite: In the semiring reduction we argued that , the same property can be proven in the same way.
Next we observe that the ’s are not useful for reaching the target matrix. Namely, let be any word of generator matrices (we do not yet identify with an element of the monoid, hence we clarify that the is concatenation here) which evaluates to . We claim that there is a word without ’s which also evaluates to the target.
Proof of claim: If does not contain ’s we are done. Hence assume that for some , i.e. that some matrix used is . Then the product , i.e. the product corresponding to a prefix of the word, has only one non-zero column. However, the target matrix has multiple non-zero columns. By the structure of our matrices, in order to produce multiple non-zero columns from a single one, we must have for some . In order for to not lead to the matrix, the non-zero column must have been the first column. The only generators where the first column is non-zero are for some . Hence we have for some . But then the product is useless. Removing it from the product, we obtain a new word with fewer ’s. Repeating the process, we eventually arrive at a word without any ’s, which still evaluates to the target, proving the claim.
By the claim, correctness now follows from the semiring correctness argument.
Finally, we have to argue that the monoid is irreducible. Let be a vector space such that . We have to show that . Since , there exists some . Let be such that . By applying the matrix , we reach the vector . Since is a vector space, i.e. closed under scalar multiplication, we have where is the first unit vector. By applying we obtain also for the other unit vectors, i.e. , which finishes the proof that .
7 Integrality
For a finite set , the decision version of the Integrality Problem asks whether is conjugate to a set of integral matrices, while the function version computes a conjugation matrix such that . Observe that a set is conjugate to a set of integral matrices if and only if this holds for the set .
Theorem 17.
The decision and function versions of the Integrality Problem lie in PTime.
To prove Theorem 17, we first extend [2, Proposition 2.3] from groups to semigroups following a similar argument.
Proposition 18.
Let be finite, and consider the -module generated by the set of vectors . Then the following are equivalent:
-
1.
is a free -module of rank ;
-
2.
there exists such that ;
-
3.
there exists a common denominator , i.e. such that .
Proof.
We first show that Item 1 implies Item 2. Let be a -basis of and define as the matrix whose -th column is , for . Given , since , for all there exists such that . Defining as the matrix with the columns we obtain . Hence, .
We next show that Item 2 implies Item 3. Assume that there exists such that . Then . Hence where is chosen such that and are integer matrices. This establishes (3).
Finally, we show that Item 3 implies Item 1. Let be such that . Then . Since is a submodule of , which is free of rank , it follows that is free of rank at most . Furthermore, since contains it has rank exactly .
The idea behind the algorithm for integrality is to determine whether a given number is a common denominator of , extending [2, Lemma 3.1] from groups to semigroups.
Lemma 19 ([2, Lemma 3.1]).
There is a PTime algorithm which, given a finite set and a number (in binary), decides whether is a common denominator of , and if so computes a conjugation matrix such that .
Proof.
Let , let and let be a common denominator. Let be the -module generated by . As shown in the proof of Item 1 implies Item 2 in Proposition 18, the columns of the required base change are a basis of .
Observe that . To compute , we define a sequence of vectors inductively as follows. First we choose to be any set of vectors spanning . Assume that we have defined for some . If there exists and such that does not lie in the -span of then we define (the choice of and doesn’t matter). Otherwise we terminate the construction. This sequence terminates in at most steps by [5, Prop. 3.1] and upon termination the resulting sequence of vectors spans . Computing the vector from involves solving linear equations over , which is well-known to be in polynomial time (by the Hermite Normal Form [9]). Having obtained a generating set of , we can compute a basis thereof using the Smith Normal Form in polynomial time.
Observe that Lemma 19 does not yet imply Theorem 17; we require a bound on the common denominator which we can write using polynomially many bits and input to the algorithm of Lemma 19. We proceed to prove such a bound.
Proposition 20.
Let be a finite set of matrices in Wedderburn-Malcev normal form. Let be a common denominator for the set of generators. Let be a basis of the enveloping algebra . Assume the monoid has some common denominator , then also is a common denominator for
Proof of Proposition 20.
Let be a finite set of matrices in Wedderburn-Malcev normal form such that has a common denominator. Just as in Proposition 12, write , where each is block diagonal and each strictly upper block triangular. Write , and . We first claim that is a common denominator for .
Proof of claim: We first show that for all . Since has a common denominator , there exists a conjugation matrix such that by Proposition 18. In particular, . Therefore , and since the trace is invariant under base change, we obtain . This in particular implies that for all .
By definition of Wedderburn-Malcev normal form the block diagonal part for can be uniquely determined from . Since , the denominator of hence divides the denominator of . By Cramer’s rule, since is an integer matrix, is a common denominator for , finishing the claim.
Since any matrix in is zero, we obtain that is a common denominator for . Since any matrix in is by the distributive law a sum of matrices in , we obtain that is also a common denominator for .
We can now prove Theorem 17.
Proof of Theorem 17.
8 Discussion
While it has been known for over 30 years that determining finiteness of finitely generated matrix groups is in polynomial time, until [4] no elementary bound was known for the case of matrix monoids. The present paper brings the complexity down to polynomial space. It is an interesting question whether this can be further improved. A more fine-grained optimisation of our results would be to improve the exponent in the polynomial bitsize bound in Theorem 13. Another direction for further work concerns the complexity of computing the Zariski closure of a finitely generated matrix monoid. This is a generalisation of the problem of determining finiteness that has various applications in automata theory and program analysis [7]. Currently no elementary upper bounds are known for this problem.
References
- [1] Rida Ait El Manssour, Mahsa Naraghi, Mahsa Shirmohammadi, and James Worrell. Algebraic closure of matrix sets recognized by 1-vass. In Proceedings of the 2026 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 5211–5240. SIAM, 2026. doi:10.1137/1.9781611978971.189.
- [2] László Babai, Robert Beals, and Daniel Rockmore. Deciding finiteness of matrix groups in deterministic polynomial time. In ISSAC93, pages 117–126. Association for Computing Machinery, 1993. doi:10.1145/164081.164104.
- [3] Jean Berstel and Christophe Reutenauer. Noncommutative Rational Series with Applications. Encyclopedia of Mathematics and its Applications. Cambridge University Press, 2010.
- [4] Georgina Bumpus, Christoph Haase, Stefan Kiefer, Paul-Ioan Stoienescu, and Jonathan Tanner. On the size of finite rational matrix semigroups. In ICALP, volume 168 of LIPIcs, pages 115:1–115:13. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. doi:10.4230/LIPIcs.ICALP.2020.115.
- [5] Alex Buna-Marginean, Vincent Cheval, Mahsa Shirmohammadi, and James Worrell. On learning polynomial recursive programs. Proc. ACM Program. Lang., 8(POPL):1001–1027, 2024. doi:10.1145/3632876.
- [6] Leonard Eugene Dickson. Algebras and their Arithmetics. University of Chicago Press, 1924.
- [7] Ehud Hrushovski, Joël Ouaknine, Amaury Pouly, and James Worrell. Polynomial invariants for affine programs. In Anuj Dawar and Erich Grädel, editors, Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science, LICS, pages 530–539. ACM, 2018. doi:10.1145/3209108.3209142.
- [8] 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.
- [9] Ravindran Kannan and Achim Bachem. Polynomial algorithms for computing the smith and hermite normal forms of an integer matrix. SIAM Journal on Computing, 8(4):499–507, 1979. doi:10.1137/0208040.
- [10] Stefan Kiefer and Andrew Ryzhikov. The asymptotic size of finite irreducible semigroups of rational matrices, 2026. doi:10.48550/arXiv.2601.01236.
- [11] 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.
- [12] Robert McNaughton and Yechezkel Zalcstein. The burnside problem for semigroups. Journal of Algebra, 34(2):292–299, 1975.
- [13] Jean-Éric Pin. Mathematical foundations of automata theory. Lecture notes LIAFA, Université Paris, 7:73, 2010.
- [14] Lajos Rónyai. Algorithmic properties of maximal orders in simple algebras over Q. Computational Complexity, 2(3):225–243, 1992. doi:10.1007/BF01272075.
- [15] Marcel Paul Schützenberger. Finite counting automata. Information and Control, 5:91–107, 1962. doi:10.1016/S0019-9958(62)90244-9.
- [16] Imre Simon. Factorization forests of finite height. Theor. Comput. Sci., 72(1):65–94, 1990. doi:10.1016/0304-3975(90)90047-L.
- [17] Benjamin Steinberg. A short proof of a bound on the size of finite irreducible semigroups of rational matrices, 2026. doi:10.48550/arXiv.2601.03206.
- [18] Andreas Weber and Helmut Seidl. On finitely generated monoids of matrices with entries in N. RAIRO Theor. Informatics Appl., 25:19–38, 1991. doi:10.1051/ITA/1991250100191.
