CMPSCI 250: Introduction to Computation
Final Exam
David Mix Barrington
1 May 2015
Directions:
- Answer the problems on the exam pages.
- There are five problems, some with multiple parts, for 120 total
points plus 10 extra credit. Actual scale was A = 110, C = 75.
- Some useful definitions precede the questions below.
- No books, notes, calculators, or collaboration.
- In case of a numerical answer, an arithmetic expression like
"2^{17} - 4" need not be reduced to a single integer.
Q1: 10 points
Q2: 20 points
Q3: 20 points
Q4: 20+10 points
Q5: 30 points
Q6: 20 points
Total: 120+10 points
Definitions:
Question 2 deals with a set D of dogs, containing exactly
the three distinct dogs Cardie (c), Duncan (d), and Whistle (w), and a
set M of mealtimes. As all hobbits know, there are six possible mealtimes
in a day: breakfast (b), second breakfast (sb), lunch (l), tea (t),
supper (s), and evening snack (e). The relation F ⊆ D × M is
defined so that F(x, y) means "dog x is fed at mealtime y".
Question 2 also refers to the following five statements, where the variables
are of type "dog" or type "mealtime". The statements are:
- Statement I: Whistle is fed at second breakfast, tea,
evening snack, and no other mealtime.
- Statement II: ∀m: ¬(F(c, m) ∧ ¬F(d, m))
- Statement III: There is no mealtime when no dog is fed.
- Statement IV: ∃m: ∀x: F(x, m) ↔ (x = d)
- Statement V: Each dog is fed at two or more mealtimes.
N is the set of naturals (non-negative integers), {0, 1,
2, 3,...}
Z is the set of all integers, {..., -3, -2, -1, 0, 1, 2, 3,...}.
Question 3 uses a function g from Z × N to Z.
This function is defined recursively on its second argument.
We define g(n, 0) to be n for any integer n. For any integer n and
natural k, we define g(n, k+1) to be 2g(n, k) - 3.
Question 4 uses a recursively defined function h from {0, 1}^{*}
to {0, 1}^{*}. We define h(λ) = 1, and for any string
w we define h(w0) to be 0h(w)0 and define h(w1) to be 1h(w).
Question 5 begins with the following λ-NFA N.
The alphabet is {a, b}, the
state set is {1, 2, 3, 4, 5}, the start state is 1, the final state set is {5},
and the transition relation Δ is
{(1, λ, 2), (1, a, 3), (2, a, 1), (2, λ, 4),
(3, b, 4), (4, λ, 5), (5, b, 5)}.
Here is a diagram of N, with "L" meaning λ:
L
>(1) - - - - - > (2)
| < - - - - - - |
| a |
| | b
|a |L ----
| | / \
V b V L V |
(3) - - - - - > (4) - - - - - > ((5)) - -|
- Question 1 (10):
Identify each of the following five concepts, giving enough detail to
make it clear that you are familiar with them (2 points each):
- (a, 2) A one-to-one function from a set X to a set Y
- (b, 2) The contrapositive of an implication
- (c, 2) The open list of a search
- (d, 2) A Turing decidable language
- (e, 2) The blank symbol of a Turing machine
- Question 2 (20):
This question deals with five statements about a set of dogs D,
consisting of the three dogs Cardie (c), Duncan (d), and Whistle (w),
and a set of mealtimes M. As all hobbits know, there are six possible
mealtimes in a day: breakfast (b), second breakfast (sb), lunch (l), tea (t),
supper (s), and evening snack (e). The relation F ⊆ D × M
is defined so that F(x, y) means "dog x is fed at mealtime y".
- (a, 5) Translate the five statements as indicated:
- Statement I: (to symbols) Whistle is fed at second breakfast, tea,
evening snack, and no other mealtime.
- Statement II: (to English) ∀m: ¬(F(c, m) ∧ ¬F(d, m))
- Statement III: (to symbols) There is no mealtime when no dog is fed.
- Statement IV: (to English) ∃m: ∀x: F(x, m) ↔ (x = d)
- Statement V: (to symbols) Each dog is fed at two or more mealtimes.
- (b, 5)
What do the five statements tell us about which dogs are fed at tea? That
is, what (if anything) can be implied from each of the five statements about
the truth values of the propositions F(c, t), F(d, t), and F(w, t)?
- (c, 10) Using any of all of Statements I-V, prove that Duncan
is fed at supper. Make clear whenever you are using one of the predicate
proof rules.
- Question 3 (20): This question uses the function g from
Z × N
to Z, defined above. For any integer n, g(n, 0) is defined to be n.
For any integer n and natural k, g(n, k+1) is defined to be 2g(n, k) - 3.
- (a, 5) Find the values of g(-1, 3), g(1, 3), g(3, 3), and g(5, 3).
- (b, 5) Prove that for any positive natural k and for any integer
n, g(n, k) is odd. (One way to do this is to let n be arbitrary, and use
induction on all positive naturals k. Another is to apply the result of part
(c) of this problem. You may use commonly known facts about even and odd
numbers without proof.)
- (c, 10) Prove by induction that for any integer n and for
any natural k, g(n, k) = 2^{k}(n - 3) + 3. Let n be arbitrary and
use induction on k.
- Question 4 (20+10): This question uses the following
recursively defined function from {0, 1}^{*} to {0, 1}^{*}.
We define h(λ) to be 1, and for any string w we define h(w0) to be
0h(w)0 and define h(w1) to be 1h(w).
- (a, 5) Compute h(00), h(01), h(10), h(11), and h(010).
- (b, 15) Prove by induction on all strings w that the length of h(w)
is the length of w, plus the number of 0's in w, plus 1. (Inventing some
notation, we can write our statement P(w) as "|h(w)| = |w| + |w|_{0}
+ 1".)
- (c, 10XC) Let X be the language that is the range of the function
h, that is, the language {h(w): w ∈ {0, 1}^{*}}. Is X a regular
language? Prove your answer. (Hint: What strings in X have exactly one 1?)
- Question 5 (30): This question is the usual one about Kleene's
Theorem constructions, staring with the λ-NFA N given above. The
transition relation of that machine is {(1, λ, 2), (1, a, 3), (2, a, 1),
(2, λ, 4), (3, b, 4), (4, λ, 5), (5, b, 5)}, its start state is
1, and its final state set is {5}.
- (a, 10) Using the construction given in lecture and in the text, find an
ordinary NFA N' such that L(N') = L(N).
- (b, 10) Using the Subset Construction on N', find a DFA D such that
L(D) = L(N).
- (c, 10) Find a regular expression R such that L(R) = L(N). You may
begin with any of the machines N, N', or D.
- Question 6 (20): Indentify each of the following ten
statements
as true or false. There are two points for each correct answer, with
no explanation requested or wanted. Note that there is no penalty for
guessing.
- (a) If X is a language containing only strings of odd
length,
then X^{*} also contains only strings of odd length.
- (b) If the statements p → q, r → q, and p ∨ r
are all true, then q must be true.
- (c) If n is any natural with n > 2, then n^{2} - 1 is
not prime.
- (d) If a natural x is congruent to 17 modulo 3 and congruent
to 17 modulo 6, then x must be congruent to -1 modulo 18.
- (e) If δ(p, a) = (q, b, L), then the Turing machine
configuration abpa☐b becomes aqbb☐b on the next step. (Here
p and q are states and a, b, and ☐ are letters.)
- (f) There exists a two-way DFA whose language is
{a^{n}b^{n}: n ≥ 0}.
- (g) If both the language X and its complement are Turing
recognizable, then both those languages are also Turing decidable.
- (h) The set of pairs {(M, w): M is a Turing machine, w is a
string, and M accepts w in ten or fewer steps} is Turing decidable.
- (i) The set of pairs {(M, w): M is a Turing machine, w is a
string, and M accepts w in ten or more steps} is Turing
decidable.
- (j) If δ(i, ☐) = (q, a, L), where i is the start
state and ☐ is the blank symbol, then the language of the Turing
machine is empty.
Last modified 14 December 2015