2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions...

118
INF2080 2. Regular Expressions and Nonregular languages Daniel Lupp Universitetet i Oslo 25th January 2018 Department of Informatics University of Oslo INF2080 Lecture :: 25th January 1 / 39

Transcript of 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions...

Page 1: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

INF20802. Regular Expressions and Nonregular languages

Daniel Lupp

Universitetet i Oslo

25th January 2018

Department ofInformatics

University ofOslo

INF2080 Lecture :: 25th January 1 / 39

Page 2: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Last week

Deterministic finite automata (DFA)

start

0

1

0

Regular languages are those languages accepted by DFA’sNondeterministic automata (NFA)

start

0

0, 1

0

1start

2 3

εa

ba, b

a

DFA ↔ NFA

INF2080 Lecture :: 25th January 2 / 39

Page 3: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Last week

Deterministic finite automata (DFA)

start

0

1

0

Regular languages are those languages accepted by DFA’s

Nondeterministic automata (NFA)

start

0

0, 1

0

1start

2 3

εa

ba, b

a

DFA ↔ NFA

INF2080 Lecture :: 25th January 2 / 39

Page 4: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Last week

Deterministic finite automata (DFA)

start

0

1

0

Regular languages are those languages accepted by DFA’sNondeterministic automata (NFA)

start

0

0, 1

0

1start

2 3

εa

ba, b

a

DFA ↔ NFA

INF2080 Lecture :: 25th January 2 / 39

Page 5: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Last week

Deterministic finite automata (DFA)

start

0

1

0

Regular languages are those languages accepted by DFA’sNondeterministic automata (NFA)

start

0

0, 1

0

1start

2 3

εa

ba, b

a

DFA ↔ NFAINF2080 Lecture :: 25th January 2 / 39

Page 6: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions

Definition (Regular Expression)

Given an alphabet Σ, a regular expression isa for some a ∈ Σ,

ε,∅,(R1 ∪ R2) for regular expressions R1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

→ Regular expressions represent languages!

INF2080 Lecture :: 25th January 3 / 39

Page 7: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions

Definition (Regular Expression)

Given an alphabet Σ, a regular expression isa for some a ∈ Σ,ε,

∅,(R1 ∪ R2) for regular expressions R1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

→ Regular expressions represent languages!

INF2080 Lecture :: 25th January 3 / 39

Page 8: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions

Definition (Regular Expression)

Given an alphabet Σ, a regular expression isa for some a ∈ Σ,ε,∅,

(R1 ∪ R2) for regular expressions R1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

→ Regular expressions represent languages!

INF2080 Lecture :: 25th January 3 / 39

Page 9: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions

Definition (Regular Expression)

Given an alphabet Σ, a regular expression isa for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressions R1,R2,

(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

→ Regular expressions represent languages!

INF2080 Lecture :: 25th January 3 / 39

Page 10: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions

Definition (Regular Expression)

Given an alphabet Σ, a regular expression isa for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressions R1,R2,(R1R2) for regular expressions R1,R2,

R∗1 for a regular expression R1.

→ Regular expressions represent languages!

INF2080 Lecture :: 25th January 3 / 39

Page 11: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions

Definition (Regular Expression)

Given an alphabet Σ, a regular expression isa for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressions R1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

→ Regular expressions represent languages!

INF2080 Lecture :: 25th January 3 / 39

Page 12: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions

Definition (Regular Expression)

Given an alphabet Σ, a regular expression isa for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressions R1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

→ Regular expressions represent languages!

INF2080 Lecture :: 25th January 3 / 39

Page 13: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions - Examples

What languages do the following regular expressions (RE) represent?0∗

10∗1(1(0 ∪ 1)∗1) ∪ (0(0 ∪ 1)∗0) ∪ 0 ∪ 1

INF2080 Lecture :: 25th January 4 / 39

Page 14: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions - Examples

What languages do the following regular expressions (RE) represent?0∗

10∗1

(1(0 ∪ 1)∗1) ∪ (0(0 ∪ 1)∗0) ∪ 0 ∪ 1

INF2080 Lecture :: 25th January 4 / 39

Page 15: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions - Examples

What languages do the following regular expressions (RE) represent?0∗

10∗1(1(0 ∪ 1)∗1) ∪ (0(0 ∪ 1)∗0) ∪ 0 ∪ 1

INF2080 Lecture :: 25th January 4 / 39

Page 16: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions - Automata

What is the connection between RE and DFA/NFA?

Language 0(0 ∪ 1)∗0:2

1start 3

0

0, 1

0

INF2080 Lecture :: 25th January 5 / 39

Page 17: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions - Automata

What is the connection between RE and DFA/NFA?

Language 0(0 ∪ 1)∗0:

2

1start 3

0

0, 1

0

INF2080 Lecture :: 25th January 5 / 39

Page 18: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions - Automata

What is the connection between RE and DFA/NFA?

Language 0(0 ∪ 1)∗0:2

1start 3

0

0, 1

0

INF2080 Lecture :: 25th January 5 / 39

Page 19: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

What is the connection between RE and DFA/NFA?

Can all RE be represented using DFA/NFA?Can all DFA/NFA be described by RE?

Yes!

INF2080 Lecture :: 25th January 6 / 39

Page 20: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

What is the connection between RE and DFA/NFA?

Can all RE be represented using DFA/NFA?Can all DFA/NFA be described by RE?

Yes!

INF2080 Lecture :: 25th January 6 / 39

Page 21: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery language described by an RE is regular.

Proof based on inductive definition of RE!

INF2080 Lecture :: 25th January 7 / 39

Page 22: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Definition (Regular Expression)

Given an alphabet Σ, a regular expressionis

a for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressionsR1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

if R = a for a ∈ Σ, then L(R) = {a} is ac-cepted by

starta

If R = ε, then L(R) = {ε} is accepted by

start

If R = ∅, then L(R) = ∅ is accepted by

start

INF2080 Lecture :: 25th January 8 / 39

Page 23: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Definition (Regular Expression)

Given an alphabet Σ, a regular expressionis

a for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressionsR1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

if R = a for a ∈ Σ, then L(R) = {a} is ac-cepted by

starta

If R = ε, then L(R) = {ε} is accepted by

start

If R = ∅, then L(R) = ∅ is accepted by

start

INF2080 Lecture :: 25th January 8 / 39

Page 24: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Definition (Regular Expression)

Given an alphabet Σ, a regular expressionis

a for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressionsR1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

if R = a for a ∈ Σ, then L(R) = {a} is ac-cepted by

starta

If R = ε, then L(R) = {ε} is accepted by

start

If R = ∅, then L(R) = ∅ is accepted by

start

INF2080 Lecture :: 25th January 8 / 39

Page 25: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Definition (Regular Expression)

Given an alphabet Σ, a regular expressionis

a for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressionsR1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

if R = a for a ∈ Σ, then L(R) = {a} is ac-cepted by

starta

If R = ε, then L(R) = {ε} is accepted by

start

If R = ∅, then L(R) = ∅ is accepted by

start

INF2080 Lecture :: 25th January 8 / 39

Page 26: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Definition (Regular Expression)

Given an alphabet Σ, a regular expressionis

a for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressionsR1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

The rest is union, concatanation and Kleenestar of regular languages, as discussed lastweek!

(recall: the union/concatanation/Kleene star ofregular languages is itself regular)

INF2080 Lecture :: 25th January 9 / 39

Page 27: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Definition (Regular Expression)

Given an alphabet Σ, a regular expressionis

a for some a ∈ Σ,ε,∅,(R1 ∪ R2) for regular expressionsR1,R2,(R1R2) for regular expressions R1,R2,R∗1 for a regular expression R1.

The rest is union, concatanation and Kleenestar of regular languages, as discussed lastweek!(recall: the union/concatanation/Kleene star ofregular languages is itself regular)

INF2080 Lecture :: 25th January 9 / 39

Page 28: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

So we’ve just proven

PropositionEvery language described by a RE is regular.

Next:

PropositionEvery regular language can be described using a RE.

INF2080 Lecture :: 25th January 10 / 39

Page 29: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

So we’ve just proven

PropositionEvery language described by a RE is regular.

Next:

PropositionEvery regular language can be described using a RE.

INF2080 Lecture :: 25th January 10 / 39

Page 30: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.

some other assumptions for convenience:start state goes to every other state, buthas no incoming statesevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

start1

(0 ∪ 1)∗

0

1∗

start((ab∗) ∪ (ba∗))∗

INF2080 Lecture :: 25th January 11 / 39

Page 31: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.

some other assumptions for convenience:start state goes to every other state, buthas no incoming statesevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

start

1

(0 ∪ 1)∗

0

1∗

start((ab∗) ∪ (ba∗))∗

INF2080 Lecture :: 25th January 11 / 39

Page 32: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.some other assumptions for convenience:

start state goes to every other state, buthas no incoming statesevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

start

1

(0 ∪ 1)∗

0

1∗

start((ab∗) ∪ (ba∗))∗

INF2080 Lecture :: 25th January 11 / 39

Page 33: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.some other assumptions for convenience:start state goes to every other state, buthas no incoming states

every state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

start

1

(0 ∪ 1)∗

0

1∗

start((ab∗) ∪ (ba∗))∗

INF2080 Lecture :: 25th January 11 / 39

Page 34: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.some other assumptions for convenience:start state goes to every other state, buthas no incoming statesevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.

all other states have one transition to allother states, including themselves.

start

1

(0 ∪ 1)∗

0

1∗

start((ab∗) ∪ (ba∗))∗

INF2080 Lecture :: 25th January 11 / 39

Page 35: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.some other assumptions for convenience:start state goes to every other state, buthas no incoming statesevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

start

1

(0 ∪ 1)∗

0

1∗

start((ab∗) ∪ (ba∗))∗

INF2080 Lecture :: 25th January 11 / 39

Page 36: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA: Convenient assumptions

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.some other assumptions for convenience:start state goes to every other state, buthas no incoming statesevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

Astart

B C

D

1

(0 ∪ 1)∗

0

1∗

ε

INF2080 Lecture :: 25th January 12 / 39

Page 37: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA: Convenient assumptions

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.some other assumptions for convenience:start state goes to every other state, buthas no incoming states Xevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

start A

B C

D

ε

1

(0 ∪ 1)∗

0

1∗

ε

∅∅

INF2080 Lecture :: 25th January 13 / 39

Page 38: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA: Convenient assumptions

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.some other assumptions for convenience:start state goes to every other state, buthas no incoming states Xevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows. Xall other states have one transition to allother states, including themselves. (X)

start A

B C

D

ε

1

(0 ∪ 1)∗

0

1∗

ε

∅∅

∅ε

ε∅

for thelast point, add ∅ transitions between any twonon-accepting/starting states that were notpreviously connected (e.g., (B,D))

INF2080 Lecture :: 25th January 14 / 39

Page 39: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

GNFA: Convenient assumptions

Generalized Nondeterministic Finite Automaton(GNFA):

NFA where the transitions are RE, notonly symbols from Σ.some other assumptions for convenience:start state goes to every other state, buthas no incoming states Xevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows. Xall other states have one transition to allother states, including themselves. (X)

start A

B C

D

ε

1

(0 ∪ 1)∗

0

1∗

ε

∅∅

∅ε

ε∅

for thelast point, add ∅ transitions between any twonon-accepting/starting states that were notpreviously connected (e.g., (B,D))

INF2080 Lecture :: 25th January 14 / 39

Page 40: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Generalized Nondeterministic Finite Automata

DefinitionA generalized nondeterministic finite automaton (GNFA) is a 5-tuple (Q,Σ, δ, qstart , qaccept)where

1 Q is a finite set of states2 Σ is the input alphabet3 δ : (Q \ {qaccept})× (Q \ {qstart})→ R is the transition function, where R is the set of

all RE’s over Σ,4 qstart is the start state, and5 qaccept is the accept state.

INF2080 Lecture :: 25th January 15 / 39

Page 41: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery regular language can be described using a RE.

Proof idea: take DFA and transform into a GNFA that accepts the same language. Iterativelyremove (non-starting and non-accepting) states so that the same language is accepted, untilonly the starting and accepting state remain. Then the RE along the transition between thetwo states describes the regular language.

INF2080 Lecture :: 25th January 16 / 39

Page 42: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery regular language can be described using a RE.

Proof idea: take DFA and transform into a GNFA that accepts the same language. Iterativelyremove (non-starting and non-accepting) states so that the same language is accepted, untilonly the starting and accepting state remain. Then the RE along the transition between thetwo states describes the regular language.

INF2080 Lecture :: 25th January 16 / 39

Page 43: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery regular language can be described using a RE.

Proof:Given a DFA M, we construct an equivalent GNFA G by adding a new start state qstartwith an ε transition to the old start state q0, as well as a new accepting state qacept , withε transitions from all old accept states.add ∅ transitions for all state pairs that do not have a transition in M.

INF2080 Lecture :: 25th January 17 / 39

Page 44: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

Recall the “convenient” properties ofGNFA:start state goes to every other state, buthas no incoming statesevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

⇒ When removing X, we only need to considersituations like this:

X

R2 R4

R3

R1

⇓R1 ∪ (R2R

∗3R4)

INF2080 Lecture :: 25th January 18 / 39

Page 45: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

Recall the “convenient” properties ofGNFA:start state goes to every other state, buthas no incoming statesevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

⇒ When removing X, we only need to considersituations like this:

X

R2 R4

R3

R1

⇓R1 ∪ (R2R

∗3R4)

INF2080 Lecture :: 25th January 18 / 39

Page 46: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

Recall the “convenient” properties ofGNFA:start state goes to every other state, buthas no incoming statesevery state goes to the unique acceptingstate, which is different from the startingstate. The accepting state does not haveany outgoing arrows.all other states have one transition to allother states, including themselves.

⇒ When removing X, we only need to considersituations like this:

X

R2 R4

R3

R1

⇓R1 ∪ (R2R

∗3R4)

INF2080 Lecture :: 25th January 18 / 39

Page 47: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

Let’s formalize this! Let us define a procedure CONVERT(G ):1 If k = 2 then G only has one start and one accept state, so return the regular expression

R of the transition connecting them.

2 if k > 2 select a state q′ 6∈ {qaccept , qstart}. Define G ′ = {Q ′,Σ, δ′, qstart , qaccept} withQ ′ = Q \ {q′} and

δ′(qi , qj) = R1 ∪ R2R∗3R4

where R1 = δ(qi , qj), R2 = δ(qi , q′), R3 = δ(q′, q′), R4 = δ(q′, qj), and .

3 Return the result of CONVERT(G ′).4 correctness still remains to be shown! See book for details! (Claim 1.65)

INF2080 Lecture :: 25th January 19 / 39

Page 48: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

Let’s formalize this! Let us define a procedure CONVERT(G ):1 If k = 2 then G only has one start and one accept state, so return the regular expression

R of the transition connecting them.2 if k > 2 select a state q′ 6∈ {qaccept , qstart}. Define G ′ = {Q ′,Σ, δ′, qstart , qaccept} with

Q ′ = Q \ {q′} andδ′(qi , qj) = R1 ∪ R2R

∗3R4

where R1 = δ(qi , qj), R2 = δ(qi , q′), R3 = δ(q′, q′), R4 = δ(q′, qj), and .

3 Return the result of CONVERT(G ′).4 correctness still remains to be shown! See book for details! (Claim 1.65)

INF2080 Lecture :: 25th January 19 / 39

Page 49: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

Let’s formalize this! Let us define a procedure CONVERT(G ):1 If k = 2 then G only has one start and one accept state, so return the regular expression

R of the transition connecting them.2 if k > 2 select a state q′ 6∈ {qaccept , qstart}. Define G ′ = {Q ′,Σ, δ′, qstart , qaccept} with

Q ′ = Q \ {q′} andδ′(qi , qj) = R1 ∪ R2R

∗3R4

where R1 = δ(qi , qj), R2 = δ(qi , q′), R3 = δ(q′, q′), R4 = δ(q′, qj), and .

3 Return the result of CONVERT(G ′).

4 correctness still remains to be shown! See book for details! (Claim 1.65)

INF2080 Lecture :: 25th January 19 / 39

Page 50: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

Let’s formalize this! Let us define a procedure CONVERT(G ):1 If k = 2 then G only has one start and one accept state, so return the regular expression

R of the transition connecting them.2 if k > 2 select a state q′ 6∈ {qaccept , qstart}. Define G ′ = {Q ′,Σ, δ′, qstart , qaccept} with

Q ′ = Q \ {q′} andδ′(qi , qj) = R1 ∪ R2R

∗3R4

where R1 = δ(qi , qj), R2 = δ(qi , q′), R3 = δ(q′, q′), R4 = δ(q′, qj), and .

3 Return the result of CONVERT(G ′).4 correctness still remains to be shown! See book for details! (Claim 1.65)

INF2080 Lecture :: 25th January 19 / 39

Page 51: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery regular language can be described using a RE.

Example:DFA:

start

1

0

1

0 0

1

GNFA:

start

1

0

1

0 0

1

∅ ∅

INF2080 Lecture :: 25th January 20 / 39

Page 52: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery regular language can be described using a RE.

Example:DFA:

start

1

0

1

0 0

1

GNFA:

start

1

0

1

0 0

1

∅ ∅

INF2080 Lecture :: 25th January 20 / 39

Page 53: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery regular language can be described using a RE.

Example:Remove state X:

start

X1

0

1

0 0

1

∅ ∅

start

0 0

1

∅ ∪ (10∗1)

INF2080 Lecture :: 25th January 21 / 39

Page 54: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery regular language can be described using a RE.

Example:Remove state X:

start

X1

0

1

0 0

1

∅ ∅

∅start

0 0

1

∅ ∪ (10∗1)

INF2080 Lecture :: 25th January 21 / 39

Page 55: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery regular language can be described using a RE.

Example:Remove state Y:

start

Y

0 0

1

(10∗1)

start

(10∗1) ∪ (01∗0)

INF2080 Lecture :: 25th January 22 / 39

Page 56: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Regular Expressions and Automata

PropositionEvery regular language can be described using a RE.

Example:Remove state Y:

start

Y

0 0

1

(10∗1)

start

(10∗1) ∪ (01∗0)

INF2080 Lecture :: 25th January 22 / 39

Page 57: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Summary

So RE = GNFA = DFA = NFA = Regular languages...

But when is a language nonregular? How can we check?⇒ Pumping Lemma!

INF2080 Lecture :: 25th January 23 / 39

Page 58: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Summary

So RE = GNFA = DFA = NFA = Regular languages...But when is a language nonregular? How can we check?

⇒ Pumping Lemma!

INF2080 Lecture :: 25th January 23 / 39

Page 59: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Summary

So RE = GNFA = DFA = NFA = Regular languages...But when is a language nonregular? How can we check?⇒ Pumping Lemma!

INF2080 Lecture :: 25th January 23 / 39

Page 60: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

DFAs only have finite memory, aka states.

Pumping lemma gives a pumping length: if a string is longer than the pumping length, itcan be pumped, i.e., there is a substring that can be repeated arbitrarily often such thatthe string remains in the languageIf a DFA has p states, and a string has length ≥ p, then the accepting path in the DFAmust visit at least p + 1 states. In other words, at least one state appears twice. ⇒ loop!This loop can be repeated while staying in the language.

INF2080 Lecture :: 25th January 24 / 39

Page 61: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

DFAs only have finite memory, aka states.Pumping lemma gives a pumping length: if a string is longer than the pumping length, itcan be pumped, i.e., there is a substring that can be repeated arbitrarily often such thatthe string remains in the language

If a DFA has p states, and a string has length ≥ p, then the accepting path in the DFAmust visit at least p + 1 states. In other words, at least one state appears twice. ⇒ loop!This loop can be repeated while staying in the language.

INF2080 Lecture :: 25th January 24 / 39

Page 62: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

DFAs only have finite memory, aka states.Pumping lemma gives a pumping length: if a string is longer than the pumping length, itcan be pumped, i.e., there is a substring that can be repeated arbitrarily often such thatthe string remains in the languageIf a DFA has p states, and a string has length ≥ p, then the accepting path in the DFAmust visit at least p + 1 states. In other words, at least one state appears twice. ⇒ loop!This loop can be repeated while staying in the language.

INF2080 Lecture :: 25th January 24 / 39

Page 63: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d

1

0

1

0 0

1

Language (10∗1) ∪ (01∗0)

DFA has 4 statesconsider string 10001, length 5⇒ path must contain a loop (in this case,at node b)

INF2080 Lecture :: 25th January 25 / 39

Page 64: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d

1

0

1

0 0

1

Language (10∗1) ∪ (01∗0)

DFA has 4 statesconsider string 10001, length 5⇒ path must contain a loop (in this case,at node b)

INF2080 Lecture :: 25th January 25 / 39

Page 65: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d

1

0

1

0 0

1

Language (10∗1) ∪ (01∗0)

DFA has 4 states

consider string 10001, length 5⇒ path must contain a loop (in this case,at node b)

INF2080 Lecture :: 25th January 25 / 39

Page 66: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d

1

0

1

0 0

1

Language (10∗1) ∪ (01∗0)

DFA has 4 statesconsider string 10001, length 5

⇒ path must contain a loop (in this case,at node b)

INF2080 Lecture :: 25th January 25 / 39

Page 67: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d

1

0

1

0 0

1

Language (10∗1) ∪ (01∗0)

DFA has 4 statesconsider string 10001, length 5⇒ path must contain a loop (in this case,at node b)

INF2080 Lecture :: 25th January 25 / 39

Page 68: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d e

1 1

0

1

0

Language 1(010)∗1DFA has 5 statesconsider string 10101, length 5⇒ path must contain a loop (in this case,at nodes b,d,e)⇒ 10100101 is also a word!

INF2080 Lecture :: 25th January 26 / 39

Page 69: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d e

1 1

0

1

0

Language 1(010)∗1

DFA has 5 statesconsider string 10101, length 5⇒ path must contain a loop (in this case,at nodes b,d,e)⇒ 10100101 is also a word!

INF2080 Lecture :: 25th January 26 / 39

Page 70: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d e

1 1

0

1

0

Language 1(010)∗1DFA has 5 states

consider string 10101, length 5⇒ path must contain a loop (in this case,at nodes b,d,e)⇒ 10100101 is also a word!

INF2080 Lecture :: 25th January 26 / 39

Page 71: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d e

1 1

0

1

0

Language 1(010)∗1DFA has 5 statesconsider string 10101, length 5

⇒ path must contain a loop (in this case,at nodes b,d,e)⇒ 10100101 is also a word!

INF2080 Lecture :: 25th January 26 / 39

Page 72: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d e

1 1

0

1

0

Language 1(010)∗1DFA has 5 statesconsider string 10101, length 5⇒ path must contain a loop (in this case,at nodes b,d,e)

⇒ 10100101 is also a word!

INF2080 Lecture :: 25th January 26 / 39

Page 73: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Example

astart

b

c

d e

1 1

0

1

0

Language 1(010)∗1DFA has 5 statesconsider string 10101, length 5⇒ path must contain a loop (in this case,at nodes b,d,e)⇒ 10100101 is also a word!

INF2080 Lecture :: 25th January 26 / 39

Page 74: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

INF2080 Lecture :: 25th January 27 / 39

Page 75: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Proof: We formalize our intuition.Let M = (Q.Σ, δ, q0,F ) be a DFA, A = L(M) the language accepted by M, and p be thenumber of states in M.

Let w = w1 · · ·wn be a word in A of length n ≥ p. Since w ∈ A, it is accepted by M, i.e.,there exists a sequence of states s1, s2, . . . sn+1 of length n + 1, where sn+1 is an acceptstate and δ(si ,wi+1) = si+1.

INF2080 Lecture :: 25th January 28 / 39

Page 76: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Proof: We formalize our intuition.Let M = (Q.Σ, δ, q0,F ) be a DFA, A = L(M) the language accepted by M, and p be thenumber of states in M.Let w = w1 · · ·wn be a word in A of length n ≥ p. Since w ∈ A, it is accepted by M, i.e.,there exists a sequence of states s1, s2, . . . sn+1 of length n + 1, where sn+1 is an acceptstate and δ(si ,wi+1) = si+1.

INF2080 Lecture :: 25th January 28 / 39

Page 77: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let w = w1 · · ·wn be a word in A of length n ≥ p. Since w ∈ A, it is accepted by M, i.e.,there exists a sequence of states s1, s2, . . . sn+1 of length n + 1.

Since n + 1 ≥ p + 1, one state must occur twice within the first p + 1 elements of thesequence (pigeonhole pricniple).Let these occurences be sj and sl . Since these occur in the first p + 1 elements of thesequence, we have l ≤ p + 1.

INF2080 Lecture :: 25th January 29 / 39

Page 78: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let w = w1 · · ·wn be a word in A of length n ≥ p. Since w ∈ A, it is accepted by M, i.e.,there exists a sequence of states s1, s2, . . . sn+1 of length n + 1.Since n + 1 ≥ p + 1, one state must occur twice within the first p + 1 elements of thesequence (pigeonhole pricniple).

Let these occurences be sj and sl . Since these occur in the first p + 1 elements of thesequence, we have l ≤ p + 1.

INF2080 Lecture :: 25th January 29 / 39

Page 79: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let w = w1 · · ·wn be a word in A of length n ≥ p. Since w ∈ A, it is accepted by M, i.e.,there exists a sequence of states s1, s2, . . . sn+1 of length n + 1.Since n + 1 ≥ p + 1, one state must occur twice within the first p + 1 elements of thesequence (pigeonhole pricniple).Let these occurences be sj and sl . Since these occur in the first p + 1 elements of thesequence, we have l ≤ p + 1.

INF2080 Lecture :: 25th January 29 / 39

Page 80: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let these occurences be sj and sl . Since these occur in the first p + 1 elements of thesequence, we have l ≤ p + 1.

define x = w1 · · ·wj−1, y = wj · · ·wl−1, z = wl · · ·wn.Then |y | > 0 and |xy | ≤ p.

INF2080 Lecture :: 25th January 30 / 39

Page 81: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let these occurences be sj and sl . Since these occur in the first p + 1 elements of thesequence, we have l ≤ p + 1.define x = w1 · · ·wj−1, y = wj · · ·wl−1, z = wl · · ·wn.

Then |y | > 0 and |xy | ≤ p.

INF2080 Lecture :: 25th January 30 / 39

Page 82: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let these occurences be sj and sl . Since these occur in the first p + 1 elements of thesequence, we have l ≤ p + 1.define x = w1 · · ·wj−1, y = wj · · ·wl−1, z = wl · · ·wn.Then |y | > 0 and |xy | ≤ p.

INF2080 Lecture :: 25th January 30 / 39

Page 83: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

define x = w1 · · ·wj−1, y = wj · · ·wl−1, z = wl · · ·wn.x takes M from s1 to sj , y takes M from sj to sl , z takes M from sl to sn+1.

Thus the word xy iz takes M from the start state s1 to sj , follows the path from sj to sl itimes (recall that sj = sl), then takes M from sl to sn+1.Thus M accepts any word xy iz for i ≥ 0.

INF2080 Lecture :: 25th January 31 / 39

Page 84: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

define x = w1 · · ·wj−1, y = wj · · ·wl−1, z = wl · · ·wn.x takes M from s1 to sj , y takes M from sj to sl , z takes M from sl to sn+1.Thus the word xy iz takes M from the start state s1 to sj , follows the path from sj to sl itimes (recall that sj = sl), then takes M from sl to sn+1.

Thus M accepts any word xy iz for i ≥ 0.

INF2080 Lecture :: 25th January 31 / 39

Page 85: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

define x = w1 · · ·wj−1, y = wj · · ·wl−1, z = wl · · ·wn.x takes M from s1 to sj , y takes M from sj to sl , z takes M from sl to sn+1.Thus the word xy iz takes M from the start state s1 to sj , follows the path from sj to sl itimes (recall that sj = sl), then takes M from sl to sn+1.Thus M accepts any word xy iz for i ≥ 0.

INF2080 Lecture :: 25th January 31 / 39

Page 86: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

define x = w1 · · ·wj−1, y = wj · · ·wl−1, z = wl · · ·wn.x takes M from s1 to sj , y takes M from sj to sl , z takes M from sl to sn+1.Thus the word xy iz takes M from the start state s1 to sj , follows the path from sj to sl itimes (recall that sj = sl), then takes M from sl to sn+1.Thus M accepts any word xy iz for i ≥ 0.

INF2080 Lecture :: 25th January 31 / 39

Page 87: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

very useful for determining if a language is nonregular

→ find a string with length ≥ p such that the pumping lemma does not holdnot very useful for proving a language is regular→ not an if and only if statement!

INF2080 Lecture :: 25th January 32 / 39

Page 88: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

very useful for determining if a language is nonregular→ find a string with length ≥ p such that the pumping lemma does not hold

not very useful for proving a language is regular→ not an if and only if statement!

INF2080 Lecture :: 25th January 32 / 39

Page 89: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

very useful for determining if a language is nonregular→ find a string with length ≥ p such that the pumping lemma does not holdnot very useful for proving a language is regular

→ not an if and only if statement!

INF2080 Lecture :: 25th January 32 / 39

Page 90: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma

very useful for determining if a language is nonregular→ find a string with length ≥ p such that the pumping lemma does not holdnot very useful for proving a language is regular→ not an if and only if statement!

INF2080 Lecture :: 25th January 32 / 39

Page 91: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let A = {0n1n | n ≥ 0}.

Is A regular?If it is, then the pumping lemma gives us a pumping length p.Let s = 0p1p.

INF2080 Lecture :: 25th January 33 / 39

Page 92: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let A = {0n1n | n ≥ 0}.Is A regular?

If it is, then the pumping lemma gives us a pumping length p.Let s = 0p1p.

INF2080 Lecture :: 25th January 33 / 39

Page 93: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let A = {0n1n | n ≥ 0}.Is A regular?If it is, then the pumping lemma gives us a pumping length p.Let s = 0p1p.

INF2080 Lecture :: 25th January 33 / 39

Page 94: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let A = {0n1n | n ≥ 0}.Let s = 0p1p.

Condition 3 tells us that y consists of only 0s.⇒ then xy iz for i ≥ 2 has more 0s than 1s. Contradiction! ⇒ A is nonregular.

INF2080 Lecture :: 25th January 34 / 39

Page 95: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let A = {0n1n | n ≥ 0}.Let s = 0p1p.Condition 3 tells us that y consists of only 0s.

⇒ then xy iz for i ≥ 2 has more 0s than 1s. Contradiction! ⇒ A is nonregular.

INF2080 Lecture :: 25th January 34 / 39

Page 96: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

If A is a regular language, then there is a number p, called the pumping length, where if w is aword in A of length ≥ p then w can be divided into three parts, w = xyz , such that

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let A = {0n1n | n ≥ 0}.Let s = 0p1p.Condition 3 tells us that y consists of only 0s.⇒ then xy iz for i ≥ 2 has more 0s than 1s. Contradiction! ⇒ A is nonregular.

INF2080 Lecture :: 25th January 34 / 39

Page 97: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Even if a language is nonregular, it might contain strings for which the pumping lemma istrue!

We have to be careful!

INF2080 Lecture :: 25th January 35 / 39

Page 98: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Even if a language is nonregular, it might contain strings for which the pumping lemma istrue!We have to be careful!

INF2080 Lecture :: 25th January 35 / 39

Page 99: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

|w | ≥ p,w = xyz , s.t.1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let B = {ω |ω contains an equal number of 0s and 1s}.Let w = (01)p.

x = ε, y = 01, z = (01)p−1

all conditions are met!

INF2080 Lecture :: 25th January 36 / 39

Page 100: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

|w | ≥ p,w = xyz , s.t.1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let B = {ω |ω contains an equal number of 0s and 1s}.Let w = (01)p.x = ε, y = 01, z = (01)p−1

all conditions are met!

INF2080 Lecture :: 25th January 36 / 39

Page 101: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

|w | ≥ p,w = xyz , s.t.1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let B = {ω |ω contains an equal number of 0s and 1s}.Let w = (01)p.x = ε, y = 01, z = (01)p−1

all conditions are met!

INF2080 Lecture :: 25th January 36 / 39

Page 102: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let B = {ω |ω contains an equal number of 0s and 1s}.Let s = 0p1p.

x = ε, y = 0p1p, z = ε

looks like it can be pumped, but are all conditions met?condition 3 ⇒ y must contain only 0s, so it cannot be pumped⇒ B nonregular!

INF2080 Lecture :: 25th January 37 / 39

Page 103: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let B = {ω |ω contains an equal number of 0s and 1s}.Let s = 0p1p.x = ε, y = 0p1p, z = ε

looks like it can be pumped, but are all conditions met?condition 3 ⇒ y must contain only 0s, so it cannot be pumped⇒ B nonregular!

INF2080 Lecture :: 25th January 37 / 39

Page 104: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let B = {ω |ω contains an equal number of 0s and 1s}.Let s = 0p1p.x = ε, y = 0p1p, z = ε

looks like it can be pumped

, but are all conditions met?condition 3 ⇒ y must contain only 0s, so it cannot be pumped⇒ B nonregular!

INF2080 Lecture :: 25th January 37 / 39

Page 105: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let B = {ω |ω contains an equal number of 0s and 1s}.Let s = 0p1p.x = ε, y = 0p1p, z = ε

looks like it can be pumped, but are all conditions met?

condition 3 ⇒ y must contain only 0s, so it cannot be pumped⇒ B nonregular!

INF2080 Lecture :: 25th January 37 / 39

Page 106: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let B = {ω |ω contains an equal number of 0s and 1s}.Let s = 0p1p.x = ε, y = 0p1p, z = ε

looks like it can be pumped, but are all conditions met?condition 3 ⇒ y must contain only 0s, so it cannot be pumped

⇒ B nonregular!

INF2080 Lecture :: 25th January 37 / 39

Page 107: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

Lemma (Pumping Lemma)

1 xy iz ∈ A for every i ≥ 0,2 |y | > 0,3 |xy | ≤ p.

Let B = {ω |ω contains an equal number of 0s and 1s}.Let s = 0p1p.x = ε, y = 0p1p, z = ε

looks like it can be pumped, but are all conditions met?condition 3 ⇒ y must contain only 0s, so it cannot be pumped⇒ B nonregular!

INF2080 Lecture :: 25th January 37 / 39

Page 108: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

A = {0n1n | n ≥ 0}.B = {ω |ω contains an equal number of 0s and 1s}Another way of showing B is nonregular is to reduce it to the nonregularity of A:

regular languages are closed under intersectionand A = B ∩ 0∗1∗

if B is regular and since 0∗1∗ is regular, then A must be as well, contradiction!

INF2080 Lecture :: 25th January 38 / 39

Page 109: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

A = {0n1n | n ≥ 0}.B = {ω |ω contains an equal number of 0s and 1s}Another way of showing B is nonregular is to reduce it to the nonregularity of A:regular languages are closed under intersection

and A = B ∩ 0∗1∗

if B is regular and since 0∗1∗ is regular, then A must be as well, contradiction!

INF2080 Lecture :: 25th January 38 / 39

Page 110: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

A = {0n1n | n ≥ 0}.B = {ω |ω contains an equal number of 0s and 1s}Another way of showing B is nonregular is to reduce it to the nonregularity of A:regular languages are closed under intersectionand A = B ∩ 0∗1∗

if B is regular and since 0∗1∗ is regular, then A must be as well, contradiction!

INF2080 Lecture :: 25th January 38 / 39

Page 111: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

A = {0n1n | n ≥ 0}.B = {ω |ω contains an equal number of 0s and 1s}Another way of showing B is nonregular is to reduce it to the nonregularity of A:regular languages are closed under intersectionand A = B ∩ 0∗1∗

if B is regular and since 0∗1∗ is regular, then A must be as well

, contradiction!

INF2080 Lecture :: 25th January 38 / 39

Page 112: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Pumping Lemma - Applied

A = {0n1n | n ≥ 0}.B = {ω |ω contains an equal number of 0s and 1s}Another way of showing B is nonregular is to reduce it to the nonregularity of A:regular languages are closed under intersectionand A = B ∩ 0∗1∗

if B is regular and since 0∗1∗ is regular, then A must be as well, contradiction!

INF2080 Lecture :: 25th January 38 / 39

Page 113: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Summary

regular expressions are shorthand notations for languages

RE = GNFA = DFA = NFA, i.e., regular expressions are shorthand for regular languagesproof involved transforming a DFA to a GNFA then reducing the number of states to 2while accepting the same language→ the regular expressions describe the paths in the DFAevery regular language has a pumping lengthuseful for determining if a language is nonregular

INF2080 Lecture :: 25th January 39 / 39

Page 114: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Summary

regular expressions are shorthand notations for languagesRE = GNFA = DFA = NFA, i.e., regular expressions are shorthand for regular languages

proof involved transforming a DFA to a GNFA then reducing the number of states to 2while accepting the same language→ the regular expressions describe the paths in the DFAevery regular language has a pumping lengthuseful for determining if a language is nonregular

INF2080 Lecture :: 25th January 39 / 39

Page 115: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Summary

regular expressions are shorthand notations for languagesRE = GNFA = DFA = NFA, i.e., regular expressions are shorthand for regular languagesproof involved transforming a DFA to a GNFA then reducing the number of states to 2while accepting the same language

→ the regular expressions describe the paths in the DFAevery regular language has a pumping lengthuseful for determining if a language is nonregular

INF2080 Lecture :: 25th January 39 / 39

Page 116: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Summary

regular expressions are shorthand notations for languagesRE = GNFA = DFA = NFA, i.e., regular expressions are shorthand for regular languagesproof involved transforming a DFA to a GNFA then reducing the number of states to 2while accepting the same language→ the regular expressions describe the paths in the DFA

every regular language has a pumping lengthuseful for determining if a language is nonregular

INF2080 Lecture :: 25th January 39 / 39

Page 117: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Summary

regular expressions are shorthand notations for languagesRE = GNFA = DFA = NFA, i.e., regular expressions are shorthand for regular languagesproof involved transforming a DFA to a GNFA then reducing the number of states to 2while accepting the same language→ the regular expressions describe the paths in the DFAevery regular language has a pumping length

useful for determining if a language is nonregular

INF2080 Lecture :: 25th January 39 / 39

Page 118: 2. RegularExpressionsandNonregularlanguages DanielLupp€¦ · Regular Expressions Definition(RegularExpression) Givenanalphabet ,aregularexpressionis a forsomea 2 ,",;, (R 1 [R

Summary

regular expressions are shorthand notations for languagesRE = GNFA = DFA = NFA, i.e., regular expressions are shorthand for regular languagesproof involved transforming a DFA to a GNFA then reducing the number of states to 2while accepting the same language→ the regular expressions describe the paths in the DFAevery regular language has a pumping lengthuseful for determining if a language is nonregular

INF2080 Lecture :: 25th January 39 / 39