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

  Task 1part onea research strategy is a plan of action that

task 1part onea research strategy is a plan of action that gives direction to your efforts enabling you to conduct your

  Create a program that reads integers

Create a program that reads integers in range 0 .. 9999. The event stops reading if -99 is entered. Your event should use Stack to store those numbers then it used Priority Queue to print out those numbers in ascending order.

  Consider the following turing-machine model

a tape that is infinitely long in both directions and is divided into cells; at any given step, each cell either is blank or contains a 1 (we will refer to the latter type of cell as a non-blank cell)

  Adjust the proposal as required

Adjust the proposal as required. Post whatever you have accomplished to the folder for the GDI to review. Inform your GDI on any difficulties and show stoppers that you might encounter.

  Explaining syntactically legal boolean expression

In this problem, we consider a very restricted subset of Boolean expressions. Define an operator to be one of  the four symbols: ¬, ∧, ∨, and →. Define a variable to be one of the five symbols

  Write a research paper excluding the title page on logical

write a research paper excluding the title page on logical circular and arithmetic shift operations. use an example not

  1-is situational leadership model a useful model and how

1-is situational leadership model a useful model and how can we apply this model effectively?2-how is the

  Verify that a number in base b3 can be converted to base b

Verify that a number in base b can be converted to base b3 by partitioning the digits of the base b number into groups of three consecutive digits starting at the radix point and proceeding both left and right and converting each group into a base..

  Give english descriptions of the languages

Give English descriptions of the languages represented by the subsequent regular expressions. Example: "languages of binary strings containing 0 in even positions. . ."

  Can validation and verification methods be found that tiein

Can validation and verification methods be found that tiein with the requirements definition process

  Productions of nonterminals as right regular grammars

Rewrite the productions for each of the following nonterminals as right regular grammars: Identifier, Float. Show the moves made using the DFSA for identifiers in accepting.

  Design a set of gui interfaces

Design a set of GUI interfaces that support the functional requirements and workflow identified for the use case Pickup Package

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