Lec04 RegularLanguageProperties
Lec04 RegularLanguageProperties
Regular Languages
0 0 0 0 0
1 1 1
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
(𝛅(p,w)F a𝐧𝐝 𝛅 (q,w)∉ F) OR (𝛅(p,w)∉F
and 𝛅(q,w)F)
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 • p is distinguishable from q
p q
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} }
• Since all states of M are distinguishable (since M is minimal), there must be distinct
0,wi) = pi for all i.
strings w1,…,wm such that δ(p
• 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
0,wk.x) = δ(p
– δ(p k,x)= is a final state and
0,wj.x) = δ(p
– δ(p j,x)= is NOT a final state, or vice versa.
– So wk.x is accepted and wj.x is not (or vice versa)
• But
1(q0,wk.x) =𝛅
𝛅 1 (𝛅
1(q0,wk),x) =𝛅
1(𝛅
1(q0,wj),x) = 𝛅
1(q0,wj.x)
• 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).
• Then Lത =L(B), where B is the DFA = (Q, , , q0, Q-F).
• That is, B is exactly like A, but the accepting states of A have become non-accepting
states of B, and vice versa.
0,w) in Q-F, which occurs if and only if w is not
• Then, w is in L(B) if and only if δ(q
in L(A).
• Thus, Lത is regular.
• To see why L(ALM) = L(AL)∩L(AM), first we can observe that an induction on |w|
proves that δ LM((qL,qM),w) = (δ L(qL,w), δ M(qM,w)).
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.
ഥ is regular.
• By closure under complement, M
ഥ is regular.
• By closure under intersection, L ∩ M
• Thus, L-M is regular.
• 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 = FR + GR
• 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.
• A non-regular language can be shown that it is NOT regular using the pumping
lemma.
• Since y and |xy| ≤n, y must contain only one or more 0s.
• If y repeats 0 times, xy0z=xz must be in L01 by the pumping lemma.
• xz has fewer 0’s than 1’s because y can only contain one or more 0s
• So, there is a contradiction with our assumption (L01 is regular)
• Proof by contradiction, we prove that L01 is NOT regular