You are on page 1of 5

Using Theoretical Computer Simulators for Formal Languages and Automata Theory

Carlos I. Chesevar Mara L. Cobo William Yurcik


*

Department of C.S. and Engineering Univ. Nacional del Sur Alem 1253 B8000CPB Baha Blanca, Argentina <{cic,lc}@cs.uns.edu.ar>

National Center for Supercomputing Applications (NCSA) University of Illinois at Urbana-Champaign Champaign, IL USA 61820 <byurcik@ncsa.uiuc.edu>

Abstract Both formal languages and automata theory (FLAT) are core to the CS curricula but are difficult to teach and to learn. This situation has motivated the development of a number of theoretical computer simulators as educational tools to allow students to bring to life many topics that traditionally were presented only mathematically. This paper discusses the main features of software tools currently freely available via the Internet for teaching FLAT. Based on our practical experience, the tradeoffs between different FLAT software tools is analyzed and discussed. We conclude with general recommendations for integrating FLAT software tools into an established curriculum. 1 Introduction

Many students find it difficult to grasp the concepts within formal languages and automata theory because the abstract formal notation overwhelms them. In other areas of computer science (such as computer architecture), software simulators provide an excellent teaching tool for enabling active learning of specialized knowledge through abstraction, interactivity, and visualization [16]. Theoretical computer simulators have some advantages with respect to their real-world counterparts - they rely on just a few (and rigorously related) theoretical models and these theoretical models are conceptually simple. We distinguish two categories of FLAT educational software, namely: 1) Generic, multi-purpose software packages for teaching and integrating several related concepts of FLAT. 2) Software tools oriented towards simulating a specific class of automata with educational purposes. In this paper we will review the main features of several software tools available for teaching FLAT in both categories. Most of these tools have been utilized during the undergraduate course Fundamentos de Ciencias de la Computacin at the Universidad Nacional del Sur, Argentina [1,8,9]. The remainder of this paper is structured as follows: Section 2 discusses multi-purpose software tools for modeling formal languages and their related automata. Section 3 discusses different software simulators for specific kinds of automata. In Section 4 we present practical considerations for the development of FLAT software teaching tools. We conclude with a summary in Section 5. 2 Multi-Purpose FLAT Software

Multi-purpose software tools for FLAT aim at integrating different simulation software into a single, unified package. We feel there are four software tools that fall into this category: DEM, JFLAP, JCT and Minerva. DEM Deus ex Machina <www.ici.uci.edu/~savoiu/dem> DEM comprises simulations of seven models of computation covered in the companion textbook [15]. It provides a generic multi-purpose platform for designing and running different kinds of automata, such as finite state automata (FSAs), pushdown automata (PDAs), Turing Machines (TMs), register machines (RMs), vector machines (VM), linear-bounded automata (LBAs) and Markov algorithms (MAs). Students can define an automaton by drawing or using nodes and arcs icons. Automata can then be run in a step mode that shows string processing as the execution of an automaton proceeds. JFLAP Java Formal Languages & Automata Package <www.cs.duke.edu/~rodger/tools/> [2,4,7,12,14] JFLAP is a package of graphical tools that can be used as an aid in learning the basic concepts of FLAT. The original version (FLAP) was written in C/C++ for X-window based systems [10]. JFLAP allows the design and simulation of

corresponding author

several variations of finite automata (FA), pushdown automata (PDA), one-tape Turing machines (TM) and twotape Turing machines (TTM). Additionally, JFLAP allows input grammars (GRM) and regular expressions (REX) and converting them between each other. Features of JFLAP include several conversions from one representation to another such as from nondeterministic finite automaton to deterministic finite automaton (DFA) or DFA to minimum state DFA. JCT Java Computability Toolkit <http://humboldt.sunyit.edu/JCT/ /> [13] JCT is multiple-window, web-accessible visualization tool for simulating Finite Automata (FA) and Turing Machines (TM). The FA environment models all binary and unary closure operations (such as union, intersection, Kleene Star, etc.) and introduces a circuit board representation of constructed FAs. The TM environment is intended for simulating deterministic Turing Machines using a high-level notation that provides hierarchical machine organization with locally or globally scoped variables. As in JFLAP, automata can be drawn on a canvas by positioning states and transitions. FAs and TMs can be executed on arbitrary input strings and executed in step-by-step fashion with immediate visual feedback. Current research involves extending JCT to consider pushdown automata (PDA) and other extensions. Minerva [3] Minerva is an interactive and visual tool implemented in Java that allows students to design, debug and run different kinds of automata (FSA, PDA and Turing machines). It also supports experimentation with grammars and the Pumping Lemma for regular languages. As in JFLAP, automata can be drawn on a canvas by positioning states and transitions. They can also be executed on arbitrary input strings and executed in step-bystep fashion with immediate visual feedback. The current version of Minerva is available only in Spanish.

2.1 Contrasting DEM and JFLAP: Our Experiences As in most FLAT courses, students have first to deal with finite state automata (FSA), and then with pushdown automata (PDA). According to our experiences, DEM was a good choice to start introducing the use of a software package as a tool for solving typical automata exercises. DEM encourages students to understand the importance of formalism as they have to provide the alphabet to be used, the corresponding input and tape language, etc. before they can run a given automaton. In contrast, JFLAP is more intuitive, not enforcing as many formal features. We combined the use of both packages to get `the best of both worlds'. First we introduced DEM, in order to emphasize the importance of notions such as input language, tape language, etc. and later, when students were more familiarized with notation issues, we switched into JFLAP. It must be noted that both DEM and JFLAP provide an interactive design screen, in which students can draw from a toolbar. In DEM, nodes and arcs can be enriched by additional comments. However, drawings are not fully resizable (nodes and fonts are always the same size) which may be a bit problematic. Although DEM provides more computation models than JFLAP (including linear-bounded automata and register machines), JFLAP provides facilities for integrating automata theory with corresponding grammars which proved to be very useful for our students. DEM is easier to install than JFLAP for students not familiar with Java-based applications. Finally, JFLAP makes use of different colors to highlight nodes, arcs, input tape, among other features. In contrast, DEM has a paler outlook as colors are used for highlighting step-by-step execution. Minerva is comparable to JFLAP. As the authors report in [3], Minerva has proven successful as a software tool for a first-year FLAT course. Even though JCT provides powerful platform-independent web-browsing facilities, it must be pointed out that it covers a narrower spectrum of simulators, not providing tools for relating grammars and finite automata (such as in JFLAP). 3 Single-Purpose Software Tools for FLAT

3.1 Formal Languages In addition to JFLAP which provides a natural connection between automata theory and their associated grammars, other tools for dealing with specific topics of formal languages have been developed. Pt <www.cs.duke.edu/~rodger/tools/pateweb> [7] Pt is a visual and interactive tool for parsing and transforming grammars. Pt can show the textual or graphical visualization of a derivation for a given grammar (restricted or unrestricted). With the textual visualization, a step-by-step derivation is displayed including the rules used at each step. In the graphical visualization, a parse tree for the derivation is shown with each node representing a symbol or a variable. Pt can also deal with grammar transformations of context-free grammars (by successively performing removal of -productions, removal of unit productions, etc.).

Pumplemma <ftp://ftp.cs.duke.edu/pub/rodger/tools> PumpLemma is a visual tool for regular languages, complementing Pt. Typical analysis determines that a language is not regular via the pumping lemma.

3.2 Finite State Automata Many simulation programs for FSA have been developed, ranging from Java applets executable from a Web browser to standalone application programs. We will briefly describe some of those we found particularly interesting for FLAT courses: CAVE Constructive Algorithm Visualization Environment <www.cif.rochester.edu/~samurai/cave.html> CAVE was designed to illustrate the operation of several useful constructive algorithms. It is intended to serve as a teaching tool for computer theory instructors and students. More specifically, CAVE implements constructive algorithms for building union and concatenation machines for DFAs. CAVE can also produce the complement of a source DFA, and build an intersection machine for two source DFAs. FSME Finite State Machine Explorer <www.belgarath.demon.co.uk/java/fsme.html> FSME is an interactive graphical system that supports the construction of FSAs. Animation is used to dynamically illustrate their behavior on given inputs. Furthermore, manipulation facilities are developed to support the study and exploration of automata, including the conversion between equivalent classes of machine, and the automatic generation of layouts. Finally, input and output capabilities are provided to enable the continued development and reuse of constructed machines. TAGS <http://cs.uns.edu.ar/~cic/fcc.htm> TAGS is a software tool designed to define and run Moore and Mealy transducer automata (MTAs). It is a standalone program that can be run on a PC, allowing the user to define and execute MTAs, as well as some conversions from one kind of MTA to another. FSA Simulator <www.cs.montana.edu/webworks/webworks-home/projects/fsa/fsa.html> [5,6] The FSA Simulator(s) are programs to simulate both deterministic and nondeterministic automata. Version 1 is a Java applet where colored circles indicate current states. Version 2 incorporates alternative representations (tables). The FSA Simulator distinguishes itself from JFLAP by using smooth highlighted transitions as opposed to jumps from state to state.

3.3 Pushdown Automata There are few teaching aids for simulating pushdown automata. Some simulators for PDAs are included in larger software packages (such as DEM or JFLAP). IPAA Interactive Pushdown Automata Animation <www.jenimac.com/JPT/Automata/details.htm> [11] IPAA provides a Java-based program for designing and running PDAs. IPAA includes several useful views for a given PDA. Students can specify a PDA by using an icon-based interface or drawing the PDA as a graph. PDAs can be run at different speeds. The input tape and the stack are shown as the computation proceeds.

3.4 Turing Machines There are many computer simulators for Turing machines available on the web, most of them available as Java applications that can be run from a browser. In our experience, the Applet Turing Machine Simulator written by Suzanne Skinner has proven especially successful. This applet is available from many websites around the world including <http://cs.uns.edu.ar/~cic/fcc.htm>. This applet has several samples Turing machines that can be run at different speeds for arbitrary input strings. The applet allows the student to modify the behavior of a given Turing Machine by providing new tuples or changing existing ones. Some of the attractive samples included in this simulator are a palindrome detector and busy beaver functions (for 5 and 6 states). Busy beavers are Turing machines with a fixed number of states which are thought to be write as many symbols as possible on the input tape and stop after a given number of steps. These busy beavers are quite puzzling for students as they are rather simple Turing machines that run for a considerable time before stopping. Finding new busy beaver functions that outperform existing ones has proven to be an attractive challenge for some students. VisualTuring provides a more sophisticated tool, a graphical IDE that can be used to edit, define and play with Turing machines. It features an advanced graphical editor (including cut copy and paste facilities, multiple undo, etc.). Machines can be run at full speed or step mode, and debugged using breakpoints and variable windows. The binary executables of this software are freeware and available from <www.cheransoft.com/vturing/download.html>.

3.5 Petri Nets In contrast with other kinds of automata that are only studied from a theoretical point of view, the design and use of Petri Nets is an active research area with several industrial applications. SIMPRES <www.ida.liu.se/~luico/> SIMPRES is a simulator for a subset of this particular computational mode corresponding to time Petri nets. For teaching purposes we found the SIMPRES simulator as the best alternative for our students. It is intended to represent embedded systems, which extend Petri nets adding data and real-time information to tokens, and associating functions and delays to transitions. Petri Net Simulator <http://cs.uns.edu.ar/~cic/fcc.htm> This Petri Net simulator provides the basic facilities for specifying and executing a Petri Net in a step-by-step fashion. Guidance on FLAT Software Levels of Abstraction Views

From our experiences, using simulators as teaching aids to complement the different topics presented in a FLAT course encourages different views for simulating a given automaton - with strong pedagogical impact. McDonald proposes four different views in [11]: (1) tape view (showing the current input tape); (2) stack view (showing the current stack); (3) path view (verbose mode); and (4) automata image view (PDA visualization as a graph). In our opinion, these four views can be generalized to consider different classes of automata presented in a FLAT course. Next we discuss some guidelines for considering these elements in a more general setting: Input/Output View: In the case of FSA, PDA, or Turing Machines, visualizing the tape onto which the input string is written provides the basic input view. In the case of Turing machines, the same tape is used as an input/output device. Tapes are easy structures to model as they behave like sequential files. Most students taking a FLAT course have already worked with sequential files so they should be able to think about a tape as a file. Hence it is important to borrow the same visual conventions for representing sequential files in order to represent tapes (e.g. the representation of the current cell/record to be processed, etc.). Other automata are not tape-based. In such cases a clear representation of input and output values is also needed. In the case of Petri nets, most computer simulators represent tokens in places as circles or numerical values (i.e. the numbers of tokens in a given place). Petri nets can also be used as language recognizers by labeling transitions with symbols in a given alphabet. In that case, transitions being fired provide an output for the Petri net similar to a production rule. Storage (or auxiliary data) View: Some automata (such as pushdown automata) rely on particular storage structures when solving problems (e.g. a stack). In other cases (such as Turing machines) it may be useful to have snapshots of every instance of the tape after each single step executed by the automaton when it was run. Such snapshots can help understand the way computation proceeds in complex settings (e.g. Turing machines with multiple tapes). Auxiliary structures should be visible and properly updated as the automaton is being simulated. Path view: In this view the student should be able to read a natural language description of every action performed by the automaton with a given input string. Two possibilities should be taken into account: 1) Basic path view: every action is shown as an item in a list. The item consists of a term explaining the basic meaning of the action.
E.g.: State s0, read 'a'. State s1, read 'b', etc.

2) Full path view: actions are described in a full-fledged text. The student would get a detailed explanation of every step performed during the execution. For example:
The initial input string is aabbcc. Current symbol is a Current state is s0. After processing symbol "a", next state is s1 and current input string is abbcc Now current state is s1.

Image view: This view should provide a graph-like representation of automaton in the same way the student would see it on a classroom board. After building the automaton, students may execute it by providing an arbitrary input string. As the automaton is being run, current states and arcs are easy recognizable (e.g. by highlighting them). States and paths already visited may be distinguished from those that were not yet reached (e.g. as done in [5]). Such conventions are intuitively helpful for identifying loops and unreachable states.

Zoom in/out view: Features for zooming in and out all relevant information for a given automaton should be provided. Some simulators (e.g. DEM or VisualTuring) provide ways of invoking sub-machines (sub-automata) for solving a problem. This favors a modular approach (playing the role of subprograms in a procedural programming language), making it easier for the student to cope with complex problems. Conclusions

Theoretical computer simulators provide an interesting link between theory and practice. In our opinion, FLAT simulation environments reinforce the significance of theoretical issues when solving practical exercises. According to our teaching experience, most topics in FLAT course can be illustrated using such simulators, most of which are freely available via the Internet (URLs have been provided). Multi-purpose simulator programs (such DEM, Minerva, and JFLAP) are a good choice as they provide a unified view of different kinds of automata. However, we also found many students were quite enthusiastic to try different simulators rather than concentrating in a single simulator. It is our experience that multiple simulators with contrasting views for the same automaton can provide profound insights into FLAT concepts while keeping the role of simulators as tools and not the topic of the course. Acknowledgments The authors want to thank Professor Jrgen Dix (University of Manchester, UK) for his comments on the use of busy beaver functions as additional motivation when teaching Turing machines. References [1] Augusto, J.C. Fundamentos de Ciencias de la Computacin Notas de Curso. Universidad Nacional del Sur, Argentina, (1995). [2] Bilska, A.O. et al. A Collection of Tools for Making Automata Theory and Formal Languages Come Alive. ACM SIGCSE Bulletin 29, 1 (1997), 15-19. [3] Estrebou, F. et al. Minerva: Una Herramienta Para un Curso de Lenguajes Formales y Autmatas. Latinamerican Conference in Informatics (CLEI), Montevideo, Uruguay, (2002). [4] Gramond, E. and S.H. Rodger. Using JFLAP to Interact with Theorems in Automata Theory. ACM SIGCSE Bulletin 31, 1 (1999), 336-340. [5] Grinder, M.T. Animating Automata: A Cross-Platform Program for Teaching Finite Automata. ACM SIGCSE Bulletin 34, 1 (2002), 63-67. [6] Grinder, M.T. et al. Loving to Learn Theory: Active Learning Modules for the Theory of Computing. ACM SIGCSE Bulletin 34, 1 (2002), 371-375. [7] Hung, T. and Roger, S. H. Increasing Visualization and Interaction in the Automata Theory Course. ACM SIGCSE Bulletin 32, 1 (2000), 6-10. [8] Hopcroft, J. and Ullman, J. Introduction to Automata Theory, Languages and Computation. Addison-Wesley, (1979). [9] Lewis, H. and Papadimitriou, C. Elements of the Theory of Computation 2nd Edition. Prentice-Hall, (1998). [10] LoSacco, M. and S.H. Rodger. FLAP: A Tool for Drawing and Simulating Automata. ED-MEDIA (1993). [11] McDonald, J. Interactive Pushdown Automata Animation. ACM SIGCSE Bulletin 34, 1 (2002), 376-380. [12] Procopiuc, M., O. Procopiuc, and S.H. Rodger. Visualization and Interaction in the Computer Science Formal Languages Course with JFLAP. ASEE/IEEE Frontiers in Education (FIE) Conference, (1996). [13] Robinson, M.B. et al. A Java-based Tool for Reasoning About Models of Computation Through Simulating Finite Automata and Turing Machines. ACM SIGCSE Conference, (1999), 105-109. [14] Rodger, S.H. Integrating Hands-On Work into the Formal Languages Course via Tools and Programming. Workshop on Implementing Automata/Lecture Notes in C. S. (LNCS) 1260, Springer-Verlag, (1996), 132-148. [15] Taylor, G. Models of Computation and Formal Languages. Oxford University Press, (1998). [16] Wolffe, G.S., W. Yurcik, H. Osborne, and M.A. Holliday. Teaching Computer Organization/Architecture With Limited Resources Using Simulators. ACM SIGCSE Bulletin 34, 1 (2002), 176-180.

You might also like