CS 301 Lecture 02 Deterministic Finite Automata (DFAs) Stephen - - PowerPoint PPT Presentation

cs 301
SMART_READER_LITE
LIVE PREVIEW

CS 301 Lecture 02 Deterministic Finite Automata (DFAs) Stephen - - PowerPoint PPT Presentation

CS 301 Lecture 02 Deterministic Finite Automata (DFAs) Stephen Checkoway January 22, 2018 1 / 30 Review from last time Alphabet Finite, nonempty set of symbols String Finite-length sequence of symbols from an alphabet Language Set of


slide-1
SLIDE 1

CS 301

Lecture 02 – Deterministic Finite Automata (DFAs) Stephen Checkoway January 22, 2018

1 / 30

slide-2
SLIDE 2

Review from last time

Alphabet Finite, nonempty set of symbols String Finite-length sequence of symbols from an alphabet Language Set of strings over an alphabet Can be empty Can be infinite Alphabet ✩ ✩ String ✧ ✩ Language ✧ ✧ If Σ is an alphabet, then Σ∗ is the language consisting of all strings over Σ

2 / 30

slide-3
SLIDE 3

State machines

A state machine is a way to structure computation It consists of

  • a fixed set of states
  • a fixed initial state
  • a specification of what action to take in response to input for each state
  • a current “active” state

3 / 30

slide-4
SLIDE 4

State machine example: An automatic swinging door

The door has a front and a back sensor We want to open the door when the front sensor is triggered, as long as it doesn’t hit someone (i.e., as long as the back sensor is not triggered) We want to close the door when the front sensor is not triggered, as long as it doesn’t hit someone

4 / 30

slide-5
SLIDE 5

State machine example: An automatic swinging door

The door can be either OPEN or CLOSED Possible inputs to the state machine: FRONT Someone is standing on the front sensor REAR Someone is standing on the rear sensor BOTH Someone is standing on both sensors NEITHER No one is standing on either sensor CLOSED OPEN REAR, BOTH, NEITHER FRONT FRONT, REAR, BOTH NEITHER

5 / 30

slide-6
SLIDE 6

State machine example: An automatic swinging door

1 Initially the door is CLOSED

CLOSED OPEN REAR, BOTH, NEITHER FRONT FRONT, REAR, BOTH NEITHER

6 / 30

slide-7
SLIDE 7

State machine example: An automatic swinging door

1 Initially the door is CLOSED 2 Alice stands on the FRONT sensor and the door changes to OPEN

CLOSED OPEN REAR, BOTH, NEITHER FRONT FRONT, REAR, BOTH NEITHER

6 / 30

slide-8
SLIDE 8

State machine example: An automatic swinging door

1 Initially the door is CLOSED 2 Alice stands on the FRONT sensor and the door changes to OPEN 3 Alice enters as Bob approaches the door so BOTH sensors are triggered and the

door stays OPEN CLOSED OPEN REAR, BOTH, NEITHER FRONT FRONT, REAR, BOTH NEITHER

6 / 30

slide-9
SLIDE 9

State machine example: An automatic swinging door

1 Initially the door is CLOSED 2 Alice stands on the FRONT sensor and the door changes to OPEN 3 Alice enters as Bob approaches the door so BOTH sensors are triggered and the

door stays OPEN

4 Alice moves away as Bob enters so only the REAR sensor is triggered and the

door stays OPEN CLOSED OPEN REAR, BOTH, NEITHER FRONT FRONT, REAR, BOTH NEITHER

6 / 30

slide-10
SLIDE 10

State machine example: An automatic swinging door

1 Initially the door is CLOSED 2 Alice stands on the FRONT sensor and the door changes to OPEN 3 Alice enters as Bob approaches the door so BOTH sensors are triggered and the

door stays OPEN

4 Alice moves away as Bob enters so only the REAR sensor is triggered and the

door stays OPEN

5 Bob moves away so NEITHER sensor is triggered and the door changes to

CLOSED CLOSED OPEN REAR, BOTH, NEITHER FRONT FRONT, REAR, BOTH NEITHER

6 / 30

slide-11
SLIDE 11

State machine example: TCP

7 / 30

slide-12
SLIDE 12

State machine example: TLS 1.3

START <----+ Send ClientHello | | Recv HelloRetryRequest [K_send = early data] | | v | / WAIT_SH ----+ | | Recv ServerHello | | K_recv = handshake Can | V send | WAIT_EE early | | Recv EncryptedExtensions data | +--------+--------+ | Using | | Using certificate | PSK | v | | WAIT_CERT_CR | | Recv | | Recv CertificateRequest | | Certificate | v | | | WAIT_CERT | | | | Recv Certificate | | v v | | WAIT_CV | | | Recv CertificateVerify | +> WAIT_FINISHED <+ | | Recv Finished \ | [Send EndOfEarlyData] | K_send = handshake | [Send Certificate [+ CertificateVerify]] Can send | Send Finished app data

  • ->

| K_send = K_recv = application after here v CONNECTED 8 / 30

slide-13
SLIDE 13

State machine example: Video games

Input is received from the controller What does the game do with the input? Depends on what state it’s in

  • During normal game play: perform an action (jump, run, start a conversation)
  • During a cut scene: nothing or maybe end the cut scene
  • During a loading screen: nothing
  • . . .

9 / 30

slide-14
SLIDE 14

Deterministic finite Automaton (DFA)

DFAs are the simplest model of computation: Given an input string, the DFA will either accept it or reject it They are state machines

  • The (finite set of) states are the DFA’s memory
  • It starts in a fixed start state
  • It processes its input one symbol at a time; for each symbol, it will transition to a

new state (or stay in the current state)

  • At the end of the input, the state it is in determines if the input is accepted or

rejected

10 / 30

slide-15
SLIDE 15

DFA notation

The states of a DFA are represented as a circle

11 / 30

slide-16
SLIDE 16

DFA notation

The states of a DFA are represented as a circle We will usually give the states short names like q0 or q1 q1

11 / 30

slide-17
SLIDE 17

DFA notation

The states of a DFA are represented as a circle We will usually give the states short names like q0 or q1 q1 The initial state is represented with an arrow and is frequently named q0 q0

11 / 30

slide-18
SLIDE 18

DFA notation

The states of a DFA are represented as a circle We will usually give the states short names like q0 or q1 q1 The initial state is represented with an arrow and is frequently named q0 q0 Transitions between states are given by directed edges, labeled by an alphabet symbol and every state must have exactly one transition for each symbol in the alphabet q1 q2 a, b b a

11 / 30

slide-19
SLIDE 19

DFA notation

The states of a DFA are represented as a circle We will usually give the states short names like q0 or q1 q1 The initial state is represented with an arrow and is frequently named q0 q0 Transitions between states are given by directed edges, labeled by an alphabet symbol and every state must have exactly one transition for each symbol in the alphabet q1 q2 a, b b a Accepting states are drawn with two circles q3

11 / 30

slide-20
SLIDE 20

DFA example

q0 q1 q2 a b a b a b States Q = {q0, q1, q2} Alphabet Σ = {a, b} Transitions δ a b q0 q0 q1 q1 q0 q2 q2 q0 q2 Start state q0 Accepting states F = {q2}

12 / 30

slide-21
SLIDE 21

DFA example

q0 q1 q2 a b a b a b

  • ababb

13 / 30

slide-22
SLIDE 22

DFA example

q0 q1 q2 a b a b a b

  • ababb

13 / 30

slide-23
SLIDE 23

DFA example

q0 q1 q2 a b a b a b

  • ababb

13 / 30

slide-24
SLIDE 24

DFA example

q0 q1 q2 a b a b a b

  • ababb

13 / 30

slide-25
SLIDE 25

DFA example

q0 q1 q2 a b a b a b

  • ababb

13 / 30

slide-26
SLIDE 26

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

13 / 30

slide-27
SLIDE 27

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

  • bbab

14 / 30

slide-28
SLIDE 28

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

  • bbab

14 / 30

slide-29
SLIDE 29

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

  • bbab

14 / 30

slide-30
SLIDE 30

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

  • bbab

14 / 30

slide-31
SLIDE 31

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

  • bbab

✩Rejected

14 / 30

slide-32
SLIDE 32

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

  • bbab

✩Rejected

  • ε

15 / 30

slide-33
SLIDE 33

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

  • bbab

✩Rejected

  • ε

✩Rejected

15 / 30

slide-34
SLIDE 34

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

  • bbab

✩Rejected

  • ε

✩Rejected What strings does this DFA accept?

16 / 30

slide-35
SLIDE 35

DFA example

q0 q1 q2 a b a b a b

  • ababb

✧Accepted

  • bbab

✩Rejected

  • ε

✩Rejected What strings does this DFA accept? Strings that end in bb We can write this as a set: {wbb ∣ w ∈ Σ∗}

16 / 30

slide-36
SLIDE 36

Formalizing DFAs

A DFA M is a 5-tuple M = (Q, Σ, δ, q0, F) where

17 / 30

slide-37
SLIDE 37

Formalizing DFAs

A DFA M is a 5-tuple M = (Q, Σ, δ, q0, F) where

  • Q is a finite set of states

17 / 30

slide-38
SLIDE 38

Formalizing DFAs

A DFA M is a 5-tuple M = (Q, Σ, δ, q0, F) where

  • Q is a finite set of states
  • Σ is an alphabet (finite set of symbols)

17 / 30

slide-39
SLIDE 39

Formalizing DFAs

A DFA M is a 5-tuple M = (Q, Σ, δ, q0, F) where

  • Q is a finite set of states
  • Σ is an alphabet (finite set of symbols)
  • δ ∶ Q × Σ → Q is the transition function

17 / 30

slide-40
SLIDE 40

Formalizing DFAs

A DFA M is a 5-tuple M = (Q, Σ, δ, q0, F) where

  • Q is a finite set of states
  • Σ is an alphabet (finite set of symbols)
  • δ ∶ Q × Σ → Q is the transition function
  • q0 ∈ Q is the start state

17 / 30

slide-41
SLIDE 41

Formalizing DFAs

A DFA M is a 5-tuple M = (Q, Σ, δ, q0, F) where

  • Q is a finite set of states
  • Σ is an alphabet (finite set of symbols)
  • δ ∶ Q × Σ → Q is the transition function
  • q0 ∈ Q is the start state
  • F ⊆ Q is the set of accepting (or final) states

17 / 30

slide-42
SLIDE 42

DFA example once again

q0 q1 q2 a b a b a b States Q = {q0, q1, q2} Alphabet Σ = {a, b} Transitions δ a b q0 q0 q1 q1 q0 q2 q2 q0 q2 Start state q0 Accepting states F = {q2} If we call this DFA M, then M = (Q, Σ, δ, q0, F) is a complete, mathematical description of the DFA The diagram is just helpful for humans; it doesn’t contain any information not contained in in the 5 components of M

18 / 30

slide-43
SLIDE 43

DFA acceptance and rejection

A DFA M = (Q, Σ, δ, q0, F) accepts a string w ∈ Σ∗ if starting from the start state q0 and moving from state to state according to the transition function δ on input w, the machine ends in one of the accepting states If M does not accept w, then it rejects w

19 / 30

slide-44
SLIDE 44

Language of a DFA

The language of a DFA M—written L(M)—is the set of strings that M accepts L(M) = {w ∈ Σ∗ ∣ M accepts w} We say that M recognizes a set A to mean L(M) = A

20 / 30

slide-45
SLIDE 45

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} If we were writing a Python program to check if a string w has one or three 0s, it might look like this count = 0 for c in w: if c == '0': count += 1 if count == 1 or count == 3: print("ACCEPT") else: print("REJECT")

21 / 30

slide-46
SLIDE 46

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} If we were writing a Python program to check if a string w has one or three 0s, it might look like this count = 0 for c in w: if c == '0': count += 1 if count == 1 or count == 3: print("ACCEPT") else: print("REJECT") states and initial state

21 / 30

slide-47
SLIDE 47

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} If we were writing a Python program to check if a string w has one or three 0s, it might look like this count = 0 for c in w: if c == '0': count += 1 if count == 1 or count == 3: print("ACCEPT") else: print("REJECT") states and initial state transition function

21 / 30

slide-48
SLIDE 48

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} If we were writing a Python program to check if a string w has one or three 0s, it might look like this count = 0 for c in w: if c == '0': count += 1 if count == 1 or count == 3: print("ACCEPT") else: print("REJECT") states and initial state transition function accept states

21 / 30

slide-49
SLIDE 49

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} Approach:

1 We need states to keep track of how many 0s the DFA has seen so far;

How many states should the DFA have?

22 / 30

slide-50
SLIDE 50

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} Approach:

1 We need states to keep track of how many 0s the DFA has seen so far;

We need five states: corresponding to 0, 1, 2, 3, and ≥ 4 ’0’ symbols q0 q1 q2 q3 q≥4

22 / 30

slide-51
SLIDE 51

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} Approach:

1 We need states to keep track of how many 0s the DFA has seen so far;

We need five states: corresponding to 0, 1, 2, 3, and ≥ 4 ’0’ symbols

2 How should the DFA move from state to state?

q0 q1 q2 q3 q≥4

22 / 30

slide-52
SLIDE 52

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} Approach:

1 We need states to keep track of how many 0s the DFA has seen so far;

We need five states: corresponding to 0, 1, 2, 3, and ≥ 4 ’0’ symbols

2 On a 1, we should remain in the current state and on a 0, we should move to the

next state (or stay in the ≥ 4 state) q0 q1 q2 q3 q≥4 1 1 1 1 0,1

22 / 30

slide-53
SLIDE 53

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} Approach:

1 We need states to keep track of how many 0s the DFA has seen so far;

We need five states: corresponding to 0, 1, 2, 3, and ≥ 4 ’0’ symbols

2 On a 1, we should remain in the current state and on a 0, we should move to the

next state (or stay in the ≥ 4 state)

3 Which states should be accepting states?

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

22 / 30

slide-54
SLIDE 54

DFA construction

Let’s build a DFA to recognize the language A = {w ∣ w contains exactly one or three 0} with the alphabet Σ = {0, 1} Approach:

1 We need states to keep track of how many 0s the DFA has seen so far;

We need five states: corresponding to 0, 1, 2, 3, and ≥ 4 ’0’ symbols

2 On a 1, we should remain in the current state and on a 0, we should move to the

next state (or stay in the ≥ 4 state)

3 The states corresponding to 1 and 3 should be accepting states

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

22 / 30

slide-55
SLIDE 55

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

23 / 30

slide-56
SLIDE 56

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

23 / 30

slide-57
SLIDE 57

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

24 / 30

slide-58
SLIDE 58

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

24 / 30

slide-59
SLIDE 59

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

24 / 30

slide-60
SLIDE 60

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

24 / 30

slide-61
SLIDE 61

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

24 / 30

slide-62
SLIDE 62

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

24 / 30

slide-63
SLIDE 63

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

25 / 30

slide-64
SLIDE 64

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

25 / 30

slide-65
SLIDE 65

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

25 / 30

slide-66
SLIDE 66

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

✧Accepted

25 / 30

slide-67
SLIDE 67

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

✧Accepted

  • 00000

26 / 30

slide-68
SLIDE 68

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

✧Accepted

  • 00000

26 / 30

slide-69
SLIDE 69

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

✧Accepted

  • 00000

26 / 30

slide-70
SLIDE 70

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

✧Accepted

  • 00000

26 / 30

slide-71
SLIDE 71

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

✧Accepted

  • 00000

26 / 30

slide-72
SLIDE 72

Running our DFA

q0 q1 q2 q3 q≥4 1 1 1 1 0,1

✧Accepted

  • 10101

✩Rejected

  • 000

✧Accepted

  • 00000

✩Rejected

26 / 30

slide-73
SLIDE 73

Formalizing DFA computation

Let M = (Q, Σ, δ, q0, F) be a DFA and let w = w1w2⋯wn be a string where wi ∈ Σ M accepts w if there exist states r0, r1, . . . , rn ∈ Q such that

27 / 30

slide-74
SLIDE 74

Formalizing DFA computation

Let M = (Q, Σ, δ, q0, F) be a DFA and let w = w1w2⋯wn be a string where wi ∈ Σ M accepts w if there exist states r0, r1, . . . , rn ∈ Q such that

1 r0 = q0

[The DFA starts in the start state]

27 / 30

slide-75
SLIDE 75

Formalizing DFA computation

Let M = (Q, Σ, δ, q0, F) be a DFA and let w = w1w2⋯wn be a string where wi ∈ Σ M accepts w if there exist states r0, r1, . . . , rn ∈ Q such that

1 r0 = q0

[The DFA starts in the start state]

2 ri = δ(ri−1, wi) for i ∈ {1, 2, . . . , n}

[The DFA moves from state to state according to δ]

27 / 30

slide-76
SLIDE 76

Formalizing DFA computation

Let M = (Q, Σ, δ, q0, F) be a DFA and let w = w1w2⋯wn be a string where wi ∈ Σ M accepts w if there exist states r0, r1, . . . , rn ∈ Q such that

1 r0 = q0

[The DFA starts in the start state]

2 ri = δ(ri−1, wi) for i ∈ {1, 2, . . . , n}

[The DFA moves from state to state according to δ]

3 rn ∈ F

[The DFA ends in an accepting state]

27 / 30

slide-77
SLIDE 77

Formalizing DFA computation

Let M = (Q, Σ, δ, q0, F) be a DFA and let w = w1w2⋯wn be a string where wi ∈ Σ M accepts w if there exist states r0, r1, . . . , rn ∈ Q such that

1 r0 = q0

[The DFA starts in the start state]

2 ri = δ(ri−1, wi) for i ∈ {1, 2, . . . , n}

[The DFA moves from state to state according to δ]

3 rn ∈ F

[The DFA ends in an accepting state] The sequence of n + 1 states r0, r1, . . . , rn are the states that the DFA moves through

  • n input w

27 / 30

slide-78
SLIDE 78

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩ ✧ 10101 ✩ 000 ✧ 00000 ✩

28 / 30

slide-79
SLIDE 79

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩Rejected ✧ 10101 ✩ 000 ✧ 00000 ✩

28 / 30

slide-80
SLIDE 80

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩Rejected q0, q1 ✧ 10101 ✩ 000 ✧ 00000 ✩

28 / 30

slide-81
SLIDE 81

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩Rejected q0, q1 ✧Accepted 10101 ✩ 000 ✧ 00000 ✩

28 / 30

slide-82
SLIDE 82

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩Rejected q0, q1 ✧Accepted 10101 q0, q0, q1, q1, q2, q2 ✩ 000 ✧ 00000 ✩

28 / 30

slide-83
SLIDE 83

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩Rejected q0, q1 ✧Accepted 10101 q0, q0, q1, q1, q2, q2 ✩Rejected 000 ✧ 00000 ✩

28 / 30

slide-84
SLIDE 84

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩Rejected q0, q1 ✧Accepted 10101 q0, q0, q1, q1, q2, q2 ✩Rejected 000 q0, q1, q2, q3 ✧ 00000 ✩

28 / 30

slide-85
SLIDE 85

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩Rejected q0, q1 ✧Accepted 10101 q0, q0, q1, q1, q2, q2 ✩Rejected 000 q0, q1, q2, q3 ✧Accepted 00000 ✩

28 / 30

slide-86
SLIDE 86

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩Rejected q0, q1 ✧Accepted 10101 q0, q0, q1, q1, q2, q2 ✩Rejected 000 q0, q1, q2, q3 ✧Accepted 00000 q0, q1, q2, q3, q≥4, q≥4 ✩

28 / 30

slide-87
SLIDE 87

Examples

q0 q1 q2 q3 q≥4 1 1 1 1 0,1 Input States r0, r1, . . . , rn Accepted/Rejected ε q0 ✩Rejected q0, q1 ✧Accepted 10101 q0, q0, q1, q1, q2, q2 ✩Rejected 000 q0, q1, q2, q3 ✧Accepted 00000 q0, q1, q2, q3, q≥4, q≥4 ✩Rejected

28 / 30

slide-88
SLIDE 88

Regular languages

A language is regular if some DFA recognizes it Recall: A DFA M recognizes a language A if A = {w ∣ M accepts w} = L(M)

29 / 30

slide-89
SLIDE 89

Prove some languages are regular

Let’s construct some DFAs with JFLAP for the following languages over Σ = {a, b}

  • A = {w ∣ w starts and ends with a}
  • B = {awa ∣ w ∈ Σ∗}
  • C = {w ∣ w starts and ends with different symbols}
  • D = Σ∗
  • E = ∅
  • F = {w ∣∣w∣ is not a multiple of 4}

30 / 30