Deciding DFA-Primality Is NP-Hard
Abstract
A DFA is composite if there exist DFAs with such that each has strictly less states than the minimal DFA deciding . Otherwise, it is prime.
Prime-DFA is the problem of deciding primality for a given DFA. It was defined by Kupferman and Mosheiff in 2015 and it was shown to be NL-hard and in ExpSpace.
This paper proves the NP-hardness of Prime-DFA, thereby making the first progress in closing this doubly-exponential gap. It proves the NP-hardness by a reduction from the propositional logic satisfiability problem. The correctness of the reduction relies on an involved characterization of primality for a class of DFAs which contains those that can occur in the reduction.
Keywords and phrases:
Deterministic finite automaton (DFA), Regular languages, Finite languages, Decomposition, Primality, NP-HardnessCategory:
Track B: Automata, Logic, Semantics, and Theory of ProgrammingCopyright and License:
2012 ACM Subject Classification:
Theory of computation Regular languages ; Theory of computation Problems, reductions and completenessEditors:
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
We consider the primality of deterministic finite automata (DFA). Intuitively, the basic question is: Given a DFA , are there a number of DFAs strictly smaller than itself that combined decide the same language as ? More formally, a DFA is composite if there exist DFAs with such that the size of every is strictly smaller than the index of . Otherwise, is prime. Here, the size of is the number of its states, while the index of is the size of the minimal DFA deciding . Prime-DFA denotes the problem of deciding primality for a given DFA.
The notion of compositionality of finite automata was introduced in [8], although a similar but more restricted notion was already studied in [4]. With [8, Theorems 2.4 and 2.5], Prime-DFA is NL-hard and in ExpSpace. Up to now, progress in closing this surprisingly large doubly-exponential gap has proven elusive. In this paper, we improve the lower complexity bound of Prime-DFA.
Compositionality in general is an important notion in both practical and theoretical computer science [3, 12]. Regular languages and DFAs are key concepts of theoretical computer science and the question whether a DFA can be decomposed in this fashion seems natural and worth studying. Furthermore, the general idea of automaton decomposition can be motivated by LTL model checking, while a question related to automaton decomposition arises in the field of automaton identification. Both will be briefly discussed below.
Contributions.
We prove the NP-hardness of Prime-DFA by reducing the propositional logic satisfiability problem to Prime-DFA.
Given a formula , the reduction yields a DFA so that every assignment for can be associated with a word of a specific form which is accepted by if and only if the underlying assignment satisfies . The proof that this is actually a reduction to Prime-DFA relies on an involved characterization of the compositionality of a class of DFAs which contains all DFAs of the form . Namely, we characterize the compositionality of “almost-acyclic” linear safety DFAs (essentially, DFAs whose states are linearly ordered, whose only rejecting state is a rejecting sink, who possess an accepting sink, and whose only cycles are its sinks). This characterization then shows that accepts a word of this specific form if and only if it is prime. This proves the correctness of the reduction.
Thus, the NP-hardness proof entails the construction of , the characterization of the compositionality of the mentioned DFA class, and the use of this characterization to link the satisfiability of and the compositionality of . Additionally, we further exploit the characterization of the compositionality of “almost-acyclic” linear safety DFAs to prove that the restriction of Prime-DFA to such DFAs is NP-complete, meaning that the established lower bound is tight for this specific class of DFAs.
Related Work.
As already mentioned, the notion of compositionality was introduced in [8], where the mentioned complexity bounds for Prime-DFA were established. This initial work was followed up by [6, 7, 10]. These works focused on restricted classes of DFAs, namely, unary DFAs, permutation DFAs, and acyclic DFAs and thereby finite languages, respectively. However, the initial complexity bounds for Prime-DFA remained unaltered.
The general idea of decomposing finite automata can be motivated by LTL model checking, where the validity of a specification, given as an LTL-formula, is checked for a system. The automata-based approach entails translating the specification into a finite automaton [13]. Since the LTL model checking problem is PSpace-complete in the size of the LTL-formula [1, Theorem 5.48], it is desirable to decompose the formula into a conjunction of subformulas. This can also be understood as decomposing the finite automaton corresponding to the formula.
A question related to the decomposition of automata arises in the field of automaton identification. The basic task here is, given a set of labeled words, to construct an automaton conforming to this set [5]. An interesting approach is to construct multiple automata instead of one, which can lead to smaller and more intuitive solutions [9].
However, the results obtained in this paper use decompositions with DFAs that are only slightly smaller than the given DFA (most often by just one state). For practical applications, decompositions into much smaller components might be more relevant.
2 Preliminaries
A deterministic finite automaton (DFA) is a -tuple where is a finite set of states, is a finite non-empty alphabet, is an initial state, is a transition function, and is a set of accepting states. As usual, we extend to words: with and .
The run of on a word starting in state is the sequence with and for each . The initial run of on is the run of on starting in . The run of on starting in is accepting if . Otherwise, it is rejecting. The DFA accepts if the initial run of on is accepting. Otherwise, it rejects . The language of is the set of words accepted by . We say that decides . A language is regular if there exists a DFA deciding it. Since we only consider regular languages, we use the terms language and regular language interchangeably.
The size of is the number of states in . A DFA is minimal if holds for every DFA with . It is well known that, for every regular language , there exists a canonical minimal DFA deciding . The index of is the size of this canonical minimal DFA. The index of is the index of the language decided by , thus . Note that is minimal if and only if .
We borrow a few terms from graph theory. Let be the run of on starting in . Then is a path in from to . Thus, for two states , there exists a path from to in if and only if there exists a with . State is reachable from if there exists a path from to . Otherwise, is unreachable from . We say that is reachable if it is reachable from . Otherwise, it is unreachable. A cycle in is a path in where and . We call a state a sink if for all , that is, if all out--transitions are self-loops.
We introduce the notions of compositionality and primality of DFAs and languages, following the definitions in [8]:
Definition 2.1.
For , a DFA is -decomposable if there exist DFAs with and for each , where . We call such DFAs a -decomposition of . We call composite if is -decomposable for a , that is, if it is -decomposable. Otherwise, we call prime.
When analyzing the compositionality of a given DFA , it is sufficient to consider minimal DFAs strictly smaller than the minimal DFA of with . Thus, we define . Obviously, the DFA is composite if and only if . We call a word a primality witness of . Clearly, a DFA is composite if and only if it has no primality witness.
We say that a regular language is prime (composite) if its minimal automaton is prime (composite).
We denote the problem of deciding primality for a given DFA by Prime-DFA. Prime-DFA is NL-hard and in ExpSpace [8, Theorems 2.4 and 2.5].
3 NP-Hardness of Prime-DFA
We improve the lower complexity bound for Prime-DFA by proving:
Theorem 3.1.
The problem Prime-DFA is NP-hard.
As mentioned, this is the first improvement of a complexity bound for Prime-DFA since [8] introduced Prime-DFA and proved that it is NL-hard and in ExpSpace.
Proof Idea
We prove the NP-hardness of Prime-DFA (Theorem 3.1) by a reduction from CNFSAT. Given a CNF-formula , the reduction yields a DFA ([11, Definition A.1] (full version), Figure 1) with the goal that is satisfiable if and only if is prime (Lemma 3.2).
In the following, we call DFAs of the form CNF-DFAs. The correctness of the reduction relies on a (somewhat technical) characterization of the compositionality of CNF-DFAs. Simplified, for a given CNF-DFA , only the words on which visits each of its non-sinks before entering its rejecting sink are relevant for its compositionality. We call these the max-visiting words of . We say that has the max-pumping-property (mp-prop) if every max-visiting word of has a factorization so that rejects for every (˜3.7). It turns out that a CNF-DFA is composite if and only if it has the mp-prop (Lemmas 3.5 and 3.9).
The CNF-DFAs are designed so that the structure of the max-visiting words and their possible factorizations are strongly restricted (Lemma 3.11). This has two major benefits. Firstly, we will have a lot of control over the behavior of on each individual max-visiting word. And secondly, we will have a whole set of max-visiting words to reason about, which could potentially break the mp-prop.
More precisely, the max-visiting words have the form with , where is the number of ’s variables, and are dummy letters, and is a value dependent on (Lemma 3.11 (i)). The prefix is interpreted as a variable assignment for . Due to the structure of , the only factorization that might witness the mp-prop for such a max-visiting word is (Lemma 3.11 (ii)). Thus, exactly the pumpings of the form are decisive for the mp-prop and thereby for the compositionality of .
Intuitively, uses the repetitions of the assignment in to check whether satisfies each clause (Lemma 3.12). Indeed, let be the number of clauses of , then the crucial pumping is : To check the clauses, repetitions of are needed; two further repetitions of are needed for technical reasons. If does not satisfy , then detects an unsatisfied clause while reading and immediately enters its rejecting sink. Otherwise, that is, if satisfies , then detects no unsatisfied clause while reading and enters the accepting sink when beginning the final -repetition.
To summarize, if is unsatisfiable, then has the mp-prop and is therefore composite. Otherwise, that is, if is satisfiable, then does not have the mp-prop and is therefore prime, which is witnessed by the pumping of the max-visiting word , where encodes a satisfying assignment for .
We outline the reduction in Section 3.1 and prove its correctness in Section 3.2. To do so, we characterize the compositionality of the relevant DFAs in Section 3.2.1 and exploit this characterization to prove the correctness in Section 3.2.2. To conclude, we prove, in Section 3.3, that the restriction of Prime-DFA to the DFAs relevant for the reduction is NP-complete, meaning that the established lower bound is tight for this specific class of DFAs. The formal proofs of the results of Section 3 can be found in the full version [11, Appendix A].
3.1 Construction of
We denote the propositional logic satisfiability problem for formulas in conjunctive normal form (CNF) by CNFSAT. It is well known that CNFSAT is NP-complete [2]. From here on, we call propositional logic formulas in CNF simply CNF-formulas.
As mentioned, we prove Theorem 3.1 by a reduction from CNFSAT. For a given CNF-formula , the reduction yields a CNF-DFA so that is satisfiable if and only if is prime.
Before we can describe the reduction, we have to fix some notation. For the remainder of Section 3, let be a set of numbered variables, and let be a CNF-formula over . W.l.o.g. we assume that has at least one clause and that every variable appears at most once in every clause.
To simplify the construction of , we fix a special notation for . Namely, we write , where is the number of clauses of , and is the -th element in the -th clause where . In other words, in our notation, every clause has exactly elements and the -th element of every clause is either a literal of the -th variable or . Here, is a special symbol that always evaluates to False. It is easy to see that can be written in this way.
Towards the definition of , we introduce some additional notation. Let . We call a string an assignment string. As usual, an assignment over is a function . An assignment over induces an assignment string in the following way: . Conversely, an assignment string induces an assignment over in the following way: for all .
Now we can consider the reduction, that is, the construction of the CNF-DFA out of the given CNF-formula . The CNF-DFA is outlined in Figure 1. It is formally defined in the full version [11, Definition A.1]. The key property of that we want to prove is formalized as:
Lemma 3.2.
The CNF-formula is satisfiable if and only if the CNF-DFA is prime.
As mentioned above, the compositionality of depends solely on the max-visiting words of . We will discuss this in Section 3.2.1. For now, we will focus on the design of and give an intuition for it.
The CNF-DFA consists of two devices, the assignment device and the formula device. The assignment device consists of the states and . To fully traverse the assignment device, that is, to start in and reach , a string with has to be read. Therefore, the assignment device enforces that every max-visiting word is prefixed by an assignment string (followed by a single ). Subsequently, the assignment string is interpreted as the assignment for which it induces.
The formula device consists of clause rows. For , the -th clause row encodes the -th clause of , that is, . Thus, the formula device in its entirety encodes all clauses and thereby . The -th clause row consists of the states and . Among these, is the positive target state of the -th clause row, which is also the designated entry point for the subsequent clause row. And further, is the negative target state of the -th clause row, which prevents from entering the subsequent clause row.
We point out that is part of the assignment device enforcing the prefix , but also functions similarly to a positive target state for letters and . In particular, it is the designated entry point for the first clause row. Therefore, we denote the state also by .
The formula device is designed to enforce two assertions.
Firstly, every max-visiting word of is of the form , where is an assignment string and depends on . To be precise, this first assertion is enforced by the two devices together: The assignment device enforces the prefix and the formula device the suffix . The first assertion is formalized further below in Lemma 3.11 (i).
Secondly, if satisfies the -th clause, then induces a run from the positive target state of the -th clause to the positive target state of the -th clause. Else, induces a run from the positive target state of the -th clause to the negative target state of the -th clause. The second assertion is formalized in:
Lemma 3.3.
Consider an assignment string . Let . If satisfies the -th clause of , then holds. Else, holds.
Note that reading or in any negative target state leads to , while reading or in the final positive target state leads to . Together with the second assertion enforced by the formula device, this implies that, for every , a word of the form is accepted by if and only if satisfies . We expand on this argument in our discussion of Lemma 3.12 in Section 3.2.2. Also in Section 3.2.2, we will see that is prime if and only if accepts some word of the form . Thus, is prime if and only if is satisfiable.
We have outlined the CNF-DFA yielded by the reduction and given an intuition for its design. Next, we prove the correctness of the reduction.
3.2 Correctness of the Reduction
We complete the proof of Theorem 3.1 by proving the correctness of the reduction. That is, we prove Lemma 3.2, that is satisfiable if and only if is prime. We accomplish this in two steps. In Section 3.2.1, we characterize the compositionality of CNF-DFAs. Then in Section 3.2.2, we exploit this characterization to prove Lemma 3.2 and thereby Theorem 3.1.
3.2.1 Compositionality of Minimal Linear Safety s
We first define minimal linear safety s and then characterize their compositionality.
Definitions: s, Linear DFAs, Safety DFAs
Following convention, a DFA is acyclic (ADFA) if there are no cycles in besides those of the rejecting sinks. Building on that, a DFA is an ADFA-plus () if possesses both a rejecting and an accepting sink and there are no cycles in besides those of the sinks. Thus, an is “almost” an ADFA but additionally has an accepting sink.
We call a DFA linear if, for every with , exactly one of the following holds: (i) is reachable from ; (ii) is reachable from ; (iii) and are unreachable from each other, and or or both are sinks. Obviously, every minimal linear DFA has at least one and at most two sinks.
For a minimal , we denote by the length of the longest word such that words with and exist. Thus, is the length of the longest word on which does not enter a sink. Because is minimal and has two sinks, such a word always exists. The following holds:
Lemma 3.4.
Consider a minimal . Then the following assertions hold:
-
(i)
.
-
(ii)
is linear if and only if .
Finally, we introduce a type of DFA already inspected in [8]. A regular language is a safety language if, for every , it holds that implies for every . A DFA is a safety DFA if is a safety language. Clearly, every non-trivial minimal safety DFA has exactly one rejecting state, and this state is a sink.
The general form of minimal linear safety s is outlined in the full version [11, Figure 3]. The following observation can be easily verified by inspecting [11, Definition A.1] and Figure 1.
Lemma 3.5.
The CNF-DFA is a minimal linear safety .
Clearly, is a safety DFA since the rejecting sink is the only rejecting state of . Further, to see that is additionally a linear , recall the following observation from Section 3.1: To fully traverse , a word of the form for and a suitable has to be read. On such a word, the states of the assignment device are traversed in the order , and the states of the formula device are traversed in the order . Intuitively, this order describes the “forward direction” in , and there are no “backward transitions” in . Thus, is acyclic (disregarding ) and its states are linearly ordered, meaning that is a linear . Lastly, regarding the minimality, note that two states of are differentiated by the suffixes of words needed to fully traverse the remainder of and enter the rejecting sink when starting in the respective states. For example, two states from the formula device are differentiated by the number of ’s needed to reach the rejecting sink. Thus, is minimal. In total, is a minimal linear safety .
Thanks to Lemma 3.5, it is sufficient to characterize the compositionality of minimal linear safety s in order to characterize the compositionality of CNF-DFAs.
Characterization of the Compositionality of Minimal Linear Safety s
Now we characterize the compositionality of minimal linear safety s. With Example 3.10 at the end of this section, we illustrate the main ideas of the characterization by considering, by way of example, two minimal linear safety s, one composite and one prime.
We point out that when we consider the compositionality of a restricted class of DFAs, the (smaller) DFAs used in the decompositions are not restricted. In particular, the DFAs we use in the characterization of the compositionality of minimal linear safety s need not be minimal linear safety s themselves.
The compositionality of a DFA boils down to the question whether, for each word , there exists some DFA with and , the latter meaning and . Indeed, if the answer is yes, the collection of these DFAs yields a decomposition of (thanks to , the collection is finite). If, on the other hand, for some , there is no such , then is a primality witness of .
For a minimal linear safety , the situation is simplified by the fact that there is only one rejecting state, namely, the rejecting sink. For words on which enters the rejecting sink without visiting every non-sink, building an appropriate DFA rejecting is relatively simple. Essentially, we can just remove one of the skipped-over states of so that the constructed DFA accepts all words on which visits and acts as on all other words, including . Details are given in the full version [11, Definition A.3, Figure 4a and Lemma A.4]. Thus, in the following, we only need to consider the words on which enters its rejecting sink after visiting every non-sink. Formally, we define the set of these words as:
Definition 3.6.
Consider a minimal linear safety over an alphabet . Let . Then we define the set of the max-visiting words of as follows:
On a max-visiting word , the does not skip over any non-sink. Thus, the idea of removing a skipped-over state to construct an appropriate DFA rejecting is not applicable. Indeed, the situation for the max-visiting words is more involved. It turns out that every relevant is a safety DFA with an accepting sink. Thus, every such possesses one accepting sink, one rejecting sink, and at most accepting non-sinks. Here, we omit the details and refer to the full version [11, Lemmas A.10 and A.11]. Since has at most non-sinks and the prefix of has length , the initial run of on has to visit a non-sink twice. Therefore, for some with and , the DFA reaches the same state after reading , and every further . This observation gives rise to the definition of the max-pumping-property:
Definition 3.7.
Consider a minimal linear safety over an alphabet . We say that has the max-pumping-property (mp-prop) if, for every max-visiting word , there are with and so that holds for every .
Before we state the desired characterization of the compositionality of minimal linear safety s in terms of the mp-prop, we introduce an alternative formulation of the mp-prop, for which we need some additional notation. Consider a word . For , we define . We refer to as a pumping of . The following lemma provides an alternative formulation of the mp-prop by translating it into the -notation.
Lemma 3.8.
Consider a minimal linear safety . Let . Then has the mp-prop if and only if, for every max-visiting word , there are with so that holds for every .
For a minimal linear safety , a max-visiting word and indices , we say that the mp-prop-condition holds for if holds for every . Note that implies for all words because is a safety DFA.
With the mp-prop defined, we can characterize the compositionality of minimal linear safety s as follows:
Theorem 3.9.
A minimal linear safety is prime if and only if it does not have the mp-prop.
We now set out to give an intuition for this result.
First, towards a proof by contraposition, assume that the minimal linear safety has the mp-prop and consider a max-visiting word . Then there are some indices with for every . Thus, when trying to build a DFA rejecting , we know that is allowed to reject every as well. We can use this to construct out of by essentially merging the states that reaches after reading and . Since we can build a suitable DFA for every max-visiting word, is composite. Details for this construction are given in the full version [11, Definition A.6, Figure 4b and Lemma A.7].
Now assume that does not have the mp-prop. Then there is a word that breaks the mp-prop, meaning that, for every indices , there is an with . We argue that this is a primality witness of .
Towards a contradiction, assume that there is a with . We pointed out above that there have to be indices so that, for every , the DFA cannot differentiate between and , meaning that rejects every such pumping . Yet, because breaks the mp-prop, there is some so that , yielding a contradiction.
Since there is no with , the selected max-visiting word is a primality witness of , meaning that is prime.
In conclusion, if has the mp-prop, we can build, for every , a suitable DFA rejecting by merging appropriate states of . Otherwise, that is, if does not have the mp-prop, then every word breaking the mp-prop is a primality witness of because every DFA in is necessarily confused about some pumpings of and can therefore not reject itself. In total, we argued that a minimal linear safety is prime if and only if it does not have the mp-prop, which is formalized above in Theorem 3.9.
We conclude this discussion of the compositionality of minimal linear safety s by using an example to further illustrate the main ideas.
Example 3.10.
In this example, we consider two simple minimal linear safety s and argue that one of them has the mp-prop, while the other has not. Further, we outline how this leads to the one being composite and the other being prime.
Consider the two DFAs and depicted in Figures 2(a) and 2(b). It is easy to verify that both DFAs are minimal linear safety s and that and hold. Thus, for both s, their possession of the mp-prop, and with it their compositionality, depends solely on the max-visiting word . Note that and differ in only one transition: We have but . Still, we will see that, with this difference, has the mp-prop and is composite, while does not have the mp-prop and is prime.
First, we consider and argue that the mp-prop-condition holds for . For , we have . Here, the transition (in contrast to ) is crucial. For , we trivially have . And lastly, for , we have due to . Thus, the mp-prop-condition holds for . Since , this immediately implies that has the mp-prop.
With Theorem 3.9, having the mp-prop implies that it is composite. In the full version, we explicitly state the decomposition of s with the mp-prop [11, Lemma A.8] and outline all necessary DFAs [11, Definitions A.3 and A.6 and Figure 4]. Here, we discuss the decomposition of the specific to motivate how its compositionality is connected to the mp-prop.
The decomposition of consists of the three simple DFAs and depicted in Figure 2(c). In this decomposition, is the only DFA exploiting the mp-prop. It is used to reject the max-visiting word (and its extensions). Basically, it omits the state and instead adds a self-loop . For this to be allowed, it is crucial that holds for every , that is, that the mp-prop-condition holds for . Further, and reject the words rejected by on which does not enter or , respectively. They are constructed out of by omitting the respective state and redirecting all in--transition into .
Indeed, in this instance, we have , meaning that can be omitted in the decomposition of . This is due to the simplicity of : For example, simply by adding the letter and the transitions and to , we get a still composite DFA in whose decomposition all three DFAs of [11, Lemma A.8] are necessary.
Next, we consider and argue that breaks the mp-prop. This follows from the simple observation that holds for all . For , we have . Here, the transition (in contrast to ) is crucial. For , we have . And lastly, for , we have . In total, there is no pair so that the mp-prop-condition holds for , meaning that breaks the mp-prop.
With Theorem 3.9, not having the mp-prop implies that it is prime. In the full version [11, Appendix A.2.1], we present the complete proof that, for an without the mp-prop, a max-visiting word breaking the mp-prop is a primality witness. Here, we discuss why is a primality witness of the specific .
For to be composite, there would have to be a with . This would have to have at least one non-sink less than (see full version [11, Lemmas A.10 and A.11]) and could therefore visit only two distinct states while reading the prefix of . Thus, would “confuse” with , or . But, as we argued above, these three words are all accepted by , meaning that every DFA in has to accept them as well. Thus, no suitable with exists, meaning that is a primality witness of .
3.2.2 From the Characterization to NP-Hardness
For Section 3.2.2, let and .
Together, Lemmas 3.5 and 3.9 imply that is prime if and only if it does not have the mp-prop. Following ˜3.7, this means that exactly the max-visiting words of are relevant for the compositionality of . How these look like and where they can potentially be pumped is then answered by:
Lemma 3.11.
The following assertions hold:
-
(i)
.
-
(ii)
For every and every , we have: If the mp-prop-condition holds for , then and .
Lemma 3.11 (i) formalizes the observation about the form of the max-visiting words of which we made in Section 3.1 and which we already revisited when discussing Lemma 3.5. In particular, note that, in every state of the formula device (except ), reading or results in “skipping over” at least one state, while reading results in entering the rejecting sink. Thus, the max-vising words of indeed have to be suffixed by .
The argumentation behind (ii) is somewhat technical. For all and all suitable with or , we can show , meaning that it suffices to consider the pumpings with to prove (ii). For the simple case , we have for some , which is akin to removing some -suffix of . Clearly, this means that the initial run of on is identical to the one on until it ends somewhere in the formula device, without reaching the rejecting sink. For the other cases, that is, for as well as for and , the key observation is that, in , some part of the prefix is removed so that a or a is read “out of place”. This means that a is read in one of the states , or a is read in one of the states , which results in entering .
With Lemma 3.11 (i), the form of the max-vising words of is highly restricted: As mentioned, they consist of an assignment string followed by . Thus, every assignment string corresponds to exactly one max-visiting word in , namely, , and vice versa. Then (ii) greatly restricts where pumping positions for the max-visiting words can lie that could witness that has the mp-prop. For every , only are possible candidates. This means that does not have the mp-prop, and is therefore prime, if and only if for some and . And because the words in have the form for , the relevant pumpings are of the form , meaning that we pump, and thereby repeat, exactly the assignment strings.
We have established that only the pumpings of the form are relevant for the compositionality of . With the following lemma, we finally cement the connection between the compositionality of and the satisfiability of , which was already perceivable in Lemma 3.3.
Lemma 3.12.
Let be an assignment string and let be the corresponding max-visiting word. Then the mp-prop-condition does not hold for if and only if the assignment induced by satisfies .
As Lemma 3.12 connects the compositionality of and the satisfiability of , it is central for the correctness of our reduction. Also, the main ideas behind the design of become apparent in its proof. Therefore, we briefly argue that it holds. Let be an assignment string and let be the corresponding max-visiting word.
First, towards a proof by contraposition, we assume that the assignment induced by does not satisfy . We argue that the mp-prop-condition holds for . Because does not satisfy , there is a so that does not satisfy the -th clause of . Let be the minimum value for which this holds.
The key insight here is that, firstly, for all , the pumping is rejected because a is read “out of place”, namely, in the state ; and that, secondly, for all , the pumping is rejected because, after traversing the -th clause row on , the state is reached, from which every continuation with a letter leads to .
To be more precise, for all , we have and therefore , with Lemma 3.3. This holds because satisfies the first clauses, meaning that, if traversing any of these clause rows on , then ends up in a -state, from which is entered on reading the subsequent . Further, for all , we have and therefore , again with Lemma 3.3. This holds because does not satisfy the -th clause, meaning that, if traversing the -th clause row on , then ends up in the state , from which is entered on reading any of the possible subsequent letters , or . Lastly, and hold obviously. In total, we have for all . So the mp-prop-condition holds for .
Second, we assume that the assignment induced by satisfies . We argue that the mp-prop-condition does not hold for .
The key insight here is that, for a satisfying assignment and a sufficiently large , reaches on reading . The reason is that, because satisfies every clause, enters the -states in every clause row and therefore always advances to the next clause row, finally reaching . From there, the transitions are such that is entered.
More precisely, with Lemma 3.3, we have . The argument is similar to above, only that now the assignment satisfies all clauses, not just the clauses up to some . With for , we then immediately have . Thus, , and indeed every , witnesses that there is an with . So the mp-prop-condition does not hold for .
In total, we have argued that, for every , the mp-prop-condition does not hold for if and only if the assignment induced by satisfies . Thus, Lemma 3.12 holds.
With Theorems 3.9, 3.5, 3.11, and 3.12, we have everything we need to prove the correctness of our reduction. That is, we have everything we need to prove Lemma 3.2, that is satisfiable if and only if is prime.
Proof of Lemma 3.2.
With Lemma 3.5, the CNF-DFA is a minimal linear safety . Together with Theorem 3.9, this implies that is prime if and only if it does not have the mp-prop. Thus, we only have to prove that is satisfiable if and only if does not have the mp-prop.
First, towards a proof by contraposition, let be unsatisfiable. Let . With Lemma 3.11 (i), we have , where is an assignment string. Because is unsatisfiable, the assignment induced by does not satisfy . With with Lemma 3.12, we therefore have that the mp-prop-condition holds for . Thus, the mp-prop-condition holds for every max-visiting word, meaning that has the mp-prop.
Now let be satisfiable. Let be a satisfying assignment. We consider the assignment string induced by and the corresponding word . With Lemma 3.11 (i), we have . And with Lemma 3.11 (ii), the mp-prop-condition does not hold for where or . Further, because satisfies , we have, with Lemma 3.12, that the mp-prop-condition does not hold for either. Thus, witnesses that does not have the mp-prop.
We have proven that is satisfiable if and only if does not have the mp-prop. As outlined, this implies that is satisfiable if and only if is prime. The proof is complete.
With Lemma 3.2, we have proven that our reduction is correct. Because the construction of is clearly possible in polytime, we then immediately get Theorem 3.1, the NP-hardness of Prime-DFA.
3.3 NP-Completeness of
In Sections 3.1 and 3.2, we improved the lower complexity bound of the general problem Prime-DFA. Now we conclude Section 3 by arguing that this improved lower bound is tight for the restriction of Prime-DFA to minimal linear safety s.
We denote the restriction of Prime-DFA to DFAs whose respective minimal DFA is a minimal linear safety by .
The restriction of Prime-DFA to ADFAs, so to truly acyclic DFAs, was studied in [10]. Motivated by this, we study . For a comparison of the compositionality of ADFAs and s, we refer to Section 4.1. Here, we prove:
Theorem 3.13.
The problem is NP-complete.
We proved Theorem 3.1, the NP-hardness of Prime-DFA, by a reduction from CNFSAT. At the heart of this reduction was the construction of the CNF-DFA out of the given CNF-formula . With Lemma 3.5, every CNF-DFA is also a minimal linear safety . Thus, we immediately get:
Lemma 3.14.
The problem is NP-hard.
To arrive at Theorem 3.13, we additionally prove:
Lemma 3.15.
The problem is in NP.
To prove that is in NP, we describe a guess-and-verify NP-algorithm for which exploits Theorem 3.9. Given a minimal linear safety , the algorithm guesses a max-visiting word and then verifies that breaks the mp-prop, meaning that witnesses that does not have the mp-prop. To do so, it simulates the initial run of on for every pair and every relevant . The key insight here is that, for every such pair , there is a polynomially bounded value such that only the values are relevant. Thus, the algorithm has to simulate only polynomially many runs. If the algorithm finds that indeed breaks the mp-prop, it accepts. Else, it rejects.
The polynomial runtime of the algorithm follows immediately from the key insight just mentioned. The runtime is dominated by the simulation of the runs. There are only polynomially many pairs . And for each pair, there are only polynomially many relevant pumpings , each having polynomial length. Thus, the algorithm has polynomial runtime.
Regarding the correctness, if is prime, then there is a word breaking the mp-prop. The algorithm guesses this word and subsequently accepts. Else, that is, if is composite, then no word breaking the mp-prop exists. Thus, the algorithm is forced to reject no matter which word it guesses. In total, the algorithm works correctly for .
To summarize, we have described an NP-algorithm for . Thus, we have proven Lemma 3.15. Together with the already established Lemma 3.14, we immediately get Theorem 3.13, the NP-completeness of .
4 Discussion
We studied the primality of DFAs and thereby of regular languages. We proved the NP-hardness of Prime-DFA. This is the first improvement of a complexity bound for Prime-DFA since [8] introduced Prime-DFA and proved that it is NL-hard and in ExpSpace.
We proved the NP-hardness of Prime-DFA by a reduction from CNFSAT. For a given CNF-formula , the reduction yields a so-called CNF-DFA so that is satisfiable if and only if is prime. To link the satisfiability of and the compositionality of , the construction of ensures that (1) is encoded in , and (2) the variable assignments for are encoded in the words relevant for the compositionality of .
Central to the NP-hardness proof was the characterization of the compositionality of CNF-DFAs. However, only certain structural aspects of CNF-DFAs were relevant for this characterization. Thus, we actually characterized the compositionality of the more general minimal linear safety s. Exploiting this characterization, we then proved the NP-completeness of , the restriction of Prime-DFA to DFAs whose respective minimal DFA is a minimal linear safety .
To wrap up this paper, we briefly discuss two points.
Firstly, we compare the complexity of and , the restriction of Prime-DFA to DFAs deciding finite languages. And secondly, we highlight that the NP-hardness of Prime-DFA carries over to S-Prime-DFA, which is a variant of the problem based on a slightly different notion of compositionality.
4.1 and
We denote the restriction of Prime-DFA to DFAs deciding a finite language by. Note that a DFA decides a finite language if and only if its minimal DFA is an ADFA. Thus, the problems and are very similar: considers ADFAs, so truly acyclic DFAs, while considers s, so “almost” acyclic DFAs possessing an accepting sink.
In this paper, we have proven that is NP-complete. With [10, Theorem 4.1], is NL-complete. Therefore, the simple addition of an accepting sink leads to a jump in the complexity of the primality problem (assuming ). We give an intuition for this somewhat surprising fact.
The reduction from CNFSAT crucially hinges on the fact that the CNF-DFA can potentially enter the accepting sink after reading the prefix of , where is a max-visiting word. In other words, it can enter the accepting sink after “pumping up” so that the assignment string is checked against every clause row. Once in the accepting sink, the suffix of dummy letters can be read and the pumping is accepted.
No construction of this kind is possible for ADFAs. Every ADFA has a threshold value so that it rejects every word longer than that threshold value. This is obvious, because for words longer than the threshold value, it runs out of non-sinks and necessarily enters the rejecting sink. Therefore, “pumping up” and thereby lengthening the ADFA-equivalent of a max-visiting word necessarily leads to an overlong word that is rejected.
Thus, with the existence of an accepting sink, no threshold value exists so that words longer than that threshold value are rejected. This simple additional complication is enough to lead to the jump in complexity, from NL-completeness for to NP-completeness for .
4.2 NP-Hardness of S-Prime-DFA
With ˜2.1, we followed [8] and defined compositionality using the index of the given DFA. However, without stating so explicitly, [6, 7] employed a slightly different definition, using the size instead of the index. In [10], this difference was made explicit by introducing the notion of S-compositionality and the respective decision problem. We follow [10] and define:
Definition 4.1.
A DFA is S-composite if it is -decomposable. Otherwise, it is S-prime.
We denote the problem of deciding S-primality for a given DFA by S-Prime-DFA.
Many results known for compositionality carry over trivially to S-compositionality. In particular, Prime-DFA is in ExpSpace [8, Theorem 2.4]. The proof of this result has to be adapted only slightly to prove that S-Prime-DFA is in ExpSpace as well [10, Theorem 6.3].
However, the NL-hardness of Prime-DFA, established in [8, Theorem 2.5], does not carry over trivially to S-Prime-DFA. The NL-hardness of S-Prime-DFA is established in [10, Theorem 6.3] by using a reduction of a different problem than the one used for Prime-DFA.
Here, we highlight that the improved lower complexity bound of Prime-DFA does carry over trivially to S-Prime-DFA. We established the NP-hardness of Prime-DFA by a reduction from CNFSAT. The CNF-DFAs yielded by this reduction are minimal. Thus, with the same reduction, we get:
Theorem 4.2.
The problem S-Prime-DFA is NP-hard.
Indeed, it is well known that DFA minimization can be done in polytime. Thus, by making the transition from NL-hardness to NP-hardness, the distinction between compositionality and S-compositionality loses its edge because we can always minimize the given DFA. This simple argument is an alternative way to arrive at Theorem 4.2.
References
- [1] Christel Baier and Joost-Pieter Katoen. Principles of Model Checking. MIT Press, 2008. URL: https://mitpress.mit.edu/9780262026499/principles-of-model-checking/.
- [2] Stephen A. Cook. The complexity of theorem-proving procedures. In Michael A. Harrison, Ranan B. Banerji, and Jeffrey D. Ullman, editors, Proceedings of the 3rd Annual ACM Symposium on Theory of Computing, May 3-5, 1971, Shaker Heights, Ohio, USA, pages 151–158. ACM, 1971. doi:10.1145/800157.805047.
- [3] Willem P. de Roever, Hans Langmaack, and Amir Pnueli, editors. Compositionality: The Significant Difference, International Symposium, COMPOS’97, Bad Malente, Germany, September 8-12, 1997. Revised Lectures, volume 1536 of Lecture Notes in Computer Science. Springer, 1998. doi:10.1007/3-540-49213-5.
- [4] Peter Gazi and Branislav Rovan. Assisted problem solving and decompositions of finite automata. In Viliam Geffert, Juhani Karhumäki, Alberto Bertoni, Bart Preneel, Pavol Návrat, and Mária Bieliková, editors, SOFSEM 2008: Theory and Practice of Computer Science, 34th Conference on Current Trends in Theory and Practice of Computer Science, Nový Smokovec, Slovakia, January 19-25, 2008, Proceedings, volume 4910 of Lecture Notes in Computer Science, pages 292–303. Springer, 2008. doi:10.1007/978-3-540-77566-9_25.
- [5] E. Mark Gold. Complexity of automaton identification from given data. Inf. Control., 37(3):302–320, 1978. doi:10.1016/S0019-9958(78)90562-4.
- [6] Ismaël Jecker, Orna Kupferman, and Nicolas Mazzocchi. Unary prime languages. In Javier Esparza and Daniel Král’, editors, 45th International Symposium on Mathematical Foundations of Computer Science, MFCS 2020, August 24-28, 2020, Prague, Czech Republic, volume 170 of LIPIcs, pages 51:1–51:12. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. doi:10.4230/LIPIcs.MFCS.2020.51.
- [7] Ismaël Jecker, Nicolas Mazzocchi, and Petra Wolf. Decomposing permutation automata. In Serge Haddad and Daniele Varacca, editors, 32nd International Conference on Concurrency Theory, CONCUR 2021, August 24-27, 2021, Virtual Conference, volume 203 of LIPIcs, pages 18:1–18:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.CONCUR.2021.18.
- [8] Orna Kupferman and Jonathan Mosheiff. Prime languages. Inf. Comput., 240:90–107, 2015. doi:10.1016/J.IC.2014.09.010.
- [9] Niklas Lauffer, Beyazit Yalcinkaya, Marcell Vazquez-Chanlatte, Ameesh Shah, and Sanjit A. Seshia. Learning deterministic finite automata decompositions from examples and demonstrations. In Alberto Griggio and Neha Rungta, editors, 22nd Formal Methods in Computer-Aided Design, FMCAD 2022, Trento, Italy, October 17-21, 2022, pages 325–330. TU Wien Academic Press, 2022. doi:10.34727/2022/ISBN.978-3-85448-053-2_39.
- [10] Daniel Alexander Spenner. Decomposing finite languages. In Jérôme Leroux, Sylvain Lombardy, and David Peleg, editors, 48th International Symposium on Mathematical Foundations of Computer Science, MFCS 2023, August 28 to September 1, 2023, Bordeaux, France, volume 272 of LIPIcs, pages 83:1–83:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2023. doi:10.4230/LIPIcs.MFCS.2023.83.
- [11] Daniel Alexander Spenner. Deciding DFA-primality is NP-hard, 2026. arXiv:2605.07031.
- [12] Stavros Tripakis. Compositionality in the science of system design. Proc. IEEE, 104(5):960–972, 2016. doi:10.1109/JPROC.2015.2510366.
- [13] Moshe Y. Vardi and Pierre Wolper. An automata-theoretic approach to automatic program verification. In Proceedings of the Symposium on Logic in Computer Science (LICS ’86), Cambridge, Massachusetts, USA, June 16-18, 1986, pages 332–344. IEEE Computer Society, 1986. URL: https://hdl.handle.net/2268/116609.
