ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

Similar documents
A Characterization of the Chomsky Hierarchy by String Turing Machines

Decidable Problems. We examine the problems for which there is an algorithm.

Chapter 14: Pushdown Automata

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

Computer Sciences Department

ECS 120 Lesson 16 Turing Machines, Pt. 2

CT32 COMPUTER NETWORKS DEC 2015

Theory of Programming Languages COMP360

Theory of Computations Spring 2016 Practice Final Exam Solutions

VISUALIZING NP-COMPLETENESS THROUGH CIRCUIT-BASED WIDGETS

CS402 - Theory of Automata Glossary By

JNTUWORLD. Code No: R

Formal languages and computation models

SOFTWARE COMPLEXITY MEASUREMENT USING MULTIPLE CRITERIA ABSTRACT

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Turing Machine Languages

CSE 105 THEORY OF COMPUTATION

Multiple Choice Questions

Introduction to Computers & Programming

UNIT I PART A PART B

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

CSCI 340: Computational Models. Turing Machines. Department of Computer Science

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

Theory and Compiling COMP360

Theory of Computation, Homework 3 Sample Solution

Final Course Review. Reading: Chapters 1-9

CSC-461 Exam #2 April 16, 2014

Theory Bridge Exam Example Questions Version of June 6, 2008


Outline. Language Hierarchy

Theory of Computation

LL Parsing, LR Parsing, Complexity, and Automata

Pushdown Automata. A PDA is an FA together with a stack.

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

Decision Properties for Context-free Languages

A Note on the Succinctness of Descriptions of Deterministic Languages

CS 44 Exam #2 February 14, 2001

Theory of Languages and Automata

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Reflection in the Chomsky Hierarchy

Equivalence of NTMs and TMs

Welcome to MTH401A!! Theory of Computation

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

where is the transition function, Pushdown Automata is the set of accept states. is the start state, and is the set of states, is the input alphabet,

T.E. (Computer Engineering) (Semester I) Examination, 2013 THEORY OF COMPUTATION (2008 Course)

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

The Big Picture. Chapter 3

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued

PDA s. and Formal Languages. Automata Theory CS 573. Outline of equivalence of PDA s and CFG s. (see Theorem 5.3)

Learn Smart and Grow with world

From Theorem 8.5, page 223, we have that the intersection of a context-free language with a regular language is context-free. Therefore, the language

Specifying Syntax COMP360

Languages and Compilers

1 Parsing (25 pts, 5 each)

LLparse and LRparse: Visual and Interactive Tools for Parsing

CS/B.Tech/CSE/IT/EVEN/SEM-4/CS-402/ ItIauIafIaAblll~AladUnrtel1ity

THEORY OF COMPUTATION

Actually talking about Turing machines this time

Formal Grammars and Abstract Machines. Sahar Al Seesi

Definition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.

CISC 4090 Theory of Computation

Limited Automata and Unary Languages

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

Variants of Turing Machines

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

Finite automata. We have looked at using Lex to build a scanner on the basis of regular expressions.

Theory of Computations Spring 2016 Practice Final

Languages and Automata

CSE 105 THEORY OF COMPUTATION

On the Recursion-Theoretic Complexity of Relative Succinctness of Representations of Languages

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

Turning Automata Theory into a Hands-on Course

1. [5 points each] True or False. If the question is currently open, write O or Open.

CS21 Decidability and Tractability

An Interactive Approach to Formal Languages and Automata with JFLAP

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

Structure of a Compiler: Scanner reads a source, character by character, extracting lexemes that are then represented by tokens.

Problems, Languages, Machines, Computability, Complexity

CSE 105 THEORY OF COMPUTATION

Derivations of a CFG. MACM 300 Formal Languages and Automata. Context-free Grammars. Derivations and parse trees

CSE 5317 Midterm Examination 4 March Solutions

Models of Computation II: Grammars and Pushdown Automata

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207.

(Refer Slide Time: 0:19)

Recursively Enumerable Languages, Turing Machines, and Decidability

Reading 1 : Introduction

Transcription:

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES * Pradip Peter Dey, Mohammad Amin, Bhaskar Raj Sinha and Alireza Farahani National University 3678 Aero Court San Diego, CA 92123 {pdey, mamin, bsinha, afarahan}@nu.edu ABSTRACT This paper presents one-stack automata as acceptors of context-free languages; these are equivalent to Pushdown Automata which are well known in automata theory. As equivalence relations such as equivalence of Turing Machines and two-stack Pushdown Automata help in learning general properties of formal modeling, the equivalence relation of Pushdown Automata and one-stack automata also helps in learning general properties of context-free language modeling. One-stack automata are helpful to students for several reasons including: (1) their contrast with two-stack Pushdown Automata and multi-stack automata is revealing for computability; (2) their computer animation is helpful for learning their salient features; (3) their graphical representation is more easily obtained by augmenting Non-Deterministic Finite Automata for regular languages which usually precede context-free language acceptors in the logical sequence of ideas. INTRODUCTION The most elegant models of computation are the mathematically defined automata including Turing Machines (TMs), two-stack Pushdown Automata (2PDA), Linear Bounded Automata (LBA), Pushdown Automata (PDA) and Finite Automata (FA). These models are usually studied in the fields of theory of computation, automata theory and computability. TMs define the most powerful automata class for processing the most complex sets, namely, recursively enumerable sets. TMs are equivalent to two-stack * Copyright 2010 by the Consortium for Computing Sciences in Colleges. Permission to copy without fee all or part of this material is granted provided that the copies are not made or distributed for direct commercial advantage, the CCSC copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Consortium for Computing Sciences in Colleges. To copy otherwise, or to republish, requires a fee and/or specific permission. 118

CCSC: Northwestern Conference automata or 2PDA as proven by Minsky [7]. Classical forms of Pushdown Automata (PDA) are required to have exactly one stack and they are non-deterministic unless otherwise explicitly stated. PDA are acceptors of the class of Context-Free Languages (CFL's) or sets. They are less powerful than TMs; they cannot accept non-cfl's. Finite Automata (FA) define a proper subset of CFL's called regular languages denoted by regular expressions; they are equivalent to Non-deterministic FA (NFA). The above narrative information with some additional information is usually presented in a tabular form called the Chomsky hierarchy of grammars and languages as shown in Table 1 [1]. The Chomsky Hierarchy of Grammars and Languages Type Language/Grammar Acceptor 0 Recursively Enumerable Turing Machines = 2PDA = Post Machines 1 Context-Sensitive Linear Bounded Automata (LBA) = Turing Machines with bounded tape. 2 Context-Free Pushdown Automata (PDA) 3 Regular Finite Automata (FA) = NFA = Transition Graphs Table 1: The Chomsky Hierarchy Unlike other automata classes, PDA are not shown to be equivalent to any other acceptors [1]. This paper proves that one-stack automata are equivalent to PDA and suggests that this equivalence relation helps in learning general properties of CFL acceptors. In addition, computer animation of one-stack automata (www.asethome.org/onestack) demonstrates their revealing features [3]. Due to numerous recent research activities with multi-stack automata [2, 6] the name and the representation of one-stack automata are carefully chosen to avoid possible confusions. This paper presents essential features of one-stack automata and describes how these features and their animation promote learning CFL modeling. ONE-STACK AUTOMATA One-stack automata are designed as acceptors of CFL's; they are unable to accept any non-cfl. For example, L 1 = { a n b n : where n >= 0 } is a well-known CFL [1] which can be accepted by a one-stack automaton. The definition of the automata is presented below followed by two examples. Definition of One-Stack Automata A one-stack automaton is composed of 5 components: 1. : a finite non-empty set of symbols called alphabet from which input strings are formed. 2. S: a finite non-empty set of states including 2a. One start state ( marked by -) ; 2b. Some (may be none) final states (marked by +) ; 3. : an optional pushdown STACK, infinite in one direction. Initially, the STACK is empty containing all blanks ( ). 119

JCSC 26, 1 (October 2010) 4. : an optional finite set of symbols called the STACK SYMBOLS. If the STACK is included then the STACK SYMBOLS are also included. 5. T: a finite set of transitions (edge labels) including: 5a. A finite set of transitions that show how to go from some states to some others, based on reading a specified symbol from input or the null string, ^. 5b. Some (may be none) special transitions called push transitions each of which reads a symbol from input and inserts a symbol onto the top of the STACK. 5c. Some (may be none) special transitions called pop transitions each of which reads a symbol from input and pops a symbol from the top of the STACK. 5d. Some (may be none) special transitions each of which examines if the stack is empty by reading and popping. EXAMPLES AND EXPLANATIONS One-stack automata are augmented from ^-NFA (NFA with null-transitions) to CFL acceptors with an optional stack and optional push and pop transitions. On the other hand, every PDA is required to have a stack and every transition in a PDA is specified with reference to the stack [4, 5, 8]. Every NFA is not a PDA, whereas every NFA is a one-stack automaton. The latter proposition helps student's understanding of the Chomsky Hierarchy, because every regular grammar is a CFG. Two examples of one-stack automata are presented below. Figure 1: A one-stack automaton for { a n b n : where n > = 0 } An example of a one-stack automaton for L 1 = { a n b n : where n > = 0 } is shown in Figure 1, where is given by {a, b}; S is given by three states each of which is represented by a circle; the start state is represented by a circle marked by -; the final state is represented by a circle marked by +; is given by a horizontal stack; is given by {a }; T is given by a set of transitions each of which is represented by an arrow. If the string, aabb, is given as an input to the automaton of Figure 1 then it would be accepted by the following sequence of steps: (i) by starting the machine at the start state (marked by -) and scanning the first a of the input string while traversing the push transition marked by a, push a which pushes a into the stack; (ii) by scanning the second a while taking the same push transition marked by a, push a again which pushes another a into the stack; (iii) by taking the null-transition marked by ^ but not consuming any symbol from the input; (iv) by scanning the third symbol b from the input while taking 120

CCSC: Northwestern Conference the loop transition marked by b, pop a; (v) by scanning the final symbol b from the input while taking the loop transition marked by b, pop a; (vi) by taking the transition marked by ^, pop. After the preceding sequence of actions the automaton meets the acceptance conditions given below and, therefore, accepts the input. The input is accepted if the following conditions are met: (a) starting with the start state (marked by -) the automaton reaches one of the accept or final states (marked by +); (b) the stack is empty; (c) the input is consumed or completely scanned. Figure 2: A one-stack automaton for { { n c} n : where n >= 0 } The one-stack automaton of Figure 2 is similar to that of Figure 1; however, it accepts strings with matching number of {'s and }'s separated by one c; programming languages such as C++ have a similar string pattern. This machine will accept {{c}} and reject {{{c}. That one-stack automata are equivalent to PDA can be proven with the following two theorems. It is assumed that the reader is familiar with PDA given in textbooks such as [1]; the proofs of the theorems are given with brevity. Theorem 1: For every one-stack automaton there is a PDA. Proof: An arbitrary one-stack automaton can be converted into a PDA. The alphabet,, is the same in both. The stack symbols and the stack are also the same in both. If the start state of the one-stack automaton has incoming transitions then using null-transitions it is mapped to a new start state without any incoming transitions. The single start state of the one-stack automaton is converted to the START state of the target PDA. If any final states of the one-stack automaton have out-going transitions then these final states are mapped to new final states without out-going transitions using null-transitions. The final states of the one-stack automaton are then converted to ACCEPT states of the PDA. Each of the push transitions of the one-stack automaton is converted to a sequence of READ-PUSH states; if a push transition of the one-stack automaton has a, push a then it is converted to: 121

JCSC 26, 1 (October 2010) Similarly, each pop transition of the one-stack automaton is also converted to a sequence of READ-POP states of the PDA. All other transitions of the one-stack automaton are converted to the READ states of the PDA. That is a transition labeled a is converted to: Null-transitions of the one-stack automaton are eliminated by creating sequences of PDA states. Theorem 2: For every PDA there is a one-stack automaton. Proof: Any arbitrary PDA can be converted to a one-stack automaton. The alphabet,, is the same in both. The stack symbols and the stack are also the same in both. The START and ACCEPT states of the PDA are converted to the corresponding start and final states of the one-stack automaton and if necessary null-transitions are added. A sequence of READ-PUSH states is converted to a push transition of one-stack automaton; if is given in the PDA then it is converted to a single loop push transition labeled by a, push a. Similarly, a sequence of READ-POP states of the PDA is converted to a single loop pop transition. Other READ states are converted to a corresponding transition with the same label. The REJECT states of the PDA are deleted; one-stack automata do not have REJECT states; they just crash if no path can be found for the letter read from the input buffer as in FA, NFA and TMs [1]. Since PDA are equivalent to one-stack automata, every formal aspect proven for PDA would apply to one-stack automata also. Thus, one-stack automata are also equivalent to CFGs, since PDA are proven to be equivalent to CFG's [1, 4, 5, 8]. Equivalence relations are often used in textbooks as learning exercises. Animation of one-stack automata clearly shows use of stack for matching strings without counting [3]. In a survey, 22 out of 25 respondents (88%) found one-stack automata helpful in learning CFL processing. 122

CCSC: Northwestern Conference CONCLUDING REMARKS One-stack automata are equivalent to PDA. This equivalence may be considered in a learning environment because learners may get a better understanding by comparing related features of the two. The equivalence relation of PDA and one-stack automata helps in learning general properties of CFL modeling. Some learners may also like the stack related generalization that zero-stack automata are equivalent to regular grammars; they accept regular languages; they do not accept non-regular languages. One-stack automata are equivalent to CFG's; they accept CFL's; they do not accept non-cfl's. Two or multi-stack automata are equivalent to un-restricted phrase structure grammars and they accept recursively enumerable sets.* REFERENCES [1] Cohen, D., Introduction to Computer Theory, 2nd Edition, New York, NY: John Wiley & Sons, 1997. [2] Dassowa, J., Mitranab, V., Stack cooperation in multistack pushdown automata, Journal of Computer and System Sciences, 58 (3), 611-621, 1999. [3] Dey, P. P., Farahani, A., One-Stack Automata Animation, http://www.asethome.org/onestack, retrieved April 12, 2010. [4] Hopcroft, J. E., Motwani, R., Ullman, J., Introduction to Automata Theory, Languages, and Computation, Pearson Education, 2007. [5] Lewis, H. R., Papadimitriou, C. H., Elements of the Theory of Computation, 2nd Edition, New Jersey: Prentice_Hall, 1998. [6] Limaye, N., Mahajan, M., Membership Testing: Removing Extra Stacks from Multi-stack Pushdown Automata, Language and Automata Theory and Applications, LNCS, Springer, 2009. [7] Minsky, M. L, Recursive insolvability of Post's problem of 'Tag' and other topics in theory of Turing Machines, Annals of Mathematics, 437-55, 1961. [8] Sipser, M., Introduction to the Theory of Computation, 2nd Edition, PWS Publishing, 2006. * Comments of some anonymous CCSC/NW reviewers were very useful. 123