HW04 due 02/19

advertisement
CmSc 365 Theory of Computation
Homework 04 due 02/19
In the following problems you have to construct several FSAs – complete deterministic
and incomplete non-deterministic FSAs. You have to represent the FSAs as quintuples
M = M = (K, ∑, δ, s, F) and M = (K, ∑, , s, F), and write down
explicitly each component, e.g.
K = {q1, q2, q3}, s = q1, F = {q3}, etc.
The transition function can be given as a table with rows for each state and
columns for each symbol in ∑.
The transition relation has to be given as a set of triples. Each triple is an
element of K x ( ∑  e) x K.
1. Construct complete deterministic FSAs to recognize the following languages:
a. { w є {0,1}*: w starts with 1 and has odd length or starts with 0 and has
even length}
b. { w є {0,1}*: w does not contain the substring 110}
Hint: construct a complete deterministic FSA that accepts strings that contain
“110” as a substring. This will help solve the problem.
2. For the FSA in 1b) give the computation as a sequence of configurations on input
“10010”
3. Consider the language of variable names in Java.
a. Construct a regular expression for the language of variable names in Java. Use
the alphabet  = {d, L, _} where d represents any digit, and L represents any
letter (upper/lower case).
b. Construct a deterministic FSA that accepts valid variable names in Java. Use
the alphabet  = {d, L, _} where d represents any digit, and L represents any
letter (upper/lower case).
4. Consider the language of real numbers of type double in Java.
a. Construct a regular expression for the language of real numbers of type double
in Java. Use the alphabet  = {+, -, d, . } where d represents any digit.
1
b. Construct a complete deterministic FSA that accepts valid real numbers of
type double in Java. Use the alphabet  = {+, -, d, . } where d represents any
digit
c. For the FSA in 2b) write down the sequence of configurations on input -.ddd
d. Based on the regular expression in 2a), construct a nondeterministic FSA that
accepts the language of real numbers of type double in Java. The FSA need
not be complete.
e. For the FSA in 2d) write down a sequence of configurations that will accept
the string “d.dd”, and a sequence of configurations that will accept “-.dd”
2
Download