CMPSCI 250: Introduction to Computation
Final Exam
David Mix Barrington
10 May 2011
Directions:
- Answer the problems on the exam pages.
- There are three problems
for 125 total points.
Actual scale is A=98, C=63.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
Q1: 30 points
Q2: 35 points
Q3: 60 points
Total: 125 points
Question 1 (30): As on the first
midterm,
we have a set of dogs G, a set of Playthings P, constants Ace (a),
Biscuit (b), Cardie (c), and Duncan (d) of type Dog, and constants
Rope Chew (r), Stuffed Chicken (s), and Tennis Ball (t) of type
Plaything, with possibly other elements of G and P as well. The
predicate H(g, p) means "Dog g has Plaything p". We define two new
predicates X and Y, each taking two Dogs as arguments. X(g, g') is
defined to mean "∀p: H(g, p) → H(g', p)" and Y(g, g') is
defined to mean "∀p: H(g, p) ↔ H(g', p)".
- (a, 10) Determine whether X is an equivalence relation, whether
X is a partial order, whether Y is an equivalence relation, and
whether Y is a partial order. Justify your answers, showing that
you know the definitions of these two types of relations and the
properties that define them. (You do not need to give quantifier
proofs that the relations have these properties.)
- (b, 10) Assuming that X(a, b), Y(a, c), and Y(b, d) are all
true, give a quantifier proof of X(c, d).
- (c, 5) Translate these two statements as indicated:
- (I, to symbols): Either Cardie has the Rope Chew, or
Duncan has the Stuffed Chicken only if Biscuit has the Stuffed
Chicken, but not both.
- (II, to English): (H(a, t) ∨ H(c, r)) → (H(d, t)
∨ H(a, r))
- (d, 5) Choose one of the statements of part (c), and prove it
given the assumptions of part (b). (I guarantee only that at
least one of those two statements can be proved from those
assumptions.) (A prose proof is sufficient if it is convincing.)
- Question 2 (35):
Let M be the following λ-NFA. The state set is {1, 2, 3, 4, 5},
the start state is 1, the final state set is {2, 5}, and the set
of transitions is {(1, b, 3), (1, λ, 4), (2, λ, 5),
(3, λ, 2), (4, a, 2), (4, λ, 5), (5, a, 5)}.
- (a, 10) Build an ordinary NFA M' such that L(M') = L(M).
- (b, 10) Build a DFA D such that L(D) = L(M').
- (c, 10) Find a regular expression R such that L(R) =
L(M). You may choose to use the state elimination
construction starting with M, M', D, or even a minimized
version of D.
- (d, 5) Build a λ-NFA whose language is that
denoted by the following regular expression: (b +
a∅b*)ba + aba. Carry out the construction from
the book (or from lecture) without first simplifying the regular
expression. (Note that this expression may have nothing to do
with parts (a)-(c) of this question.)
- Question 3 (60):
In the game of ScrabbleTM, each of the letters in the
alphabet {A, B, ..., Z} is assigned a numerical value from the
set {1, 2, ..., 10}. We define LV(ch) to be the value of the
letter ch, so that for example LV('D') = LV('G') = 2 and
LV('O') = 1. The function WV gives the value of a string over
this alphabet, which is the sum of the values of the letters
in the string, so that WV("DOG") = 2 + 1 + 2 = 5. Finally,
for any fixed natural number n, we define the language
Cn to be the set of all strings w such that WV(w) = n.
- (a, 5) Give a recursive definition of the function WV for all
strings w, with a base case for the empty string and an inductive
case for adding a letter to a string.
- (b, 5) Give a recursive pseudo-Java method
int wv
(string w)
to compute WV for any pseudo-Java string, using the
base methods isEmpty
, last
, and
allButLast
. (Recall that last("DOG")
is
'G'
and that allButLast("DOG")
is
"DO"
. Also remember that these are pseudo-Java
string
values, where string
is a primitive
type, not real Java String
objects.) Don't worry about
input strings that are not over the correct alphabet. You are given
a method int lv (char ch)
that returns LV(ch) for any
character ch in that alphabet.
- (c, 10) Prove that for any natural number n, the language
Cn defined above is regular. (Hint: You can build a DFA
with exactly n + 2 states.)
- (d, 10) Let Z be the language {1n$w: w ∈
Cn} over the alphabet {1, $, A, ..., Z}. (An example of a
string in Z is
"11111$DOG"
.) Is Z a regular language?
Prove your answer. Is Z the language of any two-way DFA?
- (e, 10) Is the language Z, defined in part (d), Turing
decidable? Justify your answer, making clear that you understand
the definitions. Is Z Turing recognizable?
- For the last two parts we consider the following weighted
directed graph G. G has a node for every string w with WV(w) ≤
30. If w is any string and a is any letter, and there is a node for
the string wa in G, then there is an edge from w to wa, with weight
LV(a). Let D be the set of nodes in G that correspond to words in
the standard Scrabble dictionary.
- (f, 10) Prove the following by strong induction for all
natural numbers (non-negative integers) k: "If k ≤ 30, and w is
any string with WV(w) = k, then there is a path in G from the node
for λ to the node for w, and this path has total weight k."
- (g, 10) Suppose we carry out a uniform-cost search of G, with
D as the set of goal nodes, starting from the node for some
particular string u. Which goal node will we find, if any?
Last modified 9 May 2012