Build a turing machine to compute the binary vigenere cypher

Assignment Help Theory of Computation
Reference no: EM131672712

Finite Automata, Context-Free Languages, Lexical analysis, Parsing

In these exercises, you will
- implement lexical analysers using lex (Problem 3);
- implement parsers using lex and yacc (Problems 1, 4);
- practise using the Pumping Lemma for regular languages (Problem 2);
- build a Turing machine (Problem 5);
- learn more about Finite Automata and universality (Problems 6-7).

Solutions to Problem 5 must be implemented in the simulator tuataraMonash, which is avail- able on Moodle.

How to manage this assignment

You should start working on this assignment now, and spread the work over the time until it is due. Aim to do at least three questions before the mid-semester break. Do as much as possible before your week 10 prac class. There will not be time during the class itself to do the assignment from scratch; there will only be time to get some help and clarification.

Don't be deterred by the length of this document! Much of it is an extended tutorial to get you started with lex and yacc (pp. 2-5) and documentation for functions, written in C, that are provided for you to use (pp. 5-7); some sample outputs also take up a fair bit of space. Although lex and yacc are new to you, the questions about them only require you to modify some existing input files for them rather than write your own input files from scratch.

Instructions
Instructions are as for Assignment 1, except that some of the filenames have changed. The file to download is now asgn2.tar.gz, and unpacking it will create the directory asgn2 within your FIT2014 directory. You need to construct new lex files, using chain.l as a starting point, for Problems 1, 3 & 4, and you'll need to construct a new yacc file from chain.y for Problem 4. Your submission must include (as well as the appropriate PDF files for the exercises requiring written solutions):
- a lex file prob1.l which should be obtained by modifying a copy of chain.l
- a lex file prob3.l which should also be obtained by modifying a copy of chain.l
- a lex file prob4.l which should be obtained by modifying a copy of prob3.l
- a yacc file prob4.y which should be obtained by modifying a copy of chain.y
- a Tuatara Turing machine file prob5.tm
PDF files for the exercises requiring written solutions, namely, prob1.pdf, prob2.pdf, prob6.pdf, and prob7.pdf.
To submit your work, simply enter the command ‘make' from within the asgn2 directory, and then submit the resulting .tar.gz file to Moodle. As last time, make sure that you have tested the submission mechanism and that you understand the effect of make on your directory tree.

INTRODUCTION: Lex, Yacc and the CHAIN language
In this part of the Assignment, you will use the lexical analyser generator lex or its variant flex, initially by itself, and then with the parser generator yacc.
Some useful references on Lex and Yacc:
- T. Niemann, Lex & Yacc Tutorial, https://epaperpress.com/lexandyacc/
- Doug Brown, John Levine, and Tony Mason, lex and yacc (2nd edn.), O'Reilly, 2012.
- the lex and yacc manpages
We will illustrate the use of these programs with a language CHAIN based on certain expressions involving strings. Then you will use lex and yacc on a language CRYPT of expressions based on cryptographic operations.

CHAIN
The language CHAIN consists of expressions of the following type. An expression consists of a number of terms, with # between each pair of consecutive terms, where each term is either a string of lower-case letters or an application of the Reverse function to such a string. Examples of such expressions include
mala # y # Reverse(mala)
block # drive # cut # pull # hook # sweep # Reverse(sweep) Reverse(side) # Reverse(direction) # Reverse(gear)
For lexical analysis, we wish to treat every lower-case alphabetical string as a lexeme for the token STRING, and the word Reverse as a lexeme for the token REVERSE.

Lex
An input file to lex is, by convention, given a name ending in .l. Such a file has three parts:
- definitions,
- rules,
- C code.
These are separated by double-percent, . Comments begin with /* and end with */. Any comments are ignored when lex is run on the file.
You will find an input file, chain.l, among the files for this Assignment. Study its structure now, identifying the three sections and noticing that various pieces of code have been commented out. Those pieces of code are not needed yet, but some will be needed later.
We focus mainly on the Rules section, in the middle of the file. It consists of a series of statements of the form
pattern { action }
where the pattern is a regular expression and the action consists of instructions, written in C, specifying what to do with text that matches the pattern.1 In our file, each pattern represents a set of possible lexemes which we wish to identify. These are:
- a string of lower-case letters;
- This is taken to be an instance of the token STRING (i.e., a lexeme for that token).

Problem 1.
(a) Construct prob1.l, as described above, so that it can be used with chain.y to build a parser for CHAIN.

(b) Show that the grammar for CHAIN given above is ambiguous.

(c) Find an equivalent grammar (i.e., one that generates the same language) that is not ambiguous.

Problem 2.
Prove that CRYPT is not regular.

Problem 3.
Using the file provided for CHAIN as a starting point, construct a lex file, prob3, and use it to build a lexical analyser for CRYPT.

Problem 4.
Make a copy of prob3.l, call it prob4.l, then modify it so that it can be used with yacc. Then construct a yacc file crypt.y from chain.y. Then use these lex and yacc files to build a parser for CRYPT.

Note that you do not have to program any of the cryptographic functions yourself. They have already been written: see the Programs section of the yacc file. The actions in your yacc file will need to call these functions, and you can do that by using the function call for reverse(. . . ) in chain.y as a template.

The core of your task is to write the grammar rules in the Rules section, in yacc format, with associated actions, using the examples in chain.y as a guide. You also need to do some modifications in the Declarations section to declare all tokens, using token, and declare all nonterminal symbols, using type.

Problem 5.
In this question, the Turing machine you build in Tuatara must have q1 as its Start State and q2 as its Accept State.

Build a Turing machine to compute the binary Vigenere cypher. Its input has the form xyk where the character y is used simply to separate the binary strings x and k. The output consists simply of the cyphertext z, a binary string of n bits. The output should have no y and/or keybits k after the cyphertext.

Your work on Tute 5, Q8, should help you get started on this Problem.

Problem 6.
Prove that a language is regular if and only if it is accepted by a Multistart FA.

Problem 7.

(a) Show that FA-REP is regular by giving a regular expression for it.

(b) Does a UFA exist? Give a proof for your answer. (It should help to use Problem 6 at some point.)

Reference no: EM131672712

Questions Cloud

Why are bribes immoral : Why are bribes immoral? How can you tell if a payment made in a business transaction is a bribe or not?
Calculate the contribution margin per direct-labor hour : Calculate the contribution margin per direct-labor hour of selling Xcel-chip and Dcel-chip. If no transfers of Xcel-chip are made to the process-control.
Components of motivation seems to be most problematic : Suppose you are a management consultant for a large, suburban hospital. Which of three components of motivation seems to be most problematic in this situation.
Conduct forecast for pricing or the future labor market : Identify two Web-based tools that you might use to conduct a forecast for pricing or the future labor market.
Build a turing machine to compute the binary vigenere cypher : FIT2014- Show that FA-REP is regular by giving a regular expression for it. Does a UFA exist? Give a proof for your answer
Would a market-based transfer price be agreeable : Transfer pricing, full cost and market-based transfer prices. Compost Systems, Inc. (CSI) operates a composting service business and produces organic.
Describe effect of alternative transfer-pricing methods : Multinational transfer pricing, effect of alternative transfer-pricing methods, global income tax minimization. Tech Friendly Computer, Inc., with headquarters.
Briefly describe three characteristics for each of colonies : briefly describe three characteristics for each of the English colonies located in the South, Middle, and New England regions Now state two religious.
Review the transfer-pricing problem : Transfer-pricing problem. Refer to Exercise. Assume that division A can sell the 1,900 units to other customers at $137 per unit, with variable marketing cost.

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