Describe languages denoted by regular expressions

Assignment Help Theory of Computation
Reference no: EM131083153

Assignment 2:

1. Exercise- Describe the languages denoted by the following regular ex-pressions:

a) a(a|b)*a.

b) ((e|a)b*)*.

c) (a|b)*a(a|b)(a|b)

d) a*ba*ba*ba*.

!! e) (aa|bb)*((ab|ba)(aa|bb)*(ab|ba)(aa|bb)*)*.

2. Write regular expressions for the following languages over the alphabet {a, b} :
(a) The set of strings with at least three a's.
(b) The set of strings with three consecutive a's.
(c) The set of strings with an odd number of a's.
(d) The set of strings that do not contain the substring bba.

3. Design an NFA for each of the four languages of the previous exercise.

4. Design a DFA for each of the four languages of exercise 3. You may want to apply subset construction (Section 3.7) to convert the NFAs of the previous exercise to equivalent DFAs. If any of the NFAs your wrote for the previous exercise are DFAs, it's enough to note that fact. Alternatively, you might choose to write a DFA for each of the four languages 2(a-d) directly, and so answer problems 3 and 4 simultaneously.

Programming Assignment

A very simple Scheme (VSS) expression takes one of several forms: a floating-point literal whose value is itself; or an application that applies the function named by an operator to zero or more argument values to which its operands evaluate; or a define expression; or a reference to a variable. A define expression, introduced by the keyword def, takes an identifier v and an expression expr; when evaluated, it evaluates expr and assigns its value val to the identifier v; the value of the expression is vat References to v that appear in subsequent expressions are replaced by v's value vat the value assigned. The most recent value assigned to v is its value, and references to unassigned variables have the value zero. A VSS program is a sequence of one or more expressions. Here is the syntax, with nonterminals in italics and terminals in uppercase or enclosed in single-quotes:

prog → expr+
expr      → DOUBLE
            |  '(' RATOR exp* ')'
            |  '(' def' ID expr ')'
            |   ID
RATOR   →  '+' |'-'|'*'|'/'.

A floating-point literal (DOUBLE) is represented by one or more digits, optionally preceded by a minus sign, and optionally followed by a radix point (.) and zero or more digits. An identifier ID is a letter followed by zero or more letters and digits and underscores(_). Semantically, dentifers are case-sensitive (e.g., apple and Apple are different identifiers). Basically, this program is similar to the previous one except that (a) applications can take a variable number of operands, (b) global variables can be defined and initialized, and (c) variables can be referenced for their value.

Your interpreter evaluates the top-level expressions in order and prints the value of the last expression. For programs that contain more than one top-level expression, all but the last one are generally there for side-effect (e.g., assignment to a variable). Here are some sample runs:

> java run
(+ 3 4 5)
^Z
12.0

> java run
(* 2 3) // discarded
(+ 2 4 (/ 8 (+ 1 (* 2 1.5))))
^Z
8.0

> java run
(def a (+ 2 3))
(* a a a)
^Z
125.0

> java run
(def hi_there (* 7 7))
(def xyz (+ 1 2 3))
(+ hi_there xyz yup)
^Z
55.0

> java run
(def a (+ 2 3))
(def b (* a a a))
(+ a b)
^Z
68.0

This illustrates the semantics of the arithmetic operators:

(+) => 0.0 // identity for addition
(+ 2 3) => 5.0
(+ 3 4 5) => 12.0
(- 5) => -5.0 // 0-5 = -5
(- 5 4) => 1.0
(- 5 4 3) => -2.0 // 5-4-3
(-) => illegal
(*) => 1.0 // identity for multiplication
(* 2 (+ 3 4) 5) => 70.0
(/ 4) => 0.25 // 1/4
(/ 6 4) => 1.5
(/ 8 4 (- 3 1)) => 1.0 // 8/4/2
(I) => illegal

The solution to Assignment 1 is attached. Assignment 2 is similar to Assignment 1. I refer you to the ANTLR tool website (antlr.org). Also, I should let you know that you need more options for the subject area. The course name is called Compilers.

Attachment:- Assignment_1 Compiler.rar

Reference no: EM131083153

Questions Cloud

Risk versus return is an old adage on wall street : Risk versus Return is an old adage on Wall Street. If higher expected returns are a “good” and greater risk of loss is a “bad,” what does a typical investor’s risk-return indifference map look like? If you were to ask Investor A if she would be willi..
Price level and expected inflation effects : M1 money growth in the U.S. was about 16% in 2008, 7% in 2009 and 9% in 2010. Over the same time period, the yield on 3-month T-bills fell from almost 3% to close to 0%. Given these high rates of money growth, why did the interest rates fall, rather ..
Disruptive and unproductive-selfish and uncaring : Following the birth of their third child, Mary and John realized that Mary had to go back to work to help make ends meet financially. This meant, however, that they would spend less time together as a family. Sociologists would say that Mary going ba..
Discussion focuses on the financial health of your company : Deliverable Length: 300-600 wordsThis week's discussion focuses on the financial health of your company. This will help you prepare for the Comp-XM exam.
Describe languages denoted by regular expressions : Describe the languages denoted by the following regular ex-pressions and write regular expressions for the languages over the alphabet {a, b}
Increase in the interest rate would affect : (a) Describe, using an example, what is meant by the term "opportunity cost".(b) Apart from a bank loan, identify one way the Silva family could borrow money.(c) Explain, in what ways, an increase in the interest rate would affect:
Develop the titration curve in spreadsheet format : If 25 mL of 0.025 M Na2SO4 is titrated with 0.040 M Pb(NO3)2, develop the titration curve in spreadsheet format and plot the limiting current versus the volume of titrant.
Explain the links between the drivers and pressures : The United Nations Environmental Programmed GEO5 Report issued in 2012 founded that "burgeoning populations and growing economies are pushing ecosystems to destabilizing limits." The Report notes a change in emphasis from a focus on environmental "dr..
How income taxes affect government revenue : A longstanding issue in economics is how income taxes affect government revenue. Proponents of increasing income taxes say that taxing citizens at a higher rate will increase government tax revenue since you are collecting more from each person. Plea..

Reviews

Write a Review

Theory of Computation Questions & Answers

  Rahman s a 2006 lsquoattitudes of malaysian teachers toward

rahman s. a. 2006 lsquoattitudes of malaysian teachers toward a performance-appraisal system journal of applied social

  Explain proof of rice-s theorem for infinite language

If you perform reduction in proof of Rice's theorem for special case of property P: "infinite language", does this reduction also show that language P L = { | N is Turing machine.

  We have two versions of tn above depending on whether we

question we have two versions of tn above depending on whether we use a constant c or not. explain why the two versions

  Give a table of combinations for the boolean function

Consider the Boolean algebra of four elements {o, 1, a, b} specified lby the following operation tables and the Boolean functionj(x,y) = ax + by where a and b are two of the elements in the Boolean algebra .Writej(x,y) in a sum-of-minterms form.

  Write down binary representation of decimal number

Calculate the sum of 2.6125 X 101 and 4.150390625 X 10-1 by hand, assuming A and B are stored in the 16-bit half precision described in exercise 3.27. Assume 1 guard, 1 round bit, and 1 sticky bit, and round to the nearest even. Show all steps.

  Modify the syntax of a programming language

Sometimes it is necessary to modify the syntax of a programming language. This is done by changing the CFG that the language uses. What changes would have to be made to ac's CFG (Figure) to implement the following changes?

  The latest entry into the snack food industry

The latest entry into the snack food industry is a health-conscious offering named Hooks, Wheels, and Ladders. Each box mixes several flavors, such as ranch, cheddar, and salsa. The snack is designed to appeal to kids based on the snack shapes

  Prove the problem by contradiction

Let n > 1 be an integer. Prove by contradiction that if n is a perfect square, and then n + 3 cannot be a perfect square.

  Show polynomial-time algorithm for gdp

Goal is to find expedition of maximum profit. Either show that there exists polynomial-time algorithm for GDP, or show that corresponding decision problem is NP-complete.

  Characterize the subgame perfect nash equilibria

Characterize the Subgame Perfect Nash Equilibria of this game. Discuss the underlying assumptions made in the analysis.

  Find input common-mode range and the range allowed for vo

A particular design of the two-stage CMOS operational amplifier of Fig. utilizes ±1-V power supplies. All transistors are operated at overdrive voltages of 0.2-V magnitude. The process technology provides devices with Vtn = / tp/ = 0.4 V. Find the..

  Create a version management system in your machine for code

Create a version management system in your machine for the code of question 5. Present how you use it to manage your code files.

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