COMPUTABILITY AND COMPLEXITY, 2020 FALL SEMESTER
Lec 03. Regular expression, Pumping lemma
Eunjung Kim
Lec 03. Regular expression, Pumping lemma Eunjung Kim F ORMAL - - PowerPoint PPT Presentation
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
COMPUTABILITY AND COMPLEXITY, 2020 FALL SEMESTER
Eunjung Kim
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. (R1 ∪ R2) is a regular expression if R1 and R2 are regular expressions. (R1 ◦ R2) is a regular expression if R1 and R2 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
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
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
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
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
expressions.
COMPUTABILITY & COMPLEXITY
5 / 12
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
Generalized NFA is a NFA in which each arc carries a regular expression as a label. We may assume qstart and qaccept 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
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 qstart and qaccept carries a single regular expression, a desired end product.
COMPUTABILITY & COMPLEXITY
8 / 12
Figure 1.67 (a), Sipser 2012.
COMPUTABILITY & COMPLEXITY
9 / 12
Consider the following languages. Which of them are regular?
1 B = {0n1n : 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
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 xyiz ∈ A for every i ≥ 0.
Proof idea: DFA for A has a finite (constant) number of states.
COMPUTABILITY & COMPLEXITY
11 / 12
1 B = {0n1n : n ≥ 0}. 2 C = {w : w has equal number of 0’s and 1’s}. 3 D = {1n2 : n ≥ 0}. 4 E = {0i1j : 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