Lecture 7 Properties of regular languages

Similar documents
Closure Properties of Regular Languages

The Pumping Lemma and Closure Properties

CS 455/555: Finite automata

Closure under the Regular Operations

Equivalence of DFAs and NFAs

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

CS 154, Lecture 3: DFA NFA, Regular Expressions

Properties of Context-Free Languages. Closure Properties Decision Properties

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

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

Finite Automata and Regular languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Sri vidya college of engineering and technology

Properties of Regular Languages (2015/10/15)

Computational Models - Lecture 3 1

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

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Inf2A: Converting from NFAs to DFAs and Closure Properties

Formal Languages, Automata and Models of Computation

Properties of Context-Free Languages

Lecture 4 Nondeterministic Finite Accepters

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

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

More Properties of Regular Languages

Properties of Regular Languages. Wen-Guey Tzeng Department of Computer Science National Chiao Tung University

Ogden s Lemma. and Formal Languages. Automata Theory CS 573. The proof is similar but more fussy. than the proof of the PL4CFL.

UNIT II REGULAR LANGUAGES

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

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

Theory of Computation (I) Yijia Chen Fudan University

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

Mathematics for linguists

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

Computational Models - Lecture 5 1

Theory of Computation

Lecture 3: Nondeterministic Finite Automata

Text Search and Closure Properties

1 Alphabets and Languages

Text Search and Closure Properties

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,

Comment: The induction is always on some parameter, and the basis case is always an integer or set of integers.

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Fooling Sets and. Lecture 5

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

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

CS 154 Formal Languages and Computability Assignment #2 Solutions

Theory of Computation Lecture 1. Dr. Nahla Belal

CMSC 330: Organization of Programming Languages

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

HW6 Solutions. Micha l Dereziński. March 20, 2015

Ogden s Lemma for CFLs

Non-deterministic Finite Automata (NFAs)

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

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

Exam 1 CSU 390 Theory of Computation Fall 2007

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

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

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

Computational Models - Lecture 3 1

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

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

CS 133 : Automata Theory and Computability

Constructions on Finite Automata

Miscellaneous. Closure Properties Decision Properties

Non-context-Free Languages. CS215, Lecture 5 c

1 More finite deterministic automata

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

Computational Models - Lecture 4

Finite Automata and Regular Languages

Regular Expressions. Definitions Equivalence to Finite Automata

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

Nondeterministic Finite Automata

Author: Vivek Kulkarni ( )

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

Pumping Lemma for CFLs

CSE 105 Theory of Computation Professor Jeanne Ferrante

Fall 1999 Formal Language Theory Dr. R. Boyer. Theorem. For any context free grammar G; if there is a derivation of w 2 from the

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

Intro to Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Theory of Computation (II) Yijia Chen Fudan University

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

Computer Sciences Department

Constructions on Finite Automata

(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},

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

3515ICT: Theory of Computation. Regular languages

Closure under the Regular Operations

Computational Models #1

Regular expressions. Regular expressions. Regular expressions. Regular expressions. Remark (FAs with initial set recognize the regular languages)

Regular expressions and Kleene s theorem

Computational Models - Lecture 1 1

This Lecture will Cover...

TDDD65 Introduction to the Theory of Computation

CSE 105 THEORY OF COMPUTATION

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

NPDA, CFG equivalence

Decidability (What, stuff is unsolvable?)

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

Transcription:

Lecture 7 Properties of regular languages COT 4420 Theory of Computation Section 4.1

Closure properties of regular languages If L 1 and L 2 are regular languages, then we prove that: Union: L 1 L 2 Concatenation: L 1 L 2 Star: L 1 * Reversal: L 1 R Complement: L1 Are regular Languages Intersection: L 1 L 2

Closure properties of regular languages If L 1 and L 2 are regular languages, then we prove that: Substitution Homomorphism Inverse homomorphism Are regular Languages Right Quotient: L 1 /L 2

Suppose this is the representation of an NFA accepting L 1. M(r)

Union L 1 L 2 M 1 M 2 w L 1 L 2 w L1 or w L2

L1 L2 = { a b} { ba} n Union - Example L1 = { a b} a n b L 2 = { ba} b a

Concatenation L 1 L 2 M 1 M 2 w L 1 L 2 w = w1w 2 : w1 L1 and w2 L2

Concatenation - Example n L1 L2 = { a b}{ ba} = { a bba} n n L1 = { a b} a L 2 = { ba} b b a

Star Operation L 1 * M 1 * w L w = w1w 2 wk : or w = w i L

Star Operation - Example L * = { a n b} * 1 a L1 = { a b} b n

Reverse L 1 R Make sure your NFA has single final state. Reverse all transitions Make the initial state accept state and make the accept state initial state. M M L ( M ) = L L ( M ) = R L

Reverse - Example L n 1 b = { a } a M 1 b L = R 1 { ba n } a M 1 b

Complement The the DFA that accepts L. Make final states non-final states and vice versa M M L ( M ) = L L ( M ) = L

Complement - Example a a,b n L1 = { a b} b a, b n L1 = { a, b}* { a b} a b a, b a,b

Intersection L 1 L 2 De Morgan s Law: L1 L2 = L1 L2 L 1 and L 2 are regular L 1 and L 2 are regular L 1 L 2 L 1 L 2 is regular is regular

Substitution A substitution f is a mapping f: Σ 2 Δ* (for some alphabet Δ). Thus f associates a language with each symbol of Σ. The mapping f is extended to strings as follows: f()= f(xa) = f(x)f(a) x Σ*, a Σ The mapping f is also extended to languages by defining:

Substitution - Example Σ={0,1} Δ={a,b} Let f(0) = ab* and f(1) = ac f(011) = ab*acac f(011*) = ab*ac(ac)* o If f(a) is a regular language for a Σ, we call the substitution a regular substitution.

Closure under substitution Theorem: Regular sets are closed under (regular) substitutions. Let R Σ * be a regular language. We need to show that f(r) is a regular language. For each a Σ, let R a Δ* be a regular set such that f(a) = R a. Select regular expressions denoting R and each R a. Replace each occurrence of a in the regular expression for R by the regular expression for R a.

Closure under substitution The resulting regular expression is denoting f(r). And it can be shown that: f(l 1 L 2 ) = f(l 1 ) f(l 2 ) f(l 1 L 2 ) = f(l 1 )f(l 2 ) f(l 1 *) = (f(l 1 ))*

Homomorphism A homomorphism h is a substitution in which a single letter is replaced with a string. for a Σ, h(a) is a single string in Δ h: Σ Δ* If w = a 1 a 2 a n then h(w) = h(a 1 )h(a 2 ) h(a n ) If L is a language on Σ, h(l) = { h(w) : w L} and is called its homomorphic image.

Homomorphism - Example Σ={0,1,2} Δ={a,b} h(0) = ab h(1) = b h(2) = a Then h(0110) = abbbab h(122) = baa The homomorphic image of L = {0110,122} is the language h(l) = {abbbab, baa}

Homomorphism Homomorphism is a substitution hence regular languages are closed under homomorphism. Inverse homomorphism: Let h: Σ Δ* be a homomorphism, then h -1 (w) = { x h(x) = w} for w Δ*. h -1 (L) = { x h(x) L} for L Δ*

Inverse Homomorphism Theorem: The class of regular sets is closed under inverse homomorphism. Let h: Σ Δ* be a homomorphism and consider L a regular language in Δ*. There must exists a dfa M=(Q, Δ, δ, q 0, F) that accepts L. We construct M Σ = (Q, Σ, δ, q 0, F) that accepts h -1 (L) by defining δ (q, a) = δ(q, h(a)) for a Σ. By induction on x we can show that x L Σ if and only if h(x) L.

Example Prove that L = { a n ba n : n 1} is not regular. Suppose we know hat {0 n 1 n : n 1} is not regular. h 1 (a) = a, h 1 (b) = ba h 1 (c)=a h 2 (a) = 0 h 2 (b) = 1 h 2 (c) = 1 h 1-1 ({a n ba n n 1}) = (a+c) n b(a+c) n-1 h 1-1 ({a n ba n n 1}) a*bc* = {a n bc n-1 : n 1} h 2 (h 1-1 ({a n ba n n 1}) a*bc* ) = {0 n 1 n : n 1} If { a n ba n : n 1} were regular since regular languages are closed under h and h -1 and intersection, {0 n 1 n : n 1} must have been regular, a contradiction.

Right Quotient Let L 1 and L 2 be languages on the same alphabet. Then the right quotient of L 1 with L 2 is defined as: L 1 /L 2 = { x: xy L 1 for some y L 2 } Example: L 1 = 0*10* L 2 =10*1 L 3 =0*1 L 1 /L 3 = 0* L 2 /L 3 =10*

Right Quotient Theorem: If L 1 and L 2 are regular languages, then L 1 /L 2 is regular. Suppose there is a dfa M=(Q, Σ, δ, q 0, F) such that L 1 = L(M). We construct M =(Q, Σ, δ, q 0, F ) that accepts L 1 /L 2. For all states q i Q determine if there exists a y L 2 such that δ*(q i, y) = q f F. In that case we add q i to F.

Right Quotient - Example L 1 = L(a*baa*) L 2 = L(ab*) L(M) = L 1

Right Quotient - Example L 1 = L(a*baa*) L 2 = L(ab*) For every state q i determine if there is a y L 2 that δ*(q i, y) F L(M) = L 1

Right Quotient - Example L 1 = L(a*baa*) L 2 = L(ab*) For every state q i determine if there is a y L 2 that δ*(q i, y) F L(M) = L 1 From q 0? No

Right Quotient - Example L 1 = L(a*baa*) L 2 = L(ab*) For every state q i determine if there is a y L 2 that δ*(q i, y) F L(M) = L 1 From q 0? No From q 1? y = a

Right Quotient - Example L 1 = L(a*baa*) L 2 = L(ab*) For every state q i determine if there is a y L 2 that δ*(q i, y) F L(M) = L 1 From q 0? No From q 1? y = a From q 2? y = a

Right Quotient - Example L 1 = L(a*baa*) L 2 = L(ab*) For every state q i determine if there is a y L 2 that δ*(q i, y) F L(M) = L 1 From q 0? No From q 1? y = a From q 2? y = a From q 3? No

Right Quotient - Example L 1 /L 2 = L(a*ba*)