Ask Automata & Computation Expert

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

Automata & Computation, Computer Science

  • Category:- Automata & Computation
  • Reference No.:- M91821098
  • Price:- $95

Priced at Now at $95, Verified Solution

Have any Question?


Related Questions in Automata & Computation

Solve the question given belowprove the following statement

Solve the question given below Prove the following statement using Hall's Theorem. For any bipartite graph G=(U, V, E), if every node (either a left node or a right node) has exactly d neighbors, where d is an arbitrary ...

Prove or disprove the following proposed inference rules

Prove or disprove the following proposed inference rules for functional dependencies. A proof should be made by using the reflexive, augmentation, transitive, decomposition, union, and pseudotransitive rules. A disproof ...

Prove or disprove the following proposed inference rules

Prove or disprove the following proposed inference rules for functional dependencies. A proof should be made by using the reflexive, augmentation, transitive, decomposition, union, and pseudotransitive rules. A disproof ...

Iot and data analytics1 analyse the taskanalyse what is

IOT and data analytics 1. Analyse the Task Analyse what is expected of you. This includes careful reading of the assignment task as specified in the Subject Outline. The executive summary of the research project is to be ...

Question 1a digital computer has a memory unit with 16 bits

Question 1: A digital computer has a memory unit with 16 bits per word. The instruction set consists of 122 different operations. All instructions have an operation code part (opcode) and an address part (allowing for on ...

Regular expressions automatacomputabilitytheory of

Regular expressions, automata/computability/theory of computation How would I go about interpreting regular expressions? For example, how would I interpret the following in English: (0+1)*011 0*1*2* 0^(+)1^(+)2^(+)

Models of computation assignment -purpose - to improve and

Models of Computation Assignment - Purpose - To improve and consolidate your understanding of regular and context-free languages, finite-state and pushdown automata. To develop skills in analysis and formal reasoning abo ...

Models of computation assignment -purpose - to improve and

Models of Computation Assignment - Purpose - To improve and consolidate your understanding of regular and context-free languages, finite-state and pushdown automata. To develop skills in analysis and formal reasoning abo ...

Question - design a state machine that will control a

Question - Design a state machine that will control a vending machine. The vending machine has 4 inputs, N, D indicating a nickel or dime was inserted as well as clk and an active high asynchronous reset. The vending mac ...

Question - design a task or function that will check the

Question - Design a task or function that will check the parity of a word for odd parity. The input to the task/function is a 5-bit word called data_in. If the parity of input data_in is not odd increment an error count ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As