To save content items to your account,
please confirm that you agree to abide by our usage policies.
If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account.
Find out more about saving content to .
To save content items to your Kindle, first ensure no-reply@cambridge.org
is added to your Approved Personal Document E-mail List under your Personal Document Settings
on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part
of your Kindle email address below.
Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations.
‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi.
‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Living systems on our planet rely on the construction of long molecules by linking relatively small units into sequences where each pair of adjoining units is connected in a uniform manner. The units of polypeptides (proteins) are a set of twenty amino acids. These units are connected by the carboxyl group (COOH) of one unit being joined through the amino group (NH2) of the next unit, with a water molecule being deleted in the process. The units of RNA are a set of four ribonucleotides. These units are connected by the phosphate group (PO4 attached at the 5′ carbon) of one unit being joined through replacement of the hydroxyl group (OH attached at the 3′ carbon) of the next unit, with a water molecule being deleted in the process. The units of single stranded DNA are a set of four deoxyribonucleotides with the joining process as in the case of RNA.
Molecules lie in three-dimensional space, whereas words lie on a line. One may adopt the convention of listing the amino acids of a protein on a line with the free amino group on the left and the free carboxyl group on the right. For both single stranded RNA and DNA molecules one may adopt the convention of listing their units on a line with the phosphate at the left and the free hydroxyl group at the right. These conventions allow us to model (without ambiguity) these biopolymers as words over finite alphabets: a twenty letter alphabet of symbols that denote the twenty amino acids and two four letter alphabets of symbols denoting the four units for RNA and DNA, respectively.
A grammar is intuitively a set of rules which are used to construct a language contained in Σ* for some alphabet Σ. These rules allow us to replace symbols or strings of symbols with other symbols or strings of symbols until we finally have strings of symbols contained in Σ allowing us to form an element of the language. By placing restrictions on the rules, we shall see that we can develop different types of languages. In particular we can restrict our rules to produce desirable qualities in our language. For example in our examples below we would not want 3 + ÷4 − ×6. We also would not want a sentence Slowly cowboy the leaped sunset. Suppose that we begin with a word add, and that we have a rule that allows us to replace add with A + B and that both A and B can be replaced with any nonnegative integer less that ten. Using this rule, we can replace A with 5 and B with 3 to get 5 + 3. There might also be an additional rule that allows us to replace add with a different string of symbols.
If we add further rules that A can be replaced by A + B and B can be replaced by A × B, we can start by replacing add with A + B. If we then replace A with A + B and B with A × B, we get A + B + A × B.
An automaton is a device which recognizes or accepts certain elements of Σ*, where Σ is a finite alphabet. Since the elements accepted by the automaton are a subset of Σ*, they form a language. Therefore each automaton will recognize or accept a language contained in Σ*. The language of Σ* consisting of the words accepted by an automaton M is the language over Σ* accepted byM and denoted M(L). We will be interested in the types of language an automaton accepts.
Definition 3.1A deterministic automaton, denoted by (Σ, Q, s0, ϒ, F), consists of a finite alphabet Σ, a finite set Q of states, and a function ϒ : Q × Σ → Q, called the transition function and a set F of acceptance states. The set Q contains an element s0 and a subset F, the set of acceptance states.
The input of ϒ is a letter of Σ and a state belonging to Q. The output is a state of Q (possibly the same one). If the automaton is in state s and “reads” the letter a, then (s, a) is the input for ϒ and ϒ(s, a) is the next state. Given a string in Σ* the automaton “reads” the string or word as follows. Beginning at the initial state s0, and beginning with the first letter in the string (if the string is nonempty), it reads the first letter of the string. If the first letter is the letter a of Σ, then it “moves” to state s = ϒ(s0, a).
This book serves two purposes, the first is as a text and the second is for someone wishing to explore topics not found in other automata theory texts. It was originally written as a text book for anyone seeking to learn the basic theories of automata, languages, and Turing machines. In the first five chapters, the book presents the necessary basic material for the study of these theories. Examples of topics included are: regular languages and Kleene's Theorem; minimal automata and syntactic monoids; the relationship between context-free languages and pushdown automata; and Turing machines and decidability. The exposition is gentle but rigorous, with many examples and exercises (teachers using the book with their course may obtain a copy of the solution manual by sending an email to solutions@cambridge.org). It includes topics not found in other texts such as codes, retracts, and semiretracts.
Thanks primarily to Tom Head, the book has been expanded so that it should be of interest to people in mathematics, computer science, biology, and possibly other areas. Thus, the second purpose of the book is to provide material for someone already familiar with the basic topics mentioned above, but seeking to explore topics not found in other automata theory books.
The two final chapters introduce two programs of research not previously included in beginning expositions. Chapter 6 introduces a visually inspired approach to languages allowed by the unique representation of each word as a power of a primitive word. The required elements of the theory of combinatorics on words are included in the exposition of this chapter.
MATLAB is exceptionally strong in linear algebra, numerical methods, and graphical interpretation of data. It is easily programmed and relatively easy to learn to use. Hence, it has proven invaluable to engineers and scientists who rely on the scientific techniques and methods at which MATLAB excels. Very often the individuals and groups that so employ MATLAB are primarily interested in the numbers and graphs that emerge from MATLAB commands, processes and programs. Therefore, it is enough for them to work in a MATLAB Command Window, from which they can easily print or export their desired output.
However, other practitioners of mathematical software find themselves with two additional requirements. First, they need a mathematical software package embedded in an interactive environment, in which it is easy to make changes and regenerate results. Second, they need a higher-level presentation mode, which integrates computation and graphics with text, uses different formats for input and output, and communicates effortlessly with other software applications. These additional requirements can be accomplished using either cells and the publish command, or else the M-book interface, both of which were briefly described in Chapter 3. The present chapter goes into more detail and discusses some of the fine points of these methods.
Fine Points of Publishing
As we mentioned Chapter 3, the simplest way to produce a finished presentation with MATLAB is to prepare your work in a script M-file and then publish the result.
MATLAB is a high-level technical computing language and interactive environment for algorithm development, data visualization, data analysis, and numerical computation. Using MATLAB, you can solve technical computing problems faster than with traditional programming languages, such as C, C++, and Fortran. – The MathWorks, Inc.
That statement encapsulates the view of The MathWorks, Inc., the developer of MATLAB®. MATLAB 7 is an ambitious program. It contains hundreds of commands to do mathematics. You can use it to graph functions, solve equations, perform statistical tests, and much more. It is a high-level programming language that can communicate with its cousins, e.g., Fortran and C. You can produce sound and animate graphics. You can do simulations and modeling (especially if you have access not just to basic MATLAB but also to its accessory Simulink®). You can prepare materials for export to the World Wide Web. In addition, you can use MATLAB to combine mathematical computations with text and graphics in order to produce a polished, integrated, interactive document.
A program this sophisticated contains many features and options. There are literally hundreds of useful commands at your disposal. The MATLAB help documentation contains thousands of entries. The standard references, whether the MathWorks User's Guide for the product, or any of our competitors, contain a myriad of tables describing an endless stream of commands, options, and features that the user might be expected to learn or access.
In this chapter we describe an effective procedure for working with MATLAB, and for preparing and presenting the results of a MATLAB session. In particular we discuss some features of the MATLAB interface and the use of M-files. We introduce a new command in MATLAB 7, publish, which produces formatted output. We also give some simple hints for debugging your M-files.
The MATLAB Interface
Starting with version 6, MATLAB has an interface called the MATLAB Desktop. Embedded inside it is the Command Window that we described in Chapter 2.
The Desktop
By default, the MATLAB Desktop (Figure 1.1 in Chapter 1) contains four windows inside it, the Command Window on the right, the Current Directory Browser and the Workspace Browser in the upper left, and the Command History Window in the lower left. Notice that there are tabs for alternating between the Current Directory and Workspace Browsers. You can change which windows are currently visible with the Desktop menu (in MATLAB 6, the View menu) at the top of the Desktop, and you can adjust the sizes of the windows by dragging their edges with the mouse. The Command Window is where you type the commands and instructions that cause MATLAB to evaluate, compute, draw, and perform all the other wonderful magic that we describe in this book. We will discuss the other windows in separate sections below.
With MATLAB you can create your own Graphical User Interface, or GUI, which consists of a Figure window containing menus, buttons, text, graphics, etc., that a user can manipulate interactively with the mouse and keyboard. There are two main steps in creating a GUI: one is designing its layout, and the other is writing callback functions that perform the desired operations when the user selects different features.
GUI Layout and GUIDE
Specifying the location and properties of various objects in a GUI can be done with commands such as uicontrol, uimenu, and uicontextmenu in an M-file. MATLAB also provides an interactive tool (a GUI itself!) called GUIDE (this stands for Graphical User Interface Development Environment) that greatly simplifies the task of building a GUI. We will describe here how to get started writing GUIs with the MATLAB 7 version of GUIDE, which has some significant enhancements over earlier versions. The version of GUIDE in MATLAB 6 is roughly similar, but some of the menu items and options are different or missing.
✓ One possible drawback of GUIDE is that it equips your GUI with commands that are new in MATLAB 7 and it saves the layout of the GUI in a binary.fig file. If your goal is to create a robust GUI that many different users can use with different versions of MATLAB, you may be better off writing the GUI from scratch as an M-file.
Every time you create an M-file, you are writing a computer program using the MATLAB programming language. You can do quite a lot in MATLAB using no more than the most basic programming techniques that we have already introduced. In particular, we discussed simple loops (using for) and a rudimentary approach to debugging in Chapter 3. In this chapter, we will cover some further programming commands and techniques that are useful for attacking more complicated problems with MATLAB. If you are already familiar with another programming language, much of this material will be quite easy for you to pick up!
✓ Many MATLAB commands are themselves M-files, which you can examine using type or edit, e.g., enter type isprime to see the M-file for the command isprime. You can learn a lot about MATLAB programming techniques by inspecting the built-in M-files.
Branching
For many user-defined functions, you can use a function M-file that executes the same sequence of commands for each input. However, one often wants a function to perform a different sequence of commands in different cases, depending on the input. You can accomplish this with a branching command, and, as in many other programming languages, branching in MATLAB is usually done with the command if, which we will discuss now. Later we will describe the other main branching command, switch.
Branching with if
For a simple illustration of branching with if, consider the following function M-file absval.m, which computes the absolute value of a real number.