Algorithm

advertisement
Decidable Questions About Regular languages
1)
Membership problem:
“Given a specification of known type and a
string w, is w in the language specified?”
2) Emptiness problem:
“Given a specification of known type, does it
specify the empty set?”
3) Finiteness problem:
“Given a specification of known type, does it
specify finite set?”
4) Equivalence problem:
“Given two specifications of the same known
type, do they specify the same language?”
Algorithm: (Decision of membership problem
for DFA)
Input: A DFA M=(Q, , , q0, F) and w in *.
Output: “YES” if w is in L(M), “NO’ otherwise.
Method: If (q0, w) is in F, say “YES”;
If not say “NO”.
Algorithm: (Decision of emptiness problem
for finite automata.)
Input: A DFA M=(Q, , , q0, F).
Output: “YES” if L(M) = ,
“NO’ otherwise.
Method: Compute the set of states accessible
from q0. {p |(q0, w) = p }
If this contains NO final state, say “YES”;
If not say “NO”.
^
Algorithm: (Decision of finiteness problem
for finite automata.)
Input: A DFA M=(Q, , , q0, F).
Output: “YES” if L(M) = is a finite set, “NO’
otherwise.
Method: Test if there are any cycles. Answer
“YES” if there are no cycles, otherwise
“NO”.
Definition: let M = (Q, , , q0, F) be a DFA,
and let q1 and q2 be two distinct states. We
say that a string x in * distinguishes q1 from
q2 if exactly one of (q1, x) and (q2, x) is in
F. We say q1 and q2 are k-indistinguishable
if and only if there is no x, with |x|  k, which
distinguishes q1 and q2.
^
^
Definition: We say q1 and q2 are (q1  q2)
indistinguishable if and only if they are
k-indistinguishable for all k  0.
q1 and q2 are equivalent states.
0
B
0
start
1
C
1
F
0
A
1
1
0
0
1
D
E
1
0
0
G
1
Table filling algorithm (p157)
Basis: If p is an accepting state and q is a
nonaccepting state, then (p, q) is a
distinguishable pair of states.
Induction: Let p and q be states such that
(p,a) = r and (q,a) = s for some input
symbol a. If (r, s) is a known pair of
distinguishable states, then (p,q) is also a
pair of distinguishable states.
Table of state inequivalences
B
C
D
E
F
G
A
B
C
D
E
F
• Theorem 4.20: It two states are not
distinguished by the table-filling algorithm,
then the states are equivalent
• Theorem4.24: If we create for each state q
of a DFA a block consisting of q and all the
states equivalent to q, then the different
blocks of states form a partition of the set of
states.
• State minimization algorithm (p162)
Algorithm: (Decision of equivalence problem for
DFA)
Input: Two DFA M1 = (Q1, 1, 1, q1, F1) and M2 =
(Q2, 2, 2, q2, F2) such that Q1 Q2 = .
Output: “YES” if L(M1) = L(M2), “NO” otherwise
Method: Construct the FA
M = (Q1  Q2 , 1  2, 1  2, q1, F1  F2).
Determine if q1  q2. If so say “YES”; otherwise
say “NO”.
Observation: L(M1) = L(M2) if and only if
(L(M1)  L(M2))  (L(M1)  L(M2)) = .
Download