COMS W3261
Computer Science Theory
Lecture 3: September 16, 2009
Deterministic Finite Automata
1. Outline
- Review
- Deterministic finite automata
- Example of a DFA
- Practice problems
2. Review
- Inductive proofs
- Regular expressions
- Examples of regular expressions
3. Deterministic Finite Automata
- A deterministic finite automaton (DFA) has five components:
- A finite set of states Q.
- An input alphabet consisting of a finite set of symbols Σ.
- A transition function δ that maps Q × &Sigma to Q.
This transition function can be represented by a transition diagram
in which the nodes are labeled by states and arcs by symbols.
- A start state which is one of the states in Q.
- A set of final (or accepting) states F.
- A DFA accepts an input string x if there is a path of transitions
from the initial state to a final state that spells out x.
- L(A), the language defined by a DFA A is the set of
strings accepted by A.
- A language accepted by a DFA is called a regular language.
4. Example of a DFA
- Consider the following DFA D with:
- The finite set of states Q = {
A, B, C}
- The input alphabet Σ = {
0, 1}
- The transition function δ as represented by the following
transition table:
State |
Input Symbol |
0 |
1 |
A |
A |
B |
B |
B |
C |
C |
C |
C |
- Start state
A
- The set of final states F = {
B}
- Given the input string
0010, D makes the following transitions
started off in its initial start state A:
- 0 0 1 0
- A A A B B
- This sequence of transitions takes D from its start state
A to the final state B.
Thus, the input 0010 is accepted by D.
- Given the input string
101, D makes the following transitions
started off in its initial start state A:
- 1 0 1
- A B B C
- This sequence of transitions takes D from its start state
A to the nonfinal state B.
Therefore, the input 101 is not accepted by D.
- The language defined by D is the set of strings of 0's and 1's having exactly
one 1.
- The regular expression 0*10* defines the same language.
5. Practice Problems
- Construct a DFA for a light switch.
- Let L be the language
{
w | w is any string of a's and
b's containing at least one a and
at least one b }.
- Construct a DFA for L.
- Show the behavior of your DFA processing the input string
aabaa.
- Construct a regular expression for L.
- Let L be the language
{
abxba | x is any string of a's,
b's, and c's not containing ba }.
This language models comments in the programming language C.
- Construct a DFA for L.
- Show the behavior of your DFA processing the input string
abcbaba.
- Construct a regular expression for L.
- Show how your regular expression generates
ababcba.
- Construct a DFA for the language L(
(a+b)*abba(a+b)*).
- Let L be the language consisting of all strings of
a's
and b's having an even number of a's and an
even number of b's.
- Construct a DFA for L.
- Show the behavior of your DFA processing the input string
abbaabab.
- Construct a regular expression for L.
- Show how your regular expression generates
abbaabab.
6. Reading Assignment
aho@cs.columbia.edu