Polynomial Complementation of Nondeterministic Two-Way Finite Automata by -Limited Automata
Abstract
We prove that, paying a polynomial increase in size only, every unrestricted two-way nondeterministic finite automaton (nfa) can be complemented by a 1-limited automaton (1-la), a nondeterministic extension of nfas still characterizing regular languages. The resulting machine is actually a restricted form of 1-las – known as nfas with common guess – and is self-verifying. A corollary of our construction is that a single exponential is necessary and sufficient for complementing 1-las.
Keywords and phrases:
descriptional complexity, inductive counting, common-guessCopyright and License:
2012 ACM Subject Classification:
Theory of computation Formal languages and automata theory ; Theory of computation Models of computation ; Theory of computation Regular languagesAcknowledgements:
The authors are very grateful to Giovanni Pighizzini for his useful comments and bibliographic help during the writing process.Editors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim ThắngSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
The study of the resources used by computational models is a central topic in automata theory. One classical problem in this area is to determine the cost of applying operations between languages (e.g., union, intersection, concatenation, Kleene star, etc.). Here, the cost is defined as the increase in size of the resulting (or target) devices after applying the operation to the languages recognized by the original (or source) machines.
In this paper, we focus on the cost of the complementation of regular languages. This operation is usually cheap (i.e., costs at most polynomial) when dealing with deterministic devices, while it is often expensive (i.e., at least exponential) for nondeterministic devices; see Table 1. The reason for this separation has been understood for a long time and originates from the nature of nondeterminism, as illustrated by the case of classical (one-way) nondeterministic finite automata (nfas). Indeed, the semantics of such a device is that a word is accepted as long as there exists a computational path leading to an accepting state. Therefore, in order to acknowledge that a word does not belong to the recognized language, one should somehow check that every computational path leads to a non-accepting state,111For ease of discussion, we admit here that the automata are complete, that is, no computational path gets stuck in the middle of the input. a semantic which is hardly captured by nondeterminism. This issue does not exist for one-way deterministic finite automata (dfas), because they admit a unique computational path on each input, and thus existential and universal quantifications on computational paths coincide. Indeed, it is folklore that exchanging accepting and non-accepting states of a dfa, while keeping the rest of the structure (initial state and transitions) unchanged, yields a dfa recognizing the complement of the language.1 On the other hand, it is well known that transforming a nfa into another one recognizing the complement of the language may cost as much as determinizing it and then complementing it (as explained above) in the worst case [18, 1, 10].
Yet, the corresponding question remains unsolved for other regular language recognizers, and in particular when dealing with two-way finite automata, an extension of finite automata allowing the machine to move its head both back and forth, and which still characterizes regular languages. Indeed, although complementing two-way deterministic automata (dfas) has been non-trivially222The main challenge when complementing dfas is to detect infinite computations induced by loops. shown to cost linear only [4], the cost for complementing their nondeterministic counterparts (nfas) is still unknown in the general case. Worse still, the best-known upper bound is exponential and is obtained by transforming the source nfa into an equivalent dfa. That is, neither two-wayness nor nondeterminism are exploited for complementing arbitrary nfas. Indeed, also the cost for determinizing nfas is a longstanding open question known as “the Sakoda and Sipser problem” [18] (see e.g. [14] for a survey). As shown in [4], the two problems are related via the linear-cost complementation of dfas. On the one hand, finding an exponential (or super-polynomial) lower bound for complementing nfas would imply a similar lower bound for determinizing them. On the other hand, finding a polynomial (or sub-exponential) upper bound for determinizing nfas would imply a similar upper bound for complementing them. It is worth noting that a polynomial-cost complementation of nfas has been obtained in some particular cases, e.g., in the unary and letter-bounded settings [4, 2], or when the nfa makes a restricted use of nondeterminism, known as outer-nondeterminism [3].
In this paper, we study the cost of complementing two-way finite automata following a different approach: Instead of using the same model as source and target devices, we relax the target machines by equipping them with some extra features while keeping the expressive power unchanged. More precisely, we use as target device a machine called 1-limited automaton (1-la), which is an extension of nfas with some rewriting capability. Technically, each time the machine visits a cell for the first time it is allowed to change its contents. This model is not more powerful than nfas [22, Thm. 12.1], i.e., it recognizes regular languages only. However, there are cases where it can represent languages more succinctly than nfas (for a recent survey on this model, see [15]). This approach has already been used to provide succinct representations of operations that have exponential cost when both source and target machines are dfas (Kleene star, reversal and concatenation), but can be done at a polynomial cost when the target machine is a deterministic 1-la (d1-la) [17].
In the survey [15], the author identifies some problems regarding the descriptional complexity of 1-las. In particular, the question of the cost of the conversion of nfas into equivalent d1-las [15, Problem 4], as well as those of the cost of determinizing 1-las [15, Problem 2] are raised. Just as complementing nfas relates to the Sakoda and Sipser problem, complementing nfas with 1-las relates to these problems; see Figure 1.
Our results.
We show polynomial simulations of nfas and nfas by self-verifying 1-las (Theorems 3.2 and 4.1). The property of being self-verifying means that the devices are able to recognize both the language and its complement (the formal definition is given in Section 2), see, e.g., [11]. In both constructions, the resulting devices are 1-las of a particular form, known as nfas with common guess (nfas), in which the rewriting of the tape is made during an initial nondeterministic memoryless traversal of the input – see [5, 6] for details and results on this model. Although a polynomial simulation of nfas by self-verifying 1-las is implied by Theorem 4.1, this particular case is treated in Theorem 3.2, which presents a specific construction for this case that is simpler, cheaper, and serves as a preparatory step for the more technical second construction. Also, because every 1-la can be converted into a nfa paying a single exponential [16], a consequence of Theorem 3.2 is a single exponential upper bound for the cost of the complementation of 1-las (Corollary 3.3). This improves the best-known upper bound for the transformation, which used the simulation of 1-las by dfas at a doubly-exponential cost. Since an exponential lower bound is known for this transformation [6], the cost order is tight. Figure 1 summarizes our results and their connection to open questions and some related results.
Outline.
The paper is organized as follows. In Section 2 we gather the definitions and notations used throughout the subsequent sections. In Section 3 we present the conversion of nfas into self-verifying nfas, and its consequence on the cost of the complementation of 1-las. In Section 4 we develop the conversion of nfas into self-verifying nfas. A brief conclusion is given in Section 5.
2 Preliminaries
In this section, we recall some fundamental definitions and notations used throughout the paper. We assume that the reader is familiar with basic concepts from formal languages and automata theory (see, e.g., [8]).
For a set , denotes its cardinality and denotes its powerset. For , denotes the set consisting of the first natural numbers (including ), namely ; in particular and . Given an alphabet , the set of strings over is denoted by . It includes the empty string denoted by . The length of a word is denoted by , and the set of strings over of length is denoted by . The number of occurrences of a symbol in is denoted by . The positions of symbols within a string are indexed from to . We use the notation to indicate the symbol at position of (i.e., the -th symbol of , e.g., is the first symbol of ) and for the factor of from index to index included, . If , we set by convention. Hence, the length of is if and otherwise.
Definition 2.1.
A two-way nondeterministic finite automaton (nfa) is a tuple , where is the finite set of states, is the input alphabet, is the initial state, is the final state,333Notice that, for convenience, we shall assume that nfas have a unique final state. This is not a limitation, since each -state nfa with many final states can easily be simulated by a -state nfa with, as in our definition, a single final state. (We do not consider one-way deterministic finite automata, for which this restriction makes a difference.) The same comment applies on initial states. and is a nondeterministic transition function with , where are two special symbols called the left and the right endmarker, respectively.
We shall often assume for , so that is ordered, with as a minimum.
In nfas, the input is written on the tape surrounded by the two endmarkers, the left endmarker being at tape position zero. Hence, on input , the right endmarker is at position . In one move, reads an input symbol, changes its state, and moves the head one position backward or forward depending on whether returns (a left move) or (a right move), respectively. Furthermore, the head cannot pass the endmarkers. The machine accepts the input if there exists a computational path which starts from the initial state with the head on the cell at position (i.e., scanning the first letter of if and scanning otherwise) and eventually halts in the final state with the head scanning the right endmarker. The language accepted by is denoted by .
A nfa is one-way (nfa) if its head can never move left, i.e., if no transition returns . The transition function of a nfa is seen as a function (that is, the endmarkers and the instruction for head direction are irrelevant).
The above models are all read-only machines. We now define -limited automata (1-las, for short) that extend nfas with a limited write ability. Just as nfas, 1-las have a finite set of states, an initial and an accepting state, and work both ways on a tape that initially contains the input surrounded by the two endmarkers. However, they are allowed to replace the contents of each tape cell (except for those containing the endmarkers) when the head visits the cell for the first time – during subsequent visits to the cell, the contents cannot be changed any longer. Acceptance for 1-las is defined exactly as for nfas, and the language accepted by a given 1-la is denoted by . It is known that 1-las recognize regular languages only [22, Thm 12.1].
Common guess.
In this paper, we use as target devices particular cases of 1-las, whose computations are somehow split into two phases. In the first phase, using one state only, these machines make a single one-way pass over the input during which they nondeterministically rewrite (or annotate) every tape cell symbol, and then move the head back to the left endmarker. In the second phase, they perform read-only two-way computations on the annotated word. In other words, this model can be seen as an extension of nfas with the ability (called common guess) to initially annotate the input word using some annotation symbols from a fixed alphabet , to which we refer as the annotation alphabet. The annotated word resulting from this initial phase is a word over the product alphabet . It is nondeterministically chosen among all the words such that (implying ), where is the natural projection of onto . We shall also use the notation for the projection of onto , and the convention and .
Definition 2.2.
A nfa with common guess (nfa) is a triplet where is the input alphabet, is the annotation alphabet, and is a nfa over the product alphabet .
The language recognized by is:
Configurations and computations.
Given one of the devices under consideration, a configuration is represented as a string , meaning that is the current state, is the contents of the tape (here denotes the tape alphabet: , , or , depending on the model under consideration) and the head is scanning the first symbol of . Hence, the initial configuration over input is , and an accepting configuration is a configuration of the form . The transition relation between configurations of is denoted by , and its reflexive-transitive closure by . A computational path of is a sequence of configurations such that for each . It is initial (resp. accepting) if is initial (resp. is accepting). In order to emphasize the locality of some computational paths, we also represent partial configurations as , where is the current state and is a factor of the tape content. The relations and , whence the notion of computational path, naturally extend onto partial configurations.
Self-verifyingness.
A nondeterministic state machine is said to be self-verifying if it has two different final states, one accepting and one rejecting, and satisfies the following property. Each string must have at least one computational path ending in a final state, and cannot admit both an accepting (i.e., ending in the accepting state) and a rejecting (i.e., ending in the rejecting state) computational path. As a consequence the set of words recognized by is partitioned into those admitting an accepting computational path, and those admitting a rejecting computational path. Observe that it is still possible to have computational paths that halt in non-final states; they are said aborted. The set of words admitting an accepting computational path is denoted as , and the set of words admitting a rejecting computational path is its complement.
Size of models.
For each model under consideration, we evaluate its size as the total number of symbols used to describe it. Hence, under standard representation and denoting by the input alphabet, the size of an -state nfa is , that of an -state 1-la with work alphabet is , and that of an -state nfa with annotation alphabet is . In our work, we generally consider as a constant.
3 Complementing 1NFAs using 2NFAs with common guess
In this section, we present a construction that transforms an arbitrary -state nfa into an equivalent self-verifying nfa with polynomially many states and annotation symbols. As in [4, 3], our simulation is based on the inductive counting technique, which originates from the proof of the well-celebrated Immerman–Szelepcsényi theorem [9, 20].
Let be an -state nfa. We assume which is thus equipped with the natural ordering. For , we define to be the set of states the automaton reaches after reading , i.e., Working on , a nfa can iteratively simulate nondeterministic computation paths of by bringing the head back to the left endmarker before starting a new simulation. It may thus find several states belonging to . Suppose that the number of states reached after reading is given, i.e., . Then, by simulating times on , and controlling at each iteration but the first that the state reached at the end of the simulation is larger than the preceding one, a nfa can enumerate all the states of . This process is described in Procedure 1, where nsimul_ stands for the nondeterministic simulation of from the initial configuration.444In enumeration algorithms, the outputs are not returned at the end of the execution, but yielded as soon as they are found. This allows an outer calling procedure to treat them one-by-one (see, e.g., Procedures 3 and 4). In Procedure 1, this yielding is indicated with the output keyword on Line 6.
Hence, according to whether one or none of them is the accepting state, the nfa recognizes whether belongs to or to its complement; see Procedure 3 in which the accepting state is passed as a parameter . Remarkably, a nfa with states can implement this process. Indeed, such a nfa only has to simultaneously store in its finite control the index of the iteration, the previously found state (), and the state in the current simulation (). One strategy to detect whether an input belongs to the complement of would therefore be to first compute , and then run the nfa . Yet, computing is not an easy task.
Suppose now that is unknown, but that there exists a nondeterministic procedure nsimul_, which, starting from some position , where is a prefix of the input , eventually halts at the same position returning a state if and only if . Then a nfa equipped with nsimul_ may inductively compute for each successive prefix of as follows. Initially, since by definition. Let be a prefix of . In order to compute from , the automaton tests for each state whether it belongs to , and counts those for which the answer is positive. This process is described in Procedure 4, in which is read from the tape (indicated as read()). Testing whether a given state belongs to is based on the following basic observation:
Using the knowledge of and nsimul_, the automaton enumerates the distinct states belonging to in ascending order as explained before (i.e., using Procedure 1). As soon as it finds one from which a transition on allows to enter , it breaks the loop as has been witnessed. If otherwise the states are correctly found but none of them has an outgoing transition to on , a witness of has been obtained. Once the number of states in has been computed, the automaton forgets those of , moves its head one cell to the right, and proceeds with the next iteration of the induction.
However, implementing nsimul_ with a nfa is challenging. Indeed, since there is an unbounded number of prefixes of inputs, it is not possible to bring the head back to its initial position (in order to restart a computation of ), and then recover the position . To overcome this issue, we use annotations, so that it is possible to simulate computations of without moving the head more than cells to the left of position . In this way, the automaton can recover the position by maintaining, in its finite control, the distance of the head from that position.
Let . The idea is to consider an annotated word such that and the following property holds. Logically dividing into factors of length (or possibly less for the last one), the -th factor encodes . Formally, decomposing as with and for each , every (except, possibly if it has length less than ) encodes the set . In this way, our nondeterministic procedure nsimul_ starting from some position , and , operates in two phases. First, it scans , from which it extracts some nondeterministically-chosen state – for , we assume from which the machine extracts . Second, it performs a direct simulation of on , starting from the selected state and halting as soon as the cell at position is entered. At that time, the reached state in the simulated path, belongs to , and thus to since .
A subset of is naturally encoded as a length- word as follows:
Hence, provided , in order for nsimul_ to select during its first phase, it is sufficient to choose a position of such that . The annotation of a word is defined now.
Definition 3.1.
For each , we let be the -length word over defined as follows. Let and be such that with :
-
if (i.e., ) then , otherwise,
-
if then , where , and ,
-
if then , where , and .
The word is the word over such that and .
Our goal is to design a nfa over of polynomial size in , with two distinguished states (for acceptance) and (for rejection) that satisfies:
-
accepts if and only if and ;
-
rejects if and only if and .
Notice that itself is not self-verifying, as it can neither accept nor reject an input such that . However, the nfa is self-verifying since every input admits an annotated variant that should be either accepted or rejected by according to whether belongs to or not.
The design of follows the above-explained inductive counting strategy. In particular, it uses the already-presented procedures enum_, member_, and count_next_ (see Procedures 1, 3, and 4), as well as nsimul_. To implement the latter, maintains two variables in its finite control: the value of its head position modulo (so it knows where each factor begins, and to which state an annotation symbol correspond), and the distance of its current head position to the position , where is the input prefix under consideration. By the locality of nsimul_, the latter information is an integer less than .
Not only has to behave correctly on inputs : it also has to detect ill-formed inputs, namely words for which . To this end, each time the length of the prefix under consideration is a positive multiple of , before considering the next prefix, checks the annotation of the length- suffix () of . This can easily be done, since at that time has been computed. Hence, the automaton can check that has occurrences of , and, using enum_, that for each .
Evaluating the size of , we get that states are sufficient for implementing nsimul_, including the two above-mentioned state components relative to the head position. Next, further uses a -state component for storing , , and two intermediate states and . Hence, the total number of states belongs to .
Theorem 3.2.
Every -state nfa has an equivalent self-verifying nfa with many states and annotation symbols.
A direct consequence is that complementing 1-las costs at most a single exponential.
Corollary 3.3.
For each -state 1-la recognizing some language , there exists a 1-la with an exponential number of states in and work symbols which recognizes the complement of .
Proof.
From [16, Theorem 2], each -state 1-la over can be simulated by a nfa with at most states. Also by Theorem 3.2, each -state nfa can be converted into an equivalent self-verifying nfa (which is a particular case of 1-la) with states and annotation symbols. Combining these two results, one can simulate each -state 1-la, by a self-verifying 1-la with work alphabet and a number of states in . As demonstrated in [6], the exponential bound in the above corollary cannot be avoided in the worst case, even when the source device is a unary dfa, namely a nfa over a singleton input alphabet whose underlying nfa is deterministic.555Remark that dfas are nondeterministic devices, since the annotation phase is nondeterministic.
4 Complementing 2NFAs using 2NFAs with common guess
In this section, we show how to simulate an arbitrary -state nfa over with a self-verifying nfa that has polynomially many states in and annotation symbols.
Theorem 4.1.
Every -state nfa has an equivalent self-verifying nfa or 1-la with a polynomial number of states in , and annotation alphabet .
The self-verifyingness of the obtained nfa is actually implied by a stronger condition which is satisfied by its underlying nfa over . This is stated in the following lemma whose proof is our main technical contribution.
Lemma 4.2.
Let be an -state nfa over , and let . Then there exist a function , and a nfa of polynomial size in over , with two distinguished halting states and such that, on input :
-
accepts if and only if and ;
-
rejects if and only if and .
Notice that, in the above lemma, itself is not a self-verifying nfa. Indeed, on inputs not belonging to , neither accepts nor rejects.666 is actually a don’t-care automaton [13], namely an automaton with the self-verifying property on inputs from a restricted domain (here, inputs of the form for some ). Yet, as the goal is to check whether a word belongs to , and since each such word has an annotated version that is either accepted or rejected by , we obtain self-verifyingness for the nfa .
The rest of the section is devoted to the proof of Lemma 4.2, and is structured as follows. In Section 4.1, we recall the principle of Shepherdson’s construction [19], introducing the basic concepts and properties on which such a simulation as much as ours relies. The definition of is given at the end of the section. The automaton is then designed in Section 4.2, where the proof of Lemma 4.2 is finally completed.
4.1 L-tables
In [19], Shepherdson proposed a construction to simulate dfas by dfas, which has then been generalized to the simulation of nfas and even 1-las by dfas, see, e.g., [12, 16]. The main ingredient of this construction is to store in each state of the finite control of the simulating dfa, a table, that we call -table,777L for “Left”; In the literature, they have sometimes been called “transition tables”. describing the finitely-many possible behaviors of the simulated two-way machine that may occur on the portion of the tape to the left of the current head position. This is formalized in the following. For , an -segment over with respect to is a computational path of over for some that starts from tape position (hence reading the last symbol of ) and ends in position (hence, reading the first symbol of ) visiting only positions in the meantime (hence, independent from ). The -table of with respect to , denoted , is the set of pairs such that there exists an -segment over starting in state and ending in state . Formally:
| where with . |
Observe that there are finitely many such tables. Also, for every , we denote by the set of states that may enter when it visits the cell containing the right endmarker for the first time during a computation over input . Namely, . Again, remark that there are finitely many such sets. Shepherdson observed that knowing and (but not ) is sufficient for deciding whether . In order to simplify, we slightly modify the simulated nfa, so that knowing will be sufficient.
Lemma 4.3.
Each -state nfa over admits an equivalent -state nfa with an inaccessible distinguished state such that, for each and each state of , on the one hand if and only if , and on the other hand . Furthermore, where is the transition function of .
The key of Shepherdson’s construction is that, given and , it is possible to compute without accessing . Indeed, an -segment on can be decomposed as a sequence alternating left-moves over and -segment s on , followed by a final right-move over . This is formalized in Proposition 4.5 below, using the following notions. For and , we define the binary relation (resp. ) on as the set of pairs for which there is a computational path that starts at position in state , ends at the same position in state , visits only positions in the meantime, and visits the position exactly (resp. at most) times (including the initial and final visits, in state and , respectively). Formally: and
and . We furthermore let denote the relation .
The following directly follow from the above definitions:
Remark 4.4.
Given a nfa , and :
-
1.
is the reflexive and transitive closure of ;
-
2.
if and only if there exists such that and ;
-
3.
for every , it holds .
In order to build from , we rely on the following property.
Proposition 4.5.
Let be a nfa, , and . Then if and only if there exists such that and .
A direct consequence of the above proposition is that implies for every . Also, provided is in the form of Lemma 4.3, we can decide whether with the only information of , which is determined from thanks to Remark 4.4:
Proposition 4.6.
Let be a nfa over in the form of Lemma 4.3, and . Then if and only if where is the accepting state of .
Not every binary relation is equal to for some . Nevertheless, each can be updated according to Proposition 4.5. We formalize this fact in the following, by introducing a variant of so that .
Definition 4.7.
Let be a nfa with state set , and let . We define as the nfa obtained from by overwriting its transitions on according to . More precisely, has the same transitions as on symbols distinct from , and transitions from to on if and only if .
Trivially, and . Also, if for some then for every .
In Shepherdson’s construction, after reading a prefix of the input, the simulating dfa stores the whole table (along with the set , which thanks to Lemma 4.3 is not needed in our presentation) in its finite control. Then, on symbol , it updates it to according to Proposition 4.5. Finally, it decides acceptance according to Proposition 4.6. This method comes with a cost: storing the -table s in the finite control implies an exponential number of states (which, for the simulation of nfas by dfas, cannot be avoided in general; see, e.g., [12]). In order to keep the size of our simulating self-verifying nfa polynomial, we do not store the successive -table s in the finite control of the machine. We rather successively store the number of elements belonging to the -table s as a state component, and encode some of these tables on the tape. Intuitively, the tape will be virtually divided into portions of length (possibly the last portion being shorter), so that the -th portion stores on its annotation track an encoding of the table where is the input prefix of length . We naturally encode a relation in a length- word over , as follows:
| for each . |
Notice that the encoding defines a bijection between binary relations on and length- words over . We denote by the inverse of , i.e., .
Definition 4.8.
For , the annotation of is the word of length defined as follows. Let and such that .
-
If (i.e., ) then , otherwise,
-
If then where and ,
-
If then where and .
The word is the word over such that and .
4.2 The automaton B
As in Section 3, a key ingredient in our construction is a subprocedure, implemented by a nfa, which, starting from and ending in some position for some prefix of the input, nondeterministically simulates the computational paths of on . Unlike those of nfas described in Section 3, such computational paths are here -segment s or variants of -segment s . Again, this procedure is made possible by the use of annotations, which allow to keep the head close to the position during the simulation. This idea has already been used in [5] for proving a polynomial upper bound for the simulation of 1-las by halting nfas. However, in that construction the resulting machine is only able to check the inclusion of the encoded relations in the corresponding -table s . In other words, the simulating nfa is allowed to “lose” some pairs of the -table s . Although this is sufficient for the simulated machine to recover acceptance of the input, it turns out to be insufficient if, as in the present work, we aim to recover rejection of the input. To address this lack of information, following the same strategy as in Section 3 and [4, 3], our construction uses inductive counting to check that every encoded relation is equal to the corresponding -table, and finally detect whether the input belongs to or not.
4.2.1 Simulating L-segments using annotations
The automaton maintains a variable ranging over in its finite control, which is updated according to each head move as now explained. The variable is incremented on right moves and decremented on left moves like a counter with the two following differences: decrementing from value is forbidden (hence left-moves from a state in which are forbidden), and incrementing from value resets the counter to . In the initial configuration, in which the head is at position , . Hence, at any point of the computation with the head at position , the value of is congruent to modulo . We call current window the portion of the tape of length at most , going from position to position where is the input length; see Figure 2.
By relative position , for , we refer to the position relatively to the current window, i.e., the absolute position . The window will slide from left to right along the input. Indeed, on the one hand, as decrementing from value is forbidden the head can never visit cells to the left of the current window. On the other hand, updating the value of from to on a right-move shifts the window to the right by cells in the following sense: after the shift, a cell that was at some relative position before the shift is either not covered by the window if , or at relative position otherwise. By using , can navigate within this window without getting lost. From now on, we assume the machine has always access to the value without mentioning it explicitly. More generally, we say that a nfa is -aware when it has access to , and we do not count the underlying state component when analyzing its size. In a (partial) configuration of some -aware nfa, indicates state with .
Our construction based on inductive counting relies on a nondeterministic subroutine nsimul_t (Procedure 5), which, assuming the annotation on the left side of the current window is correct, allows to simulate -segment s of while keeping the head within the current window. In particular, on input , if called from position for a prefix of , the procedure eventually halts (if an -segment on is found) with the head at position . The procedure can be implemented by a nfa of polynomial size in , as stated in the following Lemma (recall Definition 4.7).
Lemma 4.9.
Let . There exists a -aware nfa with same state set as , such that, for every , every , and every :
where with , and equals if or otherwise.
Proof.
The behavior of is described in Procedure 5, where the value of is deduced from the initial relative position (Line 24), and which uses a variable ranging over . The states of are the valuations of this variable. The absence of outgoing transitions when is ensured by the main loop condition (Line 26). Let , , , , and be as in the lemma statement. We also let with . Starting from the last position of (thus scanning ) with and , nondeterministically simulates a computational path of starting from configuration . Yet, does not work on but on . Hence, in order to simulate , proceeds in two modes (mainly distinguished by whether or not, c.f. Line 27).
-
Mode 1
As far as it scans the portion containing (), it performs a direct simulation by reading the symbols from the input track. Since on this portion these symbols are distinct from , the transition of are the same as those of . Hence, nondeterministically chooses one transition of on the corresponding symbol, and then updates its state and moves its head accordingly (Lines 28–30).
-
Mode 2
As soon as the last position of the portion containing is entered (from the right, detected as ), it simulates a transition of on . If then and thus such transitions are the same as those of . Hence the same simulation as in the previous case works (c.f. the second condition for entering the previous mode on Line 27). Otherwise, scans backward the annotation track carrying (Lines 32–39) in order to find some relative position where is the current value of (detected as ) and such that (Line 33). Such a position indeed indicates that belongs to , or equivalently, that from state scanning , may move its head rightward and enter . Upon encountering such a position, nondeterministically chooses either to ignore it or to select it (Line 34). In the former case it proceeds with the backward scan of , while in the latter it sets to and moves the head rightward to relative position (Lines 38–39), so that the simulation may resume from there. If at some point and no position has been found and selected, then the machine aborts (Line 36).
By construction, simulates on relative position less than . Next, its transitions are determined from the only information of that ranges over , and the scanned symbol. Hence, has states (not counting the -component).
In order to update the -table s according to Proposition 4.5, we need to consider other relations, e.g. for . The automaton can be easily adapted so that the resulting nfa is able to find any computational path of witnessing the membership of a pair to such relations.
Lemma 4.10.
Let . There exists an -aware nfas with state set such that, for every , , , , and :
where equals if and otherwise.
We let be the disjoint union of ’s over . In subsequent procedures, the call to is referred to as the procedure nsimul_ which takes two parameters, namely the starting state and the value of , and eventually returns a state when called from head position .
Let be (resp. for some ), and denote the size of . Equipped with the procedure nsimul_t (resp. nsimul_), a nfa can enumerate the elements of as soon as is known. Indeed, in a similar way as Procedure 1 enumerates the elements of , it is possible to repeat calls to nsimul_t (resp. nsimul_) and check that at each iteration but the first, the found pair is larger than the preceding one. The so-described enumeration procedure is named enum_ (resp. enum_), and can be implemented by a -aware nfa with polynomially many states in .
Checking the annotation-track contents.
The whole machinery above relies on the procedure nsimul_t, which in turn relies on the correctness of the annotation on the left side of the current window. Hence, as in Section 3, we have to check that the annotation track contents do encode the expected -table s . Because our strategy requires to compute the size of for the successive prefixes of the correctly-annotated input, our automaton can trigger a special mode, on each time the length of such a prefix is a positive multiple of , just after having computed . This special mode is responsible of checking that the -length suffix of carries the correct annotation symbols, namely, that . (Technically, it checks that where if or if for some . Since is assumed to have already been checked by induction, it follows .) Because at the time this special mode is entered is known (i.e., is stored within the finite control of ), the verification can be easily obtained as follows. First the device checks that has exactly bits equal to . Second, it enumerates the pair using enum_ and checks for each of them that . It is routine to implement this procedure, to which we refer as check_table, by a nfa of size polynomial in .
Lemma 4.11.
There exists an -aware nfa with polynomially many states in , and two injections and from to the states of such that, for every , , and :
where equals if and otherwise, and .
4.2.2 Inductively computing the size of L-tables
We now explain how our nfa inductively computes for each prefix of . More precisely, we inductively ensure the following invariant for every prefix of :
| () |
Initially, for , is a precomputed constant, encoded in the initial state of . Let be a prefix of with . Assume that is known (i.e., stored in the finite control of ) and the head is on position , scanning . In order to compute , follows the following steps:
-
Step 1
It computes from ;
-
Step 2
It then inductively computes from ;
-
Step 3
It finally computes from .
Each of these steps is performed through a computational path of that starts from position , ends in position , and visits only position in the meantime.
Steps 1 and 3 are the simplest ones, as they follow from Remarks 4.4 and 4.5, respectively. Indeed, for Step 1, can detect whether a given pair belongs to given by enumerating the elements of using enum_ (using the same idea as in Procedure 3). Thus, it can detect whether a pair belongs to based on Item 2 of Remark 4.4, and, by trying all pairs and counting those that belong to , it can compute . Similarly for Step 3, can detect whether a given pair belongs to given by enumerating the elements of using enum_ with (so that by Item 3 of Remark 4.4). Thus, it can detect whether a pair belongs to based on Proposition 4.5, and by trying all pairs and counting those that belong to , it can compute . The resulting procedures get_S1_from_t and get_t_from_S* can be implemented using a polynomial number of states (as stated in Lemmas 4.12 and 4.12 below).
It thus remains to explain Step 2, which follows the same idea but with an inner induction. Indeed, one way of computing from is to successively compute for . However, we follow a cheaper and simpler big-step strategy, where we compute these cardinalities only for successive powers of , using the following observation:
| for all . |
Hence, since knowing allows to detect which pairs of states belong to using enum_, our automaton is able to compute from . The resulting procedure get_next_S (Procedure 6) can be implemented using a polynomial number of states only. By successively computing such cardinalities for , we obtain which is equal to by Remark 4.4. The resulting procedure get_S*_from_S1 (Procedure 7) can be implemented using a polynomial number of states in only.
Lemma 4.12.
Let . There exist three -aware nfas , , of size polynomial in , each provided with two mappings and from to their respective set of states, such that for every , , , and :
where equals if and otherwise.
4.2.3 Gathering the mechanisms: the automaton
We are now ready to prove Lemma 4.2 by concluding the presentation of whose high-level behavior is described by Procedure 8.
Proof of Lemma 4.2.
The mapping is defined in Definition 4.8, while the nfa implements Procedure 8 using and maintaining the variable in its finite control, as explained in Section 4.2.1. We first show the correctness of , based on the preliminary work, and then argue that its has polynomial size in .
The behavior of can be decomposed into two phases. First, it has one main loop for visiting all tape cells until hitting the right endmarker (Lines 53–58) while iteratively computing for the corresponding prefix . Then, a final phase decides the acceptance or the rejection of the input. In any phase, abortion of the computation, due to wrong choices or incorrect annotation are possible.
During the first phase, we ensure the invariant () where is the input-track contents to the left of the head position, at the loop entrance. This prefix is extended, symbol by symbol, at each iteration of the loop (see Line 58). Indeed, knowing at the beginning of the loop with the head scanning with , the machine computes by following the three steps that were presented in Section 4.2.2 (Lines 54–56). In order for the simulation to work properly, checks the annotation track contents using the procedure check_table each time a factor of length have been completed (Line 57).
The second phase is entered when the head has reached . To ensure unicity of the annotation, checks that the annotation-track contents ends with , where is known as (Line 59). Also, at that time, the state of contains the information of . Hence, in a similar way as done during the loop, the machine can compute (Lines 60–61). It then decide acceptance by testing whether the pair belongs to or not according to Proposition 4.6, using enum_ with (Line 62).
The number of states of is polynomial in . This can easily be seen as the given procedure and sub-procedures use finitely many variables (including ), each ranging over at most values. Indeed a state of roughly consists in a valuation of these variables, together with a mode specifying at which point (which procedure and line) the simulation is. A rough analysis could show that states are sufficient (hopefully a finer analysis and/or design could decrease this exponent, possibly using further annotation symbols).
5 Conclusion
We investigated the descriptional complexity of the complementation of nfas. Our results show that, if we relax the target device so that, in addition to the usual nondeterminism it enjoys common guess (i.e., it works on nondeterministically annotated inputs), then a polynomial cost can be met. By adapting our construction or applying the results from [5], the resulting nfa can furthermore be made halting. A natural improvement of our result consists in a finer analysis of the upper-bounding polynomial, or – more promising – in the design of an alternative cheaper construction, possibly using more annotation symbols. In the opposite direction, deriving non-trivial (e.g., quadratic) upper bounds for the transformation is left as a challenging open problem.
Another extension could be to consider more restricted forms of nfas as target devices. In particular, dfas are of particular interest. In contrast with nfas, their nondeterminism is limited to the annotation phase only. This limitation already allows to derive similar lower bounds for their simulation by nfas, nfas, dfas, or deterministic 1-las (d1-las) as those obtained for the simulation of general 1-las [6]. A natural question is whether common guess is sufficient for capturing the usual form of nondeterminism up-to a polynomial size increase. This reduces to the question of the size cost of the conversion of nfas into equivalent dfas, a weakening of [15, Problem 4]; see Figure 1. Hence, a future line of research consists in the investigation of these costs, as well as the related problem of the cost of complementing nfas or nfas by dfas.
References
- [1] Jean-Camille Birget. Intersection and union of regular languages and state complexity. Information Processing Letters, 43(4):185–190, 1992. doi:10.1016/0020-0190(92)90198-5.
- [2] Alessandro Clerici Lorenzini, Giovanni Pighizzini, and Luca Prigioniero. Two-way automata and bounded languages. In Conference on Implementation and Application of Automata CIAA 2025, Proceedings, volume 15981 of Lecture Notes in Computer Science, pages 73–85. Springer, 2025. doi:10.1007/978-3-032-02602-6_6.
- [3] Viliam Geffert, Bruno Guillon, and Giovanni Pighizzini. Two-way automata making choices only at the endmarkers. Information and Computation, 239:71–86, 2014. doi:10.1016/j.ic.2014.08.009.
- [4] Viliam Geffert, Carlo Mereghetti, and Giovanni Pighizzini. Complementing two-way finite automata. Information and Computation, 205(8):1173–1187, 2007. doi:10.1016/j.ic.2007.01.008.
- [5] Bruno Guillon and Luca Prigioniero. Linear-time limited automata. Theoretical Computer Science, 798:95–108, 2019. doi:10.1016/j.tcs.2019.03.037.
- [6] Bruno Guillon, Luca Prigioniero, and Javad Taheri. Nondeterminism makes unary 1-limited automata concise. In Developments in Language Theory DLT 2025, Proceedings, volume 16036 of Lecture Notes in Computer Science, pages 153–165. Springer, 2025. doi:10.1007/978-3-032-01475-7_11.
- [7] Bruno Guillon, Luca Prigioniero, and Javad Taheri. Polynomial complementation of nondeterministic 2-way finite automata by 1-limited automata. CoRR, abs/2507.11209, 2025. doi:10.48550/arXiv.2507.11209.
- [8] John E. Hopcroft and Jeffrey D. Ullman. Introduction to Automata Theory, Languages and Computation. Addison-Wesley, 1979.
- [9] Neil Immerman. Nondeterministic space is closed under complementation. SIAM Journal on Computing, 17(5):935–938, 1988. doi:10.1137/0217058.
- [10] Galina Jirásková. State complexity of some operations on binary regular languages. Theoretical Computer Science, 330(2):287–298, 2005. doi:10.1016/j.tcs.2004.04.011.
- [11] Galina Jirásková and Giovanni Pighizzini. Optimal simulation of self-verifying automata by deterministic automata. Information and Computation, 209(3):528–535, 2011. doi:10.1016/j.ic.2010.11.017.
- [12] Christos A. Kapoutsis. Removing bidirectionality from nondeterministic finite automata. In Mathematical Foundations of Computer Science MFCS 2005, Proceedings, volume 3618 of Lecture Notes in Computer Science, pages 544–555. Springer, 2005. doi:10.1007/11549345_47.
- [13] Nelma Moreira, Giovanni Pighizzini, and Rogério Reis. Optimal state reductions of automata with partially specified behaviors. Theoretical Computer Science, 658:235–245, 2017. doi:10.1016/j.tcs.2016.05.002.
- [14] Giovanni Pighizzini. Two-way finite automata: Old and recent results. Fundamenta Informaticae, 126(2-3):225–246, 2013. doi:10.3233/FI-2013-879.
- [15] Giovanni Pighizzini. Limited automata: Properties, complexity and variants. In Descriptional Complexity of Formal Systems DCFS 2019, Proceedings, volume 11612 of Lecture Notes in Computer Science, pages 57–73. Springer, 2019. doi:10.1007/978-3-030-23247-4_4.
- [16] Giovanni Pighizzini and Andrea Pisoni. Limited automata and regular languages. International Journal of Foundations of Computer Science, 25(7):897–916, 2014. doi:10.1142/s0129054114400140.
- [17] Giovanni Pighizzini, Luca Prigioniero, and Simon Sádovský. Performing regular operations with 1-limited automata. Theory of Computing Systems, 68(3):465–486, 2024. doi:10.1007/s00224-024-10163-1.
- [18] William J. Sakoda and Michael Sipser. Nondeterminism and the size of two way finite automata. In Symposium on Theory of Computing STOC 1978, Proceedings, pages 275–286. ACM, 1978. doi:10.1145/800133.804357.
- [19] John C. Shepherdson. The reduction of two-way automata to one-way automata. IBM Journal of Research and Development, 3(2):198–200, 1959. doi:10.1147/rd.32.0198.
- [20] Róbert Szelepcsényi. The method of forced enumeration for nondeterministic automata. Acta Informatica, 26(3):279–284, 1988. doi:10.1007/BF00299636.
- [21] Moshe Y. Vardi. A note on the reduction of two-way automata to one-way automata. Information Processing Letters, 30(5):261–264, 1989. doi:10.1016/0020-0190(89)90205-6.
- [22] Klaus W. Wagner and Gerd Wechsung. Computational Complexity. Mathematics and its Applications. Springer, 1986.
