Q1: 30 points Q2: 20+10 points Q3: 40 points Q4: 30 points Total: 120 points
Exam text is in black, solutions in blue.
Here are definitions of some terms, sets, predicates, and statements used on this exam.
Question 1 deals with the following scenario:
Many of the dogs in my neighborhood are fans of rap music. One day a set D of four dogs: Cardie (c), Duncan (d), Rio (r), and Scout (s) met to discuss their preferences among a set R of four rap artists: Cardi B (CB), Drake (DR), Kendrick Lamar (KL), and Kanye West (KW).
Note that variables and constants with lower case letters denote dogs, and those with capital letters denote rappers. Note also that Cardie the dog is spelled differently from Cardi B the rapper.
The predicate P(x, Y, Z) means "dog x prefers rapper Y to rapper Z". Each dog's preferences establish a total order on the rappers, so that for each dog x the predicate "(Y = Z) ∨ P(x, Y, Z)" is reflexive, antisymmetric, transitive, and total.
Question 1 also refers to the following five statements, where the variables are of type "dog" or type "rapper".
The statements are:
N is the set of naturals (non-negative integers, {0, 1, 2, 3,...}.
Question 2 uses a recursive function f from N to N defined by the rules f(0) = 1, and for n ≥ 0, f(n+1) = f(n) + n2 + n - 1.
Question 2 also refers to the language L, over the alphabet {a, b, c}, which is denoted by the regular expression (∅* + b + bb)(a + ab + abb + acc)*. Note that a similar but different regular language is the subject of Question 3.
Question 2 also uses a recursive function g from N to N, defined by the rules g(0) = 1, g(1) = 2, g(2) = 4, and, for n ≥ 2, g(n+1) = g(n) + g(n-1) + 2g(n-2).
Question 3 uses the following λ-NFA N, which has state set {1, 2, 3, 4}, start state 1, final state set {1}, alphabet {a, b, c}, and transition relation Δ = {(1, a, 2), (2, λ, 1), (2, b, 3), (2, c, 4), (3, b, 1), (3, λ, 1), and (4, c, 1)}.
Here is a diagram of N, with "L" representing λ:
c
----------(4)
| ^
| | c
| |
V a |
>((1)) -----> (2)
^ <------ |
| L |
| | b
| |
| |
| b, L V
--------- (3)
The predicate P(x, Y, Z) means "dog x prefers rapper Y to rapper Z". Each dog's preferences establish a total order on the rappers, so that for each dog x the predicate "(Y = Z) ∨ P(x, Y, Z)" is reflexive, antisymmetric, transitive, and total.
"If any rapper is not Cardi B, then Cardie prefers Cardi B to them." That is, "Cardi B is Cardie's favorite rapper" or "Cardie prefers Cardi B to all other rappers".
∀x: P(x, DR, KW) ∧ P(x, KL, KW)
"If Duncan prefers Drake to Cardi B, then he also prefers Cardi B to Kendrick Lamar. And it is not the case that if Scout prefers Kendrick Lamar to Cardi B, then Duncan prefers Cardi B to Drake." Many people did some of the work of part (b) here, by translating the second part to "Scout prefers Kendrick Lamar to Cardi B, and Duncan does not prefer Cardi B to Drake", using the Definition of Implication and DeMorgan. This was fine, of course.
I thought it was pretty clear that since "each" dog preferred Cardi B to some rapper, there was no reason that those two rappers had to be the same. So I was looking for "∃Y:∃Z P(s, CB, Y) ∧ P(r, CB, Z)" which allows Y and Z to be the same rapper but does not require it. If you instead said "∃Y: P(s, CB, Y) ∧ P(r, CS, Y)", I took off a point unless you made it clear that you were interpreting the English that way.
"There is a rapper such that for every dog and every other rapper, either the two rappers are the same or the dog prefers the second rapper over the first." Equivalently, "There is a rapper who is the common least favorite of all the dogs".
If we let a, b, and c denote those three propositions, we can first observe that P(d, DR, CB) is equivalent to ¬a because the relation is antisymmetric and total, and DR and CB are different rappers. So Statement III becomes "(¬a → b) ∧ ¬(c → a)". By Definition of Implication and DeMorgan, this becomes "(¬a → b) ∧ (c ∧ ¬a)". So c must be true, a must be false, and (by Modus Ponens on the first part) b must be true.
A short but convincing proof in English goes like this: Because each
dog's preference establishes a total order and there are
only finitely many rappers, each dog must have a least
favorite rapper. By Statement II, this rapper cannot be DR
or KL, as all dogs prefer them over KW. We can rule out CB
as the least favorite of any dog, using cases to consider
each dog. Cardie prefers CB over all others, Duncan prefers
her over KL, and Scout and Rio each prefer her over some
unspecified
rapper. So KW must be the common least favorite of all the
dogs.
Here is a more traditional proof using the methodology of
quantifier proofs in the text. Since the conclusion is an
existential statement, our last rule will be Existence. So
we must first decide for which rapper Y we can prove
"∀x:∀Z:(Y = Z) ∨ P(x, Z, y)". We choose to
let Y be KW. (By the way, some of you showed that none
of the other three rappers could be Y and then concluded that Y
was KW, neglecting to prove that the dogs shared a common
least favorite rapper at all.) (Corrections in bold made
19 December 2019.)
Now we have a Generalization proof. We let x be an
arbitrary dog and let Z be an arbitrary rapper, and set out
to prove "(KW = Z) ∨ P(x, Z, KW)" by cases:
Base Case: f(0) = 1 by the definition, and the formula says f(0) =
(03 - 4(0) + 3)/3 = 1, so the statement P(0) is true.
It was not sufficient to just say "f(0) = 1" -- you need to
check against the formula.
Inductive Hypothesis: f(n) = (n3 - 4n + 3)/3.
Inductive Goal: f(n+1) = ((n+1)3 - 4(n+1) + 3)/3.
Inductive Step: By the definition, f(n+1) is f(n) +
n2 + n -1, which by the IH is (n3 - 4n +
3)/3 + n2 + n - 1 = (n3 - 4n + 3 +
3n2 + 3n - 3)/3 = (n3 + 3n2 -
n)/3 = ((n3 + 3n2 + 3n + 1) - 4(n+1) + 3)/3,
matching the desired formula for f(n+1). We have proved P(n+1)
from the assumption of P(n), completing the inductive step of an
ordinary induction.
Base cases: We need three base cases because the general rule does not
tell us about g(n+1) unless n ≥ 2. We are told that g(0) = 1, g(1) = 2 and g(2) = 4. To prove
the base cases, we must note that each of these three values
matches the formula g(n) = 2n, since 1 = 20,
2 = 21, and 4 = 22.
Strong Inductive hypothesis: g(i) = 2i for all i
such that i ≤ n. In particular we will need to use the
cases i = n, i = n-1, and i = n-2.
Inductive Step: We must prove that g(n+1) = 2n+1.
We are told that g(n+1) = g(n) + g(n-1) + 2g(n-2), and by
the SIH this equals 2n + 2n-1 +
2(2n-2), which by arithmetic equals 2n+1.
Base cases: We need three base cases because we will not be able to
prove anything about h(n+1) from earlier cases unless n ≥ 2. We
need to show that h(0) = 1, h(1) = 2, and h(2) = 4. To do this we
check the strings of these lengths in the language L. For length 0
there is only λ, for length 1 there are a and b, and for length
2 there are aa, ab, ba, and bb.
Strong Inductive Hypothesis: h(i) = g(i) for all i with i ≤ n.
In particular we will need that h(n) = g(n), h(n-1) = g(n-1), and
h(n-2) = g(n-2).
Inductive Step: We need to prove that h(n+1) = h(n) + h(n-1) +
2h(n-2), from which we can get (by the SIH) that h(n+1) equals the
given formula for g(n+1). To prove this we need to analyze all
strings in L of length n+1. Since n ≥ 2, these strings must each
have a nonempty component from the language
(a+ab+abb+acc)*, meaning that they end with a string from
(a+ab+acc+abb). It's important that the entire string can end with
such a string in only one way, so that the total number of strings is
just the sum of the numbers of strings that can be made in each way,
without any correction for double counting.
If the string w is of the form va, then v is a string in L of
length n. If w = vab, v is a string in L of length n-1. If w = vabb
or w = vacc, v is a string in L of length n-2. We know that the
number of strings in L of each of these lengths is h(n), h(n-1), and
h(n-2) respectively, giving us the result that h(n+1) = h(n) + h(n-1)
+ 2h(n-2). So the strong induction is complete.
We have nine states with start state 1 and only final state 9. The transitions are (1, λ, 2), (2, λ, 8), (2, a, 3), (2, a, 4), (2, a, 6), (2, a, 8), (3, b, 8), (4, b, 5), (5, b, 8), (6, c, 7), (7, c, 8), (8, λ, 2), and (8, λ, 9). I gave four points out of five for any λ-NFA with the correct langauge that was not isomporphic to this one (meaning, this one with possibly different node names). This includes simpler automata made by merging some or all of the a-edges into one, because these are made from different, though equivalent, regular expresssions. (Correction in bold made 13 December 2018.)
We have the same state set {1, 2, 3, 4}, the same start state 1, and the same final state {1}. (States 2 and 3 do not become final according to the construction, although making them final does not change the language of the machine and does not affect the result of part (c).) The λ-moves of N are already transitive, so we don't need to add any new ones. To find the transitions of N', we look at each letter-move of N. Move (1, a, 2) gives rise to six letter moves in N', because we can get to state 1 from state 2 or 3, and go from state 1 to state 2. These six moves are (1, a, 1), (1, a, 2), (2, a, 1), (2, a, 2), (3, a, 1), and (3, a, 2). Move (2, 3, b) gives rise to itself and (2, b, 1). The other three letter moves give rise only to themselves, so we have in all six a-moves, three b-moves, and two c-moves.
The start state is {1}, which is final. This has an a-move to {1, 2}, which is final, and a b-move and c-move to ∅, which is non-final. State {1, 2} has an a-move to itself, a b-move to {1, 3} which is final, and a c-move to {4} which is non-final. State ∅ has all three moves to itself. State {1, 3} has an a-move to {1, 2}, a b-move to {1}, and a c-move to ∅. State {4} has an a-move and a b-move to ∅ and a c-move to {1}. We are done because each of these five states has moves only to states among these five.
Minimization construction: We divide the five states into the final
states F = {{1}, {1, 2}, {1, 3}} and the non-final states N =
{∅, {4}}. The behaviors of the three states in F on a, b, and c
are (F, N, N), (F, F, N), and (F, F, N). So state {1} must be in its
own class. The behaviors of the two states in N are (N, N, N) and (N,
N, F), so these states are each in their own class. We must perform a
second round of the construction on the class X containing states {1,
2} and {1, 3}. Their behaviors are now (X, X, {4}) and (X, {1},
∅), which are different, so each of the five states is in its
own class. Hence D was already minimal.
Direct proof: We can separate {1} from {1, 2} by the string a, {1}
from {1, 3} by the string cc, and {1, 2} from {1, 3} by the
string cc. We can separate ∅ from {4} by the string
c. Since each pair of final states, and each pair of
non-final states, can be separated, the DFA is minimal.
(Here "separating states x and y by string w" means that w
takes one of the two states to a final state and the other
to a non-final state.)
We begin by adding a new start state i, with a transition {i,
λ, {1}), adding a new final state f with λ-moves from
the three final states, and eliminating the death state ∅. (The
latter requires adding no new moves.
We eliminate state {4}, creating the single new move ({1, 2}, cc,
{1}).
We could now eliminate any of the three remaining intermediate
states. I think it is easiest to eliminate {1, 3}, creating
three new transitions ({1, 2}, bb, {1}) (which merges to
create ({1, 2}, bb + cc, {1})), ({1, 2}, ba, {1, 2}) (which
merges to create ({1, 2}, a + ba, {1, 2})), and ({1, 2}, b,
f) (which merges to create ({1, 2}, λ + b, f).
Now we can eliminate {1} and create four new moves: (i, a, {1, 2}),
(1, λ, f), ({1, 2}, (bb+cc)a, {1, 2}) (which merges to create
({1, 2}, a+ba+bba+cca, {1, 2}), and ({1, 2}, bb+cc, f) (which merges
to create ({1, 2}, λ + b + bb + cc, f).
Finally, eliminating {1, 2} gives us the regular expression
λ + a(a + ba + bba + cca)*(λ + b + bb + cc).
TRUE. Statement V says that there exists a rapper who is the least preferred by every dog, which means this rapper cannot be the favorite of any dog. Statement II by itself implies that KW cannot be the favorite of any dog. Thus the function h is not onto. Since its domain (D) and its codomain (R) are the same size, h is onto if and only if it is one-to-one. So it is not one-to-one either. The statements do not suffice to tell us which two dogs have the same favorite, but this has to happen because four dogs are choosing favorites from a set of three rappers.
FALSE. 11 is a counterexample. This appears to be an attempt to use the Chinese Remainder Theorem, ignoring the requirement that the moduli be relatively prime (4 and 6 are not).
TRUE. Let e be the number of times p occurs in the prime factorization of x (which must exist by the Fundamental Theorem of Arithmetic). Then pe is a factor of x but pe+1 is not. It is important that e is allowed to be 0, to cover the case where p is not a factor of x at all.
FALSE. There is a path from 1 to 2 to 4 to 1 to 2 to 3 to 1. We can get from any node to any other node by following this path. So the graph is strongly connected.
TRUE. If there is an edge between i and j, one of the numbers is odd and the other even. So we can partition the nodes into odd and even, and be sure that no edge goes from odd to odd or from even to even.
FALSE. Both A* searches (with proper heuristics) and uniform-cost searches find an optimal path, and all optimal paths have the same total cost or they wouldn't be optimal. The advantage of A* search is that it may find an optimal path more quickly than uniform-cost search does.
TRUE. Since a tree is connected, the DFS will find all the nodes and will need to put all n-1 edges in the tree in order to do so (as each node other than the start node is found through a separate edge). If there are n-1 edges in the DFS tree and no other edges, then this tree is equal to the original graph, has n nodes and contains all the nodes.
TRUE. This is the Game Determinacy Theorem from the text. The algorithm marks every node of the game tree, starting from the leaves, as a winning position for either Black or White. When it marks the start node, it has the answer as to which player has the winning strategy.
TRUE. If Y is Σ*, which is regular, X could be any language at all, including a non-regular langauge like Paren.
TRUE. Representatives of the classes are λ, a, b, ab, and aa. The string ba is equivalent to ab, and every string w except for λ, a, b, ab, and ba four of these is equivalent to aa, because wx is not in the language for any string x.
TRUE. It is proved in the text that the langauge of any 2WDFA has finitely many Myhill-Nerode classes, and thus must be regular.
FALSE. For example, X could be &Sigma*, which is TD and therefore TR, and Y could be any language at all, including a non-TR language such as LBS.
FALSE. This is a garbled version of the TR-TD Theorem, which says that the language is TD if and only if both it and its complement are TR. It is true that if X is TD, both X and X-bar are TR. But the other half of the garbled version is false. For example, the langauge LBS-bar is TR, but neither it nor its complement is TD.
FALSE. It moves exactly one step left or right, unless it halts and does not move at all.
TRUE. The question is whether a Turing machine could take the description of a DFA as input and determine whether the DFA has a non-empty language. It has a non-empty language if and only if there is a path in the DFA's diagram from the start state to any final state. This can be determined by a DFS or BFS of the diagram's directed graph starting from the start state. Since an algorithm can solve this general problem, getting the correct solution for any DFA, by the Church-Turing thesis a TM could be designed to solve this problem.
Last modified 19 December 2018