arXiv:2610.31273cs.DSOct 2026

Manuscript Offprint

arXiv:2610.31273

Hardness and Approximation for Compressing Deterministic Finite Automata

Philip Bille, Inge Li Gørtz, Christoffer Krogh, Christian Møller Mikkelstrup

Abstract

The delayed deterministic finite automaton (D²FA) is a powerful tool for compressing the prohibitively large deterministic finite automata (DFAs) used in modern signature-based deep packet inspection systems. A D²FA augments a DFA with unlabeled default transitions to remove transitions that are similar. This technique works well in practice and has inspired numerous subsequent studies. However, existing approaches do not guarantee a D²FA of optimal size as they restrict the default transitions to form a forest.

In this paper, we consider the problem of finding an optimal D2FAD^{2}FA. We make the key observation that cycles of default transitions can be valid and produce a smaller D2FAD^{2}FA, provided that for every character in the alphabet, at least one state in the cycle has an outgoing transition labeled by that character. This observation raises fundamental questions concerning the computational complexity of finding an optimal D2FAD^{2}FA and the approximation guarantee of the standard (forest-restricted) approach.

We answer both questions by showing that it is NP-hard to find an optimal D2FAD^{2}FA and by proving that the standard approach provides a 3/2-approximation to the optimum. To establish NP-hardness, we construct a reduction from set cover using a DFA with gadgets where valid default transition choices correspond to selecting sets. To prove our approximation ratio, we compare the cycles in an optimal solution to a variant where the default transitions form a forest. Finally, we demonstrate that this 3/2 ratio is tight via a constructed family of DFAs.

1 Introduction

Signature-based deep packet inspection is a fundamental technique in modern network-security applications for identifying malicious content, sensitive information, and security-policy violations in network traffic. This technique relies on a collection of predefined patterns, represented as regular expressions, that are matched against an input (or data stream). The natural approach to this pattern matching is to use the deterministic finite automaton (DFA) to represent the patterns and then simulate it over the input. This DFA-based approach to matching is used in the Snort [23], Zeek [21], and Suricata [24] intrusion detection systems (see also snort.org, zeek.org, and suricata.io). A DFA consists of states and labeled transitions between states. Every state has an outgoing transition for each character in an alphabet.

Unfortunately, DFAs for the collections of regular expressions used in modern intrusion detection systems are prohibitively large and not feasible for practical implementation. To overcome the space issue, significant work has been done on compressing DFAs [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,19,20,22,25]. One elegant and powerful approach is the delayed deterministic finite automaton (D²FA) introduced by Kumar, Dharmapurikar, Yu, Crowley, and Turner [13] and applied in many subsequent works [4,6,7,11,14,15,16,17,18,19,20]. Although this approach performs remarkably well in practice, we still know very little about its theoretical properties and performance guarantees.

The key idea behind the D2FAD^{2}FA is to leverage the observation that many states in the DFAs for real-world regular expression collections have similar sets of outgoing transitions [13]. Specifically, a D2FAD^{2}FA is a DFA where each state can additionally have an outgoing unlabeled transition, called a default transition. A default transition from state u to state v can reduce the number of transitions in a D2FAD^{2}FA if u and v have a set of transitions with matching labels and target states. In this case, we can remove these transitions from u and look for them at v after following the default transition. Finding a transition with the desired label may require following a chain of default transitions, thus incurring a delay (as the name suggests). Two D2FAsD^{2}FAs over the same set of states are equivalent if, starting from any given state and reading any character, both automata reach the same next state. Likewise, a D2FAD^{2}FA and a DFA are equivalent if they satisfy this same condition. The size of a D2FAD^{2}FA (or DFA) is the number of transitions and default transitions (where a DFA has zero default transitions). Among all equivalent D2FAsD^{2}FAs, those of minimum size are considered optimal. The D2FAD^{2}FA compression problem asks for an optimal (i.e. minimum-size) D2FAD^{2}FA equivalent to a given input DFA.

To address the D2FAD^{2}FA compression problem, previous work uses a weighted complete graph over the DFA states, known as the space reduction graph (SRG). In this graph, each edge represents a candidate default transition and is weighted by the number of transitions that can be removed after adding this candidate. Existing algorithms compute a maximum spanning forest on the SRG and use the corresponding default transitions to compress the input DFA. We refer to any D2FAD^{2}FA that maximizes size reduction under this forest constraint as an MSF compression.

We highlight the important observation that the default transitions of a D2FAD^{2}FA need not be restricted to form a forest. In fact, cycles of default transitions are completely valid as long as, for every character in the alphabet, at least one state in each cycle has an outgoing transition labeled by that character. As demonstrated in Figure 1, lifting the forest restriction allows us to construct an optimal D2FAD^{2}FA that is smaller than the MSF compression. This observation gives rise to two natural questions:

• What is the complexity of computing an optimal D2FAD^{2}FA?

• How far from the optimal D2FAD^{2}FA is the MSF compression?

Our contributions. In this paper, we answer both of these questions. We establish that computing an optimal D2FAD^{2}FA is NP-hard via a polynomial-time reduction from the set cover problem, and we prove that the MSF compression approach is a 3/2-approximation to the problem. Formally, our main results are as follows:

Theorem 1. The D2FAD^{2}FA compression problem is NP-hard.

Theorem 2. The MSF compression is a 3/2-approximation for the D2FAD^{2}FA compression problem, and this ratio is tight.

Techniques. As every state in a D2FAD^{2}FA has at most one outgoing default transition, the default transitions of an unrestricted D2FAD^{2}FA form a pseudoforest (a graph where each connected component contains at most one cycle). This structural property might intuitively suggest that an optimal D2FAD^{2}FA can be obtained by simply augmenting an MSF compression with additional default transitions. However, not every cycle of default transitions is valid. Specifically, cycles of default transitions are only valid when, for every character in the alphabet, at least one state in the cycle has an outgoing transition labeled by that character. Thus, adding the default transition that completes a cycle of default transitions may not allow for the removal of as many transitions as expected. Because of this, the optimal placement of default transitions may differ completely from the placement in the MSF compression if it allows for better cycles of default transitions.

To capture this difficulty, we design a polynomial-time reduction from the set cover problem. The core challenge is to construct an input DFA such that any equivalent optimal D2FAD^{2}FA directly corresponds to a solution to this set cover instance. We achieve this by creating a DFA with as many gadgets as the number of sets allowed in the set cover instance. We design these gadgets such that the choice of default transitions within a gadget corresponds to the choice of a set in the set cover instance. The key difficulty in the reduction is to ensure that the default transitions of any optimal D2FAD^{2}FA form a cycle going through the gadgets. By carefully placing additional transitions in the input DFA, we guarantee that maximal size reduction is attained if and only if the default transitions form a cycle that encodes a valid set cover. For a no-instance of set cover, the default transitions may look completely different. However, in this case they allow for less reduction in size. As a result, we prove that it is at least as difficult to solve the D2FAD^{2}FA compression problem as the set cover problem, thereby classifying it as NP-hard.

Figure

Figure 1: (Left) A DFA for the regular expression (C|E|A(A|E|CE*(A|C)))*, where A=(a|b), C=(c|d), and E=(e|f) are colored blue, yellow, and red, respectively. (Middle) An equivalent MSF compression. (Right) A minimum equivalent D²FA. This example shows that the optimal D²FA might have cycles. In this case, the optimum has a reduction of 1 transition compared to the MSF compression.

Having established the intractability of the general problem, we next analyze the approximation guarantee of the MSF compression relative to an optimal unrestricted D²FA. However, as we discussed, the configuration of default transitions in the two D²FAs can differ substantially, complicating any direct comparison. Instead, we consider an intermediate forest-restricted D²FA derived from the optimal D²FA. Because the MSF compression is optimal over all forest-restricted D²FAs, the size of this intermediate D²FA provides an upper bound on the size of the MSF compression.

Although the default transitions of an optimal D2FAD^{2}FA may form multiple connected components, we bound the approximation ratio by analyzing the single component where the intermediate D2FAD^{2}FA performs worst relative to the optimum. For this component, we can characterize its structure and which transitions can be removed by default transitions. Bounding the approximation ratio on this worst-case component yields an upper bound of 3/2 for the intermediate D2FAD^{2}FA, thereby establishing a 3/2-approximation ratio for the MSF compression.

Finally, to prove that this bound is tight, we construct a family of DFAs for which the optimal D2FAD^{2}FA features a cycle of default transitions and two transitions for each character in the alphabet. For this family, the size of the MSF compression approaches 3/2 times the optimum.

Outline. We present the problem and the corresponding prerequisites in Section 2 and Section 3. We prove Theorem 1 in Section 4 and Theorem 2 in Section 5.

References (22)