Finite state automaton, Computer Engineering

Assignment Help:

Once a finite state automaton (FSA) is designed, its transition diagram can be translated in a straightforward manner into program code. However, this translation process is considerably tedious if the FSA is large and troublesome if the design is modified. The reason is that the transition information and mechanism are combined in the translation.

To do it differently, we can design a general data structure such as a table or a list to hold the transition information, and to implement in program code only a general transition mechanism. Using this approach, the resulted program is not only smaller, but it can also be modified easily to simulate a different FSA by just changing the transition information and the general data structure holds. We shall refer to such a program as a universal finite state automaton.

Your job for this assignment is to implement such a universal finite state automaton. To convince you that it is very easy to do so, I have suggested an algorithm below; however, you are free to modify it. Note that your program has to be designed to handle the FSA where the input transition function is partial, which means there is a default dead-end, or trap state.

1173_Finite State Automaton.png

You must represent each FSA in the input file with the following format, and put all input machines in one file:

(1) The number of states, say N.
For ease of implementation, number states from 0 to N-1, with 0 representing the initial state, and N the dead-end state.

(2) The set of final states.
You need a boolean array FINAL [0..N-1].

(3) The alphabet.
Symbols in the alphabet should be numbered internally so that the value returned by the function NextSymbol is an integer.

(4) A sequence of transitions of the form (p,a,q).
The triple (p,a,q) means that in state p, looking at input symbol a, the FSA will change its state to q. For this project, store this information in a table, say next_state, so that the value returned by the function NextState is next_state [state, symbol].

Test your program with the following 5 finite state automata using the given test strings.

(1) A FSA which recognizes the set of strings over {0,1} that do not have three consecutive 1's.  Strings: ?, 1, 000, 111000, 000111, 011010, 1010101110, 10101, 00110110110, 111

(2) A FSA which recognizes email addresses. A valid email address is defined as follows: [email protected], where the user name consists of at least one symbol with any combination of letters, digits, hyphens, underscores, or periods. The server name is any string of at least one symbol with any combination of letters, digits, hyphens, and underscores. The domain name must have 2 to 4 letters. Strings: [email protected], jsmith, jsmith@olympus, [email protected], [email protected], jsmith.edu, [email protected], [email protected], [email protected], [email protected]

(3) A FSA for a vending machine that provides only candy bars, each costs 25 cents. The initial state indicates that nothing has happened yet. If you insert a nickel, the machine will change to a state indicating that the total amount received so far is 5 cents. If you then insert another nickel, it will change to a state indicating that the total amount received is now 10 cents. If you then press a button to select a candy bar, the machine will ignore this input, since the proper amount has not yet been paid. When the total amount reaches at least 25 cents, however, the machine will now respond if you select a candy bar. It will deliver the candy bar and return to its starting state, which is also an accepting state. ∑ = {n, d, q, s}, where n stands for nickel, d for dime, q for quarter, and s for the select button. Strings: s, sds, nnns, ddd, ddds, qqsqs, sdsnsnsns, sdqsd, ndnqdqndqn, ssnqdss

(4) A FSA which recognizes the set of strings over {a,b} where the number of a's is even and the number of b's has remainder one when divided by three. Strings: ?, aa, baa, aba, aabb, babababab, aabbaabb, aaababbaa, abbbbaa, bbbbbbb

(5) A FSA which recognizes the set of all signed or unsigned decimal numbers without superfluous leading or trailing zeros. For instance, 0.0, -0.5, +120.01, and 123000.0 are in the language, but 0.00, 00.5, and 0123.4 are not. Each decimal number has the form of A.B, where A and B are strings of digits and they cannot be empty at the same time. Strings: +1.23, -.123, 123., -0.0, 01234.5, -789, ., 56.30, +120.0001, 123000.0
Sample input of a FSA:
    2
    1
    0 1
    (0 0 0)
    (0 1 1)
    (1 0 1)
    (1 1 0)
    1000
    10001
    ........

Corresponding output:
Finite State Automaton #1.
(1) number of states: 2
(2) final states: 1
(3) alphabet: 0, 1
(4) transitions:
0   0   0
0   1   1
1   0   1
1   1   0
(5) strings:
1000        Accept
10001        Reject
        ........

Submit on Bb and turn in the printout of (1) program code with proper comments including your name and clear instructions to compile, link, and run your program, (2) input file containing the description of the above five machines and corresponding test strings, and (3) output of executions.


Related Discussions:- Finite state automaton

What is ''LRU'' page replacement policy, 'LRU' page replacement policy is ?...

'LRU' page replacement policy is ? Ans. Least Recently Used.

What is the role of a controller in an mvc application, The controller resp...

The controller responds to user interactions, with the application, by selecting the act method to implement and also selecting the view to render.

Cobol coding, What is cobol codin for heap sort?

What is cobol codin for heap sort?

Answering systems- database query, Answering Systems / Database Query T...

Answering Systems / Database Query There are a large number of opportunities for get faster through parallelizing a Database Management System (DBMS). However, the actual purpo

Numbers square, Your professor wants you to fill a two-dimensional N by N m...

Your professor wants you to fill a two-dimensional N by N matrix with some numbers by following a specific pattern. According to his explanation as in the figure below, you have to

Disadvantages of pipeline - computer architecture, Disadvantages of pipelin...

Disadvantages of pipeline: Pipeline architecture has 2 major disadvantages.  First is its complexity and second is the inability to constantly run the pipeline at full speed,

Conversion of decimal number 25.5 into binary number, Conversion of decimal...

Conversion of decimal number 25.5 into binary number Ans. There is integer part is 25 and fractional part is 0.5.  Firstly convert the integer part 25 in its equal to binary numb

Show list files by dir command, Q. Show list files by Dir command? The ...

Q. Show list files by Dir command? The Dir command can also be used to list files from the exacting directory. For example, the list of files present in the WORD directory in d

Define a variant of top-down parsing without backtracking, A parser which i...

A parser which is a variant of top-down parsing without backtracking is? Ans. Recursive Descend is a variant of top-down parsing without backtracking.

Representation of real-system, Maria opened her authentic Mexican restauran...

Maria opened her authentic Mexican restaurant MiCazuela in Tucson inthe 1980s. It quickly became popular for the tasty food and use of fresh organicproduce and all-natural meats. L

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd