Closure Properties of Regular Languages

Slides:



Advertisements
Similar presentations
CS2303-THEORY OF COMPUTATION Closure Properties of Regular Languages
Advertisements

&& Department of nskinfo-i educationwww.nsksofttch.com CS2303-THEORY OF COMPUTATION uChapter: Closure.
6.2 Closure Properties of CFL's
The Pumping Lemma for CFL’s
Properties of Regular Languages
Lecture 8 From NFA to Regular Language. Induction on k= # of states other than initial and final states K=0 a a* b a c d c*a(d+bc*a)*
Closure Properties of CFL's
Automata and Formal Languages Tim Sheard 1 Lecture 9 Reasoning with DFAs.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
1 Module 21 Closure Properties for LFSA using NFA’s –From now on, when I say NFA, I mean any NFA including an NFA- unless I add a specific restriction.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
Definitions Equivalence to Finite Automata
1 Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism.
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Regular Expressions and Finite State Automata  Themes  Finite State Automata (FSA)  Describing patterns with graphs  Programs that keep track of state.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
1 State SymbolRead- Q E(Q) a b a b a b Convert to a DFA: Start state: Final States:
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages.
Chapter 4 Properties of Regular Languages
1 Regular Expressions Reading: Chapter 3. 2 Regular Expressions vs. Finite Automata Offers a declarative way to express the pattern of any string we want.
1 Closure Properties of Regular Languages L 1 and L 2 are regular. How about L 1  L 2, L 1  L 2, L 1 L 2, L 1, L 1 * ?
CS 203: Introduction to Formal Languages and Automata
1 Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Strings and Languages Denning, Section 2.7. Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
1 Introduction to the Theory of Computation Regular Expressions.
P Symbol Q E(Q) a b a b a b Convert to a DFA: Start state: Final States:
1 Closure E.g., we understand number systems partly by understanding closure properties: Naturals are closed under +, , but not -, . Integers are closed.
Chapter 2 Regular Languages & Finite Automata. Regular Expressions A finitary denotation of a regular language over . ØL Ø = Ø aL a = {a} where a ∈ 
Cpt S 317: Spring 2009 Reading: Chapter 3
Regular Languages, Regular Operations, Closure
Properties of Context-Free Languages
Closure Properties of Regular Languages
Properties of Regular Languages
PROPERTIES OF REGULAR LANGUAGES
Regular Expressions.
Formal Language & Automata Theory
Regular Expressions Sections:1.3 page 63 September 17, 2008
Lecture 9 Theory of AUTOMATA
Single Final State for NFA
Chapter Seven: Regular Expressions
Decision Properties of Regular Languages
Properties of Regular Languages
Properties of Regular Languages
CS 154, Lecture 3: DFANFA, Regular Expressions.
Closure Properties of DFAs
CSE322 CONSTRUCTION OF FINITE AUTOMATA EQUIVALENT TO REGULAR EXPRESSION Lecture #9.
4. Properties of Regular Languages
CSE 2001: Introduction to Theory of Computation Fall 2009
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Closure Properties of Regular Languages
Finite-State Methods in Natural-Language Processing: Basic Mathematics
Lecture Closure Properties for Regular Languages
The Pumping Lemma for CFL’s
Properties of Context-Free languages
Closure Properties of Regular Languages
Regular Languages ภาษาปกติ.
Convert to a DFA: Start state: Final States: State Symbol Read- Q E(Q)
Convert to a DFA: Start state: Final States: P Symbol Q E(Q) a b.
CSCI 2670 Introduction to Theory of Computing
CSC312 Automata Theory Kleene’s Theorem Lecture # 12
NFAs accept the Regular Languages
Presentation transcript:

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

Review Closure Properties Recall a closure property is a statement that a certain operation on languages, when applied to languages in a class (e.g., the regular languages), produces a result that is also in that class. For regular languages, we can use any of its representations to prove a closure property.

Closure Under Union If L and M are regular languages, so is L  M. Proof: Let R and S be the REs that define L and M. Then R+S is a regular expression whose regular language is L  M. Therefore, RLs are closed under union

Closure Under Concatenation and Kleene Closure Same idea: RS is a regular expression whose language is LM; therefore LM is regular. R* is a regular expression whose language is L*; therefore L* is regular

Closure Under Intersection If L and M are regular languages, then LM is regular. Proof: Let A and B be DFA’s whose languages are L and M, respectively. Construct C = p-DFA of A and B States of C are distinct pairs [q(A),r(B)] Start state is pair [start(A), start(B)] δ([q(A),r(B)],a) = [δA(q,a), δB(r,a)] Make the accepting states of C be the pairs consisting of accepting states of both A and B.

Product DFA for Intersection B 1 0, 1 P-DFA(L  M ) L [A,C] [A,D] 1 1 1 1 C D [B,C] [B,D] 1 M String w accepted by p-DFA iff it is accepted by both DFA(L) and DFA(M). P-DFA defines (LM ), which is regular

Closure Under Difference L– M = strings in L but not M. If L and M are regular languages, then so is L-M Proof: Let A and B be DFA’s whose languages are L and M, respectively. Construct C = p-DFA of A and B. Make the accepting states of C be the pairs where A-state is accepting but B-state is not. p-DFA defines the RL of L-M.

Product DFA for Difference B 1 0, 1 p-DFA(L-M) L [A,C] [A,D] 1 1 1 C D 1 [B,C] [B,D] 1 M p-DFA(L-M) is the empty language in this case, why?

Closure Under Complementation The complement of a language L (with respect to an alphabet Σ such that Σ* contains L) is Σ* – L. Since Σ* is regular, the complement of a regular language is regular because it is the difference of regular languaes.

Closure Under Reversal Given language L, LR is the set of strings whose reversal is in L. Example: L = {0, 01, 100}; LR = {0, 10, 001}. Proof: Let E be a regular expression for L. We show how to reverse E, to provide a regular expression ER for LR.

Reversal of a Regular Expression Basis: If E = a, ε, or ∅, then ER = E. Induction: If E=F+G, then ER = FR + GR. If E=FG, then ER = GRFR If E=F*, then ER = (FR)*. Example find ER of 1*0 + 0*1. Show all steps

Example: Reversal of a RE Let E = 01* + 10*. ER = (01* + 10*)R = (01*)R + (10*)R (union rule) = (1*)R0R + (0*)R1R (concat. rule) = (1R)*0 + (0R)*1 (closure rule) = 1*0 + 0*1.

Homomorphisms A homomorphism on an alphabet is a function that assigns a string to every symbol in that alphabet Example on S={0,1} Define h(0) = ab h(1) = ε Extend to strings by h(a1…an) = h(a1)…h(an) example: h(01010) = ababab h(L)={h(w)|w is in L}=homomorphism of L Language formed by applying h to every string in L

Closure Under Homomorphism If L is a regular language, and h is a homomorphism on its alphabet, then h(L)= {h(w)|w is in L} is also a regular language. Proof: Let E be a regular expression for L. Apply h to each symbol in E. Language of resulting RE is h(L).

Exercise: find the RE of h(L) and simplify h(0) = ab; h(1) = ε. L = the language of RE = 01* + 10* Find the RE of h(L) and simplify

Simplify the RE for h(L) abε* + ε(ab)* ε* = ε ε is the identity under concatenation. abε*+ε(ab)*=abε+ε(ab)*=ab+(ab)*. ab is contained in (ab)* RE for h(L) is (ab)*

Inverse Homomorphism of a string h-1(w) is read “inverse homomorphism of w w’=h-1(w), iff h(w’)=w Testing a string for inverse homomorphism is easy. Just apply homomorphism to the string

Inverse homomorphisms of a language Let h be a homomorphism defined on S Let h(L) be a homomorphism of L defined on S Let h-1(L) denote the inverse homomorphism of L defined by h(L) h-1(L) ={w’| such that h(w’) is in L}

Example: Inverse Homomorphism Let h(0) = ab; h(1) = ε. Let L = {abab, baba} h-1(L) = {all w defined on {0,1} such that h(w) is either abab or baba} No w such that h(w)=baba h-1(L) = any w with two 0’s and any number of 1’s because h(w)=abab

Closure of RLs under Inverse Homomorphism Proof by construction Start with a DFA(L) = A Construct the ih-DFA = B for h-1(L) with: The same set of states. The same start state. The same final states. Input alphabet = the symbols to which homomorphism h applies Transition function δB(q, a) = δA(q, h(a))

Example of ih-DFA Construction ih-DFA defined on {0,1} DFA defined on {a,b} 1 Since h(1) = ε a B C B A , 0 Since h(0) = ab a A b b b C a δB(q, a) = δA(q, h(a)) h(0) = ab h(1) = ε

CptS 317 Fall 2016   Assignment 12, Due 10-28-16 Exercises 4.2.1 (a), (c) and (e) text p 147

Quotient of a language L/a L/a = set of all strings w such that wa is in L a is a symbol in the alphabet of L a is the last symbol in the test string wa Example: if L={a,aab,baa} then L/a ={e,ba} If L is regular, so is L/a Proof by construction: q-DFA(L/a) same as DFA(L) except that q is an accepting state of q-DFA iff d(q,a) is an accepting state of DFA

Derivative of a language: a\L a\L = set of all strings w such that aw is in L a is the first symbol in the test string aw Example: if L={a,aab,baa} then a\L={e,ab} Called “derivative” because RE of L compared to RE a\L is similar to derivative of algebraic expression Example: a\(R+S)=a\R+a\S remove a after union is the same as union of strings with a removed Concatenation example on board

Exercise 4.2.5e What is the implication of 0\L = nil? Exercise 4.2.5f Example of L such that 0\L = L

Using Closure to prove non-regular L1 is language in question L2 is language known to be non-regular O is an operation under which regular languages are closed. L2 = O L1 If L1 were regular, then L2 would be regular, but it isn’t. Therefore L1 is not regular

Using Closure to prove non-regular Example: 4.2.13 p149 Prove L1={0i1j|i>0,j>0,i not = j} not reg. Assume L1 is regular Then L2=0*1*-L1 is regular by closure under difference L2={0n1n|n>0} why? L2={0n1n|n>0} is not regular Therefor the assumption about L1 is false