CMPSCI 250: Introduction to Computation
Final Exam
David Mix Barrington
8 May 2012
Directions:
- Answer the problems on the exam pages.
- There are four problems
for 125 total points.
Actual scale is A = 105, C = 68.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
- In case of a numerical answer, an arithmetic expression
like "32× 26 + 13 × 41" need not be reduced to a
single integer.
Q1: 20 points
Q2: 50 points
Q3: 25 points
Q4: 30 points
Total: 125 points
Here are several definitions used on the exam.
- Remember that natural always means "non-negative integer".
This exam's boolean logic problem involves four atomic propositions
and three compound propositions:
- DB means "Duncan is barking".
- HF means "Duncan heard a fox".
- HO means "Duncan heard an owl".
- IN means "Duncan imagined a noise".
- Statement 1 is "If Duncan is not barking, then he heard an owl
if and only if he imagined a noise."
- Statement 2 is "¬(¬HF ∨ IN) → DB".
- Statement 3 is "If Duncan heard an owl, then he is barking,
and if he is not barking, then either he heard a fox or he imagined
a noise or both."
- Here are two properties that a formal language X might or
might not have, expressed in predicate logic where the type of the
variables is "string". Since I can't think of good descriptive
names for these properties, I have named them after my dogs.
- X has the Cardie property if ∃u:∀v: uv
∈ X.
- X has the Duncan property if ∀u:∃v: uv
∈ X.
- A death state of a DFA is a non-final state that
has all its arrows to itself. That is, if d is the state,
δ(d, a) = d for all letters a in the alphabet. A victory
state in a DFA is a final state that has all its arrows
to itself.
- The function g from naturals to naturals is defined by the
rules g(0) = 1 and g(n + 1) = 2g(n) + 2. So g(1) = 4, g(2) = 10,
and g(3) = 22.
- The function h from naturals to naturals is defined by the
following recursive pseudo-Java code:
public natural h (natural n) {
if (n == 0) return 0;
if ((n % 2) == 1) return 1;
return 2 * h(n/2);}
- The λ-NFA M has state set {1, 2, 3, 4}, start state 1,
final state set {4}, and transitions (1, a, 2), (1, b, 3), (2, b,
2), (2, λ, 4), and (3, a, 4). It looks like this:
/---\ b
\ /
\ V
/-->(2)--\
a / \ lambda
/ V
>(1) ((4))
\ ^
b \ / a
\-->(3)--/
- Question 1 (20):
This boolean logic problem deals with the atomic propositions and the
Statements 1, 2, and 3 defined above.
- (a, 5) Translate statements 1 and 2 into symbols, and
translate Statement 2 into English.
- (b, 15) From Statements 1, 2, and 3, prove that Duncan is
barking.
You may use either truth tables or propositional proof rules.
(Hint: The similar "murder mystery" made heavy use of Proof by
Cases. You might also try Proof by Contradiction.)
- Question 2 (50): These questions all deal with the
Cardie and Duncan properties of a formal language, defined above.
- Question 3 (25): These problems refer to the functions g
and h defined above.
- (a, 10) Prove, by ordinary induction on naturals, that for
any natural n, g(n) = 3(2n) - 2.
- (b, 10) Prove, by strong induction on naturals, that for
any positive natural n, the number h(n) divides n.
- (c, 5) Describe the output of the function h(n) in terms
of the prime factorization of the input n.
- Question 4 (30): Here is the inevitable question on Kleene's
Theorem constructions.
- (a, 5) Using the construction from lecture, build a
λ-NFA from the regular expression ab* + ba.
(This λ-NFA is equivalent to, but different from, the
λ-NFA M given above. We will use M for the rest of the
problem, to make your life easier.
- (b, 10) Build an ordinary NFA N that is equivalent to the
given λ-NFA M, so that L(N) = L(M).
- (c, 10) Using the Subset Construction, build a DFA D such
that L(D) = L(N).
- (d, 5) Show the steps of the State Elimination algorothm to
get the regular expression ab* + ba from D.
Last modified 3 June 2012