types of automata and its applications

51
Term Paper (THEORY OF COMPUTATION) ON REAL WORLD APPLICATIONS OF DIFFERENT TYPES OF AUTOMATA Submitted By: Vishaldeep Singh Section: K18E3 Roll No. : 03 Reg. No.: 10802706

Upload: vishaldeep-singh

Post on 24-Apr-2015

8.560 views

Category:

Documents


60 download

TRANSCRIPT

Page 1: Types of automata and its applications

Term Paper(THEORY OF COMPUTATION)

ON

REAL WORLD APPLICATIONS OFDIFFERENT TYPES OF AUTOMATA

Submitted By:

Vishaldeep Singh

Section: K18E3

Roll No. : 03

Reg. No.: 10802706

Page 2: Types of automata and its applications

Serial

No.

CONTENTS

1 Introduction

2 General Applications of Automata

Biology

Cellular Automata

Game for Life Pascal’s Triangle Brain’s Brain

Finite Automata Applications

Other Applications

TYPES OF AUTOMATA AND APPLICATIONS

TURING MACHINE

LINEAR BOUNDED AUTOMATA

PUSH DOWN AUTOMATA

FINITE AUTOMATA

3 Turing Machine

Real time Implementation

Software Implementation

4 Applications of Turing Machine

Turing Machine Counting

Turing Machine Subtraction

3-State Busy Beaver

4-State Busy Beaver

Justification

5 Linear Bounded Automata

Page 3: Types of automata and its applications

6 Applications of LBA

Genetic Programming

Parse Trees

Emptiness Problem

7 Push Down Automata

8 Applications of PDA

Online Transaction process system

The UPPAAL tool

Tower of Hanoi (Recursive Solution)

Timed Automata Model

Deterministic Top Down Parsing LL Grammar

Context free Language

Predictive Bottom up Parsing LR Grammar

Converting a PDA

9 Finite Automata

10 Applications of Finite Automata

Finite State Programming

Event Driven Finite State Machine(FSM)

Virtual FSM

DFA based text filter in Java

Acceptors and Recognizers

Transducers

UML state diagrams

Hardware Applications

FSM Real Time Scenario 1

FSM Real Time Scenario 2

11 Conclusion

Page 4: Types of automata and its applications

INTRODUCTION

Automata theory is the basis for the theory of formal languages. A propertreatment of formal language theory begins with some basic definitions:

A symbol is simply a character, an abstraction that is meaningless by itself. An alphabet is a finite set of symbols. A word is a finite string of symbols from a given alphabet. Finally, a language is a set of words formed from a given alphabet.

The set of words that form a language is usually infinite, although it maybe finite or empty as well. Formal languages are treated like mathematical sets, sothey can undergo standard set theory operations such as union and intersection.Additionally, operating on languages always produces a language. As sets, they aredefined and classified using techniques of automata theory.

Formal languages are normally defined in one of three ways, all of which can bedescribed by automata theory:

regular expressions standard automata a formal grammar system

Regular Expressions Example :

alphabet A1 = {a, b}alphabet A2 = {1, 2}

language L1 = the set of all words over A1 = {a, aab, ...}language L2 = the set of all words over A2 = {2, 11221, ...}language L3 = L1 ∪ L2

language L4 = {an | n is even} = {aa, aaaa, ...}

language L5 = {anbn | n is natural} = {ab, aabb, ...}

Languages can also be defined by any kind of automaton, like a Turing Machine. In general, any automataor machine M operating on an alphabet A can produce a perfectly valid language L. The system could be

Page 5: Types of automata and its applications

represented by a bounded Turing Machine tape, for example, with each cellrepresenting a word. After the instructions halt, any word with value 1 (or ON) isaccepted and becomes part of the generated language. From this idea, one candefne the complexity of a language, which can be classified as P or NP, exponential,or probabilistic, for example.

Noam Chomsky extended the automata theory idea of complexity hierarchy toa formal language hierarchy, which led to the concept of formal grammar. A formalgrammar system is a kind of automata specifically defined for linguistic purposes.The parameters of formal grammar are generally defined as:

a set of non-terminal symbols N a set of terminal symbols Σ a set of production rules P a start symbol S

Grammar Example:

start symbol = Snon-terminals = {S}terminals = {a, b}production rules: S → aSb, S → ba

S → aSb → ababS → aSb → aaSbb → aababb

L = {abab, aababb, ...}

As in purely mathematical automata, grammar automata can produce a widevariety of complex languages from only a few symbols and a few production rules.Chomsky's hierarchy defines four nested classes of languages, where the moreprecise a classes have stricter limitations on their grammatical production rules.

The formality of automata theory can be applied to the analysis and manipulationof actual human language as well as the development of human-computerinteraction (HCI) and artificial intelligence (AI).

Page 6: Types of automata and its applications

GENERAL APPLICATIONS OFAUTOMATA

Biology:

To the casual observer, biology is an impossibly complex science. Traditionally, theintricacy and variation found in life science has been attributed to the notionof natural selection. Species become "intentionally" complex because it increasestheir chance for survival. For example, a camouflage-patterned toad will have a farlower risk of being eaten by a python than a frog coloured entirely in orange. Thisidea makes sense, but automata theory offers a simpler and more logicalexplanation, one that relies not on random, optimizing mutations but on a simpleset of rules.

Basic automata theory shows that simplicity can naturally generate complexity.Apparent randomness in a system results only from inherent complexities in thebehaviour of automata, and seemingly endless variations in outcome are only theproducts of different initial states. A simple mathematical example of this notion isfound in irrational numbers. The square root of nine is just 3, but the square rootof ten has no definable characteristics. One could compute the decimal digits forthe lifetime of the universe and never find any kind of recurring patter or orderlyprogression; instead, the sequence of numbers seems utterly random. Similarresults are found in simple two-dimensional cellular automaton. These structuresform gaskets and fractals that sometimes appear orderly and geometric, but canresemble random noise without adding any states or instructions to the set ofproduction rules.

The most classic merging of automata theory and biology is John Conway's Gameof Life. "Life" is probably the most frequently written program in elementarycomputer science. The basic structure of Life is a two-dimensional cellularautomaton that is given a start state of any number of filled cells. Each time step,or generation, switches cells on or off depending on the state of the cells thatsurround it. The rules are defined as follows:

Page 7: Types of automata and its applications

All eight of the cells surrounding the current one are checked to see if theyare on or not.

Any cells that are on are counted, and this count is then used to determinewhat will happen to the current cell:

1. Death: if the count is less than 2 or greater than 3, the current cell isswitched off.

2. Survival: if (a) the count is exactly 2, or (b) the count is exactly 3 andthe current cell is on, the current cell is left unchanged.

3. Birth: if the current cell is off and the count is exactly 3, the currentcell is switched on.

Like any manifestation of automata theory, the Game of Life can be defined usingextremely simple and concise rules, but can produce incredibly complex andintricate patterns.

In addition to the species-level complexity illustrated by the Game of Life,complexity within an individual organism can also be explained using automatatheory. An organism might be complex in its full form, but examining constituentparts reveals consistency, symmetry, and patterns. Simple organisms, like mapleleaves and star fish, even suggest mathematical structure in their full form. Usingideas of automata theory as a basis for generating the wide variety of life forms wesee today, it becomes easier to think that sets of mathematical rules might beresponsible for the complexity we notice every day.

Inter-species observations also support the notion of automata theory instead ofthe specific and random optimization in natural selection. For example, there arestriking similarities in patterns between very different organisms:

Mollusks and pine cones grow by the Fibonacci sequence, reproducible bymath.

Leopards and snakes can have nearly identical pigmentation patterns,reproducible by two-dimensional automata.

With these ideas in mind, it is difficult not to imagine that any biological attributecan be simulated with abstract machines and reduced to a more manageable levelof simplicity.

Page 8: Types of automata and its applications

Cellular Automata:

The history of cellular automata dates back to the forties with Stanislas Ulam. Thismathematician was interested in the evolution of graphic constructions generatedby simple rules. The base of his construction was a two-dimensional space dividedinto "cells", a sort of grid. Each of these cells could have two states : ON or OFF.Starting from a given pattern, the following generation was determined accordingto neighbourhood rules. For example, if a cell was in contact with two "ON" cells, itwould switch on too ; otherwise it would switch off. Ulam, who used one of thefirst computers, quickly noticed that this mechanism permitted to generatecomplex and graceful figures and that these figures could, in some cases, self-reproduce. Extremely simple rules permitted to build very complex patterns. Onthat basis, the following question was asked : can these recursive mechanisms (i.e.in that case depending on their own previous state) explain the complexity of thereal ? Is this complexity only apparent, the fundamental rules being themselvessimple.Cellular automata left laboratories in 1970 with the now famous Game of Life ofJohn Horton Conway.

(I) Game for Life

Like Ulam's cellular spaces, the game of life is based a grid constituted of cells, forexample :

Determination of neighbourhood

Page 9: Types of automata and its applications

First generation

Second generation

Example of a 1 dimension automaton (Pascal's triangle)

It is also possible to modify the determination of neighbourhood. If we considertwo dimensions automata, the most common neighbourhoods are6 :

For example, Fredkin's automata, that uses a Moore neighbourhood is based onthe parity of neighbourhood. It's a totalistic automaton, that is to say the state ofthe cells depends on the sum of the states of neighbouring cells. In this case thereis reproduction only if there is an odd neighbourhood value. This automata has gotthe remarkable property to reproduce nine copies of any basic pattern. Fredkin'srule can easily be generalized to more than two dimensions.

(II) Pascal’s Triangle

Pascal’s triangle is an array of numbers which has found uses in many areas ofmathematics.

11 1

Page 10: Types of automata and its applications

1 2 11 3 3 1

1 4 6 ? 1Do you see the pattern?

Example

Can you find the missing number?

Example

Can you find the next row?

Answer: The missing number is 4 and is found by adding the two numbers above

the empty space.

Answer: The next row is formed by the addition rule for finding missing spaces: 1,

5, 10, 10, 5, 1.

The 1’s on either end also follow this rule if there are implicit zeros. So the triangle

really looks

like

. . . 0 1 0 . . .. . . 0 1 1 0 . . .

. . . 0 1 2 1 0 . . .. . . 0 1 3 3 1 0 . . .

. . . 0 1 4 6 4 1 0 . . .One of the most common uses of numbers from Pascal’s triangle is in the binomialformulas,

Page 11: Types of automata and its applications

such as:

The coefficients of (a + b)ncome from row n of Pascal’s triangle.

(III) Brain’s Brain:

It is also possible to modify the number of states. You needn't restrict yourself toboth states life/death. Numerous famous automata use more than two states. Oneof the most famous is Brian's Brains presented by Brian Silverman in 1984. Thisthree states automaton (life, ghost, death) generates a wide diversity of complexgliders within astonishing graphic patterns.

Brian's Brain

In a general way, it is possible to build any type of automata by playingon structural and functional rules. The first ones define the spatial structure of theautomata network, that is its number of dimensions, the disposition of cells(squares, hexagons,… in a two dimensional automaton) and the type ofneighbourhood determination. The second ones will determine the number ofstates and the transition rules8. The choice of these two types of rules permits tobuild a universe adapted to the demanded aim.

Page 12: Types of automata and its applications

Finite Automata Applications:

� Software for designing and checking the behaviour of digital circuits

� Lexical analyzer of a typical compiler

� Lexical analyzer of a typical compiler

�finding

� Sowa r e for ver i fyi ng systems of al l types that have a fini te numb er ofstates (e.g., stock market transaction, communication/network protocol)

Other Applications :

Many other branches of science also involve unbelievable levels of complexity,impossibly large degrees of variation, and apparently random processes, so itmakes sense that automata theory can contribute to a better scientificunderstanding of these areas as well. The modern-day pioneer of cellular automataapplications is Stephen Wolfram, who argues that the entire universe mighteventually be describable as a machine with finite sets of states and rules and asingle initial condition. He relates automata theory to a wide variety of scientificpursuits, including:

Fluid Flow Snowflake and crystal formation Chaos theory Cosmology Financial analysis

Graphical Application of Cellular Automata

Page 13: Types of automata and its applications

Types of Automata&

Applications

(1.) Turing Machine

(2.) Linear Bound Automata

(3.) Push Down Automata

(4.) Finite Automata

Page 14: Types of automata and its applications

TURING MACHINE

Introduction:

A Turing machine is a theoretical device that manipulates symbols on a strip oftape according to a table of rules. Despite its simplicity, a Turing machine can beadapted to simulate the logic of any computer algorithm, and is particularly usefulin explaining the functions of a CPU inside a computer.

The "Turing" machine was described by Alan Turing in 1936, who called it an"(automatic)-machine". The Turing machine is not intended as a practicalcomputing technology, but rather as a thought experiment representing acomputing machine. Turing machines help computer scientists understand thelimits of mechanical computation.

Real Time Implementation

Read/Write Head

The read/write head is the center of the machine. The tape in the machine is a1000’ roll of white 35mm film leader. The characters are written by the machinewith a black dry erase marker. Each character cell is 1.125” in width. Although thetape is not infinite in length, it is long enough for any practical use and can holdapproximately 10K bits worth of binary data.

Page 15: Types of automata and its applications

The read/write head from the front The read/write head from the top. Here you cansee the servo that controls the "Y" axis of thepen. The base of the head is 8.5 x 4".

(1)View from the back of the head showing the transport system. The stepper motor is at the lower leftand includes a home sensor.

(2)Here is one of the film drive cogs with its cover/hold down moved aside. There is one cover at each endon the read/write head base.

(1). Back view of the write section of the head. Here you can see the two servos, one for the Y axis, theother for pen lift. The pen is fit into and slides through telescoping brass tubes.

(2). Line scan camera and illumination section. The TSL-1401 linescan camera captures 128 bits of data ina single line. Exposure time is about 1/200 sec.

Page 16: Types of automata and its applications

(1). View of the erase section from the back. The mechanism is raised and lower with the small pin thatcomes through the base of the head. This pin rides on a cam attached to a servo.

(2). The erase section from the top. The erase cylinder is covered with 1/4" thick felt. The whole erasesection pivots when it is raised and lowered on a small shaft attached to the frame.

Schematic of the electrical components of the Turing machine.

Page 17: Types of automata and its applications

Software Overview:

The Turing machine is controlled by a Parallax Propeller chip. Most of theprogramming for the machine is done in the Propeller chip's Spin language. Thereare two major sections of the programming. One deals with the user interactionsand the other is the actual running of the Turing states.

User interactions:

Loading programs from SD card. Formally, these programs are called statesor transition rules.

Creating a default tape. Programs often work on a tape that has somenumber already on it and these can be edited by the user.

Utility functions. This includes things like moving the tape to a new position,erasing a bulk section of the tape, and changing the way a program runs orsteps through its actions.

Turing Machine Loop:

Reads, writes and erases the tape.

Finds the state rule that matches the current state and what was read fromthe cell.

Updates the feedback display.

Page 18: Types of automata and its applications

Applications of Turing Machine

(1.) Turing Machine Counting

Counting is one of the first math skills we learn. It's really not that much different for a computeror a Turing machine except they normally use binary numbers, so they count in binary. In thisTuring machine example, you can see the machine following a simple set of steps to count inbinary.

How the Turing Machine Counts

Counting is really just repeatedly adding one to a number. If we count in decimal likemost humans do, we keep adding one to a number. When adding one causes a digit tochange to a zero we have to carry an extra one over to the digit to the left and add itthere. This has become so automatic for us that we seldom even think about it any more.The Turing machine counts in the same way, it's just adding one to the number that iscurrently on the tape. The big difference is that the Turing machine counts in binary.When it changes a digit to a zero it also carries and adds the one to the digit to the left.But because there are only zeros and ones in binary this carry happens a lot more often.The states required for counting with the Turning machine are some of the easiest tounderstand. The three rules that make up state "0" do not change the tape, they simplemove to the right most cell without changing the tape. When a blank cell is found, thetape moves one cell back to the left and changes to state "1".

State "1" is where the counting happens. The three rules of state "1" are really rules foradding one and carrying. We know that we are starting from the right most digit because

Page 19: Types of automata and its applications

we are coming to this state from state "0". If we read a zero, we change it to a one andhave finished adding because there is nothing to carry. So the state is changed back to"0" and the tape is moved back to the right. If though, we read a one, it is changed to azero, and we now need to carry that one to the left. This carry is accomplished with thesecond rule of state "1". It does this by moving to the left one digit and staying in state"1". By staying in state "1" the machine in a sense stays in the add one mode, thuscarrying the one. The machine will stay in state one until it finds a zero to add the one toor it finds a blank. The third rule of state "1" handles blank cells by treating them just likezeros, that is they are changed to a one and the adding of one is completed.

The States Used For This Example (Explanation of the Programming Syntax Used)

(0,1) -> (0,1) Right //This state moves the tape to the right most digit(0,0) -> (0,0) Right //This state moves the tape to the right most digit(0,B) -> (1,B) Left //When a blank at the right is found we change to state1

//This next block, state 1, is where the counting really happens(1,0) -> (0,1) Right //If we change a 0 to a 1 we change back to state 0(1,1) -> (1,0) Left //If we change a 1 to a 0 we keep looking to the left(1,B) -> (0,1) Right //If we change a Blank to a 1 we change back to state 0

For the Keen Observers

Keen observers will note that the sample shown in the video stops on it's own after itreaches 16 in decimal. This was done for the video and only takes one change to theprogram shown above. The third rule of state "1" is changed to:

(1,B) -> (0,1) Halt //If we change a Blank to a 1 we stop

This has the effect of stopping the counting when the tape adds a one to the blank cell atthe left of the number.

For the Really Keen Observers

Really keen observers will note that the sample shown in the video continues to move tothe left after a one was written to the tape. This was done so that the whole tape wasvisible on each pass of adding one. It doesn't change the outcome in any way. It was doneby adding a state "2" and changing state "1" like this:

(1,0) -> (2,1) Left //If we change a 0 to a 1 we change to state 2(1,1) -> (1,0) Left //If we change a 1 to a 0 we keep looking(1,B) -> (0,1) Halt //We have to stop sometime, so if we find a blank westop

(2,1) -> (2,1) Left //This state moves the tape to the left most digit(2,0) -> (2,0) Left //This state moves the tape to the left most digit(2,B) -> (0,B) Right //When the blank at the left is found we switch tostate 0

Page 20: Types of automata and its applications

(2.) Turing Machine Subtraction

Although there are a number of Turing state machines that will accomplish subtraction,this method uses only ones, zeros, and blank cells. It's not that difficult to understandhow a Turing machine does subtraction.

In this example, the space between the number sets separates the two sides of theequation. The machine removes matching "1"s from each side of the equation until thereare no more "1"s on the right side. A count of the "1"s on the left side of the equationgives us the answer.

While there are a large number of states in this example, most of them are responsiblefor finding the parts of the equation and the ends of each part (states 0, 1, 3, 4, 5). Twostates (states 6 and 7) remove the leftover zeros at the end. The two states "2" and "8"remove the ones that match on each side of the equation.

The States Used For This Example :

(0,0) -> (0,0) Right //finds right edge of first number(0,1) -> (0,1) Right(0,B) -> (1,B) Right

(1,0) -> (1,0) Right //finds right edge of second number(1,1) -> (1,1) Right(1,B) -> (2,B) Left

Page 21: Types of automata and its applications

(2,0) -> (2,0) Left //if a 0 keep looking for a 1(2,1) -> (3,0) Left //removed right most 1 from right number(2,B) -> (5,B) Right //if we find a blank before a 1, then erase 0s

(3,0) -> (3,0) Left //move to left number(3,1) -> (3,1) Left(3,B) -> (8,B) Left

(4,0) -> (4,0) Right //finds right edge of first number(4,1) -> (4,1) Right(4,B) -> (5,B) Right

(5,0) -> (5,0) Right //finds right edge of second number(5,1) -> (5,1) Right(5,B) -> (6,B) Left

(6,0) -> (6,B) Left //removed 0 from right number(6,1) -> (6,1) Left(6,B) -> (7,B) Left

(7,0) -> (7, ) Left //removes 0 from left number(7,1) -> (7,1) Left(7,B) -> (9,B) Right

(8,0) -> (8,0) Left //move left looking for a 1 to change to a 0(8,1) -> (0,0) Right //if a 1 is found, change to zero and loopagain(8,B) -> (4,B) Right //if blank then all done, then erase 0s

(9,0) -> (9,0) Halt //halts the program(9,1) -> (9,1) Halt(9,B) -> (9,0) Halt

Page 22: Types of automata and its applications

(3.) A 3-State busy beaver

The busy beaver problem is an interesting theoretical computer science problem. The problemis to find the smallest number of states that outputs as much data as possible yet eventuallyhalts on its own. More formally it goes something like this — given an n-state Turing machinewith a two symbol alphabet {0, 1}, what is the maximum number of 1s that the machine mayprint on an initially blank tape before halting?This problem turns out to be non-computable, that is, for a small number of states an answercan be found, but in general it cannot be solved. Theorists call such problems non-computable.The number of steps it takes to run to completion (halt) grows very rapidly as the number ofstates increase. This 3-state example takes 14 steps while the 4-state example takes 107 steps.Increasing from there, a 5-state example has been found that takes 47,176,870 steps, and a 6-state example that takes 2.584 x102879 steps. I will not be trying any of these in the near future.

The States Used For This Example(0,0) -> (1,1) Right(0,1) -> (0,1) Halt(0,B) -> (1,1) Right

(1,0) -> (2,0) Right(1,1) -> (1,1) Right(1,B) -> (2,0) Right

(2,0) -> (2,1) Left(2,1) -> (0,1) Left(2,B) -> (2,1) Left

Page 23: Types of automata and its applications

(4.) A 4-State busy beaver

The smallest number of states that outputs as much data as possible yet eventually halts on it'sown. More formally it goes something like this — given an n-state Turing machine with a twosymbol alphabet {0, 1}, what is the maximum number of 1s that the machine may print on aninitially blank tape before halting?This problem turns out to be non-computable, that is, for a small number of states an answercan be found, but in general it cannot be solved. Theorists call such problems non-computable.The number of steps it takes to run to completion (halt) grows very rapidly as the number ofstates increase. A 3-state example takes 14 steps while this 4-state example takes 107 steps.Increasing from there, a 5-state example has been found that takes 47,176,870 steps, and a 6-state example that takes 2.584 x102879 steps.

The States Used For This Example(0,0) -> (1,1) Right(0,1) -> (1,1) Left(0,B) -> (1,1) Right

(1,0) -> (0,1) Left(1,1) -> (2,0) Left(1,B) -> (0,1) Left

(2,0) -> (2,1) Halt(2,1) -> (3,1) Left(2,B) -> (2,1) Halt

(3,0) -> (3,1) Right(3,1) -> (0,0) Right(3,B) -> (3,1) Right

Page 24: Types of automata and its applications

Justification:

How the States for the Turing Machine are Written

Programming for my Turing machine is written as simple text files on any computer and savedto SD cards. The states described in these text files are then loaded into and interpreted bythe Turing machine. I use a fairly standard notation for describing the states:( State Number, Symbol Read) -> ( Next State Number, Symbol To Write) Next Cell

Each state normally consists of three rules, one for each of the three symbols (0, 1, blank) thatcan possibly be read from a cell. So the first rule in the following state sample tells themachine:If the machine is in state "1" and there is a zero in the cell, change this to a one, change tostate "0", and move one cell to the left.

(1,0) -> (0,1) Left

(1,1) -> (1,0) Left

(1,B) -> (0,1) Right

The second rule tells the machine:

If there is a one in the cell, change this to a zero, leave the state as "1", and move one cell tothe left.

The third rule tells the machine:

If the cell is blank, change this to a one, change to state "0", and move one cell to the right.

The only other rule you will see in the sample programs is the next cell move of "Halt".

(1,B) -> (0,1) Halt

This is just as it sounds, when this rule is followed the cell is changed from blank to one andthe machine stops.

Summary of The Examples:

While I have taken some liberty with a number of terms and concepts, I hope you can see justhow simple the rules that drive a Turing machine are. Changing ones to zeros, moving one cellto the left or right, these concepts are simple, yet they can compute anything that iscomputable. And from these simple concepts, the most complex computers of today are born.

Page 25: Types of automata and its applications

LINEAR BOUND AUTOMATA

In computer science, a linear bounded automaton (plural linear boundedautomata, abbreviated LBA) is a restricted form of nondeterministic Turingmachine.

Linear bounded automata satisfy the following three conditions:

1. Its input alphabet includes two special symbols, serving as left and right end-

markers.

2. Its transitions may not print other symbols over the end-markers.

3. Its transitions may neither move to the left of the left end-marker or to the

right of the right end-marker.

As in the definition of Turing machines, it possesses a tape made up of cells thatcan contain symbols from a finite alphabet, a head that can read from or write toone cell on the tape at a time and can be moved, and a finite number of states. Itdiffers from a Turing machine in that while the tape is initially considered to haveunbounded length, only a finite contiguous portion of the tape, whose length isa linear function of the length of the initial input, can be accessed by theread/write head. Instead of having potentially infinite tape on which to compute,computation is restricted to the portion of the tape containing the input plus thetwo tape squares holding the end markers. Since the size of the accessible tape isbounded by some linear function of the length of the input, the linear boundedautomaton is computationally equivalent to a nondeterministic Turingmachine restricted to the portion of the tape containing the input, hence thename linear bounded automaton.

This limitation makes the LBA a somewhat more accurate model of computers thatactually exist than a Turing machine, whose definition assumes unlimited tape.

Page 26: Types of automata and its applications

Applications of Linear Bound Automata

(1.) Genetic Programming:

GP is a child of the genetic algorithm (GA). The seminal work on GAs isAdaptation in natural and artificial systems . In outline, Gas work as follows.

1 InitialisationGenerate an initial population at random.

2 EvaluationCompute the fitness of each individual in the population, which is a measure

of how well it meets the requirements.

3 BreedingBreed a new population, favouring fitter individuals as parents.

4 TerminationIf the population contains an individual which meets the requirements, or if

some other limit is reached, then stop. Otherwise continue from

Step 2.For example, suppose we wish to design a roof truss in the form of a trianglewith 2 braces on each side:

Roof truss

Page 27: Types of automata and its applications

We can reasonably expect the truss to be symmetrical, so for a given heightAnd width there are 4 variables, shown in the figure as a, b, c and d. These arereal values within a limited range. We can thus represent any individual designby a real array of length 4, and an initial population of designs could easily begenerated with a random number generator (RNG). An array of 4 reals permitsdesigns where the braces cross each other or cross the centre of the truss. Ifwe want to exclude these or similar possibilities, then a differentrepresentation might be necessary.

(2.) Parse Trees

The input to our algorithm is a set of strings, S, in an SEC q p

language where the dimensionality, p, and degree, q, are known. S must containat least all strings in the language up to a depth d (the value of d is discussedlater). The shortest

string in S is the concatenation of the elements in the axiom. However, there aremultiple possibilities for what the actual axiom is (depending on thedimensionality of the language). From the shortest string, a set of possible

Page 28: Types of automata and its applications

axioms, A, is generated. For example, if p=2 and the shortest string in S is aa,then the set of possible axioms is { (λ, aa), (a, a), (aa, λ) } .

(3.) Emptiness Problem

Page 29: Types of automata and its applications

Example:

Page 30: Types of automata and its applications

PUSH-DOWN AUTOMATA

We discovered that finite automata were far too weak to even tell if an input stringwas of the form anbn. In this section we shall extend the power of finite automataa little so that we can decide membership in sets which cannot be accepted byfinite automata. Let's begin. In fact, let's provide a finite automaton with a datastructure which will allow it to recognize strings of the form a

Recognition AlgorithmIt is clear exactly what happens when the algorithm of figure 1 is used on the inputaaabbb. The machine reads the a's and builds a pile of three discs. Then it readsthe b's and removes the discs from the pile one by one as each b is read. At thispoint it has finished the input and its pile is empty so it accepts. If it was givenaabbb, it would place two discs on the pile and then remove them as it read thefirst two b's. Then it would leave the second while loop with one b left to read(since the pile was empty) and thus not accept. For aaabb it would end with onedisk on the pile and not accept that input either. When given the input stringaabbab, the machine would finish the second loop with ab yet to be read

Page 31: Types of automata and its applications

Applications of Push Down Automata

(1.) Online Transaction Processing system

In this work an attempt is made to model the on-line transaction processingsystem of a banking organization with timed automata. In Figure 2 theorganization of the bank is depicted. It consists of multiple branches withmultiple tellers at each branch.

The transactions that are performedrepresent the work done when acustomer makes a deposit or awithdrawal. Transactions arehandled by a database system,which considers them as concurrentprocesses. For each transaction thereis a set of records, each one ofwhich can be in a locked orunlocked state. The way the concurrent processes are processed by thedatabase system is pictorially presented.

(2.) The UPPAAL tool

A simulation model is a model which is formulated by using arithmetic andalgebraic relations along with non-mathematical logical processes. It consistsof five major components: state variables, variables, functional relations,inputs and outputs. UPPAAL is a tool for modeling, simulating and verifyingreal-time systems. The tool is appropriate for systems that can be modeledas a collection of non-deterministic processes with finite control

Page 32: Types of automata and its applications

structure and real-valued clocks, communicating through channels or sharedvariables.

UPPAAL consists of three main parts: a description language, a simulator and amodel-checker. An automaton contains location and transitions connectingthe locations. In UPPAAL, time is modeled using clock variables. The timingconstraints are attached to transitions or to the locations in the form of labels. Alabel can be a guard that expresses the conditions under which the transitioncan be performed. A transition can contain clocks, boolean variables, integervariables or synchronous channels. A system in UPPAAL consists of a collectionof automata. These automata can communicate using the shared variables orthe synchronous channels. The synchronization of two channels is indicatedby the use of an exclamation mark (!) and a question mark(?). The ! at theend of the channel name indicates that the channel is used for sending. The? is used to indicate that the channel receives. The label of a location consistsof three parts: the name of the location, the option invariant and theoption Committed or Urgent. The invariant indicates the period that theautomaton can remain in the location.

(3.) Tower Of Hanoi (Recursive Solution)

(4.) The Timed Automata Model

In this work a model with three branches and different number of tellers isconsidered where some customers are served while others may arrive. A fiveautomata model has been developed to describe the dynamic processing oftransactions by the bank database system. These five automata have been

Page 33: Types of automata and its applications

given the tag names OLTP, P0, Clock, P2 and P3. The OLTP is the basicautomaton, which is synchronized with the others and is shown.

(5.) Determinsitic Top-Down Parsing and LLGrammars

The basic idea is simple: given the current input symbol and the current non-terminal symbol, usually pushed onto the stack, consult a parsing table, or, inthe jargon of automata theory, a finite state transition function (the currentstate is the current non-terminal symbol), and replace the symbol on the stackwith the proper right-hand side to continue simulating the derivation. SeeFig. 5.9 for an illustration of this process. If the top of the stack is a terminalsymbol and matches the input, then just pop that symbol and continue with therest of the input string. A simplified process is given in the following algorithm.

Page 34: Types of automata and its applications

Figure 5.9: Top-Down Parser as a PDA

(6.) Context-Free Languages

Page 35: Types of automata and its applications

(7.) Predictive Bottom-Up Parsing and LRGrammars

If one does then introduce a new rule S' S and make S' the new startsymbol. Bottom up methods are a little more involved in the theory ofparsing. Consider, for example, the right derivation of theexpression a + b*c:

E E + T E + T*F E + T*id E + T*c E + F*c E + id*c

E + b*c T + b*c F + b*c id + b*c a + b*c.

Example:

Predictive Parse of the expression a + b*cStack Input Action$ a + b*c$ Shiftid$ + b*c$ ReduceF$ + b*c$ ReduceT$ + b*c$ ReduceE$ + b*c$ Reduce+ E$ b*c$ Shiftb + E$ *c$ Shiftid + E$ *c$ ReduceF + E$ *c$ ReduceT + E$ *c$ Reduce*T + E$ c$ Shiftc*T + E$ $ Reduceid*T + E$ $ ReduceF*T + E$ $ ReduceT + E$ $ ReduceE$ $ Accept

(8.) Converting a PDA

In order to change the acceptance mode of a PDA one has to click on the menu

entry Convert. As soon as some PDA has been selected the input file is checked

for errors. If everything is fine a new window, filled with the information of

Page 36: Types of automata and its applications

the chosen PDA, appears.

Converting a PDA

At next the user has to enter a new initial stack symbol, a new start state, and anew final state. Note that these information are needed for both conversions (seeSection 2.3). So it is irrelevant whether the given PDA should be converted into a

PDA that accepts by empty stack or by final state. After that the user has to choosewhether the given PDA accepts by empty stack or by final state, by clicking on thebutton Accepts by Empty Stack or Accepts by Final State. If the first button isselected, the given PDA is converted into a PDA that accepts by final state.Otherwise a PDA that accepts by empty stack is constructed. As soon as one ofthose buttons is pressed the new PDA is displayed in the bottom of the window.Finally, via the Save button it is possible to store the created PDA.

Page 37: Types of automata and its applications

FINITE AUTOMATA

Hardware applications:

The circuit diagram for a 4-bit TTLcounter, a type of state machine

In a digital circuit, an FSM may be built using a programmable logic device,a programmable logic controller, logic gates and flip flops or relays. Morespecifically, a hardware implementation requires a register to store state variables,a block of combinational logic which determines the state transition, and a secondblock of combinational logic that determines the output of an FSM. One of theclassic hardware implementations is the Richards controller.

Mealy and Moore machines produce logic with asynchronous output, becausethere is a propagation delay between the flip-flop and output. This causes sloweroperating frequencies in FSM. A Mealy or Moore machine can be convertible to aFSM which output is directly from a flip-flop, which makes the FSM run at higherfrequencies. This kind of FSM is sometimes called Medvedev FSM.[9] A counter isthe simplest form of this kind of FSM.

Software applicationsThe following concepts are commonly used to build software applications withfinite state machines:

Automata-based programming

Event driven FSM

Virtual FSM (VFSM)

Page 38: Types of automata and its applications

Applications of Finite Automata

(1.) Automata-based programming / Finite StateProgramming

Automata-based programming is a programming paradigm in which theprogram or its part is thought of as a model of a finite state machine (FSM) orany other (often more complicated) formal automaton (see automata theory).Sometimes a potentially-infinite set of possible states is introduced, and such aset can have a complicated structure, not just an enumeration.

FSM-based programming is generally the same, but, formally speaking, doesn'tcover all possible variants as FSM stands for finite state machine andautomata-based programming doesn't necessarily employ FSMs in the strict sense.

The following properties are key indicators for automata-based programming:

Page 39: Types of automata and its applications

The time period of the program's execution is clearly separated down tothe steps of the automaton. Each of the steps is effectively an executionof a code section (same for all the steps), which has a single entry point.Such a section can be a function or other routine, or just a cycle body. Thestep section might be divided down to subsection to be executeddepending on different states, although this is not necessary.

Any communication between the steps is only possible via the explicitlynoted set of variables named the state. Between any two steps, theprogram (or its part created using the automata-based technique)cannot have implicit components of its state, such as local (stack)variables' values, return addresses, the current instruction pointer etc.That is, the state of the whole program, taken at any two moments ofentering the step of the automaton, can only differ in the values of thevariables being considered as the state of the automaton.

Example:

Traditional (imperative) program in CThe program which solves the example task in traditional (imperative) style can look something like this:

#include <stdio.h>int main(void){

int c;do {

c = getchar();while(c == ' ')

c = getchar();while(c != EOF && c != ' ' && c != '\n') {

putchar(c);c = getchar();

}putchar('\n');while(c != EOF && c != '\n')

c = getchar();} while(c != EOF);return 0;

}

Page 40: Types of automata and its applications

Automata-based style program (FSP)The same task can be solved by thinking in terms of finite state machines. Note that line parsing has threestages: skipping the leading spaces, printing the word and skipping the trailing characters. Let's callthem states before, inside and after. The program may now look like this:

#include <stdio.h>int main(void){

enum states {before, inside, after

} state;int c;state = before;while((c = getchar()) != EOF) {

switch(state) {case before:

if(c == '\n') {putchar('\n');

} elseif(c != ' ') {

putchar(c);state = inside;

}break;

case inside:switch(c) {

case ' ': state = after; break;case '\n':

putchar('\n');state = before;break;

default: putchar(c);}break;

case after:if(c == '\n') {

putchar('\n');state = before;

}}

}return 0;

}Although the code now looks longer, it has at least one significant advantage:there's only one reading (that is, call to the getchar() function) instruction in the

Page 41: Types of automata and its applications

program. Besides that, there's only one loop instead of the four the previousversions had.

In this program, the body of the while loop is the automaton step, and the loopitself is the cycle of the automaton's work.

The program implements (models) the work of a finite state machine shown on thepicture. The N denotes the end of line character, the S denotes spaces, andthe A stands for all the other characters. The automaton follows exactly one arrowon each step depending on the current state and the encountered character. Somestate switches are accompanied with printing the character; such arrows aremarked with asterisks.

(2.) Event driven finite state machine

In computation, a finite-state machine (FSM) is event driven if the transition fromone state to another is triggered by an event or a message. This is in contrast to theparsing-theory origins of the term finite-state machine where the machine isdescribed as consuming characters or tokens.

Often these machines are implemented as threads or processes communicatingwith one another as part of a larger application. For example, a telecommunicationprotocol is most of the time implemented as an event-driven finite-state machine.

(3.) Virtual Finite State Machine

A virtual finite state machine is a finite state machine (FSM) defined in a virtualenvironment. The VFSM concept provides a software specification method todescribe the behaviour of a control system using assigned names of input controlproperties and of output actions.

Page 42: Types of automata and its applications

The VFSM method introduces an execution model and facilitates the idea ofan executable specification. This technology is mainly used in complex machinecontrol, instrumentation and telecommunication applications.

(4.) A DFA-based Text Filter in Java

The first thing to deal with is the input alphabet. The DFA above uses thealphabet 0, 1, which is the alphabet of interest for this problem. But theprogram will work with a typed input string, so we do not have the luxuryof restricting the alphabet in this way. The program should accept ”011” (arepresentation for the number 3) and reject ”101” (a representation for thenumber 5), but it must also properly reject strings like ”01i” and ”fred”. Thealphabet for the Java implementation must be the whole set of charactersthat can occur in a Java stringthat is, the whole set of values making up theJava char type. The DFA we actually implement will have four states, likethis:

(5.) Acceptors and recognizers

Acceptors and recognizers (also sequence detectors) produce a binary output,saying either yes or no to answer whether the input is accepted by the machine ornot. All states of the FSM are said to be either accepting or not accepting. At thetime when all input is processed, if the current state is an accepting state, the inputis accepted; otherwise it is rejected. As a rule the input are symbols (characters);

Page 43: Types of automata and its applications

actions are not used. The example in figure 2 shows a finite state machine whichaccepts the word ”nice”. In this FSM the only accepting state is number 7.Themachine can also be described as defining a language, which would contain everyword accepted by the machine but none of the rejected ones; we say then that thelanguage is accepted by the machine. By definition, the languages accepted byFSMs are the regular languages - that is, a language is regular if there is some FSMthat accepts it. Start state The start state is usually shown drawn with an arrow”pointing at it from anywhere” Accept state An accept state (sometimes referredto as an accepting state) is a state at which the machine has successfully performedits procedure. It is usually represented by a double circle. An example of anaccepting state appears on the right in this diagram of a deterministic finiteautomaton (DFA) which determines if the binary input 4 contains an even numberof 0s. S1 (which is also the start state) indicates the state at which an even numberof 0s has been input and is therefore defined as an accepting state. This machinewill give a correct end state if the binary number contains an even number of zerosincluding a string with no zeros. Examples of strings ac-cepted by this DFA are epsilon (the empty string), 1, 11, 11..., 00, 010, 1010,10110and so on.

(6.) Transducers

Transducers generate output based on a given input and/or a state using actions.They are used for control applications and in the field of computational linguistics.Here two types are distinguished:

Moore machineThe FSM uses only entry actions, i.e. output depends only on the state. Theadvantage of the Moore model is a simplification of the behaviour. Consider anelevator door. The state machine recognizes two commands ”command open” and”command close” which trigger state changes. The entry action (E:) in state”Opening” starts a motor opening the door, the entry action in state ”Closing”starts a motor in the other direction closing the door. States ”Opened” and”Closed” don’t perform any actions. They signal to the outside world (e.g., to otherstate machines) the situation: ”door is open” or ”door is closed”.

Page 44: Types of automata and its applications

Mealy machineThe FSM uses only input actions, i.e., output depends on input and state. The useof a Mealy FSM leads often to a reduction of the number of states. The example infigure 4 shows a Mealy FSM implementing the same behaviour as in the Mooreexample (the behaviour depends on the implemented FSM execution model andwill work, e.g., for virtual FSM but not for event driven FSM). There are two inputactions (I:): ”start motor to close the door if command close arrives” and ”startmotor in the other direction to open the door if command open arrives”. The”opening” and ”closing” intermediate states are not shown.

(7.) UML state machines

The Unified Modeling Language has a very rich semantics and notation fordescribing state machines. UML state machines overcome the limitations oftraditional finite state machines while retaining their main benefits. UML statemachines introduce the new concepts of hierarchically nested states andorthogonal regions, while extending the notion of actions. UML state machineshave the characteristics of both Mealy machines and Moore machines. Theysupport actions that depend on both the state of the system and the triggeringevent, as in Mealy machines, as well as entry and exit actions, which areassociated with states rather than transitions, as in Mooremachines.UML state machine example (a toaster oven)

(8.) Hardware applications

1. From the network management perspective (the access provider):

• It may be interested on grabbing usual information which would be inter-esting to improve long term relationship with the user;• It may collect information about the handovers of a user and relate themwith positioning information;• It may correlate information about routes and timing of accesses.

Page 45: Types of automata and its applications

2. From the content provider perspective:

• It may adapt the delivery of media to specifics of devices, location, timing,type of user, etc• It can understand the criteria by which the user chooses the access providers;• It can explore the contextual information to add value to the content (ad-vertisement, linking to 3rd party products, etc);• As the user has the control over the mobility aspects, the access providercan focus on providing better and more varied services[4];• It can provide brokerage services based on the common information available.

3. From the user perspective:

• It can choose the provider based upon several criteria:• Best price• Better response• Best matching to his/her requirements• Economy (use a home user-owned WLAN, during a traffic jam)• It can use contextual information to adapt the user device profile of usage:• Power management (CPU, memory, display, network interface)• Streaming control (proximity to known blind spots such as tunnels)• Optimization of content delivery to a new profile, on vertical handoverswith a lower bandwidth provider.

(9.) FSM real time application scenario:

One possible way to implement finite state machines is to have a controller ofsome type which acts as switch box. When the thread of execution swings aroundto execute code of the FSM, it is pointed at the controller which evaluates ordetermines the current state, usually through the use of a switch (case) statementor if-then-else statements. Once the current state is determined, the code for thatstate is executed, actions performed and possibly state transitions for the nexttime the FSM is executed. The controller may be a simple switch statementevaluating an integer, but an implementation may see the controller performingsome pre-processing of inputs and triggering of state transitions before-hand.

Page 46: Types of automata and its applications

Figure 3.1: A FSM implementation where the controller acts as a switch box todetermine which state to run. The red line denotes the thread of execution.

We started out with a definition of finite state machine, learning that it can beused as a control technique for a system, describing states or behaviors of thatsystem, and defining rules or conditions that govern transitions from the systemscurrent state to another state.

Section one showed that a finite state machine is considered to be deterministicwhich means its actions are easily predictable. A number of extensions to finitestate machines such as random selection of transitions, and fuzzy state machinesshows us another common type of FSM called non-determinist where the systemsactions were not as predictable, giving a better appearance of intelligence.

Page 47: Types of automata and its applications

(10.) FSM real time application scenario (2):

A finite state machine isn't a crazy type of machine. A finite state machine isone way to write programs. A finite state machine is usually just called a FSM

A FSM is made up of two things. First, it has some writing about what'shappening. Then, it has some arrows that show different choices you canmake. You should make a choice and follow the arrow.

Page 48: Types of automata and its applications

FSMs are good for making games and stories. Here is one game where youhave to find some treasure. First, go to Start. Then, you just follow the arrowsuntil you get to the end.

Here is a simpler FSM that lets you explore the rooms of a house.

Let's try making a program that lets you explore the house. First, number all ofthe rooms.

Page 49: Types of automata and its applications

Now we'll start programming. When programming a FSM, you need thecomputer to know which room you are in. You should start in room 1.

The computer should tell you something different depending on which room you are in.

The computer should also ask you where you want to go. The computer should thenchange the room number depending on your answer.

Page 50: Types of automata and its applications

After your room has changed, the computer should go back to the beginningand tell you about the new room. You can use a loop for this.

That's it! You can run the program now. You will be able to move through the differentrooms.

Try taking the FSM for the treasure game and programming it into the computer. Then,try making your own FSM game.

Conclusion:

Finite state machines represent a very powerful way of describing andimplementing the control logic for applications. I have used them to implementcommunication protocols, to control the interactions in a GUI, and many manyother applications. FSMs are powerful because they are a very denserepresentation. A lot of logic can be represented by a relatively small diagram.They are powerful because they follow very simple rules, and are easy to verify.And they are powerful because they can be used to generate code.

Page 51: Types of automata and its applications

CONCLUSIONWe started out with a definition of finite state machine, learning that it can beused as a control technique for a system, describing states or behaviors of thatsystem, and defining rules or conditions that govern transitions from the systemscurrent state to another state.

Section one showed that a finite state machine is considered to be deterministicwhich means its actions are easily predictable. A number of extensions to finitestate machines such as random selection of transitions, and fuzzy state machinesshows us another common type of FSM called non-determinist where the systemsactions were not as predictable, giving a better appearance of intelligence.

Next we took a close look at a simple real world implementation and learned howa rocket projectile could be modeled using FSM. This lead us to a more advancedexample where we saw the behavior of a semi-intelligent monster modeled using acombination of hierarchical finite state machines and the use of goals as a primarymotivator. This showed us a real implementation of a non-deterministic finite statemachine where the monsters "melee attack" state was selected using acombination of inputs and a randomly generated number.

Finally we took a broader look at the Quake computer game implementation andexamined the framework used to support the monsters that populate the gamessingle player experience. We learned how a polymorphic approach was used forthe execution of a monsters "current state" and that input events were alsoprocessed using polymorphism allowing any entity finite state machine’s actions todirectly effect entities. We saw how a simple framework that supported a varietyof state machines could be considered a simple multi-agent system where eachindividual state machine simple had to plug in relevant monster specific code intothe framework.

Finite state machines are a simple and effective artificial intelligence technique forcontrolling a system and providing the appearance of intelligence. We learned thatthat the perceived appearance of intelligence is more important than actualintelligence, and that finite state machines are able to provide this perception. Thiswas proven through practical analysis of a computer game, which is a veryunforgiving domain when it comes to quality of both product and game playingexperience.