finite state automata and determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5...

83
Finite State Automata and Determinisation Tim Dawborn January, 2017

Upload: others

Post on 07-Sep-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Finite State Automata and Determinisation

Tim Dawborn

January, 2017

Page 2: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 2

Outline

1 Languages

2 Finite State Automata (fsa)

3 Non-deterministic Finite State Automata (nfa)

4 Regular Expressions

5 Deterministic Finite State Automata (dfa)

6 Determinisation

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 3: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 3

Alphabets

• An alphabet Σ is a set of tokens used by a language• Σ = {0, 1} is the alphabet for binary• Σ = {., 0, 1, . . . , 9} is the alphabet for a decimal number• Σ = {marco, polo} is the alphabet for the communications

protocol in the game Marco Polo1

• What language(s) is this the alphabet for?Σ = {x, 0, 1, . . . , 9, A, B, . . . , F}

1A game involving calling out “Marco!” and “Polo!”,with an optional swimming pool

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 4: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 4

Strings

• A combination2 of elements from Σ is called a string• “0”, “101101”, “111” are all strings of Σ = {0, 1}

• The set Σ∗ is the infinite set of all combinations of theelements of Σ

• For the binary alphabet, Σ = {0, 1}, Σ∗ is3

Σ∗ = {∅, (0), (1), (00), (01), (10), (11), (000), (001), . . .}

2Obviously, a contiguous ordered tuple of elements, not a set:“01” is a different string from “10”

3Here the empty set will do to represent a null or empty string

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 5: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 5

Languages

• A language L is a set of items from Σ∗ which are deemed tobe valid (L ⊆ Σ∗)

• For hexadecimal, only the strings which begin with “0x” andhave at least one more non-“x” token are deemed valid4 “0xF9”8 “1234”4 “0x0”8 “0x”8 “1xA”8 “” (the empty string)

• A language in this context is not a set of rules, syntax,grammar and all: it’s just a set of valid strings

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 6: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 6

Finite State Automata

• Finite State Automata are representations of a self-containedfinite set of states, with rules that govern movement amongthose states.

• Finite State Automata (fsas) exist everywhere

• They are used to illustrate• the possible states some process can be in• how the process moves between these states

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 7: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 7

Finite State Automata

• E.g. a state machine for PIN code entry on your mobile4:

waiting

waiting0-9

cancel

waiting

0-9

cancel

waiting

0-9cancel

check password!

0-9

cancel

4How many people do you know who say “PIN Number”?

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 8: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 8

Finite State Automata

waiting

waiting0-9

cancel

waiting

0-9

cancel

waiting

0-9cancel

check password!

0-9

cancel

• fsas have nodes

• fsas have edges

• fsa edges (transitions) have labels

• fsas have a start node (entry point)

• fsas have accepting nodes, denoted with the double outline

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 9: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 8

Finite State Automata

waiting

waiting0-9

cancel

waiting

0-9

cancel

waiting

0-9cancel

check password!

0-9

cancel

• fsas have nodes

• fsas have edges

• fsa edges (transitions) have labels

• fsas have a start node (entry point)

• fsas have accepting nodes, denoted with the double outline

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 10: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 8

Finite State Automata

waiting

waiting0-9

cancel

waiting

0-9

cancel

waiting

0-9cancel

check password!

0-9

cancel

• fsas have nodes

• fsas have edges

• fsa edges (transitions) have labels

• fsas have a start node (entry point)

• fsas have accepting nodes, denoted with the double outline

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 11: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 8

Finite State Automata

waiting

waiting0-9

cancel

waiting

0-9

cancel

waiting

0-9cancel

check password!

0-9

cancel

• fsas have nodes

• fsas have edges

• fsa edges (transitions) have labels

• fsas have a start node (entry point)

• fsas have accepting nodes, denoted with the double outline

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 12: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 8

Finite State Automata

waiting

waiting0-9

cancel

waiting

0-9

cancel

waiting

0-9cancel

check password!

0-9

cancel

• fsas have nodes

• fsas have edges

• fsa edges (transitions) have labels

• fsas have a start node (entry point)

• fsas have accepting nodes, denoted with the double outline

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 13: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 9

Finite State Automata

waiting

waiting0-9

cancel

waiting

0-9

cancel

waiting

0-9cancel

check password!

0-9

cancel

• You are always “on” one of the nodes, i.e., in one of thestates.

• You can travel between the nodes following the directed edges

• You can only travel along an edge if you see the label that ison the edge

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 14: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9”

q0 → q1 → q2 → q3 → q3 4

“1234” q0 8

“0x0” q0 → q1 → q2 → q3 4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 15: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3

4

“1234” q0 8

“0x0” q0 → q1 → q2 → q3 4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 16: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234” q0 8

“0x0” q0 → q1 → q2 → q3 4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 17: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234”

q0 8

“0x0” q0 → q1 → q2 → q3 4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 18: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234” q0

8

“0x0” q0 → q1 → q2 → q3 4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 19: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234” q0 8

“0x0” q0 → q1 → q2 → q3 4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 20: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234” q0 8

“0x0”

q0 → q1 → q2 → q3 4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 21: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234” q0 8

“0x0” q0 → q1 → q2 → q3

4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 22: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234” q0 8

“0x0” q0 → q1 → q2 → q3 4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 23: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234” q0 8

“0x0” q0 → q1 → q2 → q3 4

“”

q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 24: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234” q0 8

“0x0” q0 → q1 → q2 → q3 4

“” q0

8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 25: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 10

Pattern Recognition using fsas

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Walk the following strings through the fsa. Are they accepted?String Path Accepts?“0xF9” q0 → q1 → q2 → q3 → q3 4

“1234” q0 8

“0x0” q0 → q1 → q2 → q3 4

“” q0 8

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 26: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 11

Non-deterministic Finite State Automata

• There are two main types of fsas• Deterministic• Non-deterministic

• What we have been looking at so far are examples ofnon-deterministic finite [state] automata (nfa)

• E.g. nfa for recognising a hexadecimal number:

q0 q3

0-9,A-F

q10 q2x 0-9,A-F

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 27: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 12

Properties of nfas

• Must have a start node

• No restrictions on the edge labels

• Allowed special ε edge labels (we’ll come back to this)

• Allowed to be “on” multiple states simultaneously• non-determinism

Basically an NFA is a FSA that isn’t fully defined: in a DFA(Deterministic Finite (State) Automaton of course),everything has to be determined: if there’s an error conditionthat has to be explained, there can’t be any ambiguity, and soon.

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 28: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 13

Non-determinism example

Is the string “ca” accepted by the nfa?Path:

{q0}→ {q1}→ {q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 29: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 13

Non-determinism example

Is the string “ca” accepted by the nfa?Path: {q0}

→ {q1}→ {q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 30: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 13

Non-determinism example

Is the string “ca” accepted by the nfa?Path: {q0}→ {q1}

→ {q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 31: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 13

Non-determinism example

Is the string “ca” accepted by the nfa?Path: {q0}→ {q1}→ {q3}Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 32: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 13

Non-determinism example

Is the string “ca” accepted by the nfa?Path: {q0}→ {q1}→ {q3}Accepted: Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 33: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 14

Non-determinism example

Is the string “ac” accepted by the nfa?Path:

{q0}→ {q0, q2}→ {q1, q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 34: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 14

Non-determinism example

Is the string “ac” accepted by the nfa?Path: {q0}

→ {q0, q2}→ {q1, q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 35: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 14

Non-determinism example

Is the string “ac” accepted by the nfa?Path: {q0}→ {q0, q2}

→ {q1, q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 36: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 14

Non-determinism example

Is the string “ac” accepted by the nfa?Path: {q0}→ {q0, q2}→ {q1, q3}Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 37: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 14

Non-determinism example

Is the string “ac” accepted by the nfa?Path: {q0}→ {q0, q2}→ {q1, q3}Accepted: Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 38: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 15

Non-determinism example

Is the string “aabc” accepted by the nfa?Path:

{q0}→ {q0, q2}→ {q0, q2}→ {q0, q1, q2}→ {q1, q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 39: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 15

Non-determinism example

Is the string “aabc” accepted by the nfa?Path: {q0}

→ {q0, q2}→ {q0, q2}→ {q0, q1, q2}→ {q1, q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 40: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 15

Non-determinism example

Is the string “aabc” accepted by the nfa?Path: {q0}→ {q0, q2}

→ {q0, q2}→ {q0, q1, q2}→ {q1, q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 41: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 15

Non-determinism example

Is the string “aabc” accepted by the nfa?Path: {q0}→ {q0, q2}→ {q0, q2}

→ {q0, q1, q2}→ {q1, q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 42: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 15

Non-determinism example

Is the string “aabc” accepted by the nfa?Path: {q0}→ {q0, q2}→ {q0, q2}→ {q0, q1, q2}

→ {q1, q3}

Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 43: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 15

Non-determinism example

Is the string “aabc” accepted by the nfa?Path: {q0}→ {q0, q2}→ {q0, q2}→ {q0, q1, q2}→ {q1, q3}Accepted:

Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 44: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 15

Non-determinism example

Is the string “aabc” accepted by the nfa?Path: {q0}→ {q0, q2}→ {q0, q2}→ {q0, q1, q2}→ {q1, q3}Accepted: Yes

q0 q3a,b

q1

c

q2

a

a

b,c

c

b

a,b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 45: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 16

ε transitions

• nfas can have a special transition label ε

• ε allows a transition without consuming any input tokens

q0 q4q1cq2a

q3b

• In English, what pattern does this nfa therefore allow us tomatch?

• Any string starting with a “c”, followed by one or moreinstances of “ab”, followed by a “c”

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 46: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 16

ε transitions

• nfas can have a special transition label ε

• ε allows a transition without consuming any input tokens

q0 q4q1cq2a

q3b

• In English, what pattern does this nfa therefore allow us tomatch?

• Any string starting with a “c”, followed by one or moreinstances of “ab”, followed by a “c”

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 47: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 17

Your turn – Woo!

Construct a nfa which accepts only binary numbers with an evennumber of zero’s.

q0

1

q100

1

As above, except for one’s instead of zero’s.

q0

0

q111

0

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 48: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 17

Your turn – Woo!

Construct a nfa which accepts only binary numbers with an evennumber of zero’s.

q0

1

q100

1

As above, except for one’s instead of zero’s.

q0

0

q111

0

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 49: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 17

Your turn – Woo!

Construct a nfa which accepts only binary numbers with an evennumber of zero’s.

q0

1

q100

1

As above, except for one’s instead of zero’s.

q0

0

q111

0

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 50: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 17

Your turn – Woo!

Construct a nfa which accepts only binary numbers with an evennumber of zero’s.

q0

1

q100

1

As above, except for one’s instead of zero’s.

q0

0

q111

0

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 51: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 18

Your turn

Construct a nfa which accepts only binary numbers with an evennumber of zero’s OR an even number of one’s.

q0

q1

1

q20

q3

0

q41

ϵ

ϵ

0

1

1

0

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 52: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 18

Your turn

Construct a nfa which accepts only binary numbers with an evennumber of zero’s OR an even number of one’s.

q0

q1

1

q20

q3

0

q41

ϵ

ϵ

0

1

1

0

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 53: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 19

Regular Expressions (re)

You remember thepower of regularexpressions? Thesethings can save theworld!regex’s rule.

. . . and it turns out they’re much better interpreted and dealt withby using FSAs.

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 54: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 20

Regular Expressions as nfas

• Regular expressions can easily berepresented using nfas

• We can group regular expressionsinto 4 different components

Character a single character:/a/

Concatenation two adjacentexpressions: /ab/

Union two OR’dexpressions: /a|b/

Kleene star zero or morerepetitions: /a*/

/a(bc|d*)*e/ can beviewed as

a

b c d

e

concat star

union

star

concat

concat

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 55: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 21

And it really does matter

Knowing the right way to do regular expressions, using goodcomputer science, means that you don’t have to make major errorsleading to really really bad performance, in a hardly-used bit ofsoftware, like say, Perl.

This is the time taken to match the sequence a?nan against an where thesuperscript represents string repeats, so a?2a2 = a?a?aa

Source: Russ Cox / [email protected] a great discussion of this, see

http://swtch.com/~rsc/regexp/regexp1.html

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 56: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 22

re to nfa: Character

/a/

q0 q1a

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 57: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 23

re to nfa: Concatenation

/ab/

q0 q1a + q2 q3b

becomes

q0 q3q1a q2ϵ b

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 58: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 24

re to nfa: Union

/a|b/

q0 q1a + q2 q3b

becomes

q4 q5

q0ϵ

q2ϵ

q1aϵ

q3bϵ

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 59: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 25

re to nfa: Kleene Star

/a*/

q0 q1a

becomes

q2 q3ϵ

q0ϵ

q1aϵ

ϵ

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 60: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 26

An example conversion

/a(bc|d*)*e/

becomes

q0

q14

q1a q2ϵq3ϵ

q4ϵ

q12

ϵ

q5b

q6

ϵ q10ϵ

q13ϵ

q7ϵ

q8d

q11ϵ

q9c

ϵ

ϵ

ϵ

ϵ

ϵ

e

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 61: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 27

DFAs vs NFAs

• How do dfas differ from nfas?• Deterministic (not non-deterministic)• No ε edges• Every edge from a node must have a unique label (can’t be in

multiple states)• Every node must have an outward edge for each token of the

alphabet (it is completely described)

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 62: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 28

dfas vs. nfas

• E.g. dfa for recognising a hexadecimal number:

q1

q4

0-9,A-F

q5

x

q20

1-9,A-F,x

q3x 0-9,A-F

0-9,A-F

x0-9,A-F,x

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 63: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 29

Why do we need dfas? What’s wrong with nfas?

• The non-deterministic aspect of nfas makes them bad formodern-day computation

• Computers cannot efficiently perform the “be in multiplestates at once”

• In a dfa, you can only be in one state at a time

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 64: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 30

Your turn

dfas can be harder to manually construct than nfas, due to theirrestrictions.

Construct a dfa over Σ = {a, b} accepting strings ending in “bb”.

q0 q2

b

a

a

q1b ba

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 65: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 30

Your turn

dfas can be harder to manually construct than nfas, due to theirrestrictions.

Construct a dfa over Σ = {a, b} accepting strings ending in “bb”.

q0 q2

b

a

a

q1b ba

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 66: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 31

nfa?= dfa

• At first glance, it would appear that nfas are more powerfulthan dfas. Why?

• multiple edges with the same label coming off a node• ε edges• ability to be in multiple states at once

• In 1959, Rabin and Scott proved that nfas and dfas have thesame expressive power

• The proof is surprisingly simple: we need to show that foreach NFA there is a DFA, and vice-versa, that accept preciselythe same languages.

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 67: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 31

nfa?= dfa

• At first glance, it would appear that nfas are more powerfulthan dfas. Why?

• multiple edges with the same label coming off a node• ε edges• ability to be in multiple states at once

• In 1959, Rabin and Scott proved that nfas and dfas have thesame expressive power

• The proof is surprisingly simple: we need to show that foreach NFA there is a DFA, and vice-versa, that accept preciselythe same languages.

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 68: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 31

nfa?= dfa

• At first glance, it would appear that nfas are more powerfulthan dfas. Why?

• multiple edges with the same label coming off a node• ε edges• ability to be in multiple states at once

• In 1959, Rabin and Scott proved that nfas and dfas have thesame expressive power

• The proof is surprisingly simple: we need to show that foreach NFA there is a DFA, and vice-versa, that accept preciselythe same languages.

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 69: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 32

Determinisation Algorithm

• This algorithm converts any nfa into an equivalent dfa

q1

q3

q4

0

q2

ϵ

0 1

1

into

{q1,q2,q3} {q2,q4}0,1

1

{q2,q3}01

{q4}00

{}1

0,1

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 70: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 33

Move and Epsilon-Closure

Move M(states, token)Given a set of states and an input token, what set ofstates do you end up at

Epsilon-Closure EC (states)Given a set of states, what set of states do you getby expanding all ε transitions

q0q3

b

q1c

q2

aa

b,c

ba,b

M({q0, q1},“a”) = {q2, q3} EC({q2, q3}) = {q0, q2, q3}

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 71: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 34

Algorithm Idea

• We need to remove the concept of non-determinism in thedfa

• Achieved by creating a state in the dfa for every possible setof states in the nfa

• Q: If the nfa has n states, what’s the maximum number ofstates its corresponding dfa could have?

• A: |P(n)| = 2n

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 72: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 34

Algorithm Idea

• We need to remove the concept of non-determinism in thedfa

• Achieved by creating a state in the dfa for every possible setof states in the nfa

• Q: If the nfa has n states, what’s the maximum number ofstates its corresponding dfa could have?

• A: |P(n)| = 2n

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 73: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 35

PseudocodeRequire: nfa

dfa ← a new DFA objectdfa.start ← EC (nfa.start)todo ← [dfa.start]

while todo 6= ∅ dostates = pop the next item off todo

for all σ ∈ ΣNFA \ {ε} dos = EC (M(states, σ))if s 6= ∅ then

Add the edge statesσ−→ s to dfa

Add s to todo if it’s newend if

end forend whilereturn dfa

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 74: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 36

Example

q0q3

b

q1c

q2

aa

b,c

ba,b

todo{0}

{0, 2}{1}{0, 1, 2}{1, 3}{3}{0, 2, 3}

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 75: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 36

Example

q0q3

b

q1c

q2

aa

b,c

ba,b

todo{0}

{0, 2}{1}{0, 1, 2}{1, 3}{3}{0, 2, 3}

{q0}

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 76: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 36

Example

q0q3

b

q1c

q2

aa

b,c

ba,b

todo{0}{0, 2}{1}

{0, 1, 2}{1, 3}{3}{0, 2, 3}

{q0}

b {q0,q2}a

{q1}c

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 77: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 36

Example

q0q3

b

q1c

q2

aa

b,c

ba,b

todo{0}{0, 2}{1}{0, 1, 2}{1, 3}

{3}{0, 2, 3}

{q0}

b {q0,q2}a

{q1}c

a{q0,q1,q2}b {q1,q3}

c

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 78: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 36

Example

q0q3

b

q1c

q2

aa

b,c

ba,b

todo{0}{0, 2}{1}{0, 1, 2}{1, 3}{3}

{0, 2, 3}

{q0}

b {q0,q2}a

{q1}c

a{q0,q1,q2}b {q1,q3}

cb,c

{q3}a

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 79: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 36

Example

q0q3

b

q1c

q2

aa

b,c

ba,b

todo{0}{0, 2}{1}{0, 1, 2}{1, 3}{3}{0, 2, 3}

{q0}

b {q0,q2}a

{q1}c

a{q0,q1,q2}b {q1,q3}

c

b{q0,q2,q3}

a

c

b,c{q3}

a

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 80: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 36

Example

q0q3

b

q1c

q2

aa

b,c

ba,b

todo{0}{0, 2}{1}{0, 1, 2}{1, 3}{3}{0, 2, 3}

{q0}

b {q0,q2}a

{q1}c

a{q0,q1,q2}b {q1,q3}

c

b{q0,q2,q3}

a

c

b,c{q3}

ab,c

a

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 81: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 36

Example

q0q3

b

q1c

q2

aa

b,c

ba,b

todo{0}{0, 2}{1}{0, 1, 2}{1, 3}{3}{0, 2, 3}

{q0}

b {q0,q2}a

{q1}c

a{q0,q1,q2}b {q1,q3}

c

b{q0,q2,q3}

a

c

b,c{q3}

ab,c

a{}

a,b,c

a,b,c

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 82: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 36

Example

q0q3

b

q1c

q2

aa

b,c

ba,b

todo{0}{0, 2}{1}{0, 1, 2}{1, 3}{3}{0, 2, 3}

{q0}

b {q0,q2}a

{q1}c

a{q0,q1,q2}b {q1,q3}

c

b{q0,q2,q3}

a

c

a,b

c

b,c{q3}

ab,c

a{}

a,b,c

a,b,c

Tim Dawborn Finite State Automata and Determinisation January, 2017

Page 83: Finite State Automata and Determinisationncss.edu.au/ckeditor_assets/attachments/26/fsa.pdf5 Deterministic Finite State Automata (dfa) 6 Determinisation Tim Dawborn Finite State Automata

Languages fsa nfa re dfa Determinisation 37

Finish

End of presentation.

Tim Dawborn Finite State Automata and Determinisation January, 2017