Design a dfa to recognize language l

Assignment Help Theory of Computation
Reference no: EM13648109

Define the language L to consist of strings that represent certain web-page addresses. For this assignment you are to design a DFA to recognize L and write a program that implements your DFA.

The Language L

To precisely specify L, first define Γ = {a, b, c, . . . , z} as the set of lower-case Roman letters, and let Σ = Γ ∪ {.}; i.e., Σ is the set consisting of all the lower-case Roman letters and the dot (or period). Define the following sets:

S1 = {www.}

S2 = ΓΓ∗, which consists of strings over Γ of positive length

S3 = {.com} ∪ {.co.jp}

Then we define the following sets of strings over Σ:

L1 = S1S2S3

L2 = S2S3

L = L1 ∪ L2

Strings in L1 are (a subset of) web addresses that have three parts, where the first part is "www.", the second part is a positive-length string of lower-case Roman letters, and the third part is ".com" or ".co.jp". (The suffix ".co.jp" is used in some web addresses in Japan.) Strings in L2 are (a subset of) web addresses that have only the last two parts. For example, the strings www.abcdef.com, www.com.com, www.co.com, www.abcdef.co.jp, www.com.co.jp, and www.co.co.jp belong to L1, and the strings abcdef.co.jp, www.co.jp, abcdef.co.jp, and www.co.jp belong to L2.

The specification of L does not include all valid web addresses since we included several restrictions to simplify the assignment. For example, only lower-case Roman letters and dots are allowed, strings in L must end with .com or .co.jp, etc.

DFA for L

First construct a DFA M = (Q, Σ, δ , q1, F ) that recognizes L. The DFA must satisfy each of the following properties:

The DFA must be defined with the above alphabet Σ. Your DFA does not have to handle symbols that are not in Σ.

The states in the DFA must be labeled q1, q2, q3, . . . , qn, where q1 is the start state and n is the number of states in the DFA. (It is also acceptable for the states to be labeled q0, q1, . . . , qn-1, with q0 the start state.)

You will lose points if your DFA is overly complicated. To simplify your DFA drawing, omit any edges going from a state q ?∈F to a "trap state" (i.e., a non-accepting state from which the DFA can never leave). All other edges must be included in your drawing. Clearly identify which state is the trap state in the drawing of your DFA. Also, to simplify your drawing, you should define Γl = Γ - {l} for any symbol l ∈ Γ; i.e., Γl is the set of all lower-case Roman letters except for l. For example, Γw = {a, b, c, . . . , v, x, y, z}, so your DFA might include something like the following:

1720_DFA.png


Thus, if the DFA is currently in state q1, then it moves to q2 on reading w, and it moves to state q3 on reading any other lower-case Roman letter.

Program Specifications

You must write your program in either C, C++, or Java. All input/output must be through standard input/output, and your program is to work as follows:

1. Your program asks the user if s/he wants to enter a string. The user then enters "y" for "yes", or "n" for "no".

If the user enters "n", then the program terminates.
If the user enters "y", then the user is prompted to enter a string over Σ.

2. If the user chooses to input a string, your program then reads in the string. After reading in the string, your program prints it. Then your program processes the entire string on the DFA, one character at a time, in the following manner.

Your program must begin in the start state of the DFA and print out the name of that state (q1 or q0).

After each character from the string is processed on the DFA, your program must print out the character and the name of the current state of the DFA. Even if your DFA is in a trap state, your program must do this for each character in the string until it reaches the end of the string.

To simplify your program, you should check the ASCII code of each character of the string and process on the DFA accordingly.

3. After processing the entire string on the DFA, your program must indicate if the string is accepted or rejected based on the state in which the DFA ended. Your program then should return to step 1.

Reference no: EM13648109

Questions Cloud

Compute what frequency do you hear : if you move at 14m/s toward a 2300Hz source that is movingtoward you with a ground speed of 38m/s, what frequency do you hear
Proton movesin a circular orbit just outside spherical shell : A particle of charge -60nC is placed at the center of anon-conducting spherical shell of inner radius 20cm and outerradius 25cm. The spherical shell is uniformly charged with acharge density of -1.33μC/m3.
What is the intensity level of this sound in decibels : The sound in a classroom is 68000 times asintense as the minimum threshold of hearing. What is the intensity level of this sound in decibels
Explain why easier to remove electron from the energy levels : Why is it easier to remove electron from the first two energy levels of mg but easier to remove third level electron of argon
Design a dfa to recognize language l : Design a DFA to recognize L and write a program that implements your DFA - you should check the ASCII code of each character of the string and process on the DFA accordingly.
Obtain what is the index of refraction of the liquid : Light in a vacuum is incident on a transparent glass slab. Theangle of incidence is 32.0° . The slab is then immersed in a pool of liquid. What is the index of refraction of the liquid
Evaluate how far would it have traveled in a vacuum : A flat sheet of crystalline quartz has athickness of 3.1 cm. It is on top of aflat sheet of diamond that has a thicknessof 3.0 cm. how far would it have traveled in a vacuum
Depict all the monochlorinated derivatives : Draw all the monochlorinated derivatives of 2,2,3,3-tetramethylbutane that are skeletal isomers of one another. To make a monochlorinated derivative of a compound, replace one H atom in the compound with Cl.
What is the radius of the pipe on the second floor : Water(density=1.00X103 kg/m3) flows at10.0m/s through a pipe with radius 0.030m. What is the radius of the pipe on the second floor

Reviews

Write a Review

Theory of Computation Questions & Answers

  Finite-state machine design

Create a finite-state machine design to turn your FPGA development board into a simple programmable music box.

  Redundant sequence identi cation

Redundant sequence identi cation

  Compute a shortest superstring

Dynamic programming algorithm to compute a shortest superstring.

  Propositional and predicate logic

Write down a structural induction principle for the PlayTree free type

  Design a syntactic analyzer

Design a syntactic analyzer for the language specified by the grammar

  Design unambiguous grammar to parse expressions

Write a program would read two numbers and then print all numbers between the first and the second, inclusive. Design unambiguous grammar to parse expressions

  Consider a logic function with three outputs

Consider a logic function with three outputs,  A ,  B , and  C , and three inputs,  D ,  E , and  F . The function is defined as follows:  A  is true if at least one input is true,  B  is true

  Considering a single programmed operating system

Considering a single programmed operating system, what is the minimal total time required to complete executions of the two processes? You should explain your answer with a diagram.

  How to construct an nfa

Give a construction that assumes you are given a DFA for L and show how to construct an NFA (with or without ε-moves) to recognize sort(L).

  Equivalence classes to construct minimal dfa for language

How many equivalence classes does this relation have and what are they? Use these equivalence classes to construct the minimal DFA for the language.

  Impact of moore-s law on data center costs

Discuss the impact of Moore's law on data center costs on such things as servers and communications equipment. List at least 3 steps or recommendations your data center can take to offset some or all of the effect of Moore's law.

  Problem encountered in statements in predicate logic

How the problem would be encountered in attempting to represent the following statements in Predicate logic. it should be possible to: John only likes to see French movies.

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