Docsity

Thompson's Construction: RE to DFA Conversion using NFA, Summaries of Data Mining

Partial preview of the text

Download Thompson's Construction: RE to DFA Conversion using NFA and more Summaries Data Mining in PDF only on Docsity!

Compiler

Compiler

Construction

Construction

Compiler

Compiler

Construction

Construction

Lecture 5

DFA and NFA

DFA and NFA DFA and NFA

DFA and NFA

Deterministic Finite Automata (DFA)

One transition per input per state.

No  - moves

NFA vs DFA

NFA vs DFA NFA vs DFA

NFA vs DFA

NFAs and DFAs recognize the same set of

languages (regular languages)

DFAs are easier to implement – table driven.

NFA vs DFA

NFA vs DFA NFA vs DFA

NFA vs DFA

For a given language, the NFA can

be simpler than the DFA.

DFA can be exponentially larger

than NFA.

RE

RE

NFA

NFA

Construction

Construction

RE

RE

NFA

NFA

Construction

Construction

The algorithm for RE to DFA conversion is

called Thompson’s construction

Build an NFA for each RE term.

Combine NFAs with e -moves.

RE

RE

NFA Construction

NFA Construction

RE

RE

NFA Construction

NFA Construction

Subset construction

NFA → DFA

Build the simulation or model.

Minimize number of states in DFA

( Hopcroft’s algorithm )

RE

RE

NFA Construction

NFA Construction RE

RE

NFA Construction

NFA Construction

s

0

a

s

1

NFA for a

s

0

a

s

1

NFA for ab

s

3

b

s

4

RE

RE

NFA Construction

NFA Construction RE

RE

NFA Construction

NFA Construction

s

0

a

s

1

NFA for a

RE

RE

NFA Construction

NFA Construction RE

RE

NFA Construction

NFA Construction

s

0

a

s

1

NFA for a

s

0

a

s

1

s

3

b

s

4

s

3

b

s

4

NFA for b

RE

RE

NFA Construction

NFA Construction RE

RE

NFA Construction

NFA Construction

s

0

a

s

1

NFA for a

s

0

a

s

1

NFA for ab

s

3

b

s

4

s

3

b

s

4

NFA for b

RE

RE

NFA Construction

NFA Construction RE

RE

NFA Construction

NFA Construction

s

1

a

s

2

NFA for a

RE

RE

NFA Construction

NFA Construction RE

RE

NFA Construction

NFA Construction

s

1

a

s

2

s

3

b

s

4

NFA for a and b

RE

RE

NFA Construction

NFA Construction RE

RE

NFA Construction

NFA Construction

s

0

s

4

s

1

a

s

2

NFA for a*

RE

RE

NFA Construction

NFA Construction RE

RE

NFA Construction

NFA Construction

s

1

a

s

2

NFA for a