Deterministic Finite Automata with Recursive Calls and Dpdas
Total Page:16
File Type:pdf, Size:1020Kb
Information Processing Letters 87 (2003) 187–193 www.elsevier.com/locate/ipl Deterministic finite automata with recursive calls and DPDAs ✩ Jean H. Gallier a, Salvatore La Torre b,∗, Supratik Mukhopadhyay c a University of Pennsylvania, Philadelphia, PA 19104, USA b Università degli Studi di Salerno, Dipartimento di Informatica ed Applicazioni, Via S. Allende, Baronissi (SA) 84081, Italy c West Virginia University, Morgantown, WV 26506, USA Received 4 December 2002; received in revised form 6 March 2003 Communicated by H. Ganzinger Abstract We study deterministic finite automata (DFA) with recursive calls, that is, finite sequences of component DFAs that can call each other recursively. DFAs with recursive calls are akin to recursive state machines and unrestricted hierarchic state machines. We show that they are language equivalent to deterministic pushdown automata (DPDA). 2003 Elsevier B.V. All rights reserved. Keywords: Formal Languages 1. Introduction spond to system transitions. To describe complex sys- tems using finite automata, several extensions are use- Finite automata are a very intuitive and widely ful. studied formalism. They are a natural framework for In this paper, we study an extension of the concept modeling and studying finite state systems. Descrip- of a DFA by allowing certain transitions to be “calls” tions using automata are useful to represent the con- to other DFAs. The automata we define are similar trol flow of a computer program, and in general the to restricted types of augmented transition networks behavior of a digital system. This makes them suit- (ATN) used in natural language processing [18], and to able for formal analysis via well-founded technolo- other hierarchic state machine models that have been gies, such as model checking. In the simplest setting, proposed in different contexts where the need for a a finite automaton consists of a labeled graph whose nesting capability is either natural or convenient. Such vertices correspond to system states and edges corre- machines have been studied in the context of inter- procedural dataflow analysis. They can model control- ✩ This research was partially supported by the supported by the flow graphs of procedures in programming languages MIUR in the framework of the project “Metodi Formali per la such as C. Our model is also related to the strict deter- Sicurezza” (MEFISTO) and MIUR grant 60% 2002. ministic grammars of Harrison and Havel [11]. In [12] * Corresponding author. a class of nondeterministic finite automata with recur- E-mail addresses: [email protected] (J.H. Gallier), [email protected] (S. La Torre), [email protected] sive calls is proved to correspond to the unambiguous (S. Mukhopadhyay). context-free languages. In the design and verification 0020-0190/$ – see front matter 2003 Elsevier B.V. All rights reserved. doi:10.1016/S0020-0190(03)00281-3 188 J.H. Gallier et al. / Information Processing Letters 87 (2003) 187–193 of large systems the use of hierarchic paradigms has guess whether the current symbol is the last symbol of been advocated by many authors both to have succinct w or not, and only in the second case, a recursive call descriptions and exploit modularity [9,4,1]. Recent re- is made after this symbol is read. sults have been concerned with the verification of re- The equivalence problem for deterministic push- cursive finite state machines [3,2]. down automata has been recently shown to be decid- Here, we are interested in recursive (deterministic) able [15]. Another proof of this result can be found finite state machines from a formal languages theo- in [17]. Besides the importance of such a result the retic perspective. It is well known that (determinis- DPDA equivalence problem has a number of impor- tic) finite automata define exactly the class of regu- tant implications which have been discussed in [16]. lar languages. Our aim is to extend this class of au- By our results, we derive from the decidability of the tomata to capture the deterministic context-free lan- DPDA equivalence problem also the decidability of guages. We define a DFA with recursive calls as the equivalence problem for DFAs with recursive calls. a finite sequence of component DFAs that can call If we see the DFAs with recursive calls as recursive each other recursively. There are three kinds of tran- program schemes, we have also that a certain kind of sitions: ordinary transitions, calls and returns (from strong equivalence is decidable (we might call it “flow calls). A call corresponds to entering another compo- equivalence”). nent DFA, and a return to exiting it. The main lim- Unwinding the recursion in a DFA with recursive itation we place on the model is that if from a state calls we obtain a deterministic automaton whose tran- q there is a call to a DFA then this is the only tran- sition graph is an infinite graph (infinite automaton). sition from q. This restriction is needed to preserve It is possible to prove that this infinite automaton is the determinism of the model. For any call we allow the “initial fixpoint” (in the sense of Lehmann [13]) multiple return points, i.e., multiple exits in the com- of a “substitution functor” induced by the set of DFAs ponent DFAs. with recursive calls. In fact, such automaton turns out The main result of this paper is that the class to be the colimit of a sequence of finite approximating of DFAs with recursive calls defines exactly the DFAs. class of deterministic context-free languages. To prove The rest of the paper is organized as follows. that this class of automata accepts only deterministic In Section 2 we introduce the model and recall the context-free languages, we use the atomic normal main definitions. In Section 3 we prove that DFAs form of deterministic pushdown automata given in [8]. with recursive calls characterize exactly the class of The completeness result, that is, each deterministic deterministic context-free languages. We conclude in context-free language has an equivalent DFA with Section 4 with further remarks. recursive calls accepting it, is shown by translating an infinite tree of a recursion scheme to a DFA with recursive calls and using the fact that such trees can 2. The model be used to characterize the class of deterministic context-free languages [8]. It is worth noticing that if In this section we introduce the notion of determin- in our model we allow nondeterminism on ordinary istic finite automata with recursive calls. transitions (i.e., transitions that are neither calls nor Let Σ be a finite alphabet and let Φ ={F1,...,FN } returns), also nondeterministic context-free languages be a set of function symbols, each having arity r(Fi) can be accepted. For example, consider the language 0. Let M = max{r(Fi) | 1 i N} and let [1,M] L ={wwR | w ∈ Σ},whereΣ is an alphabet. We can denote the set {1,...,M} (with [1, 0]=∅). The define an automaton with deterministic recursive calls symbols of Φ will be called nonterminals, while the that accepts L, as follows. The automaton consists of a symbol in Σ will be called terminals. The elements of single component that can call itself recursively. Calls Φ can be considered as procedure names. are used to push symbols onto the stack and returns to A deterministic finite automaton with recursive pop symbols from the stack. The top of the stack can calls is a set of component DFAs that can call each be stored in the state of the current activation of the other recursively. Calls and returns are modeled as component. Thus, nondeterminism is needed only to special transitions that do not read input symbols. J.H. Gallier et al. / Information Processing Letters 87 (2003) 187–193 189 Moreover, if from a state q there exists a call transition • δ : Q × Σ ∪ Φ ∪[1,M]→Q is a partial function then this is the only transition leaving from q.Ifp called the transition function and satisfies the is the state reached after a call, it can have only an following conditions: entering transition, and the transitions exiting p are (1) For every p ∈ Q and Fj ∈ Φ,ifq = δ(p,Fj ) exactly the returns from this call and each of them is defined, then δ(p,α) is not defined for any corresponds to an exit of the called component. There other α ∈ Σ ∪ Φ ∪[1,M],thatis,δ(p,Fj ) is exists a one-to-one correspondence between the exits the only transition defined from p. of a called component and the returns of the calling (2) If δ(p,Fj ) = q then δ(q,k) is defined only component. For any call we allow multiple return for k such that 1 k r(Fj ),andδ(q,α) is points, i.e., multiple exits in the component DFAs. not defined for any α ∈ Σ ∪ Φ. Formally, a deterministic finite automaton with re- (3) If defined, δ(p,Fj ) is not a final state and has cursive calls consists of a finite sequence D = F ⇐ 1 no other incoming edges. D ,...,F ⇐ D of DFA definitions, where D 1 N N i Furthermore, the entry state in has no incoming is a DFA which can issue calls F ,...,F respec- 1 N transitions, every state in dom(OUT) has no out- tively to any of the component DFAs D1,...,DN . going transitions and every state lies on a path The first definition F1 ⇐ D1 is considered to be the from in to some exit state. “main definition”. Given an Fi ∈ Φ, a DFA definition Fi ⇐ Di for Fi of arity m is a 6-tuple Q, Σ ∪ Φ ∪ [1,M],δ,in, OUT, FINAL where: As an example of a DFA with recursive calls, consider the automaton D given by the tuple of ⇐ ⇐ ⇐ • Q is a finite set of states.