Equivalence of NFA and Regular...

52
Equivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology Indore January 17, 2018 Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 1 / 11

Transcript of Equivalence of NFA and Regular...

Page 1: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Equivalence of NFA and Regular Expressions

Dr. Neminath Hubballi

Indian Institute of Technology Indore

January 17, 2018

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 1 / 11

Page 2: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Overview

1 Equivalence Proof

2 Regular Languages and Equivalence

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 2 / 11

Page 3: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Definition

A Generalized Transition Graph is an NFA which has

1 A single start and final state.

2 There is no incoming edge on start state.

3 There is no outgoing edge on final state.

4 Any edge between states qi and qj is a regular expression r .

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 3 / 11

Page 4: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Definition

A Generalized Transition Graph is an NFA which has

1 A single start and final state.

2 There is no incoming edge on start state.

3 There is no outgoing edge on final state.

4 Any edge between states qi and qj is a regular expression r .

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 3 / 11

Page 5: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Definition

A Generalized Transition Graph is an NFA which has

1 A single start and final state.

2 There is no incoming edge on start state.

3 There is no outgoing edge on final state.

4 Any edge between states qi and qj is a regular expression r .

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 3 / 11

Page 6: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Definition

A Generalized Transition Graph is an NFA which has

1 A single start and final state.

2 There is no incoming edge on start state.

3 There is no outgoing edge on final state.

4 Any edge between states qi and qj is a regular expression r .

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 3 / 11

Page 7: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Definition

A Generalized Transition Graph is an NFA which has

1 A single start and final state.

2 There is no incoming edge on start state.

3 There is no outgoing edge on final state.

4 Any edge between states qi and qj is a regular expression r .

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 3 / 11

Page 8: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Definition

A Generalized Transition Graph is an NFA which has

1 A single start and final state.

2 There is no incoming edge on start state.

3 There is no outgoing edge on final state.

4 Any edge between states qi and qj is a regular expression r .

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 3 / 11

Page 9: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

M=(Q,Σ, δ, q0,F )

whereQ - Finite non empty set of states.Σ- Finite non empty set of alphabetq0- Start stateF = {qf } (Final state)δ : {Q-F} X {Q-q0} → RΣ Transition function with mapping of everystate to a regular expression

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 4 / 11

Page 10: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

M=(Q,Σ, δ, q0,F )where

Q - Finite non empty set of states.Σ- Finite non empty set of alphabetq0- Start stateF = {qf } (Final state)δ : {Q-F} X {Q-q0} → RΣ Transition function with mapping of everystate to a regular expression

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 4 / 11

Page 11: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

M=(Q,Σ, δ, q0,F )whereQ - Finite non empty set of states.

Σ- Finite non empty set of alphabetq0- Start stateF = {qf } (Final state)δ : {Q-F} X {Q-q0} → RΣ Transition function with mapping of everystate to a regular expression

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 4 / 11

Page 12: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

M=(Q,Σ, δ, q0,F )whereQ - Finite non empty set of states.Σ- Finite non empty set of alphabet

q0- Start stateF = {qf } (Final state)δ : {Q-F} X {Q-q0} → RΣ Transition function with mapping of everystate to a regular expression

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 4 / 11

Page 13: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

M=(Q,Σ, δ, q0,F )whereQ - Finite non empty set of states.Σ- Finite non empty set of alphabetq0- Start state

F = {qf } (Final state)δ : {Q-F} X {Q-q0} → RΣ Transition function with mapping of everystate to a regular expression

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 4 / 11

Page 14: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

M=(Q,Σ, δ, q0,F )whereQ - Finite non empty set of states.Σ- Finite non empty set of alphabetq0- Start stateF = {qf } (Final state)

δ : {Q-F} X {Q-q0} → RΣ Transition function with mapping of everystate to a regular expression

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 4 / 11

Page 15: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

M=(Q,Σ, δ, q0,F )whereQ - Finite non empty set of states.Σ- Finite non empty set of alphabetq0- Start stateF = {qf } (Final state)δ : {Q-F} X {Q-q0} → RΣ Transition function with mapping of everystate to a regular expression

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 4 / 11

Page 16: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

1 Transition: NFA reads a block of symbols from input and makes anon-deterministic move from state qi to state qj

2 Acceptance: NFA reads all input symbols in w through a sequence ofmoves q0, · · · qf where qf ∈ F . i.e., δ∗(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 5 / 11

Page 17: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

1 Transition: NFA reads a block of symbols from input and makes anon-deterministic move from state qi to state qj

2 Acceptance: NFA reads all input symbols in w through a sequence ofmoves q0, · · · qf where qf ∈ F . i.e., δ∗(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 5 / 11

Page 18: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Theorem

For any NFA M with L= L(M), ∃ a regular expression r such thatL(M) = L(r)

Proof:

1 Convert given NFA into GNFA.

2 If GNFA has only two states q0 and qf then regular expression is thelabel on edge from q0 to qf

3 IF GNFA has K ≥ 3 states then reduce it to a GNFA with K − 1states successively to get a GNFA with 2 states.

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 6 / 11

Page 19: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Theorem

For any NFA M with L= L(M), ∃ a regular expression r such thatL(M) = L(r)

Proof:

1 Convert given NFA into GNFA.

2 If GNFA has only two states q0 and qf then regular expression is thelabel on edge from q0 to qf

3 IF GNFA has K ≥ 3 states then reduce it to a GNFA with K − 1states successively to get a GNFA with 2 states.

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 6 / 11

Page 20: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Theorem

For any NFA M with L= L(M), ∃ a regular expression r such thatL(M) = L(r)

Proof:

1 Convert given NFA into GNFA.

2 If GNFA has only two states q0 and qf then regular expression is thelabel on edge from q0 to qf

3 IF GNFA has K ≥ 3 states then reduce it to a GNFA with K − 1states successively to get a GNFA with 2 states.

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 6 / 11

Page 21: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Theorem

For any NFA M with L= L(M), ∃ a regular expression r such thatL(M) = L(r)

Proof:

1 Convert given NFA into GNFA.

2 If GNFA has only two states q0 and qf then regular expression is thelabel on edge from q0 to qf

3 IF GNFA has K ≥ 3 states then reduce it to a GNFA with K − 1states successively to get a GNFA with 2 states.

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 6 / 11

Page 22: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Theorem

For any NFA M with L= L(M), ∃ a regular expression r such thatL(M) = L(r)

Proof:

1 Convert given NFA into GNFA.

2 If GNFA has only two states q0 and qf then regular expression is thelabel on edge from q0 to qf

3 IF GNFA has K ≥ 3 states then reduce it to a GNFA with K − 1states successively to get a GNFA with 2 states.

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 6 / 11

Page 23: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Theorem

For any NFA M with L= L(M), ∃ a regular expression r such thatL(M) = L(r)

Proof:

1 Convert given NFA into GNFA.

2 If GNFA has only two states q0 and qf then regular expression is thelabel on edge from q0 to qf

3 IF GNFA has K ≥ 3 states then reduce it to a GNFA with K − 1states successively to get a GNFA with 2 states.

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 6 / 11

Page 24: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

GNFA with K states to GNFA with K − 1 states

M = (Q,Σ, δ, q0,F )

M′= (Q

′,Σ, δ

′, q0,F )

whereQ′

= {Q-qi} qi ∈ Q and qi 6= q0 and qi 6= qfTransitions:

1 For any two states qa and qb ∈ Q′1 with transitions

δ(qa, r1) = qi , δ(qi , r2) = qi and δ(qi , r3) = qb and δ(qa, r4) = qbAdd an edge from qa to qb with the regular expression r1r

∗2 r3 + r4

2 For cases qa and qb ∈ Q′

where @ a path from qa to qb through qibut there is a direct edge with label r , retain that label.

1qa and qb may be sameDr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 7 / 11

Page 25: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

GNFA with K states to GNFA with K − 1 statesM = (Q,Σ, δ, q0,F )

M′= (Q

′,Σ, δ

′, q0,F )

whereQ′

= {Q-qi} qi ∈ Q and qi 6= q0 and qi 6= qfTransitions:

1 For any two states qa and qb ∈ Q′1 with transitions

δ(qa, r1) = qi , δ(qi , r2) = qi and δ(qi , r3) = qb and δ(qa, r4) = qbAdd an edge from qa to qb with the regular expression r1r

∗2 r3 + r4

2 For cases qa and qb ∈ Q′

where @ a path from qa to qb through qibut there is a direct edge with label r , retain that label.

1qa and qb may be sameDr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 7 / 11

Page 26: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

GNFA with K states to GNFA with K − 1 statesM = (Q,Σ, δ, q0,F )

M′= (Q

′,Σ, δ

′, q0,F )

whereQ′

= {Q-qi} qi ∈ Q and qi 6= q0 and qi 6= qfTransitions:

1 For any two states qa and qb ∈ Q′1 with transitions

δ(qa, r1) = qi , δ(qi , r2) = qi and δ(qi , r3) = qb and δ(qa, r4) = qbAdd an edge from qa to qb with the regular expression r1r

∗2 r3 + r4

2 For cases qa and qb ∈ Q′

where @ a path from qa to qb through qibut there is a direct edge with label r , retain that label.

1qa and qb may be sameDr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 7 / 11

Page 27: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

GNFA with K states to GNFA with K − 1 statesM = (Q,Σ, δ, q0,F )

M′= (Q

′,Σ, δ

′, q0,F )

where

Q′

= {Q-qi} qi ∈ Q and qi 6= q0 and qi 6= qfTransitions:

1 For any two states qa and qb ∈ Q′1 with transitions

δ(qa, r1) = qi , δ(qi , r2) = qi and δ(qi , r3) = qb and δ(qa, r4) = qbAdd an edge from qa to qb with the regular expression r1r

∗2 r3 + r4

2 For cases qa and qb ∈ Q′

where @ a path from qa to qb through qibut there is a direct edge with label r , retain that label.

1qa and qb may be sameDr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 7 / 11

Page 28: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

GNFA with K states to GNFA with K − 1 statesM = (Q,Σ, δ, q0,F )

M′= (Q

′,Σ, δ

′, q0,F )

whereQ′

= {Q-qi} qi ∈ Q and qi 6= q0 and qi 6= qf

Transitions:

1 For any two states qa and qb ∈ Q′1 with transitions

δ(qa, r1) = qi , δ(qi , r2) = qi and δ(qi , r3) = qb and δ(qa, r4) = qbAdd an edge from qa to qb with the regular expression r1r

∗2 r3 + r4

2 For cases qa and qb ∈ Q′

where @ a path from qa to qb through qibut there is a direct edge with label r , retain that label.

1qa and qb may be sameDr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 7 / 11

Page 29: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

GNFA with K states to GNFA with K − 1 statesM = (Q,Σ, δ, q0,F )

M′= (Q

′,Σ, δ

′, q0,F )

whereQ′

= {Q-qi} qi ∈ Q and qi 6= q0 and qi 6= qfTransitions:

1 For any two states qa and qb ∈ Q′1 with transitions

δ(qa, r1) = qi , δ(qi , r2) = qi and δ(qi , r3) = qb and δ(qa, r4) = qbAdd an edge from qa to qb with the regular expression r1r

∗2 r3 + r4

2 For cases qa and qb ∈ Q′

where @ a path from qa to qb through qibut there is a direct edge with label r , retain that label.

1qa and qb may be sameDr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 7 / 11

Page 30: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

GNFA with K states to GNFA with K − 1 statesM = (Q,Σ, δ, q0,F )

M′= (Q

′,Σ, δ

′, q0,F )

whereQ′

= {Q-qi} qi ∈ Q and qi 6= q0 and qi 6= qfTransitions:

1 For any two states qa and qb ∈ Q′1 with transitions

δ(qa, r1) = qi , δ(qi , r2) = qi and δ(qi , r3) = qb and δ(qa, r4) = qbAdd an edge from qa to qb with the regular expression r1r

∗2 r3 + r4

2 For cases qa and qb ∈ Q′

where @ a path from qa to qb through qibut there is a direct edge with label r , retain that label.

1qa and qb may be sameDr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 7 / 11

Page 31: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

GNFA with K states to GNFA with K − 1 statesM = (Q,Σ, δ, q0,F )

M′= (Q

′,Σ, δ

′, q0,F )

whereQ′

= {Q-qi} qi ∈ Q and qi 6= q0 and qi 6= qfTransitions:

1 For any two states qa and qb ∈ Q′1 with transitions

δ(qa, r1) = qi , δ(qi , r2) = qi and δ(qi , r3) = qb and δ(qa, r4) = qbAdd an edge from qa to qb with the regular expression r1r

∗2 r3 + r4

2 For cases qa and qb ∈ Q′

where @ a path from qa to qb through qibut there is a direct edge with label r , retain that label.

1qa and qb may be sameDr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 7 / 11

Page 32: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Correctness Claim: Has two parts

Part 1) If w ∈ L(M) ⇒ w ∈ L(M′)

Let w = a1a2, · · · , an ∈ L(M) ⇒δ∗(q0,w) = qf=δ∗(q0, a1a2, · · · , an) = qf=δ∗(δ(q0, a1), a2, · · · , an) = qf=δ∗(ql , a2, · · · , an) = qf=δ∗(δ(ql , a2), a3, · · · , an) = qf...= δ(qk , an) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 8 / 11

Page 33: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Correctness Claim: Has two partsPart 1) If w ∈ L(M) ⇒ w ∈ L(M

′)

Let w = a1a2, · · · , an ∈ L(M) ⇒δ∗(q0,w) = qf=δ∗(q0, a1a2, · · · , an) = qf=δ∗(δ(q0, a1), a2, · · · , an) = qf=δ∗(ql , a2, · · · , an) = qf=δ∗(δ(ql , a2), a3, · · · , an) = qf...= δ(qk , an) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 8 / 11

Page 34: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Correctness Claim: Has two partsPart 1) If w ∈ L(M) ⇒ w ∈ L(M

′)

Let w = a1a2, · · · , an ∈ L(M) ⇒

δ∗(q0,w) = qf=δ∗(q0, a1a2, · · · , an) = qf=δ∗(δ(q0, a1), a2, · · · , an) = qf=δ∗(ql , a2, · · · , an) = qf=δ∗(δ(ql , a2), a3, · · · , an) = qf...= δ(qk , an) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 8 / 11

Page 35: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Correctness Claim: Has two partsPart 1) If w ∈ L(M) ⇒ w ∈ L(M

′)

Let w = a1a2, · · · , an ∈ L(M) ⇒δ∗(q0,w) = qf

=δ∗(q0, a1a2, · · · , an) = qf=δ∗(δ(q0, a1), a2, · · · , an) = qf=δ∗(ql , a2, · · · , an) = qf=δ∗(δ(ql , a2), a3, · · · , an) = qf...= δ(qk , an) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 8 / 11

Page 36: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Correctness Claim: Has two partsPart 1) If w ∈ L(M) ⇒ w ∈ L(M

′)

Let w = a1a2, · · · , an ∈ L(M) ⇒δ∗(q0,w) = qf=δ∗(q0, a1a2, · · · , an) = qf

=δ∗(δ(q0, a1), a2, · · · , an) = qf=δ∗(ql , a2, · · · , an) = qf=δ∗(δ(ql , a2), a3, · · · , an) = qf...= δ(qk , an) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 8 / 11

Page 37: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Correctness Claim: Has two partsPart 1) If w ∈ L(M) ⇒ w ∈ L(M

′)

Let w = a1a2, · · · , an ∈ L(M) ⇒δ∗(q0,w) = qf=δ∗(q0, a1a2, · · · , an) = qf=δ∗(δ(q0, a1), a2, · · · , an) = qf

=δ∗(ql , a2, · · · , an) = qf=δ∗(δ(ql , a2), a3, · · · , an) = qf...= δ(qk , an) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 8 / 11

Page 38: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Correctness Claim: Has two partsPart 1) If w ∈ L(M) ⇒ w ∈ L(M

′)

Let w = a1a2, · · · , an ∈ L(M) ⇒δ∗(q0,w) = qf=δ∗(q0, a1a2, · · · , an) = qf=δ∗(δ(q0, a1), a2, · · · , an) = qf=δ∗(ql , a2, · · · , an) = qf

=δ∗(δ(ql , a2), a3, · · · , an) = qf...= δ(qk , an) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 8 / 11

Page 39: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Correctness Claim: Has two partsPart 1) If w ∈ L(M) ⇒ w ∈ L(M

′)

Let w = a1a2, · · · , an ∈ L(M) ⇒δ∗(q0,w) = qf=δ∗(q0, a1a2, · · · , an) = qf=δ∗(δ(q0, a1), a2, · · · , an) = qf=δ∗(ql , a2, · · · , an) = qf=δ∗(δ(ql , a2), a3, · · · , an) = qf

.

.

.= δ(qk , an) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 8 / 11

Page 40: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Correctness Claim: Has two partsPart 1) If w ∈ L(M) ⇒ w ∈ L(M

′)

Let w = a1a2, · · · , an ∈ L(M) ⇒δ∗(q0,w) = qf=δ∗(q0, a1a2, · · · , an) = qf=δ∗(δ(q0, a1), a2, · · · , an) = qf=δ∗(ql , a2, · · · , an) = qf=δ∗(δ(ql , a2), a3, · · · , an) = qf...= δ(qk , an) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 8 / 11

Page 41: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

The sequence of states visited are q0, q1, · · · , qf

Two cases

1 δ∗(q0,w) = q0, q1, · · · qf where qy 6= qi . ⇒δ′∗

(q0,w) = q0, q1, · · · qf where qy 6= qi2 δ∗(q0,w) = q0, · · · , qj , qi , · · · , qi , qm, · · · , qf After reading

a1, · · · , ai−1, ai , · · · , ai+1, · · · an⇒ ai ∈ ri−1 and ai+1 ∈ ri+1

which is nothing but ri−1r∗i ri+1

⇒ δ′∗

(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 9 / 11

Page 42: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

The sequence of states visited are q0, q1, · · · , qfTwo cases

1 δ∗(q0,w) = q0, q1, · · · qf where qy 6= qi . ⇒δ′∗

(q0,w) = q0, q1, · · · qf where qy 6= qi2 δ∗(q0,w) = q0, · · · , qj , qi , · · · , qi , qm, · · · , qf After reading

a1, · · · , ai−1, ai , · · · , ai+1, · · · an⇒ ai ∈ ri−1 and ai+1 ∈ ri+1

which is nothing but ri−1r∗i ri+1

⇒ δ′∗

(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 9 / 11

Page 43: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

The sequence of states visited are q0, q1, · · · , qfTwo cases

1 δ∗(q0,w) = q0, q1, · · · qf where qy 6= qi . ⇒

δ′∗

(q0,w) = q0, q1, · · · qf where qy 6= qi2 δ∗(q0,w) = q0, · · · , qj , qi , · · · , qi , qm, · · · , qf After reading

a1, · · · , ai−1, ai , · · · , ai+1, · · · an⇒ ai ∈ ri−1 and ai+1 ∈ ri+1

which is nothing but ri−1r∗i ri+1

⇒ δ′∗

(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 9 / 11

Page 44: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

The sequence of states visited are q0, q1, · · · , qfTwo cases

1 δ∗(q0,w) = q0, q1, · · · qf where qy 6= qi . ⇒δ′∗

(q0,w) = q0, q1, · · · qf where qy 6= qi

2 δ∗(q0,w) = q0, · · · , qj , qi , · · · , qi , qm, · · · , qf After readinga1, · · · , ai−1, ai , · · · , ai+1, · · · an⇒ ai ∈ ri−1 and ai+1 ∈ ri+1

which is nothing but ri−1r∗i ri+1

⇒ δ′∗

(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 9 / 11

Page 45: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

The sequence of states visited are q0, q1, · · · , qfTwo cases

1 δ∗(q0,w) = q0, q1, · · · qf where qy 6= qi . ⇒δ′∗

(q0,w) = q0, q1, · · · qf where qy 6= qi2 δ∗(q0,w) = q0, · · · , qj , qi , · · · , qi , qm, · · · , qf After reading

a1, · · · , ai−1, ai , · · · , ai+1, · · · an

⇒ ai ∈ ri−1 and ai+1 ∈ ri+1

which is nothing but ri−1r∗i ri+1

⇒ δ′∗

(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 9 / 11

Page 46: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

The sequence of states visited are q0, q1, · · · , qfTwo cases

1 δ∗(q0,w) = q0, q1, · · · qf where qy 6= qi . ⇒δ′∗

(q0,w) = q0, q1, · · · qf where qy 6= qi2 δ∗(q0,w) = q0, · · · , qj , qi , · · · , qi , qm, · · · , qf After reading

a1, · · · , ai−1, ai , · · · , ai+1, · · · an⇒ ai ∈ ri−1 and ai+1 ∈ ri+1

which is nothing but ri−1r∗i ri+1

⇒ δ′∗

(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 9 / 11

Page 47: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

The sequence of states visited are q0, q1, · · · , qfTwo cases

1 δ∗(q0,w) = q0, q1, · · · qf where qy 6= qi . ⇒δ′∗

(q0,w) = q0, q1, · · · qf where qy 6= qi2 δ∗(q0,w) = q0, · · · , qj , qi , · · · , qi , qm, · · · , qf After reading

a1, · · · , ai−1, ai , · · · , ai+1, · · · an⇒ ai ∈ ri−1 and ai+1 ∈ ri+1

which is nothing but ri−1r∗i ri+1

⇒ δ′∗

(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 9 / 11

Page 48: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

The sequence of states visited are q0, q1, · · · , qfTwo cases

1 δ∗(q0,w) = q0, q1, · · · qf where qy 6= qi . ⇒δ′∗

(q0,w) = q0, q1, · · · qf where qy 6= qi2 δ∗(q0,w) = q0, · · · , qj , qi , · · · , qi , qm, · · · , qf After reading

a1, · · · , ai−1, ai , · · · , ai+1, · · · an⇒ ai ∈ ri−1 and ai+1 ∈ ri+1

which is nothing but ri−1r∗i ri+1

⇒ δ′∗

(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 9 / 11

Page 49: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

The sequence of states visited are q0, q1, · · · , qfTwo cases

1 δ∗(q0,w) = q0, q1, · · · qf where qy 6= qi . ⇒δ′∗

(q0,w) = q0, q1, · · · qf where qy 6= qi2 δ∗(q0,w) = q0, · · · , qj , qi , · · · , qi , qm, · · · , qf After reading

a1, · · · , ai−1, ai , · · · , ai+1, · · · an⇒ ai ∈ ri−1 and ai+1 ∈ ri+1

which is nothing but ri−1r∗i ri+1

⇒ δ′∗

(q0,w) = qf

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 9 / 11

Page 50: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Part 2: If w ∈ L(M′)⇒ w ∈ L(M)

Take it as exercise !

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 10 / 11

Page 51: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Generalized NFA

Part 2: If w ∈ L(M′)⇒ w ∈ L(M)

Take it as exercise !

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 10 / 11

Page 52: Equivalence of NFA and Regular Expressionsiiti.ac.in/people/~neminath/CS202/KleenTheoerem.pdfEquivalence of NFA and Regular Expressions Dr. Neminath Hubballi Indian Institute of Technology

Reular Languages

Theorem

For any regular expression r with L(r), ∃ an NFA M such thatL(M) = L(r).

Theorem

For any NFA M with L= L(M), ∃ a regular expression r such thatL(r) = L(M)

Theorem

For any NFA M with L= L(M), ∃ a DFA M′such that L(M) = L(M

′)

Dr. Neminath Hubballi (IIT Indore) Kleene Theorem January 17, 2018 11 / 11