CMPSCI 250: Introduction to Computation
Final Exam
David Mix Barrington
14 May 2005
Solutions to this exam are here.
Directions:
- Answer the problems on the exam pages.
- There are five problems for 125 total points plus 10 extra credit.
Scale is A=110, C=70.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
Q1: 15 points
Q2: 25 points
Q3: 25
Q4: 25 points plus 10 extra credit
Q4: 35 points
Total: 125 points plus 10 extra credit
- Question 1 (15):
Suppose we throw three identical, fair six-sided dice. (In gaming terms,
we "throw 3D6".) The six sides of each die are labeled 1, 2, 3, 4, 5, and 6.
- (a,5)
What is the probability that the three numbers of the three dice are all
different? Is this probability greater than, equal to, or less than 1/2?
- (b,5) How many possibilities are there for the set of numbers
appearing on the three dice? (For example, if all three dice show 5, this set
is {5}. If the numbers are 4, 2, and 3, this set is {2,3,4}.)
- (c,5) How many possibilities are there for the multiset of
numbers appearing on the three dice? (For example, if all three dice show 5,
the muliset is {5,5,5}. If all three numbers are different, the multiset is
the same as the set.)
- Question 2 (25):
Both this question and Question 3 deal with a predicate P(w), where w
represents a string over the alphabet {a,b}. The predicate is defined
recursively by four rules:
- P(a) is true.
- If w is any string and P(w) is true, then P(bbw) is also true.
- If w is any string and P(w) is true, then P(wb) is also true.
- If P(w) is not forced to be true by rules 1, 2, and 3, then it is false.
- (a,10) Prove by induction on this definition that for any string w
such that P(w) is true, w has exactly one a.
- (b,5) Let A be the language {w: P(w)}. Give a regular expression
denoting A.
- (c,10)
Describe or draw a λ-NFA whose language is A. (The λ-NFA made
from the regular expression by the construction has nine states. There is a
correct λ-NFA that has only three states. Remember that any ordinary
NFA is also a &lambda-NFA.)
- Question 3 (25):
Let f(n) be the function defined recursively by the following rules:
- f(0) = 0, f(1) = 1, and f(2) = 1
- If n ≥ 3, then f(n) = f(n-1) + f(n-2) - f(n-3)
- (a,10) Explain why f(n) is exactly the number of strings of length
n in the language A from Question 2. (Hint: Use the result of Question 2 part
(a) to explain the base case. For the inductive case, use the Double Counting
Rule to count the strings of length n formed by Rule 2 and Rule 3, determining
exactly how many strings are formed in both ways.)
- (b,15) Compute f(n) for n up to at least 5, and determine a formula or
rule that gives the value of f(n) for any n. (You may find the Java integer
division operator useful.) Prove by induction that your rule is correct. (A
good way to do this is by strong induction, with separate cases for odd and
even n in the inductive step.)
- Question 4 (25+10):
Define the following four predicates on strings over the alphabet {0,1}:
- C(x) means "x is a valid description of a Turing machine"
- H(x,y) means "C(x) is true, and x halts when run on input y"
- A(x,y) means "H(x,y) is true, and x outputs "yes" when run on input y"
- T(x) means "∀y:H(x,y)"
(If you are unsure about Turing machines, don't panic. Parts (a) and (b) of
this question can be answered by the rules of logic without specific knowledge
about Turing machines.)
- (a,5)
Prove that for any string x, T(x) → C(x). You may use either symbolic
language or clear English.
- (b,15)
Using quantifier rules carefully, prove the statement
¬∃u:∀v: C(u) ∧ [H(u,v) ↔ ¬H(v,v)]
(Hint: Assume the negation of this statement and derive a contradiction
using quantifier rules.)
- (c,5) Explain the meaning of the statement of part (b) in English.
What does it assert to be impossible?
- (d,10) Explain the meaning of the statement
∀x:[T(x) → ∃z: C(z) ∧ ∀w:
[H(z,w) ↔ A(x,w)]]
Explain informally why it is true.
- Question 5 (35):
Define the following λ-NFA M: The state set is {1,2}, the start
state is 1, the final state set is {1}, and the transition relation Δ
is {(1,a,1), (1,λ,2), (2,a,1), (2,b,2)}.
- (a,5) Draw a diagram for M. Remember that you should have one arrow
for each triple in Δ.
- (b,10) Using the "killing λ-moves" construction, build an
ordinary NFA N that is equivalent to M.
- (c,10) Use the subset construction to build a DFA D that is equivalent
to M and N. (Partial credit for any correct DFA for this language. If you
have trouble with (b), make sure you give some answer here so that you can do
part (d).)
- (d,10) Apply the state minimization construction to your D to get a
minimal DFA (which may or may not be D itself).
Last modified 17 May 2005