Abstract 1 Introduction 2 Preliminaries 3 Structure Theory of Matrix Monoids and Algebras 4 Height Bound for Finite Monoids 5 Finiteness and Membership 6 PSPACE-hardness in Proposition 15 7 Integrality 8 Discussion References

Revisiting Finiteness of Matrix Monoids

Rida Ait El Manssour ORCID University of Oxford, UK    Roland Guttenberg ORCID University of Warsaw, Poland    Nathan Lhote ORCID Aix-Marseille Université, LIS, France    Mahsa Shirmohammadi ORCID CNRS & IRIF, Paris, France    James Ben Worrell ORCID University of Oxford, UK
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 coNExpNP 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 Bound
Category:
Track B: Automata, Logic, Semantics, and Theory of Programming
Funding:
Rida Ait El Manssour: Supported by the EPSRC Fellowship (EP/X033813/1).
Roland Guttenberg: Supported by the ERC grant INFSYS, agreement No. 950398.
Mahsa Shirmohammadi: Supported by the ERC Synergy Grant VePaSS (agreement No. 101224640) and the grant VeSyAM (ANR-22-CE48-0005).
James Ben Worrell: Supported by the EPSRC Fellowship (EP/X033813/1).
Copyright and License:
[Uncaptioned image] © Rida Ait El Manssour, Roland Guttenberg, Nathan Lhote, Mahsa Shirmohammadi,
and James Ben Worrell; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Automata over infinite objects
Editors:
Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele Puppis

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 d and a finite set of matrices XMd() generating a monoid X.

  1. 1.

    Finiteness Problem: given XMd(), determine whether X is finite.

  2. 2.

    Finite Membership Problem: given XMd() and a target matrix a, determine whether aX, under the promise that X is finite.

  3. 3.

    Integrality Problem: given XMd(), determine whether X is conjugate to a matrix monoid with integer entries.

Our first main result shows that the Finiteness Problem is in PSpace, improving the coNExpNP 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 GLd() of invertible matrices in Md(). If a finite subgroup has generators with integer entries of absolute value at most M, the entries of every matrix in the group have absolute value at most Md2d3d2+3 [2, Theorem 1.1]. Finiteness is also decidable in polynomial time for finitely generated submonoids of Md(). If such a monoid is finite then it consists of matrices whose entries are at most Md15d/2dd [18, Theorem A.2], where M 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 Md() in terms of the dimension d and the number of generators.

The first elementary bound was obtained only recently, in [4], which shows that the cardinality is bounded by m2O(d2logd), where d is the dimension and m 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 2d(2d+3)g(d)d+1, where g(d)2dd! is the maximum order of a finite subgroup of GLd(). 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 MMd() is irreducible if the only subspaces of d invariant under all matrices in M are {0} and d. Schützenberger showed that such a monoid, if finite, has cardinality at most (2d+1)d2 [15]. This bound has very recently been improved to 3d2, with an almost matching lower bound of 2d2/4 [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 Md,e(R) for the set of d×e matrices with entries in a ring R and denote by Md(R):=Md,d(R) the set of square matrices of dimension d. We denote the d×d identity matrix by idd. Given X,YMd(R), we write XYMd(R) for the element-wise product and, for r, we write Xr for the r-fold product of X with itself. Note that X0={idd}. We also write Xr:=i=0rXi and X<r:=i=0r1Xi. The submonoid of Md(R) generated by X is X:=i=0Xi, while the subsemigroup generated by X is X+:=i=1Xi.

For an invertible matrix b, we denote by cof(b) the cofactor matrix of b, that is, the (i,j)-entry of cof(b) is (1)i+jdet(c(i,j)) where c(i,j) denotes the matrix obtained from b by deleting row j and column i. Then Cramer’s rule gives b1=1det(b)cof(b)T.

2.1 Height of Matrices

Given a finite set of matrices XMm,n(), and an integer q, we say that q is a common denominator of X if qXMm,n(). The height of X is defined as:

X=max(m,n)qp

where q is the least common denominator of X and p is the maximum absolute value of entries of elements of qX.

In particular, for a reduced fraction pq seen as an element of M1() we have pq=|pq|. 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 XMm,n() and YMn,() be finite sets of matrices. Then:

XYXYandΣi=1kXkX. (1)

Indeed, observe that given x1,,xkX, the least common denominator of (x1++xk) divides the one of X. 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 d1 and let aGLd(), then a1a2d.

Proof.

Let q be the least common denominator of a and let p be the maximum absolute value of entries of b=qa. By Cramer’s rule, b1=1det(b)cof(b)T. From the Hadamard bound, det(b)dd2pd. For the same reason, we have cof(b)ddd2pd. Thus

b1det(b)cof(b)dddp2d.

Finally since a1=qb1, we have by the scalar submultiplicative property that

a1qb1qdd+1p2da2d.

2.2 Semisimplicity and the Jacobson Radical

A vector space AMd() containing idd is called an algebra if A is closed under matrix multiplication. Given XMd(), the vector space spanned by X, or equivalently the smallest algebra E containing X is called the enveloping algebra Env(X). For example, let

a:=(1100),b:=(0101),X:={a,b}.

Recall that X denotes the submonoid generated by X, which contains the identity matrix id2. Direct computation gives

a2=a,b2=b,ab=(0200),ba=0.

Hence X={id2, 0,a,b,ab}. Moreover, ab=a+bid2, and therefore

Env(X)=Span{a,b,id2}={(xy0z)|x,y,z}.

A key notion when studying algebras is that of (nilpotent) ideals. A vector subspace IE is called an ideal if EI=I=IE. An ideal I is called nilpotent if there exists d such that Id={0}; the smallest such exponent d is called the nilpotency index of I. In the above example, the sets

I1={(xy00)x,y} I2={(0y0z)y,z} I3={(0y00)y}

are ideals, with I3 being a nilpotent ideal of nilpotency index 2. Nilpotent ideals are a cause of complexity, but thankfully sets of strictly upper block triangular matrices like I3 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 tr(a) of aMd() is the sum of the diagonal entries of a. An algebra EMd() is called semisimple if {0} is its only nilpotent ideal. We define J(E):={aEbE:tr(ab)=0} and have the following classical theorem of Dickson [6].

Theorem 2.

The set J(E) is a nilpotent ideal and the quotient E/J(E) is semisimple.

Theorem 2 implies that J(E) is the largest nilpotent ideal, that is, J(E) is identical to the Jacobson radical of E. In Section 2.3 and Section 3.1 we will recall a proof of the fact that J(E) 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 J(E) as follows. Let B={b1,,bk}Md(), with kd2, be a basis of E. Define the -linear trace map TrB:Ek by

TrB(a):=(tr(ab1),,tr(abk)).

With respect to the basis B on E this map is represented by the trace matrix

TB=(tr(bibj))1i,jk (2)

We have ker(TrB)=J(E): Indeed, since the trace tr is a linear map, tr(ab1)==tr(abk)=0 implies for all b=i=1kλibiE that

tr(ab)=tr(ai=1kλibi)=i=1kλitr(abi)=0.

2.3 Block Decompositions of Matrices

A filtration of the vector space d is a strictly increasing sequence of subspaces

{0}=W0W1Wk=d. (3)

We say that a basis B={v1,,vd} of d is adapted to the filtration (3) if it arises as the disjoint union of bases of subspaces V1,,Vkd such that Wi=V1Vi for i{0,,k}. Such an adapted basis can be constructed by first choosing a basis of W1, and then successively extending a basis of Wi to a basis of Wi+1, for i=1,,k1. An algebra EMd() is said to preserve the filtration (3) if EWiWi for all i{0,,k}. In such a case, let pMd() be the matrix whose columns are given by B. Then for all bE the matrix a:=p1bp has the upper block triangular form

a=(a1,1a1,2a1,k0a2,2a2,k000ak,k),

where ai,j has dimension di×dj for ji, where di=dim(Vi) and dj=dim(Vj). Here we say that (d1,,dk) is the signature of the block decomposition of a.

Note that if E=Env(X) is the enveloping algebra of a set of matrices XMd(), then for an invertible matrix pMd(), the conjugated algebra p1Ep is in upper block triangular form if and only if p1Xp 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 EMd() is in Wedderburn–Malcev form if, with respect to some signature, E consists of upper block triangular matrices and the Jacobson radical J(E) consists of strictly upper block triangular matrices. In this case we have that BlockDiag(E)E/J(E) is semisimple, where BlockDiag() is the projection onto the set of block diagonal matrices.

Proposition 3.

Let E be a sub-algebra of Md() and let J be a nilpotent ideal in E. Given a basis B of J, one can compute in polynomial time an invertible matrix pMd() such that

  1. (i)

    the conjugated algebra p1Ep and conjugated ideal p1Jp consist of upper block triangular and strictly upper block triangular matrices, respectively;

  2. (ii)

    pBd and p1B2d2.

Proof.

We first show Item (i). Let kd be the nilpotency index of J and write Wi:=Jkid. Then we obtain the following filtration:

{0}=W0W1Wk=d. (4)

The above chain of inclusions is strict. Indeed, if the sequence were not strict then we would have W0=Wi for some i<k. But this contradicts the fact that W0={0} and Wi{0} by minimality of k. Note, moreover, that E preserves the filtration (4). Indeed, since J is an ideal, we have EWi=EJkidJkid=Wi.

Let {v1,,vd} be a basis adapted to the filtration in (4), as defined in Section 2.3, and let p be the matrix whose i-th column is vi, for i{1,,d}. Since E preserves the filtration, it follows that the conjugated algebra p1Ep consists of upper block triangular matrices. We claim furthermore that the conjugated ideal p1Jp consists of strictly upper block triangular matrices. To see this, let aJ and i1. Then the inclusion aWiJWi=Wi1 holds, meaning that multiplication by a strictly lowers the index in the filtration. This implies that p1ap is strictly upper block triangular in the adapted basis.

Height analysis: We next establish Item (ii). We start by computing bases Bi of the Wis. We take Bk to be the canonical basis of Wk. For i{1,,k}, BiB spans Wi1. By submultiplicativity of the height we obtain bases such that BiBd for any i{1,,k}. From these bases we can select a basis adapted to the filtration in (4): first select a basis of W1. Then for i{1,,k1}, given a basis adapted to the filtration W0Wi, we can extend it to a basis adapted to W0Wi+1 by adding vectors from Bi+1.

Let p be the change of basis matrix obtained from these vectors, then pBd. Using Claim 1, above, we obtain p1B2d2.

Theorem 4.

There is a polynomial-time algorithm that, given a basis B of an algebra EMd(), determines an invertible matrix pMd() such that p1Ep is in Wedderburn–Malcev form. Moreover we have {p,p1}=BO(d4) .

Proof.

By bilinearity of the trace, the Jacobson radical J(E) is defined by the following system of linear equations:

J(E)={aEbB:tr(ab)=0}.

Thus we can compute a basis B of J(E) from B in polynomial time.

Applying Proposition 3 to E and J:=J(E), given in terms of the basis B, we can compute in polynomial time an invertible matrix pMd() such that p1Ep is upper block triangular and p1Jp is strictly upper block triangular.

Height analysis. Using the Bareiss algorithm, the Hadamard bound gives us a bound on the height of elements of B. This is similar to the result of Claim 1, except that here the dimension is bounded by d2: BBO(d2).

Applying Proposition 3, we obtain {p,p1}=BO(d4).

3.2 Diameter Bound for Finite Monoids via Factorisation Forests

Recall that a finitely generated monoid has diameter D if every element of the monoid can be written as the product of a list of generators of length at most D. 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 φ:Σ+Md(), a Ramseyan factorisation forest of a word wΣ+ is a finite unranked plane tree whose nodes are labelled with elements of Σ+. The root is labelled w, the children have labels in Σ, and an internal node with label x whose children are labelled x0,,xs1, satisfies

(i)

φ(x)=φ(x0x1xs1), and

(ii)

if s3 then φ(x0),,φ(xs1) generate a subgroup of Md().

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 wΣ+ has a Ramseyan factorisation forest of height at most 2d(d+3) and reduced height at most d.

We first show that Theorem 5 implies the claimed diameter bound, before proceeding to its proof.

Corollary 6 ([4, Theorem 1]).

Let d be a positive integer and let XMd(). If X is finite, then its diameter is at most 22d(d+3)g(d)d, where g(d) is the maximum cardinality of a subgroup of Md().

Proof.

Let φ:Σ+Md() be a morphism such that φ(Σ)=X. With respect to φ, every word wΣ+ has a Ramseyan factorisation forest of height at most 2d(d+3) and reduced height at most d. We can moreover assume that the non-binary nodes of such a tree have arity at most g(d). Such a tree thus has at most 22d(d+3)g(d)d 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 φ:Σ+Md(), a weak factorisation forest of a word wΣ+ is a finite unranked plane tree whose nodes are labelled with elements of Σ+. The root is labelled w, the children have labels in Σ, and a node with label x whose children are labelled x0,,xs1, satisfies

(i)

φ(x)=φ(x0x1xs1), and

(ii)

if |s|3 then rk(φ(x0))==rk(φ(xs1))=rk(φ(x))=rk(φ(x)2).

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 φ:Σ+Md() be a semigroup morphism. Then every word has a weak factorisation forest of height d(d+3) and reduced height d.

Recall that the notion of Ramseyan factorisation forest strengthens Condition (ii) to the requirement that φ(x0),,φ(xs1) generate a subgroup of Md(). 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 a1,,aMd() and a:=a1a. Assume that

rk(a1)==rk(a)=rk(a) (5)

Then there exist 1=i1<i2<<it=, where t2d+1, such that ker(a)=ker(ai1ait) and im(a)=im(ai1ait).

The following is a version of [4, Lemma 11].

Proposition 9.

Assume φ has a finite image. Let s3 and w,w0,,ws1Σ+ such that:

  • φ(w)=φ(w0w1ws1),

  • rk(φ(w0))==rk(φ(ws1))=rk(φ(w))=rk(φ(w)2).

Then there exist u0,,ut1{w0,,ws1}2d+2 such that φ(w)=φ(u0ut1) and, moreover, φ(u0),,φ(ut1) generate a subgroup of Md().

Proof.

For i{0,,s2}, we apply Lemma 8 to φ(wi+1)φ(wi+2)φ(ws1) and φ(w0)φ(w1)φ(wi) respectively to obtain xi,yi{w0,,ws1}2d+1 such that

  • im(φ(xi))=im(φ(wi+1)),ker(φ(xi))=ker(φ(ws1)).

  • im(φ(yi))=im(φ(w0)),ker(φ(yi))=ker(φ(wi)).

From the rank condition rk(φ(w0))==rk(φ(ws1))=rk(φ(w))=rk(φ(w)2), we obtain that ker(φ(yi))im(φ(xi))={0}, which implies that

ker(φ(yixi))=ker(φ(xi))=ker(φ(ws1)),im(φ(yixi))=im(φ(yi))=im(φ(w0)).

Let p be the smallest integer such that φ(yixi)p=φ(yixi)2p for all i. Such an integer p exists since φ has a finite image. Moreover, φ(yixi)p acts as the identity on im(φ(yixi))=im(φ(w0)). We then rewrite φ(w) as

φ(w)=φ(w0x0)φ(y0x0)p1φ(y0w1x1)φ(y1x1)p1φ(ys2xs2)p1φ(ys2ws1).

Let (uj)j=0t1 be the finite sequence obtained by listing the factors (uj)j=0t1:=

(w0x0,y0x0,,y0x0p1 times,y0w1x1,y1x1,,y1x1p1 times,,ys2xs2,,ys2xs2p1 times,ys2ws1).

Then each uj belongs to {w0,,ws1}2d+2, and φ(w)=φ(u0ut1).

Let G={φ(u0),,φ(ut1)}Md(). Note that for every 0it1, ui has one of the forms w0x0,yjxj,yjwj+1xj+1,ys2ws1. Therefore, for every 0it1, ker(φ(ui))=ker(φ(ws1)), im(φ(ui))=im(φ(w0)), and moreover, ker(φ(ui))im(φ(ui))={0}. Since the φ(ui) all have the same kernel U and image V such that moreover UV={0}, G is isomorphic to a finite monoid of invertible linear endomorphisms of V, i.e. is a group.

Proof of Theorem 5.

We will show that every vΣ+ has a Ramseyan factorisation forest of height at most 2d(d+3), and reduced height at most d. Fix vΣ+. The construction of the Ramseyan factorisation forest of v relies on the weak factorisation forest given in Theorem 7. Let T be the weak factorisation forest of v, with height at most d(d+3) and reduced height at most d. We modify T 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 w has more than two children labelled w0,,ws1, apply Proposition 9 to that node, and replace that node by the corresponding subtree as in Figure 1.

Figure 1: A schematic Ramseyan factorisation tree for w with leaves among wi of height d+3. The root w is decomposed into u0,u1,,ut1. We display u0=w0x0,u1=y0x0,,ut1=ys1ws1. Each factor xi, yi, is further refined by a binary subtree down to leaves among the wj.

Each application of Proposition 9 increases the height below that node by at most d+3, and does not increase the reduced height. Since, for each path from the root to leaf we can pass through at most d nodes that have more than two children, on every such path we can apply Proposition 9 at most d times. Therefore, the total height increases by at most d(d+3), and the reduced height remains unchanged. Hence, the resulting tree has height at most 2d(d+3), reduced height at most d, 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 d. 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 XMd() be a finite monoid. Then tr(a){d,,d} for all aX.

Proof.

Consider a matrix aX. Since X is finite, there exists m>n such that am=an. It follows that the minimal polynomial of a divides xnxm, i.e. every eigenvalue of a is either 0 or a root of unity. In particular, |λ|1 for all eigenvalues λ of a and hence |tr(a)|=|i=1dλi|d. As a sum of algebraic integers, tr(a) is itself an algebraic integer. Since tr(a) is moreover rational and integrally closed in , we obtain tr(a). The lemma immediately follows.

Theorem 11.

Let XMd() be a finite monoid such that Env(X) is semisimple, with a basis BX. Then X=dO(d2)B.

Proof.

Let XMd() be such that X is finite and Env(X) semisimple. One can choose B a basis of Env(X) within Xd21 since Env(X) has dimension at most d2 (and iddX). From Equation (1), BXd2.

By Lemma 10, the matrix TB, defined in Equation (2), is an integer matrix with entries in {d,,d}. We have by Claim 1 that TB1(d3)2d2.

Let aX and let α=(αb)bBB be such that a=bBαbb. Then for any cB, tr(ca)=bBαbtr(cb)=(TBα)c. By Lemma 10, the vector TBα has entries in {d,,d}, and thus has height at most d3. We write a=bB(TB1TBα)bb. Let A=TB1{d,,d}B and let C be the set of entries of elements of A. Then CA(d3)2d2+1. Then since XbBCB, we have by triangle inequality that:

X d2CBd2(d3)2d2+1B=dO(d2)B

Proposition 12.

Let XMd() be a finite monoid such that Env(X) is in Wedderburn–Malcev form, with a basis BX. Then X=dO(d3)XdBd.

Proof.

By assumption we can write the set of generators of Env(X) as X={a1+c1,,am+cm}X, where each ai is block diagonal and each ci strictly upper triangular on blocks. Write A:={a1,,am}, C:={c1,,cm} and D:={a1,,am,c1,cm}.

We first obtain a bound on the height of D. By definition of Wedderburn–Malcev normal form, Env(A)=BlockDiag(Env(X)) is semisimple. Hence, by Theorem 11, A=dO(d2)B. Moreover, since any matrix in (AC)d is zero, we get that a non-zero matrix in D contains at most d1 occurrences of elements of C. Hence D(AC)d=dO(d3)XdBd.

Let aX. By Corollary 6, a can be written as a product of at most

L(d):=22d(d+3)+d2(d!)d=dO(d2)

matrices from the generating set X. By the distributive law we can write a as the sum of elements of D. Since any matrix in (AC)d is zero, most of these summands are zero, and the number of non-zero summands is bounded by i<d(L(d)i)dL(d)d=dO(d3). By Equation (1), summing k elements of a set can at most multiply the height by k. Thus

XdL(d)dD=dO(d3)XdBd.

Relationship between height and bitsize. Before stating our main result on the height of a finite matrix monoid, we define size(X) the bitsize of a finite set X of matrices: size(X) is defined as the maximal number of bits necessary to write (the absolute values of) numerators and denominators of entries of elements of X. Thus any element of X can be represented with mn(size(X)+1) many bits. Observe that the least common denominator of X is smaller than 2mnsize(X). In particular, if m=n=d, then the following relationships hold:

size(X)log(X)(2d2+1)size(X)+logd (6)
size(X)log(X)size(X)+logd, if X has integer entries. (7)
Theorem 13.

Let XMd() such that X is finite, then X=XO(d7), 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 size(X)=O(d9size(X)). Note that if XMd(), then size(X)=O(d7(logd+size(X))).

Proof.

The first step is to compute a basis B of Env(X). Since Env(X) has dimension at most d2, one can find a basis within Xd21, which gives BXd2. We then put the matrices in Wedderburn–Malcev normal form. Applying Theorem 4, we obtain a change of basis matrix p such that p1(XB)p=XO(d6). Finally, by applying Proposition 12, we obtain that

Xpp1Xpp1=XO(d7).

Combining this with Equation (6), we obtain the polynomial size bound. If X 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 aX, that is initially the identity. At each step, the algorithm nondeterministically chooses bX and makes the assignment a:=ab. 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 aX, that is initially the identity. At each step, it nondeterministically guesses a generator bX and performs the update a:=ab. By Theorem 13, the bitsize of a remains polynomially bounded throughout the computation. The algorithm accepts if it reaches the target matrix t.

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 R{0} and to irreducible monoids.

6 PSPACE-hardness in Proposition 15

Recall that the DFA intersection emptiness problem asks, given n and DFAs D1,,Dn over a common alphabet Σ, whether the intersection of their languages is nonempty.

For simplicity, we think of each DFA Di as a weighted -automaton (αi,(Mσ,i)σΣ,γi) with di states, where αi{0,1}1×di is the initial row vector, Mσ,i{0,1}di×di is the transition matrix of σΣ and γi{0,1}di×1 is the final column vector. By construction, the weighted automaton (αi,(Mσ,i)σΣ,γi) counts the number of runs of Di on a given word. Since each Di is deterministic, the value of the weighted automaton on a word wΣ is 1 if Di accepts w and 0 otherwise.

The reduction constructs 3+|Σ| matrices of dimension d:=2+i=1ndi, namely Minit,Mend,Mt, and Mσ for each σΣ. The matrix Mt is the target matrix, and the question is to check whether Mt lies in the monoid generated by the other matrices. Below, for simplicity of notation, we extend the map σMσ,i to a monoid homomorphism Σ in a natural way (where for the empty word ε the matrix Mε,i is the identity matrix for appropriate size). Analogously, we extend the maps σMσ to Σ. The idea is to simulate the computation of all weighted automata (αi,(Mσ,i)σΣ,γi) over words w, that is by definition αiMw,iγi, simultaneously by the matrix product MinitMwMend.

To this end, we define the matrix Minit which initializes all weighted automata simultaneously, and similarly the matrix Mend which accounts for the final column vectors:

Minit:=(0α1α2αn0𝟎(d1)×d)andMend:=(𝟎d×(d1)0)

For σΣ, the matrix Mσ simulates simultaneously applying the transition matrices Mσ,i, relying on the block multiplication:

Mσ:=(𝟎1×dMσ,1𝟎d1×d2𝟎d1×dn𝟎d2×d1Mσ,2𝟎d2×dn𝟎d×1𝟎d×1𝟎dn×d1𝟎dn×d2Mσ,n𝟎1×d)

The target matrix Mt is zero everywhere except in its top-right entry, where it is n.

We argue the correctness of the reduction as follows. Let X:={Minit,Mend}{MσσΣ}. By the block matrix multiplication, X+MinitX={0} and XMendX+={0}. Hence we can restrict ourselves to products Minit1MwMend1 with wΣ. Moreover, we can assume the form MinitMwMend, otherwise the top-right entry is 0 instead of n.

By a simple induction, we can see that MinitMw, with wΣ, is in the following form:

MinitMw:=(0α1Mw,1αnMw,n0𝟎(d1)×d) (8)

where the base of induction (w=ε) holds by the definition of Minit, and the induction step follows by block multiplication. Given the form in (8), it follows that MinitMwMend is a zero matrix, except in its top-right entry, where it stores i=1nαiMw,iγi. The latter is n if and only if w is accepted by all Di. To conclude the proof, we note that entries of matrices in the monoid range over {0,,n}, hence the monoid is finite.

Extension to semirings.

The proof extends for matrices over any semiring R{0} and irreducible monoids as follows. To extend to a semiring R{0}, we have to prevent addition 1+1 from occurring, as its value would depend on the semiring. To this end, we adapt the above construction as follows: We set d:=1+n+i=1ndi, where the extra dimensions are used as additional target states. The idea is that instead of accumulating all n runs on the same target state, for every DFA Di we have a separate target state which checks whether the corresponding DFA accepts. Formally, we still use 3+|Σ| matrices Minit,Mend,Mt and Mσ for every σ. The matrices Minit and Mσ are as defined above, extended with n1 additional zero columns at the right. The matrices Mt and Mend are now defined as follows, the left matrix being Mt and the right matrix is Mend.

(𝟎d×(dn)𝟏1×n) (000γ10d1×10d1×1𝟎(dn)×(dn)0d2×1γ20dn1×10dn×10dn×1γn𝟎n×d)

We argue correctness similarly to the above. Let X:={Minit,Mend}{MσσΣ}. Again, X+MinitX={0} and XMendX+={0}. Hence we can restrict ourselves to products Minit1MwMend1 with wΣ. Again, we can assume MinitMwMend, as otherwise the top-right entries are 0 instead of 1. With a similar induction as before, we observe that MinitMwMend is a zero matrix, except in the top-right entries, where the i-th entry stores αiMw,iγi, i.e. is equal to 1 if and only if the DFA Di accepts w. Hence all these entries are equal to 1 as in Mt if and only if w is accepted by all Di. Moreover, observe that every aX fulfills a{0,1}d×d, because the only operations performed are 0+0=0, 1+0=1, 10=0 and 11=1 which hold in every semiring R.

Extension to Irreducible Finite Monoids.

A monoid MMd() is called irreducible if there is no vector space 0Vd such that VMV222Defining 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 M. We will show that membership is PSpace-hard also for irreducible finite monoids M.

Proposition 16.

Membership is PSpace-hard even under the promise that X is an irreducible finite matrix monoid.

Proof.

We again use d:=1+n+i=1ndi and base this construction on the semiring reduction. As opposed to the above reductions though, we now use 3+|Σ|+2(d1) many matrices. The first 3+|Σ| matrices are Minit,Mend,Mt and Mσ for every σΣ as before, they even have exactly the same definition as in the semiring reduction. Again, Mt is the target matrix. The new matrices are {δ1,jj{2,,d}} and {δj,1j{2,,d}}, where δi,j is the Kronecker delta, i.e. the matrix with every entry 0 except a 1 at the intersection of the i-th row and j-th column. These matrices are added purely to ensure irreducibility. Namely δj,1 resets the j-th state to the initial state, and is otherwise 0. The matrix δ1,j 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 X is still finite: In the semiring reduction we argued that X{0,1}d×d, 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 wXconcat be any word of generator matrices (we do not yet identify w with an element of the monoid, hence we clarify that the is concatenation here) which evaluates to Mt. We claim that there is a word w′′ without δ’s which also evaluates to the target.

Proof of claim: If w does not contain δ’s we are done. Hence assume that w[k]=δi,j for some i,j,k, i.e. that some matrix used is δi,j. Then the product w[1]w[k], 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 w[k]=Minit for some k>k. In order for Minit to not lead to the 0 matrix, the non-zero column must have been the first column. The only generators xX where the first column is non-zero are δj,1 for some j. Hence we have w[k1]=δj,1 for some j. But then the product w[1]w[k1] is useless. Removing it from the product, we obtain a new word w′′=w[k]w[|w|] with fewer δ’s. Repeating the process, we eventually arrive at a word w′′ 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 X is irreducible. Let 0V be a vector space such that VXV. We have to show that V=d. Since 0V, there exists some 0vV. Let j be such that v[j]0. By applying the matrix δj,1, we reach the vector (v[j],0,,0)V. Since V is a vector space, i.e. closed under scalar multiplication, we have e1V where e1d is the first unit vector. By applying δ1,j we obtain ejV also for the other unit vectors, i.e. j=2,,d, which finishes the proof that V=d.

7 Integrality

For a finite set XMd(), the decision version of the Integrality Problem asks whether X is conjugate to a set of integral matrices, while the function version computes a conjugation matrix pGLd() such that p1XpMd(). Observe that a set X is conjugate to a set of integral matrices if and only if this holds for the set X.

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 XMd() be finite, and consider the -module L generated by the set of vectors Xd. Then the following are equivalent:

  1. 1.

    L is a free -module of rank d;

  2. 2.

    there exists pGLd() such that p1XpMd();

  3. 3.

    there exists a common denominator q, i.e. q{0} such that qXMd().

Proof.

We first show that Item 1 implies Item 2. Let v1,,vdd be a -basis of L and define pGLd() as the matrix whose i-th column is vi, for i{1,,d}. Given aX, since aLL, for all i{1,,d} there exists bid such that avi=pbi. Defining b as the matrix with the columns bi we obtain ap=pb. Hence, p1ap=bMd().

We next show that Item 2 implies Item 3. Assume that there exists pGLd() such that p1XpMd(). Then XpMd()p1. Hence Xq2Md() where q{0} is chosen such that qp and qp1 are integer matrices. This establishes (3).

Finally, we show that Item 3 implies Item 1. Let q{0} be such that qXMd(). Then nL1qn. Since L is a submodule of 1qn, which is free of rank n, it follows that L is free of rank at most n. Furthermore, since L contains n it has rank exactly n.

The idea behind the algorithm for integrality is to determine whether a given number is a common denominator of X, 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 XMd() and a number q (in binary), decides whether q is a common denominator of X, and if so computes a conjugation matrix pGLd() such that p1XpMd().

Proof.

Let XMd(), let m:=size(X) and let q be a common denominator. Let L:=Span(Xd)d be the -module generated by Xd. As shown in the proof of Item 1 implies Item 2 in Proposition 18, the columns of the required base change p are a basis of L.

Observe that qdqLd. To compute qL, we define a sequence of vectors (vk) inductively as follows. First we choose v1,,vd to be any set of vectors spanning qd. Assume that we have defined v1,,vk for some k. If there exists aX and l{1,,k} such that avl does not lie in the -span of {v1,,vk} then we define vk+1:=avl (the choice of a and vl doesn’t matter). Otherwise we terminate the construction. This sequence terminates in at most d(log2q)+d2m steps by [5, Prop. 3.1] and upon termination the resulting sequence of vectors spans qL. Computing the vector vk+1 from {v1,,vk} 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 qL, 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 q 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 XMd() be a finite set of matrices in Wedderburn-Malcev normal form. Let q be a common denominator for the set X of generators. Let BX be a basis of the enveloping algebra Env(X). Assume the monoid X has some common denominator q, then also q:=det(TBlockDiag(B))d(q)d1 is a common denominator for X.

Proof of Proposition 20.

Let XMd() be a finite set of matrices in Wedderburn-Malcev normal form such that X has a common denominator. Just as in Proposition 12, write X={a1+c1,,am+cm}X, where each ai is block diagonal and each ci strictly upper block triangular. Write A:={a1,,am}, C:={c1,,cm} and D:={a1,,am,c1,cm}. We first claim that det(TBlockDiag(B)) is a common denominator for A.

Proof of claim: We first show that tr(a) for all aX. Since X has a common denominator q, there exists a conjugation matrix pGLd() such that p1XpMd() by Proposition 18. In particular, p1apMd(). Therefore tr(p1ap), and since the trace is invariant under base change, we obtain tr(a). This in particular implies that TrB(a)|B| for all aX.

By definition of Wedderburn-Malcev normal form the block diagonal part a for a+cX can be uniquely determined from TrB(a). Since TrB(a)|B|, the denominator of a hence divides the denominator of TrB1. By Cramer’s rule, since TBlockDiag(B) is an integer matrix, det(TBlockDiag(B)) is a common denominator for TBlockDiag(B)1, finishing the claim.

Since any matrix in (AC)d is zero, we obtain that q=(det(TBlockDiag(B)))d(q)d1 is a common denominator for D. Since any matrix in X is by the distributive law a sum of matrices in D, we obtain that q is also a common denominator for X.

We can now prove Theorem 17.

Proof of Theorem 17.

By Theorem 4 we can transform X to Wedderburn-Malcev normal form with polynomial overhead. Henceforth assume that X is in Wedderburn-Malcev normal form. Compute the number q=det(TBlockDiag(B))d(q)d1 of Proposition 20, and output the result of applying Lemma 19 with (X,q) as input.

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.