Properties of Regular Languages

Slides:



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

Deterministic Finite Automata (DFA)
1 Midterm I review Reading: Chapters Test Details In class, Wednesday, Feb. 25, :10pm-4pm Comprehensive Closed book, closed notes.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
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.
Fall 2006Costas Busch - RPI1 Regular Expressions.
1 Positive Properties of Context-Free languages. 2 Context-free languages are closed under: Union is context free is context-free.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Sets Definition of a Set: NAME = {list of elements or description of elements} i.e. B = {1,2,3} or C = {x  Z + | -4 < x < 4} Axiom of Extension: A set.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
CS 310 – Fall 2006 Pacific University CS310 Strings, String Operators, and Languages Sections: August 30, 2006.
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 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
Fall 2006Costas Busch - RPI1 Properties of Regular Languages.
Courtesy Costas Busch - RPI1 Non-regular languages.
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
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.
Lecture 1 String and Language. String string is a finite sequence of symbols. For example, string ( s, t, r, i, n, g) CS4384 ( C, S, 4, 3, 8) (1,
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,
1 Chapter 1 Introduction to the Theory of Computation.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet:
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 1 Regular Languages
Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
Chapter 6 Properties of Regular Languages. 2 Regular Sets and Languages  Claim(1). The family of languages accepted by FSAs consists of precisely the.
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
Regular Expressions Costas Busch - LSU.
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.
BİL711 Natural Language Processing1 Regular Expressions & FSAs Any regular expression can be realized as a finite state automaton (FSA) There are two kinds.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
1 Closure E.g., we understand number systems partly by understanding closure properties: Naturals are closed under +, , but not -, . Integers are closed.
Regular Languages, Regular Operations, Closure
Languages.
Standard Representations of Regular Languages
Languages Prof. Busch - LSU.
Properties of Regular Languages
PROPERTIES OF REGULAR LANGUAGES
Formal Language & Automata Theory
CSE 3813 Introduction to Formal Languages and Automata
PDAs Accept Context-Free Languages
Single Final State for NFA
Closure Properties for Regular Languages
CSE322 PROPERTIES OF 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
Deterministic PDAs - DPDAs
Closure Properties of Context-Free languages
Elementary Questions about Regular Languages
Closure Properties of Regular Languages
Chapter 4 Properties of Regular Languages
Properties of Context-Free languages
Closure Properties of Regular Languages
Chapter 1 Introduction to the Theory of Computation
NFAs accept the Regular Languages
Languages Fall 2018.
Presentation transcript:

Properties of Regular Languages Reading: 4.1 & 4.2

Closure Questions Is the class of regular languages closed under union? That is, given 2 regular languages L1 & L2, is L1 U L2 also regular?

Closure by definition Regular Languages are closed under Union L(r1) or L(r2) Concatenation L(r1)∙L(r2) Star-closure L(r1*) These are true by definition of regular expressions If L1 is regular, then there exists some regular expression r1 which describes it. Same for L2. Then: L1 U L2 = L(r1) U L(r2) = r1 + r2 r1 + r2 is a regular expression and therefore describes a regular language.

Closure under Complementation Remember: L is the language of all strings not in L. Prove: If L is regular, so is L Proof Idea: Show a FSA for L given the FSA for L. Let M for L be (Q,Σ, δ, q0, F) Then M for L is

Closure Under Intersection Given L1 and L2 that are regular, prove that L1 ∩ L2 is regular. There are 2 dfa’s: M(L1) = (Q,Σ, δ1, q0, F) and M(L2) = (P,Σ, δ2, p0, G) Create dfa for L1 and L2: states are all states (qi,pj). Transition from (qi,pj) to (qk,pl) on a if there is a transition in L1 from qi to qk on a and from pj to pl on a.

Example a q0 q2 a p0 p3 b a q1 b a a b p1 p2 a qo p0 q2 p3 b a q1 p1

Closure Under Intersection Proof 2 DeMorgan’s Law: L1∩L2 = L1 U L2 L1 and L2 are regular So L1 and L2 are regular (Closure under complementation) So L1 U L2 is regular (Closure under union) So L1 U L2 is regular. (Closure under comp.) So L1 ∩ L2 is regular.

Closure Under Difference L1 – L2 is regular if L1 and L2 are regular L1 – L2 = L1 ∩ L2 L1 and L2 are regular Then L2 is regular (closure under comp.) Then L1 ∩ L2 is regular (closure under inter.) So L1 – L2 is regular

Closure Under Reversal If L is regular, then LR is regular. L is regular so it has a FSA. FSA for LR can be constructed: Make one final state Make final state initial Make initial state final Reverse all arrows. LR has a FSA, so it is regular.

Homomorphisms A homomorphism is a function whose domain is an alphabet and range is the star closure of an alphabet. A homomorphism takes a letter and substitutes it with a string. The homomorphic image of a language is all strings h(w) when w is a string in the language.

Homomorphism Example Σ = {a,b} h(a) = b h(b) = aac So h(abaa) = baacbb The homomorphic image of the language L = {aba, bba} = {baacb, aacaacb}

Closure Under Homomorphism If L is regular and h is a homomorphism, then h(L) (the homomorphic image of L) is also regular. Proof idea: Find the regular expression for L. Exchange each symbol s in the regular expression for h(s). The resulting regular expression describes the homomorphic image of L. Since it is described with a regular expression, it is a regular language.

Right Quotient of Languages Let L1 and L2 be languages on the same alphabet. Then the right quotient of L1 with L2 is L1 / L2 = {x: xy is in L1 and y is in L2} In other words, if the string in L1 has a suffix from L2, remove the suffix and the resulting string is in L1 / L2

Closure under right quotient If L1, L2 are regular then L1 / L2 is regular. L1 is regular so it has a FSA. For each node in the FSA, see if there is a walk from that node to a final node using a string in L2. If so, mark that node final. So L1 / L2 is regular.

Example L1 = L(a*baa*); L2 = L(ab*) DFA for L1: a a b a q2 q0 q1 b b

Example L1 = L(a*baa*); L2 = L(ab*) Remove final marking, remember final is q2. a a b a q2 q0 q1 b b q3 a,b

Example L1 = L(a*baa*); L2 = L(ab*) For each node, look for a walk on element of L2 to q2. a a b a q2 q0 q1 b b q3 a,b

Example L1 = L(a*baa*); L2 = L(ab*) DFA for L1/L2: a a b a q2 q0 q1 b

Representations Regular languages can be described by: English descriptions (all strings with ab as a substring) Set Notation ({ba, ab, bba}) FSA Regular Expression Regular Grammars All but English descriptions are standard representations

Easy Problems for Reg Langs Membership (Is this string a member of Reg Lang L?) Is L empty, finite, or infinite? Equality (Is L1 = L2, for L1,L2 regular)

Equality Algorithm Is L1 = L2 for L1 and L2 regular? Define L3 = (L1 ∩ L2) U (L1 ∩ L2) We know L3 is regular So, we can test if L3 is empty L3 = Ø L1 = L2

Example Problems Draw a FSA for (a+b)a*  baa* Draw a FSA for (ab+ba)b*ba / b*a* Show that the family of regular languages is closed under the “nor” operation Give an algorithm to determine if a regular language is a “palindrome” language Give an algorithm to determine if L = L* for a regular language L. Give an algorithm to determine if a regular language has any strings of even length.