Properties of Regular Languages
Properties of Regular Languages
Regular Languages
1 1
A minimal DFA
• In practice, we are interested in the DFA with the minimal number of states.
– Use less memory
– Use less hardware (flip-flops)
• We can find a minimal DFA for any given DFA and their languages are equal.
• Hence, a state p is distinguishable from state q if there is at least one string w such
that either 𝛅(p,w)F or 𝛅(q,w)F and the other is NOT.
– There exists a string w such that
BBM401 Automata Theory and Formal Languages 4
(𝛅 (p,w)F a𝐧
𝐝𝛅(q,w)∉ F) or (𝛅 (p,w)∉F and 𝛅(q,w)F)
Indistinguishable States
• Indistinguishable states behave the same for all possible strings.
– So, we do not need all of states from a set of indistinguishable states.
– We can eliminate all of them by keeping only one of them to represent that set
of indistinguishable states.
Basis:
• Any non-accepting state is distinguishable from any accepting state.
Induction:
• States p and q are distinguishable if there is some input symbol a such that (p,a)
is distinguishable from (q,a).
• All other pairs of states are indistinguishable, and can be merged appropriately.
0
q x
0 q
• p is distinguishable from q
p r x and r by basis, mark them
1 1 p q
1
0
r
p
0 q
• Equivalence relation partitions
(equivalence classes): { {p}, {q,r} }
1 1
1 • q and r are indistinguishable.
0
r
p
0,1 {q,r} 1
A ≡ E since
• (A,0)=B, (E,0)=H and B ≡ H
• (A,1)=F, (E,1)=F and F ≡ F
A ≡ G since (A,1)=F, (G,1)=E and F ≢ E
B ≡ H since
• (B,0)=G, (H,0)=G and G ≡ G
• (B,1)=C, (H,1)=C and C ≡ C
D ≡ F since
• (D,0)=C, (F,0)=C and C ≡ C
• (D,1)=G, (F,1)=G and G ≡ G
A ≡ E since
• (A,0)=B, (E,0)=H and B ≡ H
• (A,1)=F, (E,1)=F and F ≡ F
B ≡ H since
• (B,0)=G, (H,0)=G and G ≡ G
• (B,1)=C, (H,1)=C and C ≡ C
D ≡ F since
• (D,0)=C, (F,0)=C and C ≡ C
• (D,1)=G, (F,1)=G and G ≡ G
Equivalence Classes:
Equivalence Classes:
{ {A,E}, {B,H}, {C}, {D,F}, {G} }
• Suppose there is an equivalent DFA M1 with transition function 1 but with fewer
states Q = {q0,…,qn} where n<m.
• Since pk and pj are distinguishable, there must be some string x such that
– δ (p ,w .x) = δ (p ,x)= is a final state and
0 k k
• But
2nd
Approach to Test Equivalence:
– Let L and M be regular languages, to test whether L = M
– Create DFAs for both L and M
– Imagine the DFA that is the union of the two DFA's (never mind there are two
start states)
– If the table filling algorithm says that the two start states are distinguishable,
then L M, otherwise L = M.
• Closure properties of regular languages also indicate that how their DFAs can
be created from DFAs of other regular languages using certain operations.
Proof:
• Since L and M are regular, they have regular expressions; say L = L(R) and M = L(S).
• Then L∪M = L(R+S) by the definition of the + operator for regular expressions.
• Thus, L∪M is regular.
Proof:
• Since L and M are regular, they have regular expressions; say L=L(R) and
M=L(S).
• Then LM=L(RS) by the definition of the concatenation operator for
regular expressions.
• Thus, LM is regular
Proof:
• Since L is regular, it has a regular expression; say L=L(R).
• Then L*=L(R*) by the definition of the closure operator for regular
expressions.
• Thus, L* is regular.
Proof:
• Let L=L(A) for some DFA A = (Q, , , q0, F).
• That is, B is exactly like A, but the accepting states of A have become non-accepting
states of B, and vice versa.
• Then, w is in L(B) if and only if δ (q ,w) in Q-F, which occurs if and only if w is
0
not in L(A).
• Thus, L is regular.
BBM401 Automata Theory and Formal Languages 32
Closure Under Complement - Example
• We already know that regular languages are closed under complement and union.
• So, L∩M is regular when L and M are regular.
LM((p,q),a) = (L(p,a),M(q,a))
BBM401 Automata Theory and Formal Languages 35
Closure Under Intersection
DFA Construction Proof (cont.)
• By induction |w|, it can be shown that
• To see why L(ALM) = L(AL)∩L(AM), first we can observe that an induction on |w|
• But A
LM accepts w if and only if δ LM ((qL,qM),w) is a pair pf accepting states.
DFA AL
DFA AM
• L(ALM) = L(AL)∩L(AM).
• L(AL) is the set of strings containing at least one 0.
• L(AM) is the set of strings containing at least one 1.
• L(ALM) is the set of strings containing at least one 0 and one 1.
Proof:
• We can observe that L - M = L ∩ M .
• Reversal is another operation that preserves regular languages; that is, if L is a regular
language, so is LR.
INDUCTION:
• There are three cases, depending on the form of E.
Case 1. E = F + G ER = F R + G R
• The reversal of the union of two languages is obtained by computing the reversals
of the two languages and taking the union of those languages.
• So, L(FR+GR ) = (L(F+G))R
MR = ( L((0+1)0*) ) R
= L( ((0+1)0*)) R )
= L( (0*)R(0+1)R )
= L( (0R)* (0R+1R) )
= L( 0*(0+1) )
Example:
• h(0) = ab; h(1) = ε.
• h(01010) = ababab.
• h({010110, 11, 1001}) = {ababab, ε, abab}
Proof:
• Let E be a regular expression for L.
• Apply h to each symbol in E.
• Language of the resulting regular expression is h(L).
• Thus, h(L) is regular.
Proof:
• Represent the language with a DFA.
• If there is a path from the start state to some final state, the language is not empty.
Key idea:
• If the DFA has n states, and the language contains any string of length n or
more, then the language is infinite.
• Otherwise, the language is surely finite. Limited to strings of length n or less.
• To decide if ∊ L, check if q0 ∊ F
• A non-regular language can be shown that it is NOT regular using the pumping
lemma.
– We can use the pumping lemma to show that this language is not
regular.
• A non-regular language can be shown that it is NOT regular using the pumping
lemma.
– We can use the pumping lemma to show that this language is not
regular.
• But, we showed that L is NOT regular previously using the pumping lemma.