CMPSCI 250: Introduction to Computation
Final Exam
David Mix Barrington
18 December 2015
Directions:
- Answer the problems on the exam pages.
- There are five problems, each with multiple parts, for 120 total
points plus 10 extra credit. Actual scale A = 108, C = 72.
- 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: 30+10 points
Q5: 40 points
Total: 120+10 points
Question 3 deals with a set D of dogs, containing the three
distinct dogs Ali (a), Cardie (c), and Duncan (d), and possibly
others, and a set of exactly four commands C, consisting of "come here"
(ch), "fetch" (f), "roll over" (r), and "sit" (s). The predicate O(x, y)
means "dog x obeys command y".
Question 3 also refers to the following five statements, where the
variables are of type "dog" or type "command":
- Statement I: No dog obeys all the commands.
- Statement II: ∀x: O(c, x) ↔ (O(a, x) ∨ O(d, x))
- Statement III: Every command is obeyed by at least one dog.
- Statement IV: ∃y: O(d, y) ∧ ¬O(a, y)
- Statement V: Ali obeys "sit" and "fetch" but not "roll over".
N is the set of naturals (non-negative integers),
{0, 1, 2, 3,...}, and Z is the set of all integers,
{..., -3, -2, -1, 0, 1, 2, 3,...}.
Question 4 uses a recursive function from strings to integers.
Let Σ be the alphabet {a, b, c}. Define a function f from
Σ^{*} to Z recursively by the rules f(λ) = 0,
f(wa) = 3f(w) - 1, f(wb) = 3f(w), and f(wc) = 3f(w) + 1.
Question 5 begins with the following λ-NFA N. The alphabet is
{a, b}, the state set is {1, 2, 3}, the start state is 1, the final state
set is {1}, and the transition relation Δ is
{(1, a, 2), (2, b, 3), (3, a, 1), (3, λ, 1)}.
Here is a diagram of N, with "L" meaning λ. Note that there
are two parallel edges from 3 to 1. There is no state at the southeast
corner of the diagram -- the edge from 2 to 3 turns a corner there.
a
>((1)) - - - - - > (2)
^ |
| |
| |
|a, L |
| | b
| |
(3)< - - - - - - <
- Question 1 (10): Compare and contrast the two concepts
in each of the following pairs, giving enough detail to make it clear that
you are familiar with them (2 points each):
- (a, 2) The input alphabet and the tape alphabet of a
Turing machine
- (b, 2) uniform-cost search and A^{*} search
- (c, 2) the multiplicative inverse and additive inverse
of a number, modulo m
- (d, 2) a partial order and a total order
- (e, 2) the commutative and associative properties of
a binary operation
- Question 2 (20):
The following are ten true/false questions, with no explanation needed
or wanted, no partial credit for wrong answers, and no penalty for
guessing. Each one counts two points.
- (a)
If Black and White play a game with a finite game tree, and the game
always ends with a victory by one player, then either Black or White must
have a winning strategy.
- (b)
The regular expressions (aba)^{*}ba and ab(aba)^{*} denote the
same language.
- (c)
If G is a finite directed graph and we either use a closed list or mark nodes
that have been seen, then a depth-first search and a breadth first search of
G with the same start node and the same goal node will return the same boolean
answer.
- (d)
Suppose that a single-tape Turing machine M has the transition
δ(p, ☐) = (q, ☐, R) where ☐ is the blank symbol.
Then if M reaches the configuration ☐ab☐p☐, it is
guaranteed never to halt.
- (e)
If X and Y are each Turing recognizable languages, then the languages
X ∪ Y and X ∩ Y must each be Turing recognizable.
- (f)
If an integer x satisfies the congruences x ≡ 13 (mod 15) and
x ≡ 4 (mod 7), then x - 210 also satisfies those two congruences.
- (g)
If p is a prime number, then p! + 1 must also be a prime number. (Here p!
is the factorial of p.)
- (h)
The compound proposition ((p ∨ q) → r) ∨ ¬(p → q) ∨
(q ∨ ¬p) is a tautology.
- (i)
Suppose that state p of an r.e.-NFA is not the start state and not the final
state. The only transitions involving p are (q, ab, p), (p, ba^{*}),
and (p, ba, q). Then I may eliminate p and replace it with one new
transition, (q, ab(ba^{*})^{*}ba, q), merging this new
transition with any existing transition from q to q.
- (j)
If every dog has another dog that likes it, then there must be a dog that likes
every other dog.
- Question 3 (20):
This question deals with five statements about a set of dogs D, consisting
of the three dogs Ali (a), Cardie (c), Duncan (d), and perhaps others, and a
set C of exactly four commands, consisting of "come here" (ch), "fetch" (f),
"roll over" (r), and "sit" (s). The predicate O(x, y) means "dog x obeys
command y".
- (a, 5) Translate each of these five statements as indicated.
- Statement I (to symbols): No dog obeys all the commands.
- Statement II (to English): ∀x: O(c, x) ↔
(O(a, x) ∨ O(d, x))
- Statement III (to symbols): Every command is obeyed
by at least one dog.
- Statement IV (to English):
∃y: O(d, y) ∧ ¬O(a, y)
- Statement V (to symbols) Ali obeys "sit" and "fetch" but not
"roll over".
- (b, 5) Based on Statements I-V, which of the three dogs might
obey "sit"? That is, of the eight possible sets of truth values for the three
propositions O(a, s), O(c, s), and O(d, s), which are consistent with the
statements?
- (c, 10) Assuming that Statements I-V are all true, prove that there
exists a dog in the set D other than Ali, Cardie, and Duncan.
- Question 4 (30+10): Let Σ be the alphabet {a, b,
c}. Define a function f from Σ^{*} to Z
recursively
by the rules f(λ) = 0, f(wa) = 3f(w) - 1, f(wb) = 3f(w), and
f(wc) = 3f(w) + 1.
- (a, 10) Prove by induction that for every natural n,
f(a^{n}) = -(3^{n} - 1)/2 and f(c^{n}) =
(3^{n} - 1)/2.
- (b, 10) Prove by induction that for any natural n and for
and for any string w of length n, f(a^{n}) ≤ f(w) and
f(w) ≤ f(c^{n}). (Here a^{n} and c^{n}
are strings.)
- (c, 10) Prove by induction on strings that for any string w,
f(aw) = -3^{n} + f(w), f(bw) = f(w), and f(cw) =
3^{n} + f(w). (In each case n is the length of w.) (Hint:
Your induction step should be to assume P(w) and prove P(wa), P(wb),
and P(wc). This will involve talking about numbers like f(bwc), for
example.)
- (d, 10XC) Prove by induction that for every natural n, f
restricted to strings of length n is a one-to-one function. That
is, if x and y are two different strings of length n, then f(x) ≠
f(y).
(Hint: In the inductive step, break into two cases depending on
whether
x and y have the same first letter. If they do, use the inductive
hypothesis and part (c). If they do not, use parts (a), (b), and (c).)
- Question 5 (40): This question is the usual one about
Kleene's Theorem constructions, starting with the λ-NFA N
given above. The transition relation of that machine is {(1, a, 2),
(2, b, 3), (3, a, 1), (3, λ, 1)}, its start state is 1, and
its
final state set is {1}.
- (a, 10) Use the construction from lecture and the text to
find a λ-NFA whose language is (ab + aba)^{*}. (N
is
such a λ-NFA, but I want the one from the construction.)
- (b, 10) Using the construction given in lecture and in the
text, find an ordinary NFA N' such that L(N') = L(N). (Use N
rather than your answer from (a) -- it will be easier.)
- (c, 10) Using the Subset Construction on N', find a DFA D
such that L(D) = L(N).
- (d, 10) Find a minimal DFA with the same language as D.
(Either run the state minimization algorithm or prove that your D
is
already minimal.)
Last modified 28 January 2016