H (A A ... A) H (A) H (A) ... H (A)
H (A A ... A) H (A) H (A) ... H (A)
Inverse homomorphism:
h1(L) = {w : h(w) L, h : * is a homom. }
97
98
Example:
Let L be recognized by the DFA below
1
Start
{q0}
0
0
{q0, q1}
{q0, q2}
0
1
Then L is recognized by
1
Start
{q0}
0
0
{q0, q1}
{q0, q2}
0
1
100
101
AL
Start
AND
Accept
AM
102
Formally
ALM = (QL QM , , LM , (qL, qM ), FL FM ),
where
LM ((p, q), a) = (L(p, a), M (q, a))
It will be shown in the tutorial by and induction
on |w| that
103
0,1
q
(a)
0
Start
0,1
s
(b)
1
Start
pr
ps
0
0,1
qr
qs
0
(c)
Another example?
104
105
Theorem 4.11.
then so is LR .
If L is a regular language,
106
Theorem 4.11.
then so is LR .
If L is a regular language,
Homomorphisms
A homomorphism on is a function h : ,
where and are alphabets.
Let w = a1a2 an . Then
h(w) = h(a1)h(a2) h(an)
and
h(L) = {h(w) : w L}
Example: Let h : {0, 1} {a, b} be defined by
h(0) = ab, and h(1) = . Now h(0011) = abab.
Example: h(L(101)) = L((ab)).
108
h(L(E )).
109
Inverse Homomorphism
Let h : be a homom. Let L ,
and define
h1(L) = {w : h(w) L}
h(L)
(a)
h-1 (L)
(b)
110
/ L((00 + 1)).
3. w = xaay. Then h(w) = z0101v and
/
L((00 + 1)).
4. w = xbby. Then h(w) = z1010v and
/
L((00 + 1)).
111
h
Input
h(a) to A
Start
Accept/reject
A
112
Decision Properties
We consider the following:
2. Is L = ?
3. Is w L?
113
114
Testing emptiness
L(A) 6= for FA A if and only if a final state
is reachable from the start state in A. Total
O(n2) steps.
Alternatively, we can inspect a regex E and tell
if L(E) = . We use the following method:
E = F + G. Now L(E) is empty if and only if
both L(F ) and L(G) are empty.
E = F.G. Now L(E) is empty if and only if
either L(F ) or L(G) is empty.
E = F . Now L(E) is never empty, since
L(E).
E = . Now L(E) is not empty.
E = a. Now L(E) is not empty.
E = . Now L(E) is empty.
116
Testing membership
To test w L(A) for DFA A, simulate A on w.
If |w| = n, this takes O(n) steps.
If A is an NFA and has s states, simulating A
on w takes O(ns2) steps.
If A is an -NFA and has s states, simulating
A on w takes O(ns3) steps.
If L = L(E), for regex E of length s, we first
convert E to an -NFA with 2s states. Then we
simulate w on this machine, in O(ns3) steps.
Does L((0+1)*0(0+1)31*) contain 10101011 or 101011101?
118
Example:
1
0
Start
0
0
1
H
0
0
(C, ) F, (G, )
/ F C 6 G
(A, 01) = C F, (G, 01) = E
/ F A 6 G
119
0
Start
A
1
0
0
(A, ) = A
/ F, (E, ) = E
/F
(A, 1) = F
K = (E, 1)
Therefore (A, 1x) = (E, 1x) = (F,
K x)
(A, 00) = G = (E, 00)
(A, 01) = C = (E, 01)
Conclusion: A E.
120
C D E
K G
F
121
122
123
124
Example:
0
Start
0
Start
E
1
x
A
x
B
C D
Minimization of DFAs
126
127
128
0
Start
D
1
0
0
0
0
to obtain
1
0
D,K
1
Start
A,E
0
0
B,H
129
0
A
1
B
0
130
131
132