CT32 COMPUTER NETWORKS DEC 2015

Similar documents
JNTUWORLD. Code No: R

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

UNIT I PART A PART B

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Multiple Choice Questions


T.E. (Computer Engineering) (Semester I) Examination, 2013 THEORY OF COMPUTATION (2008 Course)

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Decision Properties for Context-free Languages

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

CS210 THEORY OF COMPUTATION QUESTION BANK PART -A UNIT- I

Decidable Problems. We examine the problems for which there is an algorithm.

Derivations of a CFG. MACM 300 Formal Languages and Automata. Context-free Grammars. Derivations and parse trees

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Formal Languages and Compilers Lecture IV: Regular Languages and Finite. Finite Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

DHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

ECS 120 Lesson 16 Turing Machines, Pt. 2

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

QUESTION BANK. Unit 1. Introduction to Finite Automata

Theory of Computation

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

1. Which of the following regular expressions over {0, 1} denotes the set of all strings not containing 100 as a sub-string?

Languages and Compilers

CS402 - Theory of Automata Glossary By

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

Limits of Computation p.1/?? Limits of Computation p.2/??

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

ECS 120 Lesson 7 Regular Expressions, Pt. 1


Computer Sciences Department

Theory Bridge Exam Example Questions Version of June 6, 2008

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

Actually talking about Turing machines this time

Learn Smart and Grow with world

Outline. Language Hierarchy

A Characterization of the Chomsky Hierarchy by String Turing Machines

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

Context Free Grammars. CS154 Chris Pollett Mar 1, 2006.

Final Course Review. Reading: Chapters 1-9

Theory and Compiling COMP360

Definition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.

1. [5 points each] True or False. If the question is currently open, write O or Open.

Formal Grammars and Abstract Machines. Sahar Al Seesi

UNIT 1 SNS COLLEGE OF ENGINEERING

Formal Languages and Compilers Lecture VI: Lexical Analysis

Front End: Lexical Analysis. The Structure of a Compiler

CS154 Midterm Examination. May 4, 2010, 2:15-3:30PM

Ambiguous Grammars and Compactification

14.1 Encoding for different models of computation

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

Formal Languages and Automata

PS3 - Comments. Describe precisely the language accepted by this nondeterministic PDA.

Question Bank. 10CS63:Compiler Design

Compiler Construction

ROEVER COLLEGE OF ENGINEERING AND TECHNOLOGY Elambalur, Perambalur DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT-I AUTOMATA

R10 SET a) Explain the Architecture of 8085 Microprocessor? b) Explain instruction set Architecture Design?

2068 (I) Attempt all questions.

Theory of Computation, Homework 3 Sample Solution

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

CSCI312 Principles of Programming Languages!

Where We Are. CMSC 330: Organization of Programming Languages. This Lecture. Programming Languages. Motivation for Grammars

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

Interpreter. Scanner. Parser. Tree Walker. read. request token. send token. send AST I/O. Console

Parsing. source code. while (k<=n) {sum = sum+k; k=k+1;}

1. Provide two valid strings in the languages described by each of the following regular expressions, with alphabet Σ = {0,1,2}.

Introduction to Automata Theory

COP 3402 Systems Software Syntax Analysis (Parser)

CISC 4090 Theory of Computation

Introduction to Computers & Programming

AUTOMATA THEORY AND COMPUTABILITY

Syntax Analysis Part I

Homework. Context Free Languages. Before We Start. Announcements. Plan for today. Languages. Any questions? Recall. 1st half. 2nd half.

Variants of Turing Machines

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

CMSC 330: Organization of Programming Languages. Architecture of Compilers, Interpreters

LECTURE NOTES THEORY OF COMPUTATION

Normal Forms for CFG s. Eliminating Useless Variables Removing Epsilon Removing Unit Productions Chomsky Normal Form

CS/B.Tech/CSE/IT/EVEN/SEM-4/CS-402/ ItIauIafIaAblll~AladUnrtel1ity

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

Models of Computation II: Grammars and Pushdown Automata

Lexical Analysis. Implementation: Finite Automata

Chapter 14: Pushdown Automata

Answer All Questions. All Questions Carry Equal Marks. Time: 20 Min. Marks: 10.

THEORY OF COMPUTATION

Automating Construction of Lexers

CMSC 330: Organization of Programming Languages. Context Free Grammars

UNIT -2 LEXICAL ANALYSIS

Lexical Analysis - 2

CS 310: State Transition Diagrams

MA513: Formal Languages and Automata Theory Topic: Context-free Grammars (CFG) Lecture Number 18 Date: September 12, 2011

CS 403 Compiler Construction Lecture 3 Lexical Analysis [Based on Chapter 1, 2, 3 of Aho2]

LECTURE NOTES THEORY OF COMPUTATION

Transcription:

Q.2 a. Using the principle of mathematical induction, prove that (10 (2n-1) +1) is divisible by 11 for all n N (8) Let P(n): (10 (2n-1) +1) is divisible by 11 For n = 1, the given expression becomes (10 (2*1-1) +1) = 11, which is divisible by 11. So, the given statement is true for n=1, i.e. P(1) is true. Let P(k) be true. Then P(k): (10 (2k-1) +1) is divisible by 11 => (10 (2k-1) +1) = 11m, for some natural number m. Now, {(10 (2(k+1)-1) +1) } = (10 (2k+1) +1) = {10 2. 10 (2k-1) +1 } = 100 x {10 (2k-1) +1} 99 = (100x 11m)-99 = 11 x (100m - 9), which is divisible by 11 => P(k+1): (10 (2(k+1)-1) +1) is divisible by 11 => P(k+1) is true, whenever P(k) is true. Thus, P(1) is true and P(k+1) is true, whenever P(k) is true. Hence by the principle of mathematical induction, P(n) is true for all n N. b. Discuss the description of Finite Automata. Why we study Automata Theory in computer science? (8) Finite Automata A finite automaton is an abstract model of a digital computer. A finite automaton has a mechanism to read input, which is a string over a given alphabet. This input is actually written on an input file, which can be read by the automaton but cannot change it. Input file is divided into cells, each of which can hold one symbol. The automaton has a temporary storage device, which has unlimited number of cells, the contents of which can be altered by the automaton. Automaton has a control unit, which is said to be in one of a finite number of internal states. IETE 1

The automaton can change state in a defined way. Types of Finite Automaton (a) Deterministic Finite Automata (b) Non-deterministic Finite Automata A deterministic automata is one in which each move (transition from one state to another) is unequally determined by the current configuration. If the internal state, input and contents of the storage are known, it is possible to predict the future behaviour of the automaton. This is said to be deterministic finite automata otherwise it is nondeterministic finite automata. Definition of Deterministic Finite Automaton A Deterministic Finite Automata (DFA) is a collection of 5-tuples as: The input mechanism can move only from left to right and reads exactly one symbol on each step. The transition from one internal state to another is governed by the transition function δ. If δ(q0, a) = q1 then if the DFA is in state q0 and the current input symbol is a, the DFA will go into state q1. Definition of Nondeterministic Finite Automaton A Nondeterministic Finite Automata (NFA) is defined by a collection of 5-tuples: A string is accepted by an NFA if there is some sequence of possible moves that will put the machine in the final state at the end of the string. Need of Study and Applications of Finite Automata String Processing Consider finding all occurrences of a short string (pattern string) within a long string (text string). This can be done by processing the text through a DFA: the DFA for all strings that end with the pattern string. Each time accept state is reached; the current position in the text is output. IETE 2

Finite-State Machines A finite-state machine is an FA together with actions on the arcs. Statecharts Statecharts model tasks as a set of states and actions. They extend FA diagrams. Lexical Analysis In compiling a program, the first step is lexical analysis. This isolates keywords, identifiers etc., while eliminating irrelevant symbols. A token is a category, for example identifier, relation operator or specific keyword. Q.3 a. Solve the following: (3+2) (i) Construct a DFA that behaves equivalent to the NDFA given by M such that M = ( {q0, q1, q2, q3}, {a, b}, δ, q0, {q3}) where δ is given by STATE Input a Input b Initial state q0 q0, q1 q0 q1 q2 q1 q2 q3 q3 Final State *q3 -- q2 (ii) Find a DFA machine that accepts an even number of either 0 s or 1 s or both 0 s and 1 s over input symbol = {0, 1}. (i) (ii) The transition system (δ) of the DFA machine is shown in the following figure: IETE 3

Hence the DFA machine is defined as ({q1, q2, q3, q4}, {0, 1}, δ, q1, {q1}). b. Find a DFA machine for the language L = {0w0 w ϵ {0, 1}*}. (4) The transition graph of the given DFA machine is shown in the following figure. This transition graph consists of 5 tuples as (Q,, δ, q0, F) that is defined as ({q0, q1, q2, q3}, {0, 1}, δ, q0, {q2}). c. Make a minimum state finite automaton that is equivalent to a DFA whose transition table is given as: (7) Definition State a b Initial State q0 q1 q2 q1 q4 q3 q2 q4 q3 Final State *q3 q5 q6 Final State *q4 q7 q6 IETE 4

q5 q3 q6 q6 q6 q6 q7 q4 q6 IETE 5

Q.4 a. Find the regular expressions corresponding to the following finite automata; consider q 1 as initial state in both automata (s): (8) (i) (i) (ii) (ii) IETE 6

(i) b. Obtain a Deterministic Finite Automaton with minimized or reduced states for the following regular expressions (8) (i) (0 + 1)* (00 + 11) (0 + 1)* (ii) 10 + (0 + 11) 0* 1 IETE 7

IETE 8

Sol (ii): IETE 9

IETE 10

Q.5 a. Solve the following: (3+3) (i) Show that the language denoted by L = { 0 i 1 i i >= 1} is not a regular language. (ii) Check whether the language represented as L = { a i b j c k k > i + j} is regular or not? Also justify your answer using pumping Lemma. (i) (ii) b. Test the equivalence of two regular languages represented by the regular expressions P = (a + b)* and Q = a*(b a*)* respectively. Is P = Q Explain your answer with proper justification? (4) IETE 11

IETE 12

(i) L.H.S. (ii) c. Solve the following: (3+3) (i) Consider the two regular Languages represented by the regular expressions P and Q respectively, where P is defined as P = (b + a a* b) and Q is any regular expression then show that P + P Q*Q = a*b Q* (ii) Consider a context free grammar G that consists of the productions S 0B 1A A 0 0S 1AA B 1 1S 0BB For the string 00110101, Find the (i) the Leftmost Derivation (ii) the Rightmost Derivation (iii) Parse Tree = PΛ + P Q*Q = P(Λ + Q*Q) = PQ* = (b + aa*b)q* (by definition of P) = (Λb + aa*b)q* = a*bq* = R.H.S. IETE 13

Q.6 a. Solve the following: (3+2) (i) Make a deterministic PDA by Final State that accepts the language L = { w ϵ {a, b}* the number of a s in w equal to the no. of b s in w}. (ii) Convert the context free grammar S asb A, A bsa S ϵ to a equivalent PDA by empty stack. (i) (ii) IETE 14

b. Construct a Pushdown Automata (PDA) that accepts the language L defined as: L = {a n b m a n m, n 1} by empty stack. Also make the corresponding CFG productions accepting the same set or language. (8) IETE 15

c. Define Inherent Ambiguity and Inherently Ambiguous Languages. If G is a context free grammar whose production rules are given as S SbS a. Check whether the given grammar G is ambiguous or inherently ambiguous. (3) Inherent Ambiguity and Inherently Ambiguous Languages The languages generated by a grammar, that have both ambiguous and unambiguous grammars but there exist languages for which no unambiguous grammar can exist. Such types of languages are called inherently ambiguous languages and the property is known as inherent ambiguity. IETE 16

IETE 17

Q.7 a. Consider a context free grammar G whose production rules are defined as S ASA ba, A B S, B c. Reduce it into Chomsky Normal Form (CNF). (6) IETE 18

b. Reduce the given CFG defined as S aabb, A aa a, B bb b into Chomsky Normal form. (6) c. Check whether the language defined as L = {a p p is a prime} is a context free language or not. Justify your answer by using the help of Pumping Lemma. (4) Q.8 a. Design Turing Machines that recognizes the following languages: (5+5) (i) L = {0 n 1 n n 1} and (ii) Set L of all strings over {0, 1} ending with 010 IETE 19

Sol (ii): IETE 20

b. Define a Turing machine. Construct a Turing Machine that accepts the language given by the expression (0 1* + 1 0*) (6) Definition of Turing Machine A Turing Machine M is a collection of 7-tuples as: As the Turing machine will have to be able to find its input, and to know when it has processed all of that input, we require: IETE 21

(a) The tape is initially blank (every symbol is #) except possibly for a finite, contiguous sequence of symbols. (b) If there are initially nonblank symbols on the tape, the tape head is initially positioned on one of them. This emphasises the fact that the input viz., the non-blank symbols on the tape does not contain #. Q.9 a. State the Post correspondence problem (PCP). Find at least three solutions to the PCP defined by the following sets: (8) A = {1, 10, 10111} and B = {111, 0, 10} Post correspondence problem (PCP): An instance of PCP consists of two lines of strings over some alphabet Σ; the two lists must be equal length. We generally refer to the A and B lists, and write A = w 1, w 2,,w k and B = x 1, x 2,,x k, for some integer k. For each i, the pair (w i, x i ) is said to be a corresponding pair. We say this instance of PCP has a solution, if there is a sequence of one or more integers i 1,i 2,, i m that, when interpreted as indexes for strings in the A and B lists, yield the same string. That is, w i1 w i2 w im = x i1 x i2 x im. We say the sequence i 1, i 2,.,i m is a solution to this instance of PCP, if so, the Post correspondence problem is: Given an instance of PCP, tell whether this has a solution. Given : A = (1, 10, 10111) B = (111, 0, 10) From the above we conclude that A1 = 1, A2 = 10, A3 = 10111 B1 = 111, B2 = 0, B3 = 10 Then A 3 A 1 A 1 A 2 = B 3 B 1 B 1 B 2 IETE 22

Hence the PCP with the given list has a solution. Repeating the sequence 3, 1, 1, 2 we can get more solutions. As a example: A 3 A 1 A 1 A 2 A 3 A 1 A 1 A 2 = B 3 B 1 B 1 B 2 B 3 B 1 B 1 B 2 = 101111110101111110 Similarly we can get an another solution as having the sequence 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2. So the three solutions to the PCP defined by the given sets: (i) 3, 1, 1, 2 (ii) 3, 1, 1, 2, 3, 1, 1, 2 (iii) 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2 b. Differentiate between Recursive Languages and Recursively Enumerable Languages. Show that if L1 and L2 are Recursively Enumerable Languages than L1 U L2 is also Recursively Enumerable as well as if L1 and L2 are Recursive Languages than L1 U L2 is also recursive. (8) IETE 23

IETE 24

IETE 25