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.
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
YES-NO machines Finite State Automata as language recognizers.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
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.
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.
1 Languages and Finite Automata or how to talk to machines...
1 Lecture 19 Closure Properties for LFSA using NFA’s –union second proof –concatenation –Kleene closure.
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.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
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 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.
Regular Languages ภาษาปกติ. Jaruloj Chongstitvatana Outline Regular expressions Regular languages Equivalence between languages accepted by.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Lecture 2 Overview Topics What I forgot from last lecture Proof techniques continued Alphabets, strings, languages Automata June 2, 2015 CSCE 355 Foundations.
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.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
 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.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
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.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
General Discussion of “Properties” The Pumping Lemma Membership, Emptiness, Etc.
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
Languages.
Properties of Context-Free Languages
Closure Properties of Regular Languages
Properties of Regular Languages
PROPERTIES OF REGULAR LANGUAGES
Why Study Automata? What the Course is About Administrivia
Formal Language & Automata Theory
Closure Properties of Regular Languages
Single Final State for NFA
Jaya Krishna, M.Tech, Assistant Professor
Chapter Seven: Regular Expressions
Decision Properties of Regular Languages
Closure Properties for Regular Languages
Properties of Regular Languages
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
4. Properties of Regular Languages
Introduction to Finite Automata
Closure Properties of Regular Languages
The Pumping Lemma for CFL’s
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.
NFA’s With ε-Transitions
Finite-State Machines with No Output
CSC312 Automata Theory Kleene’s Theorem Lecture # 12
NFAs accept the Regular Languages
CSCE 355 Foundations of Computation
Presentation transcript:

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

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 L and M be the languages of regular expressions R and S, respectively. Then R+S is a regular expression whose language is L  M.

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

Closure Under Intersection 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, the product automaton of A and B. Make the final states of C be the pairs consisting of final states of both A and B.

Example: Product DFA for Intersection 1 [A,C] [A,D] A B 1 0, 1 1 1 1 [B,C] [B,D] 1 C D 1

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

Example: Product DFA for Difference 1 [A,C] [A,D] A B 1 0, 1 1 1 1 [B,C] [B,D] 1 C D Notice: difference is the empty language 1

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

Closure Under Reversal Recall example of a DFA that accepted the binary strings that, as integers were divisible by 23. We said that the language of binary strings whose reversal was divisible by 23 was also regular, but the DFA construction was very tricky. Good application of reversal-closure.

Closure Under Reversal – (2) 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 is a symbol a, ε, or ∅, then ER = E. Induction: If E is F+G, then ER = FR + GR. FG, then ER = GRFR F*, then ER = (FR)*.

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

Homomorphisms A homomorphism on an alphabet is a function that gives a string for each symbol in that alphabet. Example: h(0) = ab; h(1) = ε. Extend to strings by h(a1…an) = h(a1)…h(an). Example: h(01010) = ababab.

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).

Example: Closure under Homomorphism Let h(0) = ab; h(1) = ε. Let L be the language of regular expression 01* + 10*. Then h(L) is the language of regular expression abε* + ε(ab)*. Note: use parentheses to enforce the proper grouping.

Example – Continued abε* + ε(ab)* can be simplified. ε* = ε, so abε* = abε. ε is the identity under concatenation. That is, εE = Eε = E for any RE E. Thus, abε* + ε(ab)* = abε + ε(ab)* = ab + (ab)*. Finally, L(ab) is contained in L((ab)*), so a RE for h(L) is (ab)*.

Inverse Homomorphisms Let h be a homomorphism and L a language whose alphabet is the output language of h. h-1(L) = {w | h(w) is in L}.

Example: Inverse Homomorphism Let h(0) = ab; h(1) = ε. Let L = {abab, baba}. h-1(L) = the language with two 0’s and any number of 1’s = L(1*01*01*). Notice: no string maps to baba; any string with exactly two 0’s maps to abab.

Closure Proof for Inverse Homomorphism Start with a DFA A for L. Construct a 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.

Proof – (2) The transitions for B are computed by applying h to an input symbol a and seeing where A would go on sequence of input symbols h(a). Formally, δB(q, a) = δA(q, h(a)).

Example: Inverse Homomorphism Construction 1 Since h(1) = ε a B C B A , 0 Since h(0) = ab a A b b b C a h(0) = ab h(1) = ε

Proof – (3) Induction on |w| shows that δB(q0, w) = δA(q0, h(w)). Basis: w = ε. δB(q0, ε) = q0, and δA(q0, h(ε)) = δA(q0, ε) = q0.

Proof – (4) Induction: Let w = xa; assume IH for x. δB(q0, w) = δB(δB(q0, x), a). = δB(δA(q0, h(x)), a) by the IH. = δA(δA(q0, h(x)), h(a)) by definition of the DFA B. = δA(q0, h(x)h(a)) by definition of the extended delta. = δA(q0, h(w)) by def. of homomorphism.