Finite Automata
Finite Automata
0 0,1
1 1
A B C
start 0
Rows = states
• Since δ(A,0100)=A and A is a final state, the string 0100 is accepted by this DFA.
0 0,1
1 1
A B C
start 0
• This DFA accepts all strings of 0’s and 1’s without two consecutive 1’s.
• Formally,
L(A) = { w | w is in {0,1}* and w does not have two consecutive 1’s }
1 0 0,1
0 0 1
A B C D
start 1
0 1
0 1
A B C
start 0
0 1
0 1
A B C
1 0,1
start 0
DS
with DS drawn
with DS drawn
The strings whose second characters from the right end are 1.
The strings whose third characters from the right end are 1.
• Example:
– One set is the language of our example DFA
– The other one is “the set of strings of 0’s and 1’s with no consecutive 1’s”
• In general, we want to prove sets S and T are equal (i.e. S=T).
• In order to prove S=T, we need to prove two parts:
1. S ⊆ T i.e. If w is in S, then w is in T.
2. T ⊆ S i.e. If w is in T, then w is in S.
• Example:
– S = the language of our example DFA
– T = “the set of strings of 0’s and 1’s with no consecutive 1’s”
• Important trick: Expand the inductive hypothesis to be more detailed than we need.
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.
Important concept:
If the “if” part of “if..then” is false,
its conclusion is true.
Proof of IH (2): If δ(A,w)=B, then w has no consecutive 1’s and ends in a single 1.
• Since δ(A,w)=B,
δ(A,x) must be A, and a must be 1 (look at the DFA).
• By the IH, x has no 11’s and does not end in 1.
• Thus, w has no 11’s and ends in a single 1.
Using Contrapositive
• Every w gets the DFA to exactly one state.
– Simple inductive proof based on:
• Every state has exactly one transition on 1, one transition on 0.
• The only way w is not accepted is if it gets to C.
• The only way to get to C [ formally: δ(A,w)=C ] is if w=x1y, x gets to B,
and y is the tail of w that follows what gets to C for the first time.
• If δ(A,x)=B then surely x=z1 for some z.
Example 1:
• L1 = {0n1n | n ≥ 1} is not regular.
• 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,…}
Example 2:
• L2 = {w | w in {(, )}* and w is balanced }
– Balanced parentheses are those that can appear in an arithmetic expression.
• E.g.: (), ()(), (()), (()()),…
• Some languages are not regular. If a language is not regular, there is no DFA for
that language.