COGS Q250, Fall 2008 Exam 2: Theory of Computation 11/04/08 Name: ____________________________ 1. (10 pts.) Define an edge in a sequence of binary digits to be any occurrence of a 1 following one or more consecutive 0’s, or any occurrence of a 0 following one or more consecutive 1’s (e.g., the binary string 000111100 has two edges, indicated by bold typeface). Design a finite state transducer that outputs whether zero, one, or more than one edges have occurred thus far in a sequence of binary inputs. The output alphabet should be {0, 1, more}. 2. (5 pts.) Trace the computation performed by your finite state transducer from (1) for the following input string. Use the table method we discussed in class to keep track of the state visited and the output produced at each step. Input: 0001100 State q0 q1 q1 q1 q3 q3 q5 q5 Input 0 0 0 1 1 0 0 Output 0 0 0 1 1 more more 3. (10 pts.) For each of the following, decide whether the statement is true or false, and BE SURE TO EXPLAIN YOUR ANSWER, as you will not receive full credit unless you do so. a. If the transition function for a Turing machine is a total function, it is possible for that machine to halt for some input. False. A Turing machine will only halt when it reaches a state/input pair for which no transition is specified. If the transition function is a total function, that means that a transition is specified for every state/input pair. Thus, the Turing machine will never halt no matter what input it receives. b. For any set A, the number of elements in A is always less than the number of elements in pow(A). True. If a set A has n elements, then pow(A) has 2n elements. Since 2n > n for any natural number n, pow(A) will always have more elements than A. c. Any language that can be recognized by a Turing machine can also be described using a regular expression. False. Turing machines can recognize any of the recursively enumerable languages, while regular expressions can be used to describe only the regular languages. Since the regular languages are a proper subset of the recursively enumerable languages, there are languages that can be recognized by a Turing machine which cannot be described using a regular expression. 4. (10 pts.) Suppose I design a new kind of machine, called a Williams machine, with the following properties. It has two finite state controllers with separate sets of states, such that at any moment the overall state of the machine is described by the states of each of its finite state controllers. At each time step, the machine receives a single input symbol and, depending on the states that its finite state controllers are in, each finite state controller transitions into a next state. The machine does not produce any output. I’m interested in developing a mathematical description for the Williams machine. So far I have the sets A and B, which are the sets of states for each of the finite state controllers; states a0 ∈ A and b0 ∈ B, which are the starting states for the two controllers; and the input alphabet I. The one remaining component that I need to specify is the transition function f, which describes the transitions made by both finite state controllers when an input is received. Describe f using the function notation that we discussed in class. (Hint: your answer should be of the form “f: __________”, where you will need to fill in the blank.) f: A × B × I → A × B 5. (15 pts.) Give regular expressions to describe the following sets of strings. a. All strings of a’s, b’s and c’s with at most one a. (b+c)*(P+a)(b+c)* b. All binary strings that have exactly two 1’s in the first three symbols and contain at least three 0’s in the entire string. (110+101+011)(0+1)*0(0+1)*0(0+1)* 6. (15 pts.) Give regular expressions to describe the sets of strings recognized by the following finite state automata. Assume that any unspecified transitions go immediately to a trap state. a. (10+01)*00(11)* b. next state state 0 1 q0 ‐‐ q1 q1 q0 q2 q2 ‐‐ q3 q3 q4 q5 q4 q2 ‐‐ q5 q2 ‐‐ q0 and q2 are both accepting states. (10)* + (10)*11(100+110)* 7. (15 pts.) Design finite state automata to recognize the following regular expressions. You are free to assume that any unspecified transitions go immediately to a trap state, or you may specify the trap state explicitly. a. (11+101)*00* b. 10(0+1)*1(0+1)*1(0+1)*01 8. (20 pts.) Describe what the final tape will look like when the following Turing machine is run with any binary string as input. (Hint: Although it is not required, it would probably be a good idea to trace the machine’s behavior on one or more input strings. That should help you figure out what the machine does, as well as provide more grounds for partial credit. Also, note that short input sequences will probably suffice to get a general idea of what the machine does.) The final contents of the tape will be the reverse of the input string, with the head positioned over the leftmost nonblank cell of the tape.
© Copyright 2025 Paperzz