1 Introduction

A deterministic automaton is called synchronizing when there exists a word that brings every state to the same state. If it exists, such a word is called reset or synchronizing.

Synchronizing automata serve as natural models of error-resistant systems because a reset word allows to turn a system into a known state, thus reestablishing the control over the system. For instance, prefix code decoders can be represented by automata. If an automaton corresponding to a decoder is synchronizing, then decoding a reset word, after an error appeared in the process, would recover the correct decoding process.

There has been a lot of research done on synchronizing automata since pioneering works of Černý [3]. Two questions that attract major interest here are whether an automaton is synchronizing and what is the length of shortest reset words if the answer to the first question is ‘yes’? These questions are also studied from different perspectives such as algorithmic, general statements etc. and in variety of settings, e.g. for particular classes of automata, random settings, etc. The reader is referred to the survey of Volkov [10] for a brief introduction to the theory of synchronizing automata.

One of the most studied direction of research in this field is the long-standing conjecture of Černý, which states that if an automaton is synchronizing, then it admits a reset word of length at most \((n-1)^2\), where n is the number of states of the automaton. This bound is best possible, as shown by Černý. However, despite many efforts, only cubic upper bounds have been obtained so far [7, 8].

It is the probabilistic settings that interest us in this article. During the attempts to tackle the conjecture of Černý, lots of experiments have been done, showing that random automata seem to be synchronizing with high probability, and that their reset words seem to be quite small in expectation. This was proved quite recently in a series of articles:

  • Skvortsov and Zaks [11] obtained some results for large alphabets (where the number of letters grows with n);

  • Berlinkov [2] proved that the probability that a random automaton is not synchronizing is in \(\mathcal {O}(n^{-k/2})\), where k is the number of letters, for any \(k\ge 2\) (this bound is tight for \(k=2\));

  • Nicaud [6] proved that with high probability a random automaton admits a reset word of length \(\mathcal {O}(n\log ^3 n)\), for \(k\ge 2\) (but with less precise error terms than in [2]).

All these results hold for the uniform distribution on the set of deterministic and complete automata with n states on an alphabet of size k, where all automata have the same probability. And it is, indeed, the first probability distribution to study. The reader is referred to the survey [5] for more information about random deterministic automata.

In this article we study a distribution on a restricted set of deterministic automata, the almost-group automata, which will be defined later in this introduction. In order to motivate our choice, we first need to outline the main features of the uniform distribution on deterministic automata and how they were used in the proofs of the articles cited above.

In a deterministic and complete automaton, one can consider each letter as a map from the set of states Q to itself, which is called its action. The action of a given letter in a uniform random automaton is a uniform random mapping from Q to Q. Properties of uniform random mappings have been long studied and most of their typicalFootnote 1 statistics are well known. The functional graph proved to be a useful tool to describe a mapping; it is the directed graph of vertex set Q, built from a mapping \(f:Q\rightarrow Q\) by adding an edge \(i\rightarrow j\) whenever \(j=f(i)\). Such a graph can be decomposed as a set of cycles of trees. Vertices that are in a cycle consists of elements \(q\in Q\) such that \(f^\ell (q)=q\) for some positive \(\ell \). They are called cyclic vertices.

The expected number of cyclic vertices in a uniform random mapping on a set of size n is in \(\varTheta (\sqrt{n})\). This is used in [6] and [2] to obtain the synchronization of most automata. The intuitive idea is that after reading \(a^n\), the set of states already shrinks to a much smaller set, in a uniform random automaton; this gives enough leverage, combined with the action of the other letters, to fully synchronize a typical automaton.

In a nutshell, uniform random automata are made of uniform random mappings, and each uniform random mapping is already likely to synchronize most of the states, due to their inherent typical properties. At this point, it seems natural to look for “harder” random instances with regard to synchronization, and it was a common question asked when the authors presented their works.

In this article, to prevent easy synchronization from the separate action of the letter, we propose to study what we call almost-group automata, where the action of each letter is a permutation, except for one of them which has only one non-cyclic vertex. An example of such an automaton is depicted on Fig. 1.

Fig. 1.
figure 1

An almost-group automaton with 7 states. The action of b is a permutation. The action of a is not, as 1 has no preimage by a; but if state 1 is removed, a acts as a permutation on the remaining states.

Since a group automaton with more than one state cannot be synchronizing, almost-group automata can be seen as the automata with the maximum number of cyclic states (considering all its letters) that can be synchronizing. The question we investigate in this article is the following.

Question: For the uniform distribution, what is the probability that a strongly connected almost-group automaton is synchronizing?

For this question, we consider automata with n states on a k-letter alphabet, with \(k\ge 2\), and try to answer asymptotically as n tends to infinity. We prove that such an automaton is synchronizing with probability that tends to 1. We also provide a precise asymptotic estimation of the probability that it is not synchronizing. In other words, one can state our result as follows: group automata are always non-synchronizing when there are at least two states, but if one allows just one letter to act not bijectively for just one state, then the automaton is synchronizing with high probability. This suggests that from a probabilistic point of view, it is very difficult to achieve non-synchronization.

This article starts with recalling some basic definitions and notations in Sect. 2. Then some interesting properties of this set of automata regarding synchronization are described in Sect. 3. Finally, we rely on this properties and some elementary counting techniques to establish our result in Sect. 4.

2 Basic Definitions and Notations

Automata and Synchronization. Throughout the article, we consider automata on a fixed k-letter alphabet \(A=\{a_0,\ldots ,a_{k-1}\}\). Since we are only interested in synchronizing properties, we only focus on the transition structure of automata: we do not specify initial nor final states, and will never actually consider recognized languages in the sequel. From now on a deterministic and complete automaton (DFA) \(\mathcal {A}\) on the alphabet A is just a pair \((Q,\cdot )\), where Q is a non-empty finite set of states and \(\cdot \), the transition mapping, is a mapping from \(Q\times A\) to Q, where the image of \((q,a)\in Q\times A\) is denoted \(q\cdot a\). It is inductively extended to a mapping from \(Q\times A^*\) to Q by setting \(q\cdot \varepsilon = q\) and \(q\cdot ua=(q\cdot u)\cdot a\), for any word \(u\in A^*\) and any letter \(a\in A\), where \(\varepsilon \) denote the empty word.

Let \(\mathcal {A}=(Q,\cdot )\) be a DFA. A word \(u\in A^*\) is a synchronizing word or a reset word if for every \(q,q'\in Q\), \(q\cdot u=q'\cdot u\). An automaton is synchronizing if it admits a synchronizing word. A subset of states \(S\subseteq Q\) is synchronized by a word \(u\in A^*\) if \(|S\cdot u|=1\).

Observe that if an automaton contains two or more terminal strongly connected componentsFootnote 2, then it is not synchronizing. Moreover if it has only one terminal strongly connected component S, then it is synchronizing if and only if S is synchronized by some word u. For this reason, most works on synchronization focus on strongly connected automata, and this paper is no exception.

Almost-Group Automata. Let \(\mathcal {S}_n\) be the set of all permutations of \(E_n=\{0,\ldots ,n-1\}\). A cyclic point of a mapping f is an element x such that \(f^\ell (x)=x\) for some positive \(\ell \). An almost-permutation of \(E_n\) is a mapping from \(E_n\) to itself with exactly \(n-1\) cyclic points; its unique non-cyclic point is called dangling point (or dangling state later on, when we use this notion for automata). Equivalently, an almost-permutation is a mapping that acts as a permutation on a subset of size \(n-1\) of \(E_n\) and that is not a permutation. Let \(\mathcal {S}'_n\) denote the set of almost-permutations on \(E_n\).

An almost-group automaton is a DFA such that one letter act as an almost-permutation and all others as permutations. An example of such an automaton is given in Fig. 1. For counting reasons, we need to normalize the automata, and define \(\mathcal {G}_{n,k}\) as the set of all almost-group automata on the alphabet \(\{a_0,\ldots ,a_{k-1}\}\) whose state set is \(E_n\) and such that \(a_0\) is the almost-permutation letter.

Probabilities. In this article, we equip non-empty finite sets with the uniform distribution, where all elements have same probability. The sets under consideration are often sequences of sets, such as \(\mathcal {S}_n\); by abuse of notation, we say that a property hold with high probability for \(\mathcal {S}_n\) when the probability that it holds, which is defined for every n, tends to 1 as n tends to infinity.

3 Synchronization of Almost-Group Automata

In this section we introduce the main tools that we use to describe the structure of synchronizing and of non-synchronizing almost-group automata.

The notion of a stable pair, introduced by Kari [4], has proved to be fruitful mostly by Trahtman, who managed to use it for solving the famous Road Coloring Problem [9]. We make use of this definition in our proof as well, along with some ideas coming from [9].

A pair of states \(\{p,q\}\) is called stable, if for every word u there is a word v such that \(p\cdot uv=q\cdot uv\). The stability relation given by the set of stable pairs joined with a diagonal set \(\{(p,p) \mid p \in Q\}\) is invariant under the actions of the letters and complete whenever \(\mathcal {A}\) is synchronizing. The definition on pairs is sound as stability is a symmetric binary relation. It is also transitive whence it is an equivalence relation on Q which is a congruence, i.e. invariant under the actions of the letters.

Notice also, that an automaton is synchronizing if and only if its stability relation is complete, that is, all pairs are stable. Because of that, if an automaton is not synchronizing and admits a stable pair, then one can consider a non-trivial factorization of the automaton by the stability relation. So, we aim at characterizing stable pairs in a strongly-connected non-synchronizing almost-permutation automaton, in order to show there is a slim chance for such a factorization to appear when switching to probabilities.

For this purpose, we need the definition of a deadlock, which is a pair that cannot be merged into one state by any word (somehow opposite to the notion of stable pair). A subset \(S \subseteq Q\) is called an F-clique of \(\mathcal {A}\) if it is a set of maximum size such that each pair of states from S is a deadlock. It follows from the definition that all F-cliques have same size and that the image of F-clique by a letter or a word is also an F-clique.

Let us reformulate [9, Lemma 2] for our purposes and present a proof for self-completeness.

Lemma 1

If S and T are two F-cliques such that \(S \setminus T = \{p\}\) and \(T \setminus S= \{q\}\), for some states p and q, then \(\{p,q\}\) is a stable pair.

Proof

By contradiction, suppose there is a word u such that \(\{p\cdot u,q\cdot u\}\) is a deadlock. Then \((S \cup T)\cdot u\) is an F-clique because all its pairs are deadlocks. Since \(p\cdot u \ne q\cdot u\), we have \(|S\cup T| = |S| + 1 > |S|\) contradicting maximality of S.   \(\square \)

Lemma 2

Each strongly-connected almost-group automaton \(\mathcal {A} \in \mathcal {G}_{n,k}\) with at least two states, admits a stable pair containing the dangling state that is synchronized by \(a_0\).

Proof

If \(\mathcal {A}\) is synchronizing, then we are done because all pairs are stable. In the opposite case, there must be an F-clique \(F_1\) of size at least two.

Let \(p_0\) be the dangling state (which is not permuted by \(a_0\)) and let d be the product of all cycle lengths of \(a_0\). Since \(\mathcal {A}\) is strongly-connected there is a word u such that \(p_0 \in F_1\cdot u\). By the property of F-cliques, \(F_2 = F_1\cdot u\) and \(F_3 = F_2\cdot a_0^{d}\) are F-cliques too. Notice that \(p_0\) is the only state which does not belong to the cycles of \(a_0\) and all the cycle states remains intact under the action \(a_0^d\), by construction of d. Hence \(F_2 \setminus F_3 = \{p_0\}\) and \(F_3 \setminus F_2 = \{p_0\cdot a_0^d\}\). Hence, by Lemma 1, \(\{p_0,p_0\cdot a_0^d\}\) is a stable pair. This concludes the proof since \(p_0\cdot a_0 = p_0\cdot a_0^{d+1}\).   \(\square \)

To characterize elements of \(\mathcal {G}_{n,k}\) that are not synchronizing, we build their factor automata, which is defined as follows. Let \(\mathcal {A}\) be a DFA with stability relation \(\rho \). Let \(\mathcal {C}=\{C_1,\ldots , C_\ell \}\) denote its classes for \(\rho \). The factor automaton of \(\mathcal {A}\), denoted by \(\mathcal {A} / \rho \), is the automaton of set of states \(\mathcal {C}\) with transition function defined by \(C_i\cdot a = C_j\) in \(\mathcal {A} / \rho \) if and only if \(C_i\cdot a \subseteq C_j\) in \(\mathcal {A}\). Or equivalently, if and only if there exists \(q\in C_i\) such that \(q\cdot a\in C_j\) in \(\mathcal {A}\).

Lemma 3

If \(\mathcal {A}\in \mathcal {G}_{n,k}\) is strongly-connected, then its factor automaton \(\mathcal {A} / \rho \) is a strongly-connected permutation automaton.

Proof

Strong-connectivity follows directly from the definition. If one of the letters was not a permutation on the factor automaton, then there would be a stable class S in \(\mathcal {A}\) which has no incoming transition by this letter. It would follow that there is no incoming transition to every state of S in \(\mathcal {A}\) either. However, this may happen only for the letter \(a_0\) and the (unique) dangling state \(p_0\) by this letter. Due to Lemma 2, the dangling state \(p_0\) must belong to a stable pair whence there is another state in S: this contradicts that \(p_0\) is the only state with no incoming transition by \(a_0\).   \(\square \)

Lemma 4

Let \(\mathcal {A}\in \mathcal {G}_{n,k}\) and let D be the stable class of \(\mathcal {A}\) that contains the dangling state \(p_0\). Then the set of stable classes can be divided into two disjoint, but possibly empty, subsets \(\mathcal {B}\) and \(\mathcal {S}\) such that

  • \(D \in \mathcal {B}\) and \(|B|=|D|\) for every \(B \in \mathcal {B}\);

  • \(|S|=|D|-1\) for every \(S \in \mathcal {S}\);

  • The \(a_0\)-cycle of \(\mathcal {A} / \rho \) that contains D only contains elements of \(\mathcal {S}\) besides D;

  • Every other cycle in \(\mathcal {A} / \rho \) lies entirely in either \(\mathcal {B}\) or \(\mathcal {S}\).

Proof

Since stable pairs are mapped to stable pairs, the image of a stable class by any letter must be included in a stable class. Recall that by Lemma 3 all letters in \(\mathcal {A} / \rho \) act as permutations on the stable classes. Our proof consists in examining the different cycles of the group automaton \(\mathcal {A}/\rho \). Let us consider any cycle of a letter a in \(\mathcal {A} / \rho \), made of the stable classes \(C_0, C_1, \dots , C_{r-1}\) with \(C_j\cdot a \subseteq C_{j+1 \pmod {r}}\), for any \(j\in \{0,\ldots r-1\}\).

If \(a\ne a_0\) then the letter a acts as a permutation in \(\mathcal {A}\), and for each j, we have \(|C_j| \le |C_{j+1 \pmod {r}}|\), since a does not merge pairs of states. Therefore,

$$ |C_0| \le |C_1| \dots \le |C_{r-1}| \le |C_0|. $$

As a direct consequence, all \(|C_j|\) have same cardinality.

If \(a = a_0\), then observe that the same argument can be used when one removes the dangling state \(p_0\) and its outgoing transition by \(a_0\): the action of \(a_0\) on \(Q\setminus \{p_0\}\) becomes a well-defined permutation. Henceforth, if this cycle does not degenerate to a simple loop consisting of only D, then all the other elements of the cycle are stable classes of size \(|D|-1\). And this is the only place where changes of size may happen in \(\mathcal {A}/\rho \). The lemma follows from the strong-connectivity of \(\mathcal {A} / \rho \).    \(\square \)

Notice that an almost-group automaton is non-synchronizing if and only if it has at least two stable classes. The following theorem is a consequence of this fact and of Lemma 4.

Theorem 1

A strongly-connected almost-group automaton \(\mathcal {A}\) is non-synchronizing if and only if its partitioning described in Lemma 4 is such that \(|\mathcal {B} \cup \mathcal {S}|>1\).

4 Counting Non-synchronizing Almost-Group Automata

In this section, we use counting arguments to establish our main result: a precise estimation of the asymptotic number of strongly connected almost-group automata that are not synchronizing.

Recall that our working alphabet is \(A=\{a_0,\ldots ,a_{k-1}\}\), that \(E_n=\{0,\ldots ,n-1\}\) and that \(\mathcal {G}_{n,k}\) is the set of almost-group automata on A with set of states \(E_n\). Our first counting lemma is immediate.

Lemma 5

For any \(n\ge 1\), there are exactly \((n-1) n!\) almost-permutations of \(E_n\). The number of elements of \(\mathcal {G}_{n,k}\) is therefore equal to \((n-1)n!^k\).

Proof

An almost-permutation of \(E_n\) is characterized by its element with no preimage \(x_0\), the way it permutes \(E_n\setminus \{x_0\}\) and the image of \(x_0\) in \(E_n\setminus \{x_0\}\). Since there are n choices for \(x_0\), \((n-1)!\) ways to permute the other elements and \(n-1\) choices for the image of \(x_0\), the result follows.   \(\square \)

4.1 Strong-Connectivity

Our computations below focus on strong-connectivity. We shall need an estimation of the number of strongly connected group automata and almost-group automata. The proofs of the following lemmas are kind of folklore and thus presented only in the extended version [1] due to a space limit.

Lemma 6

There are at most \(n(n-1)!^k(1+o(1))\) group automata with set of states \(E_n\) that are not strongly-connected. Henceforth, there are \(n!^k(1+o(n^{1-k}))\) strongly-connected group automata.

Lemma 7

The number of not strongly-connected almost-group automata is at most \(2(n-1)n(n-1)!^{k}(1+o(1))\). Henceforth, almost-group automata are strongly connected with high probability: there are \((n-1)n!^k(1+o(n^{1-k}))\) strongly connected elements in \(\mathcal {G}_{n,k}\).

4.2 Non-synchronizing Almost-Group Automata: A Lower Bound

In this section we give a lower bound on the number of strongly connected elements of \(\mathcal {G}_{n,k}\) that are not synchronizing. In order to do so, we build a sufficiently large family of automata of that kind. The construction of this family is intuitively driven by the structure given in Lemma 4 but the formal details of the construction can be done without mentioning this structure.

For \(n\ge 3\), let \(\mathcal {F}_{n,k}\) be the subset of \(\mathcal {G}_{n,k}\), made of the almost-group automata on A with set of states \(E_n\) such that:

  1. 1.

    there exists a state p that is not the dangling state \(p_0\) such that for every letter \(a\ne a_0\), either \(p\cdot a = p_0\) and \(p_0\cdot a=p\), or \(p\cdot a = p\) and \(p_0\cdot a=p_0\);

  2. 2.

    for at least one letter \(a\ne a_0\), we have \(p\cdot a = p_0\) and \(p_0\cdot a=p\);

  3. 3.

    there exists a state \(q\in Q'=E_n\setminus \{p,p_0\}\) such that the action of \(a_0\) on \(Q\setminus \{p_0\}\) is a permutation with q being the image of p;

  4. 4.

    the image of the dangling state by \(a_0\) is \(p_0\cdot a_0 = q\).

  5. 5.

    let \(q'\) be the preimage of p by \(a_0\); if one removes the states p and \(p_0\) and set \(q'\cdot a_0=q\), then the resulting automaton is a strongly connected group automaton;

The structure of such an automaton is depicted on Fig. 2. Clearly from the definition, an element of \(\mathcal {F}_{n,k}\) is a strongly connected almost group automaton with the dangling state \(p_0\).

Fig. 2.
figure 2

The shape of an element of \(\mathcal {F}_{n,k}\), with the dangling state \(p_0\).

Lemma 8

For every \(n\ge 3\), every automaton of \(\mathcal {F}_{n,k}\) is not synchronizing.

Proof

First observe that \(\{p_0,p\}\) is the only pair that can be synchronized by reading just a letter, which has to be \(a_0\). The preimage of \(\{p_0,p\}\) is either \(\{p_0,p\}\) for \(a \ne a_0\) or a singleton \(\{q'\}\) otherwise. Hence, no other pair can be mapped to \(\{p_0,p\}\) and thus be synchronized by more that one letter.    \(\square \)

Lemma 9

There are \((2^{k-1}-1)n(n-1)(n-2)(n-2)!^{k}(1+o(n^{1-k}))\) elements in \(\mathcal {F}_{n,k}\). Thus there are at least that many strongly connected non-synchronizing almost-group automata.

Proof

From the definition of \(\mathcal {F}_{n,k}\), we observe that there are \(n(n-1)(n-2)\) ways to choose \(p_0\), p and q. Once it is done, we choose any strongly connected group automaton \(\mathcal {A}'\) with \(n-2\) states in \(E_N\setminus \{p_0,p\}\); there are \((n-2)!^k(1+o(n^{1-k}))\) ways to do that according to Lemma 6. We then change the transition from the preimage \(q'\) of q by \(a_0\) by setting \(q'\cdot a_0 = p\). We set \(p\cdot a_0=p_0\cdot a_0 =q\). Finally we choose the actions of the letters \(a\in A \setminus \{a_0\}\) on \(\{p_0,p\}\) in one of the \(2^{k-1}-1\) possible ways, as at least one of them is not the identity. This concludes the proof, since all the elements of \(\mathcal {F}_{n,k}\) are built exactly once this way.   \(\square \)

Observe that using the definitions of Lemma 4, an element of \(\mathcal {F}_{n,k}\) consists of exactly one stable class \(\{p_0,p\}\) in \(\mathcal {B}\) and \(n-2\) stable classes of size 1 in \(\mathcal {S}\).

4.3 Non-synchronizing Almost-Group Automata: An Upper Bound

In this section, we upper bound the number of non-synchronizing strongly-connected elements of \(\mathcal {G}_{n,k}\) using the characterization of Lemma 4. In the sequel, we freely use the notations used in this lemma (the sets D, \(\mathcal {B}\), \(\mathcal {S}\), ...).

Let \(b\ge 1\), \(s\ge 0\) and \(\ell \ge 1\) be three non-negative integers such that \((\ell +1)b + \ell s = n\). Let \(\mathcal {G}_{n,k}(b,s,\ell )\) denote the subset of \(\mathcal {G}_{n,k}\) made of the automata such that \(|\mathcal {B}|=b\), \(|\mathcal {S}|=s\) and \(|D|=\ell +1\).

Lemma 10

The number of non-synchronizing strongly-connected elements of \(\mathcal {G}_{n,k}(b,s,\ell )\) is at most

$$ {\left\{ \begin{array}{ll} n! (n-2)!^{k-1}(n-2)(2^{k-1}-1) &{} \text {if }b=1,\,s=n-2,\text { and}\ \ell =1,\\ n! \max (1,s) \ell \big (b!s!(\ell +1)!^{b}\ell !^{s}\big )^{k-1}&{}\text {otherwise}. \end{array}\right. } $$

Proof

Our proof consists in counting the number of ways to build, step by step, an element of \(\mathcal {G}_{n,k}(b,s,\ell )\).

Firstly, by elementary computations, one can easily verify that the number of ways to split \(E_n\) into b subsets of size \(\ell +1\) and s subsets of size \(\ell \) is exactly

$$\begin{aligned} \frac{n!}{(\ell +1)!^{b}\ell !^{s}b!s!}. \end{aligned}$$
(1)

Secondly, let us count the number of ways to define the transitions at the level of the factor automaton, i.e. between stable classes, as follows:

  • Choose a permutation on \(\mathcal {B}\) in b! ways and on \(\mathcal {S}\) in s! ways for each of the \(k-1\) letters \(a \ne a_0\).

  • Choose which stable class of \(\mathcal {B}\) is the class D, i.e. the one containing the dangling state \(p_0\), amongst the b possibilities.

  • Choose a permutation for \(a_0\) on the \(b-1\) classes \(\mathcal {B} \setminus \{D\}\) in \((b-1)!\) ways.

  • If \(s\ne 0\), choose one of the s! permutations of \(\mathcal {S}\) for the action of \(a_0\) on these classes, then alter the action of \(a_0\) the following way: choose the image \(D'\) of D by \(a_0\) in \(\mathcal {S}\) in s ways, then insert it in the \(a_0\)-cycle: if \(D''\) is the former preimage of \(D'\), then now \(D\cdot a_0 = D'\) and \(D''\cdot a_0 = D\) in \(\mathcal {A}/\rho \).

  • If \(s=0\), then set \(D\cdot a_0 = D\) in \(\mathcal {A}/\rho \).

In total, the number of ways to define the transitions of the factor automaton \(\mathcal {A} / \rho \), once the stable classes are chosen is

$$\begin{aligned} (b!s!)^{k-1}b(b-1)!\max (1,s)s! = b!^ks!^{k}\max (1,s). \end{aligned}$$
(2)

Now, we need to define transitions between stable classes for all letters. For all letters but \(a_0\), there are b injective transitions between stable classes of size \(\ell +1\) and s injective transitions between stable classes of size \(\ell \), that is, there are at most \((\ell +1)!^b \ell !^s\) ways to define them for each of the \(k-1\) letters. This is an upper bound, as some choices may result in an automaton that is, for instance, not strongly connected. We refine this bound for the case \(\ell =1, b=1, s=n-2\): one of the letters must swap the states in the single 2-element class in \(\mathcal {B}\) for strong connectivity, so we count just one choice instead of 2 (for \((\ell +1)!\)) to define this letter on this component, that is, we consider only \(2^{k-1}-1\) ways to define all permutations on \(\mathcal {B}\) in this case, instead of the \(((\ell +1)!^b)^{k-1}\) upper bound in the general case (this refinement is used to match our lower bound).

For the action of \(a_0\), we additionally choose the dangling state \(p_0 \in D\) in \(\ell +1\) ways and its image in \(D\cdot a_0\) in \(\ell \) ways: there are \(\ell \) choices in the case where \(D\cdot a_0=D\), since \(p_0\cdot a_0\ne p_0\), and also when \(D\cdot a_0\ne D\), since \(D\cdot a_0\in \mathcal {S}\) in this case, according to Lemma 4. Then, it remains to define the injective transitions between the \(\mathcal {B} \setminus \{D\}\) blocks in \((\ell +1)!^{b-1}\) ways, and the \(s+1\) injective transitions between the \(\mathcal {S} \cup \{D'\}\) blocks in \(\ell !^{s+1}\) ways, where \(D'=D\setminus \{p_0\}\).

Thus, the number of ways to define the transitions between stable classes is at most \(((\ell +1)!^b \ell !^s)^{k-1}\ell (\ell +1)(\ell +1)!^{b-1}\ell !^{s+1} = \ell (\ell +1)!^{bk}\ell !^{sk}\), in the general case, and \(2(2^{k-1}-1)\) in the case \(\ell =1, b=1, s=n-2\).

Putting together (1), (2) and this last counting result yield the lemma.   \(\square \)

Lemma 11

The number of non-synchronizing strongly-connected almost-group automata in \(\mathcal {G}_{n,k}\) is at most \(n(2^{k-1}-1)n!(n-2)!^{k-1}(1+o(1/n))\).

Proof

By Lemma 9 and Theorem 1, the number of non-synchronizing strongly-connected almost-group automata in \(\mathcal {G}_{n,k}\) is at most

$$\begin{aligned} n!\sum _{\ell =1}^{\lfloor n/2 \rfloor }\sum _{\{b,s \mid b(\ell +1) + s\ell = n\} } N_{\ell ,b,s}, \end{aligned}$$
(3)

where \(b \ge 1\), \(s \ge 0\), and \(b+s\ge 2\), and where \(N_{\ell ,b,s}\) is defined by

$$\begin{aligned} N_{\ell ,b,s} = {\left\{ \begin{array}{ll} \max (1,s) \ell (b!s!(\ell +1)!^{b}\ell !^{s})^{k-1}, &{} \text {for } (\ell ,b,s) \ne (1,1,n-2) \\ (n-2)!^{k-1}(n-2)(2^{k-1}-1), &{} \text {for } (\ell ,b,s) = (1,1,n-2). \end{array}\right. } \end{aligned}$$
(4)

To finish the proof, it will be sufficient to prove that the sum in (3) is asymptotically equivalent to the term \(N_{1,1,n-2}\) since \(n!N_{1,1,n-2}\) is asymptotically equivalent to the expression stated in Lemma 11.

To prove this, let us consider the following fraction for \((\ell ,b,s) \ne (1,1,n-2)\):

$$\begin{aligned} \frac{N_{1,1,n-2}}{N_{\ell ,b,s}} = \frac{n-2}{\max (1,s) \ell }\frac{(n-2)!^{k-1}(2^{k-1}-1)}{ (b!s!(\ell +1)!^{b}\ell !^{s})^{k-1}} \ge \left( \frac{(n-2)!}{b!s!(\ell +1)!^{b}\ell !^{s}}\right) ^{k-1}, \end{aligned}$$
(5)

where we used that \(n-2 = s\ell + b(\ell +1)-2 \ge s \ell \), as b and \(\ell \) are positive; thus \(n-2\ge \max (1,s)\ell \) if \(s>0\); but it also holds if \(s=0\) since \(b+s\ge 2\).

Observe that, for positive \(\ell \) and m we have

$$\begin{aligned} \frac{(bm)!}{m!^b}&= \left( \frac{1\cdot 2\cdots m}{1\cdot 2\cdots m}\right) \left( \frac{(m+1)(m+2)\cdots 2m}{1\cdot 2\cdots m}\right) \cdots \left( \frac{((b-1)m+1)\cdots bm}{1\cdot 2\cdots m}\right) \\&\ge 1^m\cdot 2^m\cdots b^m = b!^m \end{aligned}$$

Hence, for \(m=\ell +1\), we have \(\frac{(b(\ell +1))!}{(\ell +1)!^b}\ge b!^{\ell +1}\). Similarly, one can get that

$$\begin{aligned} {\frac{n!}{(b(\ell +1))!}}\frac{1}{\ell !^s} \ge \left( \frac{(b+s)!}{b!}\right) ^{\ell }. \end{aligned}$$
(6)

Let \(M_{\ell ,b,s}=\frac{(n-2)!}{b!s!(\ell +1)!^{b}\ell !^{s}}\), the expression in brackets of (5). This quantity can be bounded from below as follows.

$$\begin{aligned} M_{\ell ,b,s}&= \frac{1}{n(n-1)b!s!}\frac{(b(\ell +1))!}{(\ell +1)!^{b}} \frac{n!}{(b(\ell +1))!\ell !^s} \end{aligned}$$
(7)
$$\begin{aligned}&\ge \frac{b!^{\ell +1}}{n(n-1)b!s!} \left( \frac{(b+s)!}{b!}\right) ^{\ell } \ge \frac{(b+s)!^\ell }{n^2 s!}. \end{aligned}$$
(8)

Recall that we want to prove that \(M_{\ell ,b,s}\) is sufficiently large, so that \(N_{1,1,n-2}\) is really larger than \(N_{\ell ,b,s}\). Notice that there are at most quadratic in n number of combinations \((\ell , b, s)\) satisfying \(b(\ell +1) + s\ell = n\), as for any values \(1 \le b, \ell < n\) there is at most one suitable value of s. Therefore, cubic lower bound on \(M_{\ell ,b,s}\) is enough in general. We distinguish two cases:

\(\triangleright \) If \(\ell \ge 2\), then \(M_{\ell ,b,s} \ge {n^{-2}(b+s)!^{\ell -1}}.\) If \(b+s \ge \ln {n}\), this expression is greater than \(\varTheta (n^3)\) by Stirling formula. Otherwise, because \(b(\ell +1)+s\ell =n\), we have \(\ell \ge \frac{n}{\ln {n}}-1\) and as \(b+s\ge 2\) the same \(\varTheta (n^3)\) lower bound holds.

\(\triangleright \) If \(\ell =1\), then \(s = n-2b\) and \(M_{\ell ,b,s} \ge \frac{(n-b)!}{n^2 (n-2b)!}.\) Clearly, this expression decreases as b increases; for \(b=3\) it is greater than \(\varTheta (n)\) (and there is only one such term) and for \(b>3\) it is greater than \(\varTheta (n^3)\). If \(b=1\), then \(s=n-2\) and this is the term \(N_{1,1,n-2}\). The only remaining case is when \(b=2\), \(\ell =1\), and \(s=n-4\). For this case by (5), we get

$$\begin{aligned} \frac{N_{1,1,n-2}}{N_{\ell ,b,s}} \ge \left( \frac{(n-2)!}{b!s!(\ell +1)!^{b}\ell !^{s}}\right) ^{k-1} = \left( \frac{(n-2)!}{8(n-4)!}\right) ^{k-1} = \varTheta (n^{2(k-1)}). \end{aligned}$$
(9)

Thus, we proved that the sum (3) is indeed asymptotically equal to the term \(N_{1,1,n-2}\) multiplied by n!.   \(\square \)

4.4 Main Result and Conclusions

Now, we are ready to prove our main result on the asymptotic number of strongly connected elements of \(\mathcal {G}_{n,k}\) that are not synchronizing.

Theorem 2

The probability that a random strongly connected almost-group automaton with n states and \(k\ge 2\) letters is not synchronizing is equal to

$$\begin{aligned} ({2^{k-1}-1}){n^{-2(k-1)}}\left( 1+o(1)\right) . \end{aligned}$$
(10)

In particular, random strongly connected almost-group automata are synchronizing with high probability as n tends to infinity.

Proof

Lemmas 9 and 11 give lower and upper bounds on the number of strongly-connected non-synchronizing almost-group automata, which are both equal to \((2^{k-1}-1)n^3(n-2)!^{k}(1+o(1/n))\). We conclude the proof using the estimation on the number of strongly-connected almost-group automata given in Lemma 7.   \(\square \)

Thus we obtained a precise asymptotic on the probability for strongly-connected almost group automata of being synchronizable for any alphabet size. Apart from generalizing this result, it would be natural, as in [2], to design an algorithm which would test on synchronization a given random strongly-connected almost-group automaton in optimal average time.

We are thankful to anonymous referees whose comments helped to improve the presentation of the results.