GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Similar documents
Sri vidya college of engineering and technology

CS 455/555: Finite automata

An automaton with a finite number of states is called a Finite Automaton (FA) or Finite State Machine (FSM).

Finite Automata and Regular languages

Closure under the Regular Operations

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

UNIT-III REGULAR LANGUAGES

Computer Sciences Department

CS 154, Lecture 3: DFA NFA, Regular Expressions

Theory of Computation (Classroom Practice Booklet Solutions)

Formal Languages, Automata and Models of Computation

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

Computational Theory

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Theory of Computation (II) Yijia Chen Fudan University

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Nondeterministic Finite Automata

Finite Automata. Finite Automata

COM364 Automata Theory Lecture Note 2 - Nondeterminism

The Pumping Lemma and Closure Properties

Author: Vivek Kulkarni ( )

Theory of Computation

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

More Properties of Regular Languages

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

Theory of Computation (I) Yijia Chen Fudan University

Inf2A: Converting from NFAs to DFAs and Closure Properties

Automata: a short introduction

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

Finite Automata and Regular Languages

Automata Theory for Presburger Arithmetic Logic

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Uses of finite automata

Closure under the Regular Operations

CS 121, Section 2. Week of September 16, 2013

Nondeterministic Finite Automata and Regular Expressions

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages

Question Bank UNIT I

CSE 105 THEORY OF COMPUTATION

Warshall s algorithm

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Chapter 3. Regular grammars

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages

Deterministic Finite Automata (DFAs)

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

Finite Automata Part Two

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

INSTITUTE OF AERONAUTICAL ENGINEERING

Lecture 17: Language Recognition

Deterministic Finite Automata (DFAs)

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

Theory of Computation

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

FABER Formal Languages, Automata. Lecture 2. Mälardalen University

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Chapter Five: Nondeterministic Finite Automata

Computational Models - Lecture 1 1

What we have done so far

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

CISC 4090 Theory of Computation

Fooling Sets and. Lecture 5

CPSC 421: Tutorial #1

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

3515ICT: Theory of Computation. Regular languages

Lecture 3: Nondeterministic Finite Automata

Deterministic Finite Automata (DFAs)

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

Non-deterministic Finite Automata (NFAs)

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

CS Automata, Computability and Formal Languages

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Automata Theory and Formal Grammars: Lecture 1

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Before we show how languages can be proven not regular, first, how would we show a language is regular?

DM17. Beregnelighed. Jacob Aae Mikkelsen

Computational Models - Lecture 3 1

UNIT-I. Strings, Alphabets, Language and Operations

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Languages, regular languages, finite automata

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Regular expressions and Kleene s theorem

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Theory of Languages and Automata

How do regular expressions work? CMSC 330: Organization of Programming Languages

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Transcription:

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three questions. Q. No. Q.1 (a) Question Marks CO Unit-1 Define automata. Explain finite automata with neat and labeled diagram. Also check acceptability of string 101101 for the given automata.. (06) CO363.1 1 1 The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled computing device which follows a predetermined sequence of operations automatically. An automaton with a finite number of states is called a Finite Automaton(FA) or Finite State Machine (FSM). Formal definition of a Finite Automaton An automaton can be represented by a 5-tuple (Q,, δ, q 0, F), where Q is a finite set of states. is a finite set of symbols, called the alphabet of the automaton. δ is the transition function. q 0 is the initial state from where any input is processed (q 0 Q). F is a set of final state/states of Q (F Q). An FA has three components: 1. input tape contains single string; 2. head reads input string one symbol at a time; and 3. Memory is in one of a finite number of states. String Acceptability: δ(q 0, 101101) δ(q 1, 01101) δ(q 3, 1101) δ(q 3, 101) δ(q 3, 01) δ(q 3, 1) q 3 Q.1 (b) As q 3 is the final state of the finite automata hence this string is accepted. Construct an NFA that accepts the set of strings defined over ={0,1} that (10)

starts with 1 and accepts the string of w mod 3=0 L={x * : x starts with 1 and x mod 3=0} Convert the NFA into equivalent DFA. Q.1 (a) OR Minimize the following finite automata. Also write procedure for minimization: (08) CO363.1 Step 1: State/Input 0 1 ->q0 q1 q3 q1 q0 q3

q2 q1 q4 q3 q5 q5 q4 q3 q3 *q5 q5 q5 Remove all un reachable states. Remove q2, q4 Step2: Separate into two sets Set 1 State/Input 0 1 ->q0 q1 q3 q1 q0 q3 q3 q5 q5 Set 2 State/Input 0 1 *q5 q5 q5 q3, q5 are indistinguishable states so we remove q3. Step 3:Combinning both sets State/Input 0 1 ->q0 q1 q5 q1 q0 q5 *q5 q5 q5 Transition Diagram 1 0 1 q 0 q 1 q 5 0,1 0 Q.1 (b) Construct a deterministic finite automata equivalent to the following NDFA. (08) Transition Table State/Input 0 1 2 ->q0 { q1, q4} q4 q3 q1 - q4 - q2 - - { q2, q3} *q3 - q4 -

q4 - - - Equivalent DFA Transition Table State/Input 0 1 2 ->q0 { q1, q4} q4 q3 *q3 - q4 - q4 - - - { q1, q4} - q4 - q0 1 q4 0 2 { q1,q4},q 1 q3 1 Q.2 (a) Unit-2 Define regular expressions and languages associated with regular expressions. Write the regular expression and finite automata (transition diagram) for following languages over alphabets = {a,b}. i) The set of strings that start with ab end with bb. ii) The set of strings that starts with a and ends with b and contain at least one sequence of aaa in that strings. Regular Expression Regular expressions can be thought of as the algebraic description of a regular language. Regular expression can be defined by the following rules: Every letter of the alphabet is a regular expression. Null string є and empty set Φ are regular expressions. If r1 and r2 are regular expressions, then (i) r1, r2 (ii) r1r2 ( concatenation of r1r2 ) (iii) r1 + r2 ( union of r1 and r2 ) (iv) r1*, r2* ( kleen closure of r1 and r2 ) are also regular expressions If a string can be derived from the rules 1, 2 and 3 then it is also a regular expression. Regular Language: Regular languages are languages that can be generated from one-element languages by applying certain standard operations a finite number of times. They are the languages that can be recognized by finite automata. These simple operations include concatenation, union and kleen closure. By the use of these operations regular languages can be represented by an explicit formula. (10) CO363.2

i) The set of strings that start with ab end with bb. ab(a+b)*bb a b b b q 0 q 1 q 2 q 3 q 4 a,b ii) The set of strings that starts with a and ends with b and contain at least one sequence of aaa in that strings. a(a+b)*aaa(a+b)*b a,b a a a q 0 q 1 q 2 q 3 a a,b q 3 b q 4 Q.2 (b) Use Arden s theorem to find regular expression for the following DFA. (6) q1= q1.0+ q3.0.(1) q2= q1.1+ q2.1+ q3.1 (2) q3= q2.0 (3) put value of (3) in (2) q2= q1.1+ q2.1+ q2.01 q2= q1.1+ q2.(1+ 01) Using Arden s Theorem q2= q1.1(1+ 01)*..(4)

Q.2 (a) put value of (3) in (1) q1= q1.0+ q2.00.(5) put value of (4) in (5) q1= q1.0+ q1.1(1+ 01)*.00+^ q1= q1(0+ 1(1+ 01)*.00)+^ using arden s theorem q1= (0+ 1(1+ 01)*.00)* Regular expression corresponding this DFA is (0+ 1(1+ 01)*.00)* OR Write the closure properties of regular languages. Explain pigeon hole principle. Prove that language L= {a n b n : n 0} is not regular using method of contradiction. Closure Properties of regular languages: Any set that represents the value of the Regular Expression is called a Regular Set. Properties of Regular Sets Property 1. The union of two regular set is regular. Let us take two regular expressions RE1 = a(aa)* and RE2 = (aa)* So, L1 = {a, aaa, aaaaa,...} (Strings of odd length excluding Null) and L2 ={ ε, aa, aaaa, aaaaaa,...} (Strings of even length including Null) L1 L2 = { ε, a, aa, aaa, aaaa, aaaaa, aaaaaa,...} (Strings of all possible lengths including Null) RE (L1 L2) = a* (which is a regular expression itself) Property 2. The intersection of two regular set is regular. Let us take two regular expressions RE1 = a(a*) and RE2 = (aa)* So, L1 = { a,aa, aaa, aaaa,...} (Strings of all possible lengths excluding Null) L2 = { ε, aa, aaaa, aaaaaa,...} (Strings of even length including Null) L1 L2 = { aa, aaaa, aaaaaa,...} (Strings of even length excluding Null) RE (L1 L2) = aa(aa)* which is a regular expression itself. Property 3. The complement of a regular set is regular. Let us take a regular expression RE = (aa)* So, L = {ε, aa, aaaa, aaaaaa,...} (Strings of even length including Null) Complement of L is all the strings that is not in L. So, L = {a, aaa, aaaaa,...} (Strings of odd length excluding Null) RE (L ) = a(aa)* which is a regular expression itself. Property 4. The difference of two regular set is regular. Let us take two regular expressions RE1 = a (a*) and RE2 = (aa)* So, L1 = {a, aa, aaa, aaaa,...} (Strings of all possible lengths excluding Null) L2 = { ε, aa, aaaa, aaaaaa,...} (Strings of even length including Null) L1 L2 = {a, aaa, aaaaa, aaaaaaa,...} (08) CO363.2

(Strings of all odd lengths excluding Null) RE (L1 L2) = a (aa)* which is a regular expression. Property 5. The reversal of a regular set is regular. We have to prove L R is also regular if L is a regular set. Let, L = {01, 10, 11, 10} RE (L) = 01 + 10 + 11 + 10 L R = {10, 01, 11, 01} RE (L R ) = 01 + 10 + 11 + 10 which is regular Property 6. The closure of a regular set is regular. If L = {a, aaa, aaaaa,...} (Strings of odd length excluding Null) i.e., RE (L) = a (aa)* L* = {a, aa, aaa, aaaa, aaaaa, } (Strings of all lengths excluding Null) RE (L*) = a (a)* Property 7. The concatenation of two regular sets is regular. Let RE1 = (0+1)*0 and RE2 = 01(0+1)* Here, L1 = {0, 00, 10, 000, 010,...} (Set of strings ending in 0) and L2 = {01, 010,011,...} (Set of strings beginning with 01) Then, L1 L2 = {001,0010,0011,0001,00010,00011,1001,10010,...} Set of strings containing 001 as a substring which can be represented by an RE (0 + 1)*001(0 + 1)* Pigeon Hole Principle: Theorem: If "n" number of pigeons or objects are to be placed in "k" number of pigeonholes or boxes; where k<n, then there must be at least one pigeonhole or box which has more than one object. Proof of Generalized Pigeonhole Principle In order to prove generalized pigeonhole principle, we shall use the method of induction. According to which we will assume the contradiction and prove it wrong. Let us suppose that total "nn" number of pigeons are to be put in "mm" number of pigeonholes and n>m. Let us assume that there is no pigeonhole with at least n/m pigeons. In this case, each and every pigeonhole will have less than n/m pigeons. Therefore, we have Number of pigeons in each pigeonhole < n/m Total number of pigeons < number of pigeonhole x n/m Total number of pigeons < m* n/m Total number of pigeons < n But given that number of pigeons are strictly equal to n. Which is a contradiction to our assumption. Hence there exists at least one pigeonhole having at least n/m pigeons. This proves the generalized form of pigeonhole principle.

Prove that language L= {a n b n : n 0} is not regular Q.2 (b) (i) If G=({s},{a},{S SS},S).Find the language generated by G. (ii) Show that L= {a n n is prime number} is not regular. (08) (i) (ii) L=ϕ. Prove that L = {a n : n is a prime number} is not regular. a. We don't know m, but assume there is one. b. Choose a string w = a n where n is a prime number and xyz = n > m+1. (This can always be done because there is no largest prime number.) Any prefix of w consists entirely of a's. c. We don't know the decomposition of w into xyz, but since xy m, it follows that z > 1. As usual, y > 0, d. Since z > 1, xz > 1. Choose i = xz. Then xy i z = xz + y xz = (1 + y ) xz. Since (1 + y ) and xz are each greater than 1, the product must be a composite number. Thus xy i z is a composite number. Unit-3 Q.3 Show that grammar S ab/ab, A aab/a, B ABb/b is ambiguous. Consider a srting w=aaabbb Constructing derivation tree for this string (08) CO363.3

As we get two derivation trees for the string w=aaabbb hence this grammar is ambiguous. OR Q.3 The productions of any grammar is given by: S 0B/1A A 0/0S/1AA B 1/ 1S/0BB For the string 00110101, Find the leftmost derivation, Rightmost derivation and derivation tree. (08) CO363.3