Foundations of Computer Science Lecture 24 Deterministic Finite - - PowerPoint PPT Presentation

foundations of computer science lecture 24 deterministic
SMART_READER_LITE
LIVE PREVIEW

Foundations of Computer Science Lecture 24 Deterministic Finite - - PowerPoint PPT Presentation

Foundations of Computer Science Lecture 24 Deterministic Finite Automata (DFA) A Simple Computing Machine: A CPU with States and Transitions What Problems Can It Solve: Regular Languages Is There A Problem It Cant Solve? Computing Problems


slide-1
SLIDE 1

Foundations of Computer Science Lecture 24 Deterministic Finite Automata (DFA)

A Simple Computing Machine: A CPU with States and Transitions What Problems Can It Solve: Regular Languages Is There A Problem It Can’t Solve?

slide-2
SLIDE 2

Computing Problems and Their Difficulty

Decision Problem Computing Problem Decision Problem Computing Problem Language L: yes-set of finite binary strings

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 2 / 15 Today →

slide-3
SLIDE 3

Computing Problems and Their Difficulty

Decision Problem Computing Problem Decision Problem Computing Problem How hard is the problem?

?

How complex is L? How hard is it to test membership in L? How complex is L? How hard is it to test membership in L? Language L: yes-set of finite binary strings

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 2 / 15 Today →

slide-4
SLIDE 4

Computing Problems and Their Difficulty

Decision Problem Computing Problem Decision Problem Computing Problem How hard is the problem?

?

How complex is L? How hard is it to test membership in L? How complex is L? How hard is it to test membership in L? Language L: yes-set of finite binary strings

A problem can be harder in two ways.

1 The problem needs more resources. For example, the problem can be solved with a

similar machine to ours, except with more states.

2 The problem needs a different kind of computing machine, with superior capabilities. Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 2 / 15 Today →

slide-5
SLIDE 5

Computing Problems and Their Difficulty

Decision Problem Computing Problem Decision Problem Computing Problem How hard is the problem?

?

How complex is L? How hard is it to test membership in L? How complex is L? How hard is it to test membership in L? Language L: yes-set of finite binary strings

A problem can be harder in two ways.

1 The problem needs more resources. For example, the problem can be solved with a

similar machine to ours, except with more states.

2 The problem needs a different kind of computing machine, with superior capabilities.

The first type of “harder” is the focus of a follow-on algorithms course. We focus on what can and can’t be solved on a particular kind of machine.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 2 / 15 Today →

slide-6
SLIDE 6

Today: Deterministic Finite Automata (DFA)

1

A simple computing machine.

States. Transitions. No scratch paper.

2

What computing problems can this simple machine solve?

Vending machine.

3

Regular languages. Closed under all the set operations: union, intersection, complement, concatenation, Kleene-star.

4

Are there problems that cannot be solved?

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 3 / 15 A Simple Computing Machine →

slide-7
SLIDE 7

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1 1 1 1 1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-8
SLIDE 8

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-9
SLIDE 9

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

q0 q1 q2 states → q0 no q1 yes q2 no

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-10
SLIDE 10

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

q0 q1 q2 states → q0 no q1 yes q2 no transitions 1 : q0 0 q1 ← In state q0, if you read

0, transition to q1 Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-11
SLIDE 11

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

q0 q1 q2 1 states → q0 no q1 yes q2 no transitions 1 : q0 0 q1 ← In state q0, if you read

0, transition to q1

2 : q0 1 q2

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-12
SLIDE 12

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

q0 q1 q2 1 1 states → q0 no q1 yes q2 no transitions 1 : q0 0 q1 ← In state q0, if you read

0, transition to q1

2 : q0 1 q2 3 : q1 0 q1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-13
SLIDE 13

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

q0 q1 q2 1 1 states → q0 no q1 yes q2 no transitions 1 : q0 0 q1 ← In state q0, if you read

0, transition to q1

2 : q0 1 q2 3 : q1 0 q1 4 : q1 1 q2

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-14
SLIDE 14

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

q0 q1 q2 1 1 0,1 states → q0 no q1 yes q2 no transitions 1 : q0 0 q1 ← In state q0, if you read

0, transition to q1

2 : q0 1 q2 3 : q1 0 q1 4 : q1 1 q2 5 : q2 0 q2 6 : q2 1 q2

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-15
SLIDE 15

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

q0 q1 q2 1 1 0,1 states → q0 no q1 yes q2 no transitions 1 : q0 0 q1 ← In state q0, if you read

0, transition to q1

2 : q0 1 q2 3 : q1 0 q1 4 : q1 1 q2 5 : q2 0 q2 6 : q2 1 q2

1: Process the input string (left-to-right) starting from the initial state q0.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-16
SLIDE 16

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

q0 q1 q2 1 1 0,1 states → q0 no q1 yes q2 no transitions 1 : q0 0 q1 ← In state q0, if you read

0, transition to q1

2 : q0 1 q2 3 : q1 0 q1 4 : q1 1 q2 5 : q2 0 q2 6 : q2 1 q2

1: Process the input string (left-to-right) starting from the initial state q0. 2: Process one bit at a time, each time transitioning from the current state to the next state according to the transition instructions.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-17
SLIDE 17

A Simple Computing Machine

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1

q0 q1 q2 1 1 0,1 states → q0 no q1 yes q2 no transitions 1 : q0 0 q1 ← In state q0, if you read

0, transition to q1

2 : q0 1 q2 3 : q1 0 q1 4 : q1 1 q2 5 : q2 0 q2 6 : q2 1 q2

1: Process the input string (left-to-right) starting from the initial state q0. 2: Process one bit at a time, each time transitioning from the current state to the next state according to the transition instructions. 3: When done processing every bit, output yes if the final resting state of the DFA is a yes-state; otherwise output no .

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

slide-18
SLIDE 18

Running the Machine on an Input

0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

slide-19
SLIDE 19

Running the Machine on an Input

0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010 0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010

M

→ q1|0⊲10

M is the name

  • f our “Machine”
  • Creator: Malik Magdon-Ismail

Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

slide-20
SLIDE 20

Running the Machine on an Input

0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010 0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010

M

→ q1|0⊲10

M is the name

  • f our “Machine”
  • 0 1 0

q0 q1 q2 1 1 0,1 q0|⊲010

M

→ q1|0⊲10

M

→ q2|01⊲0

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

slide-21
SLIDE 21

Running the Machine on an Input

0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010 0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010

M

→ q1|0⊲10

M is the name

  • f our “Machine”
  • 0 1 0

q0 q1 q2 1 1 0,1 q0|⊲010

M

→ q1|0⊲10

M

→ q2|01⊲0 0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010

M

→ q1|0⊲10

M

→ q2|01⊲0

M

→ q2|010⊲

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

slide-22
SLIDE 22

Running the Machine on an Input

0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010 0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010

M

→ q1|0⊲10

M is the name

  • f our “Machine”
  • 0 1 0

q0 q1 q2 1 1 0,1 q0|⊲010

M

→ q1|0⊲10

M

→ q2|01⊲0 0 1 0 q0 q1 q2 1 1 0,1 q0|⊲010

M

→ q1|0⊲10

M

→ q2|01⊲0

M

→ q2|010⊲ no, reject

Pop Quiz. Give computation trace for ε, 010, 000. What strings does the machine accept and say yes ? Pop Quiz. Determine yes or no if you can from partial traces. q0 |

? ⊲ 0000;

q1 |

? ⊲ 0000;

q2 |

? ⊲ 0000.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

slide-23
SLIDE 23

Computing Problem Solved by a DFA

The computing problem solved by M is the language L(M) = {w | M(w) = yes}.

L(M) is the automaton’s yes-set. For our automaton M L(M) = {0, 00, 000, 0000, . . .} = {0•n | n > 0}.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 6 / 15 The Vending Machine →

slide-24
SLIDE 24

Computing Problem Solved by a DFA

The computing problem solved by M is the language L(M) = {w | M(w) = yes}.

L(M) is the automaton’s yes-set. For our automaton M L(M) = {0, 00, 000, 0000, . . .} = {0•n | n > 0}.

1 For an automaton M, what is the computing problem L(M) solved by M? 2 For a computing problem L, what automaton M solves L, i.e., L(M) = L?

  • Practice. Exercise 24.2 gives you lots of training in question 1.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 6 / 15 The Vending Machine →

slide-25
SLIDE 25

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-26
SLIDE 26

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-27
SLIDE 27

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-28
SLIDE 28

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-29
SLIDE 29

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-30
SLIDE 30

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-31
SLIDE 31

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-32
SLIDE 32

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-33
SLIDE 33

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-34
SLIDE 34

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-35
SLIDE 35

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition 10¢ transition plus dispense soda

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-36
SLIDE 36

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition 10¢ transition plus dispense soda

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-37
SLIDE 37

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition 10¢ transition plus dispense soda

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-38
SLIDE 38

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition 10¢ transition plus dispense soda

Input sequence: 10¢,

0¢ 10¢

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-39
SLIDE 39

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition 10¢ transition plus dispense soda

Input sequence: 10¢, 10¢,

0¢ 10¢ 20¢

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-40
SLIDE 40

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition 10¢ transition plus dispense soda

Input sequence: 10¢, 10¢, 5¢,

0¢ 10¢ 20¢ 0¢ (+ soda)

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-41
SLIDE 41

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition 10¢ transition plus dispense soda

Input sequence: 10¢, 10¢, 5¢, 10¢,

0¢ 10¢ 20¢ 0¢ (+ soda) 10¢

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-42
SLIDE 42

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition 10¢ transition plus dispense soda

Input sequence: 10¢, 10¢, 5¢, 10¢, 10¢,

0¢ 10¢ 20¢ 0¢ (+ soda) 10¢ 20¢

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-43
SLIDE 43

The Vending Machine

Vending machine takes nickels and dimes and dispenses a soda when it has 25¢.

0¢ 5¢ 10¢ 15¢ 20¢

5¢ transition 5¢ transition plus dispense soda 10¢ transition 10¢ transition plus dispense soda

Input sequence: 10¢, 10¢, 5¢, 10¢, 10¢, 10¢.

0¢ 10¢ 20¢ 0¢ (+ soda) 10¢ 20¢ 5¢ (+ soda).

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 7 / 15 DFA for a Finite Language →

slide-44
SLIDE 44

DFA for a Finite Language

L = {10}.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 8 / 15 DFAs for Infinite Languages →

slide-45
SLIDE 45

DFA for a Finite Language

L = {10}.

q0

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 8 / 15 DFAs for Infinite Languages →

slide-46
SLIDE 46

DFA for a Finite Language

L = {10}.

q0 e 0,1

0 means move to a rejecting error state and stay there

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 8 / 15 DFAs for Infinite Languages →

slide-47
SLIDE 47

DFA for a Finite Language

L = {10}.

q0 e q1 1 0,1

0 means move to a rejecting error state and stay there 1 is partial success.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 8 / 15 DFAs for Infinite Languages →

slide-48
SLIDE 48

DFA for a Finite Language

L = {10}.

q0 e q1 1 0,1 1

0 means move to a rejecting error state and stay there 1 is partial success. Another 1 puts you into error since you want 0;

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 8 / 15 DFAs for Infinite Languages →

slide-49
SLIDE 49

DFA for a Finite Language

L = {10}.

q0 e q1 q2 1 0,1 1

0 means move to a rejecting error state and stay there 1 is partial success. Another 1 puts you into error since you want 0; 0 from q1 and you are ready to accept . . . unless . . .

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 8 / 15 DFAs for Infinite Languages →

slide-50
SLIDE 50

DFA for a Finite Language

L = {10}.

q0 e q1 q2 1 0,1 1 0,1

0 means move to a rejecting error state and stay there 1 is partial success. Another 1 puts you into error since you want 0; 0 from q1 and you are ready to accept . . . unless . . . More bits arrive, in which case move to error.

  • Practice. Try random strings other than 01 and make sure our DFA rejects them.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 8 / 15 DFAs for Infinite Languages →

slide-51
SLIDE 51

DFAs for Infinite Languages

L1 = ∗0∗ L2 = ∗1

(wildcard ∗ = Σ∗) Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 9 / 15 Two DFAs in One →

slide-52
SLIDE 52

DFAs for Infinite Languages

L1 = ∗0∗ = {strings with a 0} = {0, 00, 01, 10, 000, 001, 010, 011, 100, . . .} L2 = ∗1

(wildcard ∗ = Σ∗)

= {strings ending in 1} = {1, 01, 11, 001, 011, 101, 111, . . .}

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 9 / 15 Two DFAs in One →

slide-53
SLIDE 53

DFAs for Infinite Languages

L1 = ∗0∗ = {strings with a 0} = {0, 00, 01, 10, 000, 001, 010, 011, 100, . . .} q0 q1 M1 1 L2 = ∗1

(wildcard ∗ = Σ∗)

= {strings ending in 1} = {1, 01, 11, 001, 011, 101, 111, . . .}

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 9 / 15 Two DFAs in One →

slide-54
SLIDE 54

DFAs for Infinite Languages

L1 = ∗0∗ = {strings with a 0} = {0, 00, 01, 10, 000, 001, 010, 011, 100, . . .} q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

= {strings ending in 1} = {1, 01, 11, 001, 011, 101, 111, . . .}

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 9 / 15 Two DFAs in One →

slide-55
SLIDE 55

DFAs for Infinite Languages

L1 = ∗0∗ = {strings with a 0} = {0, 00, 01, 10, 000, 001, 010, 011, 100, . . .} q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

= {strings ending in 1} = {1, 01, 11, 001, 011, 101, 111, . . .} s0 s1 M2 1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 9 / 15 Two DFAs in One →

slide-56
SLIDE 56

DFAs for Infinite Languages

L1 = ∗0∗ = {strings with a 0} = {0, 00, 01, 10, 000, 001, 010, 011, 100, . . .} q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

= {strings ending in 1} = {1, 01, 11, 001, 011, 101, 111, . . .} s0 s1 M2 1 1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 9 / 15 Two DFAs in One →

slide-57
SLIDE 57

DFAs for Infinite Languages

L1 = ∗0∗ = {strings with a 0} = {0, 00, 01, 10, 000, 001, 010, 011, 100, . . .} q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

= {strings ending in 1} = {1, 01, 11, 001, 011, 101, 111, . . .} s0 s1 M2 1 1

  • Complement. Consider L1:

Must accept strings M1 rejects.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 9 / 15 Two DFAs in One →

slide-58
SLIDE 58

DFAs for Infinite Languages

L1 = ∗0∗ = {strings with a 0} = {0, 00, 01, 10, 000, 001, 010, 011, 100, . . .} q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

= {strings ending in 1} = {1, 01, 11, 001, 011, 101, 111, . . .} s0 s1 M2 1 1

  • Complement. Consider L1:

Must accept strings M1 rejects.

q0 q1 M 1 0,1

← flip yes and no-states.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 9 / 15 Two DFAs in One →

slide-59
SLIDE 59

Two DFAs in One: Union and Intersection

L1 = ∗0∗ q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

s0 s1 M2 1 1

The Joint-DFA has product states {q0s0, q0s1, q1s0, q1s1}:

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 10 / 15 Concatenation and Kleene Star →

slide-60
SLIDE 60

Two DFAs in One: Union and Intersection

L1 = ∗0∗ q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

s0 s1 M2 1 1

The Joint-DFA has product states {q0s0, q0s1, q1s0, q1s1}:

q0s0

q0s0: M1 is in state q0 and M2 is in state s0.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 10 / 15 Concatenation and Kleene Star →

slide-61
SLIDE 61

Two DFAs in One: Union and Intersection

L1 = ∗0∗ q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

s0 s1 M2 1 1

The Joint-DFA has product states {q0s0, q0s1, q1s0, q1s1}:

q0s0 q0s1 1

q0s0: M1 is in state q0 and M2 is in state s0. q0s1: M1 is in state q0 and M2 is in state s1.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 10 / 15 Concatenation and Kleene Star →

slide-62
SLIDE 62

Two DFAs in One: Union and Intersection

L1 = ∗0∗ q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

s0 s1 M2 1 1

The Joint-DFA has product states {q0s0, q0s1, q1s0, q1s1}:

q0s0 q0s1 q1s0 1

q0s0: M1 is in state q0 and M2 is in state s0. q0s1: M1 is in state q0 and M2 is in state s1. q1s0: M1 is in state q1 and M2 is in state s0.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 10 / 15 Concatenation and Kleene Star →

slide-63
SLIDE 63

Two DFAs in One: Union and Intersection

L1 = ∗0∗ q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

s0 s1 M2 1 1

The Joint-DFA has product states {q0s0, q0s1, q1s0, q1s1}:

q0s0 q0s1 q1s0 1 1

q0s0: M1 is in state q0 and M2 is in state s0. q0s1: M1 is in state q0 and M2 is in state s1. q1s0: M1 is in state q1 and M2 is in state s0.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 10 / 15 Concatenation and Kleene Star →

slide-64
SLIDE 64

Two DFAs in One: Union and Intersection

L1 = ∗0∗ q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

s0 s1 M2 1 1

The Joint-DFA has product states {q0s0, q0s1, q1s0, q1s1}:

q0s0 q0s1 q1s0 q1s1 1 1 1

q0s0: M1 is in state q0 and M2 is in state s0. q0s1: M1 is in state q0 and M2 is in state s1. q1s0: M1 is in state q1 and M2 is in state s0. q1s1: M1 is in state q1 and M2 is in state s1.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 10 / 15 Concatenation and Kleene Star →

slide-65
SLIDE 65

Two DFAs in One: Union and Intersection

L1 = ∗0∗ q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

s0 s1 M2 1 1

The Joint-DFA has product states {q0s0, q0s1, q1s0, q1s1}:

q0s0 q0s1 q1s0 q1s1 1 1 1 1

q0s0: M1 is in state q0 and M2 is in state s0. q0s1: M1 is in state q0 and M2 is in state s1. q1s0: M1 is in state q1 and M2 is in state s0. q1s1: M1 is in state q1 and M2 is in state s1.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 10 / 15 Concatenation and Kleene Star →

slide-66
SLIDE 66

Two DFAs in One: Union and Intersection

L1 = ∗0∗ q0 q1 M1 1 0,1 L2 = ∗1

(wildcard ∗ = Σ∗)

s0 s1 M2 1 1

The Joint-DFA has product states {q0s0, q0s1, q1s0, q1s1}:

q0s0 q0s1 q1s0 q1s1 1 1 1 1

q0s0: M1 is in state q0 and M2 is in state s0. q0s1: M1 is in state q0 and M2 is in state s1. q1s0: M1 is in state q1 and M2 is in state s0. q1s1: M1 is in state q1 and M2 is in state s1.

Pop Quiz.

1

Run the joint and individual DFAs for ε, 0100, 11, 101. What are the final states of each DFA?

2

If you want to solve L1 ∪ L2, what should the accept states of the joint-DFA be?

3

If you want to solve L1 ∩ L2, what should the accept states of the joint-DFA be?

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 10 / 15 Concatenation and Kleene Star →

slide-67
SLIDE 67

Concatenation and Kleene Star

L1 = {1} (M1) q0 q1 e 1 0,1 0,1 L2 = {0} (M2) s0 s1 e 1 0,1 0,1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 11 / 15 The Power of DFAs →

slide-68
SLIDE 68

Concatenation and Kleene Star

L1 = {1} (M1) q0 q1 e 1 0,1 0,1 L2 = {0} (M2) s0 s1 e 1 0,1 0,1

L1 •L2:

q0 q1s0 e1 1 0,1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 11 / 15 The Power of DFAs →

slide-69
SLIDE 69

Concatenation and Kleene Star

L1 = {1} (M1) q0 q1 e 1 0,1 0,1 L2 = {0} (M2) s0 s1 e 1 0,1 0,1

L1 •L2:

q0 q1s0 e1 s1 e2 1 0,1 1 0,1 0,1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 11 / 15 The Power of DFAs →

slide-70
SLIDE 70

Concatenation and Kleene Star

L1 = {1} (M1) q0 q1 e 1 0,1 0,1 L2 = {0} (M2) s0 s1 e 1 0,1 0,1

L1 •L2:

q0 q1s0 e1 s1 e2 1 0,1 1 0,1 0,1

L∗

1:

q0 q1 e 1 0,1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 11 / 15 The Power of DFAs →

slide-71
SLIDE 71

Concatenation and Kleene Star

L1 = {1} (M1) q0 q1 e 1 0,1 0,1 L2 = {0} (M2) s0 s1 e 1 0,1 0,1

L1 •L2:

q0 q1s0 e1 s1 e2 1 0,1 1 0,1 0,1

L∗

1:

q0 q1 e 1 1 0,1

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 11 / 15 The Power of DFAs →

slide-72
SLIDE 72

The Power of DFAs: What can they Solve?

Finite languages.

(building blocks of regular expressions)

Complement, intersection, union.

(operations to form complex regular expressions)

Concatenation and Kleene-star (little more complicated, see text).

(operations to form complex regular expressions)

That’s what we need for regular expressions.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 12 / 15 What Can’t DFAs Solve? →

slide-73
SLIDE 73

The Power of DFAs: What can they Solve?

Finite languages.

(building blocks of regular expressions)

Complement, intersection, union.

(operations to form complex regular expressions)

Concatenation and Kleene-star (little more complicated, see text).

(operations to form complex regular expressions)

That’s what we need for regular expressions. DFAs solve languages (computing problems) expressed as regular expressions.

(That is why the languages solved by DFAs are called regular languages.)

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 12 / 15 What Can’t DFAs Solve? →

slide-74
SLIDE 74

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-75
SLIDE 75

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-76
SLIDE 76

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-77
SLIDE 77

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-78
SLIDE 78

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-79
SLIDE 79

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-80
SLIDE 80

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

M

→ · · ·

M

→ state(0•k−1)

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-81
SLIDE 81

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

M

→ · · ·

M

→ state(0•k−1)

M

→ state(0•k)

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-82
SLIDE 82

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

M

→ · · ·

M

→ state(0•k−1)

M

→ state(0•k) After k 0’s, k + 1 states visited. There must be a repetition (pigeonhole).

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-83
SLIDE 83

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

M

→ · · ·

M

→ state(0•k−1)

M

→ state(0•k) After k 0’s, k + 1 states visited. There must be a repetition (pigeonhole). state(0•i) = state(0•j) = q, i < j ≤ k.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-84
SLIDE 84

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

M

→ · · ·

M

→ state(0•k−1)

M

→ state(0•k) After k 0’s, k + 1 states visited. There must be a repetition (pigeonhole). state(0•i) = state(0•j) = q, i < j ≤ k. Consider the two input strings 0•i1•i ∈ L0n1n and 0•j1•i ∈ L0n1n.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-85
SLIDE 85

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

M

→ · · ·

M

→ state(0•k−1)

M

→ state(0•k) After k 0’s, k + 1 states visited. There must be a repetition (pigeonhole). state(0•i) = state(0•j) = q, i < j ≤ k. Consider the two input strings 0•i1•i ∈ L0n1n and 0•j1•i ∈ L0n1n. After M has processed the 0s in both strings, it is in state q, and the traces of the two computations are

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-86
SLIDE 86

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

M

→ · · ·

M

→ state(0•k−1)

M

→ state(0•k) After k 0’s, k + 1 states visited. There must be a repetition (pigeonhole). state(0•i) = state(0•j) = q, i < j ≤ k. Consider the two input strings 0•i1•i ∈ L0n1n and 0•j1•i ∈ L0n1n. After M has processed the 0s in both strings, it is in state q, and the traces of the two computations are q | 0•i⊲1•i and q | 0•j⊲1•i.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-87
SLIDE 87

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

M

→ · · ·

M

→ state(0•k−1)

M

→ state(0•k) After k 0’s, k + 1 states visited. There must be a repetition (pigeonhole). state(0•i) = state(0•j) = q, i < j ≤ k. Consider the two input strings 0•i1•i ∈ L0n1n and 0•j1•i ∈ L0n1n. After M has processed the 0s in both strings, it is in state q, and the traces of the two computations are q |

? ⊲1•i

and q |

? ⊲1•i.

Same number of 1’s remain, from state q. Either both rejected or both accepted. FISHY!

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-88
SLIDE 88

Is There Anything DFAs Can’t Solve?

Pop Quiz. Give a DFA to solve {0}∗ •{1}∗ = {0•n1•k | n ≥ 0, k ≥ 0}.

What about “equality,”

L0n1n = {0•n1•n | n ≥ 0}.

  • Theorem. There is no DFA that solves L0n1n

Proof.

  • Contradiction. Suppose a DFA M with k states solves {0n1n}.

What happens to this DFA when you keep feeding it 0’s? q0 = state(0•0)

M

→ state(0•1)

M

→ state(0•2)

M

→ · · ·

M

→ state(0•k−1)

M

→ state(0•k) After k 0’s, k + 1 states visited. There must be a repetition (pigeonhole). state(0•i) = state(0•j) = q, i < j ≤ k. Consider the two input strings 0•i1•i ∈ L0n1n and 0•j1•i ∈ L0n1n. After M has processed the 0s in both strings, it is in state q, and the traces of the two computations are q |

? ⊲1•i

and q |

? ⊲1•i.

Same number of 1’s remain, from state q. Either both rejected or both accepted. FISHY!

Intuition: The DFA has no “memory” to remember n.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 13 / 15 Our First Computing Machine →

slide-89
SLIDE 89

Our First Computing Machine

DFAs can be implemented using basic technology, so practical. Powerful (regular languages), but also limited.

Computing Model Rules to:

  • 1. Construct machine;
  • 2. Solve problems.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 14 / 15 Adding Memory →

slide-90
SLIDE 90

Our First Computing Machine

DFAs can be implemented using basic technology, so practical. Powerful (regular languages), but also limited.

Computing Model Rules to:

  • 1. Construct machine;
  • 2. Solve problems.

Analyze Model

  • 1. Capabilities: what can be solved?
  • 2. Limitations: what can’t be solved?

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 14 / 15 Adding Memory →

slide-91
SLIDE 91

Our First Computing Machine

DFAs can be implemented using basic technology, so practical. Powerful (regular languages), but also limited.

Computing Model Rules to:

  • 1. Construct machine;
  • 2. Solve problems.

Analyze Model

  • 1. Capabilities: what can be solved?
  • 2. Limitations: what can’t be solved?

Do we need a new model?

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 14 / 15 Adding Memory →

slide-92
SLIDE 92

Our First Computing Machine

DFAs can be implemented using basic technology, so practical. Powerful (regular languages), but also limited.

Computing Model Rules to:

  • 1. Construct machine;
  • 2. Solve problems.

Analyze Model

  • 1. Capabilities: what can be solved?
  • 2. Limitations: what can’t be solved?

Do we need a new model?

DFAs fail at so simple a problem as equality. That’s not acceptable. We need a more powerful machine.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 14 / 15 Adding Memory →

slide-93
SLIDE 93

Adding Memory

DFAs have no scratch paper. It’s hard to compute entirely in your head.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 15 / 15

slide-94
SLIDE 94

Adding Memory

DFAs have no scratch paper. It’s hard to compute entirely in your head.

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1 1

Stack Memory. Think of a file-clerk with a stack of papers.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 15 / 15

slide-95
SLIDE 95

Adding Memory

DFAs have no scratch paper. It’s hard to compute entirely in your head.

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1 1

Stack Memory. Think of a file-clerk with a stack of papers. The clerk’s capabilities: see the top sheet; remove the top sheet (pop) push something new onto the top of the stack. no access to inner sheets without removing top. DFA with a stack is a pushdown automaton (PDA)

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 15 / 15

slide-96
SLIDE 96

Adding Memory

DFAs have no scratch paper. It’s hard to compute entirely in your head.

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1 1

Stack Memory. Think of a file-clerk with a stack of papers. The clerk’s capabilities: see the top sheet; remove the top sheet (pop) push something new onto the top of the stack. no access to inner sheets without removing top. DFA with a stack is a pushdown automaton (PDA)

How does the stack help to solve {0•n1•n | n ≥ 0}?

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 15 / 15

slide-97
SLIDE 97

Adding Memory

DFAs have no scratch paper. It’s hard to compute entirely in your head.

q0 q7 q6 q5 q4 q3 q2 q1

yes

  • r

no

1 1 1 1 1

Stack Memory. Think of a file-clerk with a stack of papers. The clerk’s capabilities: see the top sheet; remove the top sheet (pop) push something new onto the top of the stack. no access to inner sheets without removing top. DFA with a stack is a pushdown automaton (PDA)

How does the stack help to solve {0•n1•n | n ≥ 0}?

1: When you read in each 0, write it to the stack. 2: For each 1, pop the stack. At the end if the stack is empty, accept.

The memory allows the automaton to “remember” n.

Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 15 / 15