Deterministic Finite Automata: Alphabets, Strings, and Languages Transition Graphs and Tables Some Proof Techniques
Deterministic Finite Automata: Alphabets, Strings, and Languages Transition Graphs and Tables Some Proof Techniques
1
Alphabets
An alphabet is any finite set of
symbols.
Examples:
ASCII, Unicode,
{0,1} (binary alphabet ),
{a,b,c}, {s,o},
set of signals used by a protocol.
2
Strings
4
Languages
A language is a subset of Σ* for some
alphabet Σ.
Example: The set of strings of 0’s and
1’s with no two consecutive 1’s.
L = {ε, 0, 1, 00, 01, 10, 000, 001, 010,
100, 101, 0000, 0001, 0010, 0100,
0101, 1000, 1001, 1010, . . . }
s, o Dead s, o
8
Graph Representation of DFA’s
Nodes = states.
Arcs represent transition function.
Arc from state p to state q labeled by all
those input symbols that have transitions
from p to q.
Arrow labeled “Start” to the start state.
Final states indicated by double circles.
9
Example: Recognizing Strings
Ending in “ing”
Not i or g
Not i Not i or n i
Start i i
Not i
10
Example: Protocol for Sending
Data
timeout
data in
Ready Sending
Start ack
11
Example: Strings With No 11
0 0,1
1 1
A B C
Start 0
String so far String so far Consecutive
has no 11, has no 11, 1’s have
does not but ends in been seen.
end in 1. a single 1.
12
Alternative Representation:
Transition Table
Final states
starred Columns =
0 1 input symbols
* A A B
Arrow for * B A C
start state C C C
0 0,1
Rows = states
A 1 B 1 C
Each entry is δ
of the row and Start 0
column. 13
Convention: Strings and Symbols
… w, x, y, z are strings.
a, b, c,… are single input symbols.
14
Extended Transition Function
We describe the effect of a string of
inputs on a DFA by extending δ to a
state and a string.
Intuition: Extended δ is computed for
state q and inputs a1a2…an by following
a path in the transition graph, starting
at q and selecting the arcs with labels
a1, a2,…, an in turn.
15
Inductive Definition of
Extended δ
16
Example: Extended Delta
0 1
A A B
B A C
C C C
δ(δ(A,1),1) = δ(B,1) = C
17
Delta-hat
We don’t distinguish between the given
delta and the extended delta or delta-
hat.
The reason:
˄ ˄
δ(q, a) = δ(δ(q, ε), a) = δ(q, a)
Extended deltas
18
Language of a DFA
Automata of all kinds define languages.
If A is an automaton, L(A) is its
language.
For a DFA A, L(A) is the set of strings
labeling paths from the start state to a
final state.
Formally: L(A) = the set of strings w
such that δ(q0, w) is in F.
19
Example: String in a Language
String 101 is in the language of the DFA below.
Start at A.
0 0,1
1 1
A B C
Start 0
20
Example: String in a Language
String 101 is in the language of the DFA below.
Start 0
21
Example: String in a Language
String 101 is in the language of the DFA below.
Start 0
22
Example: String in a Language
String 101 is in the language of the DFA below.
Start 0
23
Example – Concluded
The language of our example DFA is:
{w | w is in {0,1}* and w does not have
two consecutive 1’s}
25
Proofs – (2)
In general, to prove S = T, we need
to prove two parts: S ⊆ T and T ⊆ S.
That is:
1. If w is in S, then w is in T.
2. If w is in T, then w is in S.
Here, S = the language of our running
DFA, and T = “no consecutive 1’s.”
26
Part 1: S ⊆ T
0 0,1
A 1 B 1C
To prove: if w is accepted by
Start 0
then w has no consecutive 1’s.
Proof is an induction on length of w.
Important trick: Expand the inductive
hypothesis to be more detailed than the
statement you are trying to prove.
27
The Inductive Hypothesis
1. If δ(A, w) = A, then w has no
consecutive 1’s and does not end in 1.
2. If δ(A, w) = B, then w has no
consecutive 1’s and ends in a single 1.
Basis: |w| = 0; i.e., w = ε.
(1) holds since ε has no 1’s at all.
(2) holds vacuously, since δ(A, ε) is not B.
Important concept:
“length of”
If the “if” part of “if..then” is false, 28
the statement is true.
0 0,1
Inductive Step A 1 B 1C
Start 0
29
0 0,1
Inductive Step – (2) A 1 B 1C
Start 0
31
Part 2: T ⊆ S X
33
Using the Contrapositive 0 0,1
– (2) A 1 B 1C
Start 0
34
Regular Languages
A language L is regular if it is the
language accepted by some DFA.
Note: the DFA must accept only the strings
in L, no others.
Some languages are not regular.
Intuitively, regular languages “cannot
count” to arbitrarily high integers.
35
Example: A Nonregular Language
L1 = {0n1n | n ≥ 1}
Note: ai is conventional for i a’s.
Thus, 04 = 0000, e.g.
Read: “The set of strings consisting of
n 0’s followed by n 1’s, such that n is at
least 1.
Thus, L1 = {01, 0011, 000111,…}
36
Another Example
L2 = {w | w in {(, )}* and w is balanced }
Balanced parentheses are those
sequences of parentheses that can
appear in an arithmetic expression.
E.g.: (), ()(), (()), (()()),…
37
But Many Languages are
Regular
They appear in many contexts and
have many useful properties.
Example: the strings that represent
floating point numbers in your favorite
language is a regular language.
38
Example: A Regular Language
L3 = { w | w in {0,1}* and w, viewed as a
binary integer is divisible by 23}
The DFA:
23 states, named 0, 1,…,22.
Correspond to the 23 remainders of an
integer divided by 23.
Start and only final state is 0.
39
Transitions of the DFA for L3
If string w represents integer i, then
assume δ(0, w) = i%23.
Then w0 represents integer 2i, so we
want δ(i%23, 0) = (2i)%23.
Similarly: w1 represents 2i+1, so we
want δ(i%23, 1) = (2i+1)%23.
Example: δ(15,0) = 30%23 = 7;
δ(11,1) = 23%23 = 0.
40
Another Example
L4 = { w | w in {0,1}* and w, viewed as the
reverse of a binary integer is divisible by 23}
Example: 01110100 is in L4, because its
reverse, 00101110 is 46 in binary.
Hard to construct the DFA.
But there is a theorem that says the reverse
of a regular language is also regular.
41