Formal Language and Automata Theory (CS21004)

Similar documents
Finite State Automata

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

Nondeterministic Finite Automata

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,

Regular Language Equivalence and DFA Minimization. Equivalence of Two Regular Languages DFA Minimization

Chapter 2: Finite Automata

CS 455/555: Finite automata

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Lecture 5: Minimizing DFAs

CS 154, Lecture 4: Limitations on DFAs (I), Pumping Lemma, Minimizing DFAs

CSE 135: Introduction to Theory of Computation Optimal DFA

CS243, Logic and Computation Nondeterministic finite automata

Constructions on Finite Automata

3515ICT: Theory of Computation. Regular languages

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

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

CS154. Non-Regular Languages, Minimizing DFAs

Fall 1999 Formal Language Theory Dr. R. Boyer. 1. There are other methods of nding a regular expression equivalent to a nite automaton in

More on Finite Automata and Regular Languages. (NTU EE) Regular Languages Fall / 41

Homomorphisms and Efficient State Minimization

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Chapter 6. Properties of Regular Languages

Fooling Sets and. Lecture 5

Computational Models - Lecture 4

Chapter Five: Nondeterministic Finite Automata

Finite Automata and Regular Languages

CS 208: Automata Theory and Logic

Constructions on Finite Automata

Outline. Summary. DFA -> Regex. Finish off Regex -> e-nfa -> NFA -> DFA -> Regex Minimization/equivalence (Myhill-Nerode theorem)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Nondeterministic Finite Automata

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

Büchi Automata and their closure properties. - Ajith S and Ankit Kumar

What we have done so far

CSE 135: Introduction to Theory of Computation Equivalence of DFA and NFA

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

COMP4141 Theory of Computation

Finite Automata and Regular languages

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

Extended transition function of a DFA

Equivalence of DFAs and NFAs

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

More on Regular Languages and Non-Regular Languages

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Computational Theory

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

2017/08/29 Chapter 1.2 in Sipser Ø Announcement:

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

CSE 460: Computabilty and Formal Languages. Minimization of FA. S. Pramanik

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

CS 321 Solutions to Homework 4 Due October 22, 5pm

Notes on State Minimization

Nondeterministic Finite Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Deterministic finite Automata

Computational Models - Lecture 3 1

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Regular Expressions and Language Properties

CS 275 Automata and Formal Language Theory

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

We define the multi-step transition function T : S Σ S as follows. 1. For any s S, T (s,λ) = s. 2. For any s S, x Σ and a Σ,

Chapter 5. Finite Automata

CS 581: Introduction to the Theory of Computation! Lecture 1!

Computational Models - Lecture 3

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

Finite Automata and Languages

Chapter 2: Finite Automata

CS 154, Lecture 3: DFA NFA, Regular Expressions

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Finite Automata and Formal Languages TMV026/DIT321 LP Testing Equivalence of Regular Languages

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

V Honors Theory of Computation

Java II Finite Automata I

Sri vidya college of engineering and technology

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

Finite Automata. Theorems - Unit I SUSAN ELIAS. Professor Department of Computer Science & Engineering Sri Venkateswara College of Engineering

Computational Models: Class 3

DM17. Beregnelighed. Jacob Aae Mikkelsen

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017

Chapter 6: NFA Applications

Advanced Automata Theory 2 Finite Automata

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Regular Languages and Finite Automata

Lecture 3: Nondeterministic Finite Automata

Inf2A: Converting from NFAs to DFAs and Closure Properties

1 More finite deterministic automata

Advanced Automata Theory 7 Automatic Functions

Non-deterministic Finite Automata (NFAs)

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Introduction to Kleene Algebra Lecture 9 CS786 Spring 2004 February 23, 2004

Final exam study sheet for CS3719 Turing machines and decidability.

CSE 105 Theory of Computation Professor Jeanne Ferrante

Finite Automata (contd)

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

Theory of Computation (II) Yijia Chen Fudan University

Transcription:

Theory (CS21004)

Announcements The slide is just a short summary Follow the discussion and the boardwork Solve problems (apart from those we dish out in class)

Table of Contents 1 2 3

Languages that are not regular L = {a n b n n 0} = {ǫ,ab,aabb,aaabbb, } needs to remember number of a-sand match with b-s. Infinite number of possibilities cannot remember with finite number of states We further provide a formal arguement

Languages that are not regular Let a DFA with k states accept L. consider some n >> k starting from initial state i, a n b n leads to the accept state f some state must have been visited more than once, let it be p Let a n b n = uvw, j = v > 0 where ˆδ(i,u) = p,ˆδ(p,v) = p,ˆδ(p,w) = f Hence ˆδ(i,uw) = f uw = a n j b n / L Similarly, ˆδ(i,uv 3 w) = f but uv 3 w = a n+2j b n / L Such a DFA does not exist

for Regular Languages Let L be a regular language. Then there exists an integer p 1 such that every string w in L of length at least p (p is called the pumping length ) can be written as w = xyz (i.e., w can be divided into three substrings), satisfying the following conditions: y 1 xy p i 0, xy i z L

for Regular Languages : general version Let L be a regular language. Then there exists an integer p 1 such that every string uwv in L with w p can be written as uwv = uxyzv such that y 1 xy p i 0, uxy i zv L standard version is a special case with u,v being empty. Since the general version imposes stricter requirements on the language, it can be used to prove the non-regularity of many more languages, such as {a m b n c n : m 1, n 1}

for Regular Languages Necessary but not sufficient condition Cannot be used to prove language as regular There are non-regular languages which satisfy the lemma Violation can be used to prove language as non-regular

Ex {a 2n n 0}. Let this be accepted by a k state DFA. Choose n such that n >> k Thus 2 n > k. Hence we may decompose the string a 2n to parts of length i,j,l such that 2 n = i +j +l and the intermediate j symbols form a cycle in the DFA The DFA will accept a 2n +j Note, i +j k < n j < n 2 n +j < 2 n +n < 2 n +2 n = 2 n+1 such a DFA cannot exist

Ex We can show using {a n b m n m} is not regular {a n! n 0} is not regular

More examples of languages not regular Alternate lines of argument : A = {w n a (w) = n b (w)} if A is regular than A L(a b ) = {a n b n n 0} is regular {a n b m n m} is regular A R = {b m a n n m} is regular C = A R [a b,b a] = {a m b n n m} is regular A C = {a n b n n 0} is regular

More examples of languages not regular U N is an ultimately periodic set, i.e. n 0, p > 0, m n, m U iff m+p U. We call p is the period of U. Every such U is regular Ex. {0,3,7,9,19,20,23,26,29,32,35, } : (n = 20,p = 3),(n = 21,p = 6) : n,p need not be unique Let A {a}. A is regular iff {m a m A} is ultimately periodic

Table of Contents 1 2 3

Equivalence of FAs When we convert NFA to DFA, We ignore unreachable states, keep them you simply have a larger DFA for the same language!! Even some reachable states can be merged preserving language equivalence!!

Example a, b a b a a, b Apply standard NFA to DFA conversion, remove unreachable states b a a b a a b a b b b a b a b a Accept states can be merged! a b a Not all such cases are as obvious b

Example a 1 a 3 a,b 0 b 2 b a b 4 5 a,b a,b a,b a,b 6 7 8 a,b

Example a a,b b a,b a,b a,b a,b a,b

How to decide which states to collapse Intuitively two states are mergeable if they behave similarly (in terms of language acceptance) for the same input string Starting from respective states, with the same input string, either both lead to respective final states or none lead to respective final states Turns out to be a necessary and sufficient condition Such relations among state pairs are equivalence relations

Equivalence relation on states p,q Q, p q iff x Σ [ˆδ(p,x) F ˆδ(q,x) F] reflexive, symmetric, transitive for any state p, [p] = {q p q} by definition, equivalence classes are mutually exclusive and exhaustive : every state is in exactly one class/partition, p q [p] = [q]

Quotient Automaton M/ for DFA M Given M = (Q,Σ,δ,s,F), M/ def = (Q,Σ,δ,s,F ) Q = {[p] p Q} δ ([p],a) = [δ(p,a)] s = [s] F = {[p] p F}

Is δ well defined?? If p,q, [p], is δ ([p],a) = [δ(p,a)] = δ ([q],a) = [δ(q,a)]? For any a Σ, y Σ ˆδ(δ(p,a),y) F ˆδ(p,ay) F ˆδ(q,ay) F by definition of ˆδ since p q ˆδ(δ(q,a),y) F by definition of ˆδ Hence, δ(p,a) δ(q,a) by definition of. So, [δ(p,a)] = [δ(q,a)]

p F [p] F p F [p] F by definition of F. What about the other direction, i.e. [p] F p F?? What is there to prove?? Note that you have [p], that does not specify any p but the overall equivalence class. Need to show that all elements of the class are in F rather than one specific member. Prove that any such equivalence class is either subset of F or disjoint.

[p] F p F [p] F x [p],x F ˆδ(x,ǫ) = x F q x,ˆδ(q,ǫ) F q x,ˆδ(q,ǫ) = q F q [p],q F by defn. of ˆδ by defn. of by defn. of ˆδ q x [p],q [p]

Prove the following x Σ, ˆδ ([p],x) = [ˆδ(p,x)] L(M/ ) = L(M) M/ cannot be collapsed any further

Here is an algorithm for computing the collapsing relation for a given DFA M with no inaccessible states. The algorithm will mark (unordered) pair of states {p, q}. A pair {p,q} will be marked as soon as a reason is discovered why p and q are not equivalent. 1 Write down a table of all pairs {p,q}, initially unmarked. 2 Mark {p,q} if p F and q F of vice versa. 3 Repeat the following until no more changes occur: If there exists an unmarked pair {p,q} such that {δ(p,a),δ(q,a)} is marked for some a Σ, then mark {p,q}. 4 When done, p q iff {p,q} is not marked.

Table of Contents 1 2 3

DFA : isomorphism Two deterministic finite automata M = (Q M,Σ,δ M,s M,F M ), N = (Q N,Σ,δ N,s N,F N ), are isomorphic iff f, f : Q M Q N such that f(s M ) = s N p Q M,a Σ, f(δ M (p,a)) = δ N (f(p),a) p F M iff f(p) F N One is just the renamed version of another. Note, M/, N/ are also isomorphic. We should be able to define a minimal automata directly from the language itself. All other possible minimal automata will be isomorphic with this.

Relations Let R Σ be regular with DFA M = (Q,Σ,δ,s,F) for R. M does not have any unreachable states. A relation M on Σ defined as x M y ˆδ(s,x) = ˆδ(s,y) M is an equivalence relation. Other properties of M 1 x,y Σ,a Σ, x y xa ya : right congruence (show this) 2 M refines R : x M y (x R y R) every M -class has either all its elements in R or none of its elements in R, i.e. R is a union of M -classes 3 The no. of M classes is finite ( = no. of states in M?)

Relations Any equivalence relation on Σ which is a right congruence of finite index refining a regular set R is called a Relation Just like M M we can M Let be an arbitrary Relation on Σ for some R Σ, i.e. is some equivalence Relation on Σ which is also right congruence of finite index refining a regular set R

M DFA M = (Q,Σ,δ,s,F) Q = {[x] x Σ } (is finite, why?) s = [ǫ] F = {[x] x R} δ([x],a) = [xa] (y [x] [xa] = [ya] by right congruence) Can show x R [x] F : The is by defn of F, for, y [x] F x F y R by refinement ˆδ([x],y) = [xy] : by induction L(M ) = R M is identical to M M is isomorphic to M

Let R Σ. The following statements are equivalent: R is regular there exists a relation for R the relation R creates a finite partitioning of Σ

Example application Consider R = {a n b n n 0} Σ. Let R be regular with a relation on Σ for R Let a m a k for any m k By right congruence a m b k a k b k Note x y [x R y R], i.e. an equivalence partition is either inside R or outside R, but cannot span across But now we have one equivalence partition containing a m b k,a k b k where a m b k / R, a k b k R. Hence, it is not the case that a k a m The relation creates an infinite partitioning of Σ R is not regular