C OMPUTABILITY AND C OMPLEXITY , 2020 F ALL SEMESTER Lec 03. Regular expression, Pumping lemma Eunjung Kim
F ORMAL DEFINITION OF R EGULAR EXPRESSION R EGULAR EXPRESSION OVER A FINITE ALPHABET Σ Regular expression over Σ is a string consisting of symbols of Σ , paren- thesis ( and ) , and operators ∪ , ◦ , ∗ that can be generated as follows. Each symbol x ∈ Σ ∪ { ǫ } is a regular expression. ∅ is a regular expression. ( R 1 ∪ R 2 ) is a regular expression if R 1 and R 2 are regular expressions. ( R 1 ◦ R 2 ) is a regular expression if R 1 and R 2 are regular expressions. R ∗ is a regular expression if R is a regular expression An expression which cannot be obtained as above is NOT a regular expres- sion. COMPUTABILITY & COMPLEXITY 1 / 12
E XAMPLES OF R EGULAR EXPRESSION Assume Σ = { 0 , 1 } . Which language does the regular expression describe? 1 0 ∗ 10 ∗ . 2 Σ ∗ 1 Σ ∗ . 3 1 ∗ ( 01 + ) ∗ . 4 (ΣΣ) ∗ . 5 0 Σ ∗ 0 ∪ 1 Σ ∗ 1 ∪ 0 ∪ 1. 6 1 ∗ ∅ = ∅ . 7 ∅ ∗ = { ǫ } . COMPUTABILITY & COMPLEXITY 2 / 12
R EGULAR LANGUAGE R EGULAR LANGUAGE = VALUE OF A REGULAR EXPRESSION For a regular expression R , the set of all strings which can be generated following the expression is denoted by L ( R ) , said to be the language of R . A language A is called a regular language if there is a regular expression R generating A , i.e. L ( R ) = A . COMPUTABILITY & COMPLEXITY 3 / 12
E QUIVALENCE OF REGULAR LANGUAGE AND FINITE AUTOMATA E QUIVALENT T HEOREM A language A ⊆ Σ ∗ regular (i.e. there exists a regular expressing generating A ) if and only if there is a finite automata M recognizing A . Which direction of the proof looks easier? COMPUTABILITY & COMPLEXITY 4 / 12
E QUIVALENCE PROOF : EASY DIRECTION E QUIVALENCE T HEOREM , P ART I If a language A ⊆ Σ ∗ regular, then there is a (nondeterminist) finite automata M recognizing A . Proof idea: inductively build an NFA accepting each symbol and each regular operations (union, concatenation, Kleene star) applied to smaller regular expressions. COMPUTABILITY & COMPLEXITY 5 / 12
E QUIV PROOF : THE OTHER DIRECTION E QUIVALENCE T HEOREM , P ART II If a language A ⊆ Σ ∗ is recognized by a finite automata A , then there is a regular expression R such that L ( R ) = A . COMPUTABILITY & COMPLEXITY 6 / 12
E QUIV PROOF : THE OTHER DIRECTION G ENERALIZED N ONDETERMINISTIC F INITE A UTOMATA Generalized NFA is a NFA in which each arc carries a regular expression as a label. We may assume q start and q accept are the unique source and sink, and all other states have an arc to every state (including itself). Figure 1.61, Sipser 2012. COMPUTABILITY & COMPLEXITY 7 / 12
E QUIV PROOF : THE OTHER DIRECTION Proof idea. Initial NFA can be seen as GNFA. Reduce the number of states of GNFA inductively, yielding an equivalent GNFA. GNFA with two states q start and q accept carries a single regular expression, a desired end product. COMPUTABILITY & COMPLEXITY 8 / 12
E XAMPLE : FROM NFA TO REGULAR EXPRESSION Figure 1.67 (a), Sipser 2012. COMPUTABILITY & COMPLEXITY 9 / 12
L IMIT OF FINITE AUTOMATA Consider the following languages. Which of them are regular? 1 B = { 0 n 1 n : n ≥ 0 } . 2 C = { w : w has equal number of 0’s and 1’s } . 3 D = { w : w has equal number of 01’s and 10’s } . COMPUTABILITY & COMPLEXITY 10 / 12
P UMPING LEMMA P UMPING LEMMA : TECHNIQUE TO PROVE NONREGULARITY Let A be a regular language. Then there exists a number p (called the pumping length ) such that any string s ∈ A of length at least p , s can be written as s = xyz such that the following holds: 1 | y | ≥ 1, 2 | xy | ≤ p , 3 xy i z ∈ A for every i ≥ 0. Proof idea: DFA for A has a finite (constant) number of states. COMPUTABILITY & COMPLEXITY 11 / 12
A PPLYING PUMPING LEMMA TO PROVE NONREGULARITY 1 B = { 0 n 1 n : n ≥ 0 } . 2 C = { w : w has equal number of 0’s and 1’s } . 3 D = { 1 n 2 : n ≥ 0 } . 4 E = { 0 i 1 j : i > j } . 5 F = { ww : w ∈ { 0 , 1 } ∗ } . Recipe: assume that A is regular and p is the pumping length. Choose a good string s , and show that rewriting s = xyz as required is impossible. COMPUTABILITY & COMPLEXITY 12 / 12
Recommend
More recommend