CMPSCI 250: Introduction to Computation
Final Exam
David Mix Barrington
7 May 2014
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 = 100, C = 65.
- Some useful definitions precede the questions below.
- No books, notes, calculators, or collaboration.
- In case of a numerical answer, an arithmetic expression like
"217 - 4" need not be reduced to a single integer.
Q1: 10 points
Q2: 30 points
Q3: 30 points
Q3: 20+10 points
Q4: 30 points
Total: 120+10 points
Definitions:
Question 2 refers to the following five statements, where the
variables
are of type "dog", the set of dogs includes the dog Duncan (d) and
possibly
others, and we use the following predicates:
- F(x) means "dog x is in the forest"
- I(x) means "dog x is illegal", ¬I(x) means "dog x is
legal"
- L(x) means "dog x is on a leash"
- V(x) means "dog x is under voice control"
- Y(x) means "dog x is in the yard"
The statements are:
- Statement I: A dog in the forest is legal if and only
it is either on a leash or under voice control, or both.
- Statement II: ∀x: ¬(Y(x) ∨ F(x))
→
(L(x) ⊕ I(x))
- Statement III: Duncan is on a leash unless he is in
the yard.
- Statement IV: ¬∃z: I(z) ∧ Y(z)
- Statement V: No dog on a leash is illegal.
N is the set of naturals (non-negative integers), {0, 1,
2, 3,...}
Question 3 uses a function f from N to N. The
function
arises in a popular video game where tiles are labeled by integers
that are powers of two. The smallest tiles are labeled 2, and
they are created without any points being scored. (We will assume
for this exam that only tiles with label 2 are created, though
actually the game also creates some with label 4.) When two tiles
each with label 2k are merged, a single tile with label
2k+1 is created and the player gets 2k+1
points.
For any positive natural k, f(k) is defined to be the number of
points scored in the process of creating a tile with label
2k. If k > 1, this includes the 2k
points for the last merge creating the tile, plus all the points
scored in the process of creating the tiles that were merged.
Question 4 uses the following two formal languages over the
alphabet
{a, b}. The language X is the set of all strings that do not have
both two a's in a row and two b's in a row. The language Y is
defined inductively as follows. Note that the text in green was
omitted when the test was given.
- The string λ is in Y.
- If the string w in Y can be written as uaa for some string u, then wa = uaaa is in Y.
- If the string w in Y can be written as ubb for some string u, then wb = ubbb is in Y.
- If the string w in Y cannot be
written as either uaa or ubb, then both wa and wb are in Y.
- The only strings in Y are those that are forced to be by rules
(1)-(4).
Question 5 uses 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, a, 2), (1, a, 3), (2, b, 4), (3, a, 5), (4, λ, 2),
(4, λ, 3), (5, a, 4)}.
Here is a diagram of N, with "L" meaning λ:
a a
>(1) ----> (3) ----> ((5))
| ^ /
| | /
| | /
| | /
|a |L / a
| | /
| | /
| | /
| | /
V b |V
(2) ----> (4)
<----
L
- 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 Turing recognizable language
- (b, 2) the shortest path from node x to node y in
a weighted directed graph
- (c, 2) a partial order on a set X
- (d, 2) the transition function of a deterministic one-tape
Turing machine
- (e, 2) a pairwise relatively prime set of naturals
- Question 2 (30):
This question deals with five statements about a set of dogs that includes
the named dog Duncan (d) and possibly others. The predicate F(x) means "dog
x is in the forest", I(x) means "dog x is illegal", L(x) means "dog x is on
a leash", V(x) means "dog x is under voice control", and Y(x) means "dog x is
in the yard". Don't draw inferences from the English meanings -- for example,
F(x) ∧ Y(x) might be true.
- (a, 5) Translate the five statements as indicated:
- Statement I (to symbols): A dog in the forest is legal if and
only if it is either on a leash or under voice control, or both.
- Statement II (to English): ∀x:¬(Y(x) ∨ F(x))
→ (L(x) ⊕ I(x))
- Statement III (to symbols): Duncan is on a leash unless
he is in the yard.
- Statement IV (to English): ¬∃z: I(z) ∧ Y(z)
- Statement V (to symbols): No dog on a leash is illegal.
- (b, 5) For each of the statements I, II, and IV, give a propositional
statement about Duncan that is implies by the statement. Which predicate proof
rule did you use?
- (c, 10) Using Statements I-IV (but not Statement V!) prove by
propositional logic that Duncan is legal. (Statement III is a propositional
statement about Duncan, and you should use the three
propositional statements about
Duncan derived in part (b).) You may use a truth table or a propositional
proof, and if you choose the latter you may use any format that makes your
arguument clear.
- (d, 10) Using Statements I-IV, prove Statement V. Make clear the
predicate proof rules that you are using.
- Question 3 (30): This question uses the function f from N
to N, defined above.
- (a, 5) State a rule giving f(k+1) in terms of f(k), with a base case for
f(1). Use this rule to compute f(1), f(2), f(3), f(4), and f(5).
- (b, 10) Prove by induction, on all naturals n such that
n ≥ 3, that f(n) ≥ 2n+1.
- (c, 15) Find a formula that describes f(n) for all positive naturals
n. Prove your formula correct by induction. (You should use ordinary induction
starting with n = 1.)
- Question 4 (20+10): This question uses the definition of
the languages X and Y above. The language X is the set of all strings that do
not have both two a's in a row and two b's in a row. The language Y is
defined inductively as follows (Note that the text in green was
omitted when the test was given):
- The string λ is in Y.
- If the string w in Y can be written as uaa for some string u, then wa = uaaa is in Y.
- If the string w in Y can be written as ubb for some string u, then wb = ubbb is in Y.
- If the string w in Y cannot be
written as either uaa or ubb, then both wa and wb are in Y.
- The only strings in Y are those that are forced to be by rules
(1)-(4).
- (a, 15) Prove Y ⊆ X. I think it is easiest to use induction on the
definition of Y, but you might also use ordinary induction on the length of
strings in Y.
- (b, 5) Is X ⊆ Y? Prove your answer.
- (c, 10XC) Find a set of pairwise Y-inequivalent strings that is as
large as possible. (If there is any such set that is infinite, then any
such infinite set is as large as possible.)
- 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, a, 2), (1, a, 3), (2, b, 4),
(3, a, 5), (4, λ, 2), (4 λ, 3), (5, a, 4)}, 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.
Last modified 25 June 2014