Design DFAs which accept the following languages over

  • Slides: 18
Download presentation
Design DFA’s which accept the following languages over Σ={a, b}: 1. Φ 2. {ε}

Design DFA’s which accept the following languages over Σ={a, b}: 1. Φ 2. {ε} 3. {a, b}* 4. {w : the number of a’s in w is 5. congruent to 1 or 2 modulo 3} 1

Announcements Assignment #2 had a small typo which has now been fixed. On Question

Announcements Assignment #2 had a small typo which has now been fixed. On Question #4: 2= {(r 0, a, r 0), (r 0, b, r 1), (r 1, a, r 0), (r 1, b, r 2), (r 2, a, r 2), (r 2, b, rb)}. should have been 2= {(r 0, a, r 0), (r 0, b, r 1), (r 1, a, r 0), (r 1, b, r 2), (r 2, a, r 2), (r 2, b, r 2)}. Note on question 3, the start state is actually q 1 and not q 0. Question 3(b) is hard. 2

A Deterministic Finite Automaton (DFA) M is defined to be a quintuple (K, Σ,

A Deterministic Finite Automaton (DFA) M is defined to be a quintuple (K, Σ, δ, s, F) where K is a finite set of states, Σ is an alphabet, δ is a function from K x Σ to K, s K is the start state, and F K is the set of final states. 3

L= { w {0, 1}* : w does not contain 11 } This implicitly

L= { w {0, 1}* : w does not contain 11 } This implicitly means that w does not contain 11 as a substring. What are (K, Σ, δ, s, F) for this DFA? 4

M= (K, Σ, δ, s, F): A configuration of a M is an element

M= (K, Σ, δ, s, F): A configuration of a M is an element of K x Σ*. For σ Σ, configuration (q, σ w ) ├ (r, w) [(q, σ w ) yields in one step (r, w)] if δ(q, σ) = r. The notation ├* means yields in zero or more steps. 5

M= (K, Σ, δ, s, F): DFA M accepts input w if and only

M= (K, Σ, δ, s, F): DFA M accepts input w if and only if (s, w) ├* (f, ε) for some f F. L(M), the language accepted by M is { w Σ* : (s, w) ├* (f, ε) for some f F}. 6

L 1 = { w {0, 1}* : w begins and ends with 0}

L 1 = { w {0, 1}* : w begins and ends with 0} L 2 = { w {a, b}* : w begins with aab} L 3 = { w {0, 1}* : has both 00 and 11 as substrings} 7

L 4 = { w {a, b}* : w ends with abab} L 5

L 4 = { w {a, b}* : w ends with abab} L 5 = { w {0, 1}* : the number of 0’s in w is even and the number of 1’s is congruent to 1 modulo 3} L 6 = { w {a, b}* : w contains abaab} 8

What language does this DFA accept? 9

What language does this DFA accept? 9

The end. http: //www. csee. umbc. edu/~squire/cs 451_lect. html 10

The end. http: //www. csee. umbc. edu/~squire/cs 451_lect. html 10

CSC 320: Lecture 9: Nondeterministic Finite Automata if [a-z][a-z 0 -9]* [0 -9]+ IF

CSC 320: Lecture 9: Nondeterministic Finite Automata if [a-z][a-z 0 -9]* [0 -9]+ IF ID NUM Picture from: Raymond Wisman, Notes from compiler design class 11

Outline: NDFA’s are like DFA’s but their operation is not deterministic. NDFA’s are defined

Outline: NDFA’s are like DFA’s but their operation is not deterministic. NDFA’s are defined and several examples are given. We prove that for every NDFA there is an equivalent DFA by giving an algorithm which constructs one. Context: By definition a language is regular if and only if there is a regular expression for it. We will soon prove that a language is regular if and only if there is a DFA which accepts it. Ultimate Consequences: You can prove that a language is regular by either 1. finding a regular expression which generates it, 2. finding a DFA which accepts it, or 3. finding a NDFA which accepts it. 12

A Nondeterministic Finite Automaton (NDFA) M is defined to be a quintuple (K, Σ,

A Nondeterministic Finite Automaton (NDFA) M is defined to be a quintuple (K, Σ, Δ, s, F) where K is a finite set of states, Σ is an alphabet, Δ, the transition relation, is a subset of K x (Σ ⋃ {ε} ) x K, s K is the start state, and F K is the set of final states. 13

M 14

M 14

M= (K, Σ, Δ, s, F): A configuration of a M is an element

M= (K, Σ, Δ, s, F): A configuration of a M is an element of K x Σ*. For σ (Σ U {ε} ), configuration (q, σ w ) ├ (r, w) if (q, σ, r) is in Δ. The notation ├* means yields in zero or more steps. 15

M= (K, Σ, Δ, s, F): NDFA M accepts input w if and only

M= (K, Σ, Δ, s, F): NDFA M accepts input w if and only if there exists some computation such that (s, w) ├* (f, ε) for some f F. L(M), the language accepted by M is { w Σ* : (s, w) ├* (f, ε) for some f F}. 16

M Some non-accepting computations: (s, abb) ├ (p, bb)├ (q, b) STUCK- no way

M Some non-accepting computations: (s, abb) ├ (p, bb)├ (q, b) STUCK- no way to finish consuming the input. (s, abb) ├ (r, bb)├ (t, b)├ (p, e) Ends in a non-final state p. 17

M Some accepting computations: (s, abb) ├ (r, bb)├ (t, b)├ (u, e) (s,

M Some accepting computations: (s, abb) ├ (r, bb)├ (t, b)├ (u, e) (s, abb) ├ (p, bb)├ (r, bb) ├ (t, b)├ (u, e) abb is in L(M) since it has at least one accepting computation. 18