Q1: 30 points Q2: 20+10 points Q3: 40 points Q4: 30 points Total: 120 points
Question 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:
The web site WeRateDogs^{TM} gives numerical ratings
of animals based on photographs, and publishes these at
twitter.com/dog_rates
. They provided ratings for a set
A of six animals, consisting exactly of Cardie (c), Duncan (d), Floyd (f),
Mia (m), Pushkin (p), and Tib (t). We thus have a function r from A to
N where r(x) is the rating of animal x.
We have a number of additional predicates defined on A:
Question 2 also refers to the following six statements, where the variables are of type "animal or type "natural". The predicate P(n) means "natural n is prime".
The statements are:
N is the set of naturals (non-negative integers, {0, 1, 2,...}.
Again, we define the predicate P on N so that P(n) means "n is prime".
Question 2 uses a recursive function f from N to n defeind by the rules f(0) = 1, f(1) = 0, f(2) = 1, and for n ≥ 2, f(n+1) = 4f(n) - 5f(n-1) + 2f(n-2).
Question 3 uses the following λ-NFA N, which has state set {1, 2, 3}, start state 1, final state set {3}, and transition relation Δ = {(1, λ, 2), (1, b, 3), (2, a, 1), (2, λ, 3), (3, b, 2)}.
Here is a diagram of N, with "L" representing λ:
L
>(1) -----> (2)
| <----- |^
| a ||
| ||
| L||b
| ||
| b V|
------->((3))
E(f) ∧ (r(f) = 7) ∧ ¬∃x: (r(x) > 7) ∧ E(x)
Every animal's rating was a prime number, and every animal was rated above 10 if and only if it was a dog.
∃x: ML(x, t) ∧ (r(x) = r(t))
For every animal, there was some other animal that received the same rating as it.
∃x:∃y: (r(x) > r(p)) ∧ (r(y) < r(p)). Many people included x ≠ p and y ≠ p, which are the consequence of the two words "other" in the English statement. The statement does not say x ≠ y, though this follows from the properties of naturals and the fact that r is a function.
It is not the case that any two animals that are both dogs have the same rating. Equivalently, there exist two dogs with different ratings. Lots of people got this wrong, which had grave consequences on parts (b) and (c). Remember that a ¬ operator applies to the next item on its right, which in this case is the entire remainder of the statement because it is all in the scope of the ∀ quantifier.
We let P(n) be the statement "f(n) = 2^{n+1} - 3n - 1". For our base cases, we must verify P(0), P(1), and P(2), because the inductive case of the definition only tells us about f(n) for n ≥ 3. We must check that each of the three given values satisfies the formula: f(0) = 1 = 2^{1} - 3(0) - 1, f(1) = 0 = 2^{1} - 3(1) - 1, and f(2) = 1 = 2^{3} - 3(2) - 1.
For the strong induction, we assume that P(i) is true for all i with i ≤ n, where n ≥ 2. We then have to prove that f(n+1) = 2^{n+2} - 3(n+1) - 1 = 2^{n+2} - 3n - 4. To do this we apply the strong IH to f(n), f(n-1), and f(n-2), and plug these values into the equation defining f(n+1):
f(n+1) = 4(2^{n+1} - 3n - 1) - 5(2^{n} - 3n + 2) + 2(2^{n-1} - 3n + 5) = 2^{n-1}(16 - 10 + 2) - n(12 - 15 + 6) - 4 - 10 + 10 = 2^{n+2} - 3n - 4.
Now we let P(n) be "f(n) is odd if and only if n is even". For our base cases we must verify P(0), P(1), and P(2) because our inductive rule does not tell us about these cases. P(0) is true because f(0) is odd and 0 is even, P(1) is true because f(1) is even and 1 is odd. P(2) is true because f(2) is odd and 2 is even.
Now we can apply the strong IH and get that P(n), P(n-1), and P(n-2) are all true, which should help us verify P(n+1). We need two cases, one where n is odd and one where n is even. (Many of you apparently missed the fact that the "if and only if" statement meant that we were talking about both odd and even n.)
If n is odd, then n+1 and n-1 are both even, and the SIH tells us that f(n-1) is odd. The rule defines f(n+1) as 4f(n) - 5f(n-1) + 2f(n-2). The first and third of these terms are even whatever f(n) and f(n-2) are, and the second term is odd because it is the product of the odd numbers -5 and f(n-1). So f(n+1) is odd, as it should be.
If n is even, we still have f(n+1) defined as the sum of three terms. The first and third are still even, but now the second is even as well because n-1 is odd and therefore by the SIH f(n-1) is even. So f(n+1) is the sum of three even numbers, and is even as it should be.
Note that I did not ask you to prove this by induction, and no induction is necessary. Many of you got full credit for an "induction proof" that gave the argument below in the inductive case, never using any IH. Others of you got confused about what you were supposed to be proving.
Here we are assuming that g(n) = a2^{n} + bn + c for some real numbers a, b, and c, and proving that the rule g(n+1) = 4g(n) - 5g(n-1) + 2g(n-2) is valid. (The restriction to n ≥ 2 is a red herring.) This is actually quite easy:
g(n+1) = a2^{n+1} + b(n+1) + c
RHS of rule = 4(a2^{n} + bn + c) - 5(a2^{n-1} + b(n-1) + c) + 2(a2^{n-2} + b(n-2) + c) = 2^{n-2}(16a -10a + 2a) + n(4b - 5b + 2b) + (5b - 4b) + c(4-5+2) = 2^{n+1} + b(n+1) + c.
The machine for a+bb has three states {1, 2, 3} and transitions (1, a, 3), (1, b, 2), and (2, b, 3). Correction made 5 May 2018.) The one for (a+b)^{*} has four states {3, 4, 5, 6} with transitions (3, λ, 4), (4, λ, 5), (4, a, 5), (4, b, 5), (5, λ, 4), and (5, λ, 6). Merging these two machines by identifying the two states called "3" gives us a six-state answer, with start state 1 and final state set {6}.
The construction here gives exactly four λ-moves. Having more than one out of place generally got four points out of five, and correct machines that were further from the construction got three.
We still have state set {1, 2, 3} with start state 1, and state 1 becomes final because λ ∈ L(N), making the final state set {1, 3}.
To make the λ-moves transitively closed we must add one from 1 to 3.
The letter move (1, b, 3) gives rise only to itself. The letter move (2, a, 1) gives rise to six a-moves because it allows for a-paths from either 1 or 2 to any of 1, 2, or 3. The letter move (3, b, 2) gives rise to six b-moves because it allows for b-paths from any of 1, 2, or 3 to either 2 or 3. The move (1, b, 3) is created twice, so we have twelve total moves in N': (1, a, 1), (1, a, 2), (1, b, 2), (1, a, 3), (1, b, 3), (2, a, 1), (2, a, 2), (2, b, 2), (2, a, 3), (2, b, 3), (3, b, 2), and (3, b, 3).
The start state {1} is final. It has an a-arrow to {1, 2, 3} and a b-arrow to {2, 3}, both of which are final states. State {1, 2, 3} has an a-arrow to itself and a b-arrow to {2, 3}. State {2, 3} has an a-arrow to {1, 2, 3} and a b-arrow to itself. We complete the DFA with only three states, all of which are final. (This wasn't my original intention, but it turned out to be a reasonable problem anyway.)
We partition the three states into a single set F of three final states. (We don't consider the empty set of non-final states to be part of the partition, since every set in a partition must be non-empty.) Each state has an a-arrow to F and a b-arrow to F. Since all three states have the same behavior, we have reached the final partition. Our DFA D' has a single state for the class F, with a-arrow and b-arrow to itself. It is the start state and also the only final state.
Many of you observed that the complement of L(N) was the empty language, but for full credit I wanted you to carry out the construction. When we make a DFA for the complement of L(D') out of D', we get one state p which is non-final and has both arrows to itself. To continue, we must add a new start state i and a new final state f, with a λ-move from i to p. Since there are no final states in the DFA for the complement, we don't add any λ-moves to f. Now we have a three-state r.e.-NFA and we can eliminate state p, which creates no new moves becuause there are no moves out of p. This yields a two-state r.e.-NFA with no moves at all, and we can observe that its regular expression is ∅ because the absence of any transition is the same thing as a transitition labeled ∅.
TRUE. It is reflexive, symmetric, and transitive because equality on naturals has these three properties/
TRUE. It is antisymmetric because we cannot have two different animals each much larger than the other (both would have be both enormous and not enormous). It is transitive because it is impossible to have both ML(x, y) and ML(y, z) be true for any x, y, and z (y would to be both enormous and not enormous). It is not reflexive (in fact it is antirelexive) because ML(x, x) would force x to be both.
TRUE. We can eliminate all the even numbers in that range and check the odds. 117 and 123 are divisible by 3, 119 = 7(17) and 121 = 11^{2}.
TRUE. C(w) could be, for example, "w ≠ b", and would have all these properties.
FALSE. Node v is part of a graph-theoretic tree, its connected component of the forest. Both searches will include all the edges of this tree as tree edges, directed away from v, so the two trees will be identical.
FALSE. Any path with n or move edges must include n+1 or more nodes and thus include the same node more than once. There must then be a shorter path obtained by deleting the edges between two visits to the same node. So the shortest path cannot have n or more edges. If any path exists, a shortest path must also exist.
TRUE. A string in this regular langauge consists of zero or more strings from {ab, ba}, the string aa, and zero or more strings from {a, b}. Any such string can be made from aa by prepending copies of ab and ba, and appending copies of a and b. Each such move preserves the property b, so that property holds for the final string as well.
FALSE. The language (a+b)^{*} from Question 3 is a counterexample (and in fact the only counterexample). It has a single equivalence class and its minimual DFA has only one state, but it is not the empty language.
TRUE. You can think of the sequence of strings as the points of a tennis match between players A and B, starting from deuce but possibly continuing after one player has one. Then AW is the set of strings in which Player A wins the match by getting a two-point lead before Player B does. Such a string consists of zero or more substrings of the form ab or ba (which return the game to a tie) followed by a string aa (causing Player A to win), followed by any string at all. This is exactly the set of strings defined by that regular expression.
FALSE. If k is the number of states in the 2WDFA, it cannot take more than kn steps without being in a loop. But it can easily take more than n. Consider with a start state 1, in which it moves right until it sees an a, then moves left and enters state 2. In state 2 it moves left until it sees a b, then moves right and enters state 3, in which it moves right to the end of the string. On the string b^{n-1}a, it makes n-1 moves right, one move left, and then two moves right, taking n+2 moves total and then terminating. (Corrections in bold made 19 December 2018.)
TRUE. From the configuration pab, the next step takes it to aqb, and the following step takes it back to pab. So it loops through these two configurations forever.
TRUE. We make a Turing machine N' that simulates N until or unless it reaches a halting state. N' accepts if it reaches either h or h', and rejects if it reaches any other halting state. Then it is possible for N' to accept w if and only if it is possible for N to reach either h or h' on input w. Thus L(N') = X ∪ X'. We know that the language of any NDTM is Turing recognizable.
FALSE. We can make a Turing machine M that runs recognizers for X, Y, and Z in parallel, until or unless two of the three recognizers have accepted. On an input w in Q, this will eventually happen because w is in at least two of the languages. But if w is not in Q, it is in at most one of the three languages and M cannot accept it. Therefore Q = L(M) and Q is Turing recognizable.
FALSE. Using the universal Turing machine, we can make a machine Z that inputs a machine description for a machine M and then simulates M on its own description, accepting if and only if M accepts its own description. The given set is thus equal to L(Z) and must be Turing recognizable.
TRUE. We can make a Turing machine Y that inputs a machine description for M and then, in parallel, simulates M on all possible strings, accepting if any of these computations accepts. If L(M) is non-empty, one computation will eventually accept and thus Y will accept M. If L(M) is empty, Y cannot accept M. So this set is equal to L(Y), making it Turing recognizable.
Last modified 19 December 2018