Lec 03. Regular expression, Pumping lemma Eunjung Kim F ORMAL - - PowerPoint PPT Presentation

lec 03 regular expression pumping lemma
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

COMPUTABILITY AND COMPLEXITY, 2020 FALL SEMESTER

Lec 03. Regular expression, Pumping lemma

Eunjung Kim

slide-2
SLIDE 2

FORMAL DEFINITION OF REGULAR

EXPRESSION

REGULAR 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. (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

slide-3
SLIDE 3

EXAMPLES OF REGULAR 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

slide-4
SLIDE 4

REGULAR LANGUAGE

REGULAR 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

slide-5
SLIDE 5

EQUIVALENCE OF REGULAR LANGUAGE

AND FINITE AUTOMATA

EQUIVALENT THEOREM

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

slide-6
SLIDE 6

EQUIVALENCE PROOF: EASY DIRECTION

EQUIVALENCE THEOREM, PART 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

  • perations (union, concatenation, Kleene star) applied to smaller regular

expressions.

COMPUTABILITY & COMPLEXITY

5 / 12

slide-7
SLIDE 7

EQUIV PROOF: THE OTHER DIRECTION

EQUIVALENCE THEOREM, PART 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

slide-8
SLIDE 8

EQUIV PROOF: THE OTHER DIRECTION

GENERALIZED NONDETERMINISTIC FINITE AUTOMATA

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

slide-9
SLIDE 9

EQUIV 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 qstart and qaccept carries a single regular expression, a desired end product.

COMPUTABILITY & COMPLEXITY

8 / 12

slide-10
SLIDE 10

EXAMPLE: FROM NFA TO REGULAR

EXPRESSION

Figure 1.67 (a), Sipser 2012.

COMPUTABILITY & COMPLEXITY

9 / 12

slide-11
SLIDE 11

LIMIT OF FINITE AUTOMATA

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

slide-12
SLIDE 12

PUMPING LEMMA

PUMPING 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 xyiz ∈ A for every i ≥ 0.

Proof idea: DFA for A has a finite (constant) number of states.

COMPUTABILITY & COMPLEXITY

11 / 12

slide-13
SLIDE 13

APPLYING PUMPING LEMMA TO PROVE

NONREGULARITY

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