Q1: 10 points Q2: 25 points Q3: 25 points Q4: 35 points Q5: 30 points Total: 125 points
Question text is in black, solutions in blue.
Correction in orange made 1 May 2015.
Definitions and Other Notes: Question 2 refers to the following five statements, where the variables are of type "dog", the set of dogs include the four distinct dogs Cardie, Duncan, Jack, Rosa, and possibly others, the predicate A(x) means "dog x is asleep", and the predicate B(x) means "dog x is barking".
N is the set of naturals, {0, 1, 2, 3,...}, and Z is the set of integers, {..., -3, -2, -1, 0, 1, 2, 3,...}.
Question 3 uses an inductively defined function from N to Z. We define f(0) = 1, and for any positive integer n we define f(n) = 2f(n-1) + n(n-3).
Question 4 uses the following two formal languages over the alphabet {a, b}. The language X is the set of all strings that have strictly more b's than they have a's. The language Y is defined inductively as follows:
Question 5 uses the following λ-NFA N. Th alphabet is {a, b}, the state set is {1, 2, 3}, the start state is 1, the final state set is {2}, and the transition relation Δ is {(1, λ, 2), (2, a, 2), (2, a, 3), (3, b, 1), (3, b, 3)}.
Here is a diagram of N, with "L" meaning "λ":
L
>(1) ---> ((2))<-\
^ / | |
| / |____| a
b | /
| /
| / a
| /
| /
|V
(3)<-\
|___| b
A free variable is one whose value must be provided to determine the meaning of the statement. For example, in "∃x: P(x, y)", y is a free variable and x is a bound variable.
The statement "a ≡ b (mod m)" means that a and b have the same remainder when divided by m, i.e., that a % m = b % m. Equivalently, it means that m divides the integer a - b.
A one-to-one function from X to Y is a function from X to Y such that there are not two distinct elements of X mapping to the same element of Y. A common wrong answer was "every element of X maps to exactly one element of Y", which is wrong because any function has this property. Many people said "each element of X maps to a unique element of Y", which would be right if it meant "each element of X maps to a different element of Y", but could also mean the wrong answer as well.
A directed multigraph is a set of nodes and arcs, where each arc is directed from one node to another (or from one node to itself), and multiple arcs may have the same source and destination. Hardly anyone had the correct definition of "multigraph" that included parallel edges.
The concatenation product is the language XY consisting of all strings uv where u is an element of X and v is an element of Y.
¬∃x:(A(x) ∧ B(x)), or equivalently ∀x:¬(A(x) ∧ B(x)).
If either Rosa or Jack (or both) is barking, then Duncan is barking.
(B(j) ∨ ¬B(r)) → (B(j) ∧ A(d))
If any dog is barking, then Cardie is asleep. (A common incorrect answer misread the parentheses to get "There exists a dog such that if it is barking, then Cardie is asleep".)
¬∀x: ∀y:(¬B(x) ∧ ¬B(y)) → (x = y), or equivalently ∃x: ∃y: ¬((¬B(x) ∧ ¬B(y)) → (x = y)).
Assume B(j). By II, B(d) is true, but by III, A(d) is also true and "B(d) ∧ A(d)" contradicts I. So we have proved ¬B(j) by contradiction. The contrapositive of III says "(¬B(j) ∨ ¬A(d)) → (¬B(j) ∧ B(r))". From this we get B(r) by Modus Ponens, and this gives us B(d) by II. So B(d) and B(r) are true, and B(j) is false.
The existential form of V is ∃x:∃y: ¬((¬B(x) ∧ ¬B(y)) → (x = y)), or equivalently ∃x:∃y: ¬B(x) ∧ ¬B(y) ∧ (x ≠ y). (A disturbingly large fraction of you failed to compute the negation of the implication correctly.)
To prove this existential statement by the Rule of Existence, we need to identift two distinct dogs that are not barking. Since we are assuming I, II, and III, to be true, we may use the conclusions of part (b). We have ¬B(j), and from B(r) we may derive ∃x:B(x) by Existence and then A(c) by Modus Ponens on IV. From I (specialized to c) we have ¬(B(c) ∧ A(c)), from which ¬B(c) follows. Thus Jack and Cardie can be our dogs x and y, letting us prove the existential form of V by using Existence twice. (We are told that no two of the named dogs are equal to one another.)
f(1) = 2f(0) + 1(-2) = 2 - 2 = 0.
f(2) = 2f(1) + 2(-1) = 0 - 2 = -2.
f(3) = 2f(2) + 3(0) = -4.
f(4) = 2f(3) + 4(1) = -8 + 4 = -4.
f(5) = 2f(4) + 5(2) = -8 + 10 = 2.
f(6) = 2f(5) + 6(3) = 4 + 18 = 22.
For the base case of n = 1, we showed above that f(1) = 0, and 0 is even. For the inductive case, we assume that f(n) is even and prove that f(n+1) is even. By the given rule, f(n+1) = 2f(n) + (n+1)(n-2). The number 2f(n) must be even because 2 times any integer is even. (We don't need the IH here, except perhaps to say that f(n) is an integer.) The number (n+1)(n-2) is guaranteed to be even, because if n is even then n-2 is even, and if n is odd then n+1 is even, so (n+1)(n-2) has an even factor. Hence the sum for f(n+1) is even.
For the base case of n = 0, we are given that f(0) = 1 and we can compute that 2^{0} - 0(0+1) = 1 - 0 = 1.
For the inductive case, we assume that f(n) = 2^{n} - n(n+1) and we want to show that f(n+1) = 2^{n+1} - (n+1)(n+2).
By the given rule, f(n+1) = 2f(n) + (n+1)(n-2) and by the IH, this is equal to 2(2^{n} - n(n+1)) + (n+1)(n-2). We can compute that this is 2^{n+1} - 2n(n+1) + (n+1)(n-2) = 2^{n+1} + (n+1)(-2n + n - 2) = 2^{n+1} - (n+1)(n+2). We have proved the desired statement for n+1 and completed the proof.
Let P(w) be the statement "w ∈ X". We want to prove P(w) for all strings w in Y. The base case of the induction on the definition is P(b), which is true because "b" has more b's than a's. For the inductive case, we assume P(w) and prove P(wab) and P(wbba). Because P(w) is true, we know that w has more b's than a's. Since wab has one more a and one more b than w, it also has more b's than a's. Since wbba has one more a and two more b's than w, it also has more b's than a's. This completes the induction on Y, because rule (3) in the definition of Y says we have now covered all cases of strings in Y.
The easiest way to do this is to note that Y is the language of the regular expression b(ab+bba)^{*}, by the definition of Kleene star, and then quote Kleene's Theorem to the effect that any regular language has a DFA. It is also simple to build an NFA for Y with five states, which actually becomes a DFA for Y if you add a sixth state that is a death state and connect all missing arrows to it. Kleene's Theorem also says that an NFA may be converted to an equivalent DFA.
X is not regular, because we can prove that it has no DFA. For any two natural numbers i and j with i > j, the strings a^{i} and a^{j} are X-distinguishable; we prove this by noting that a^{i}b^{i} is not in X but a^{j} is. Since there is an infinite set of pairwise X-distinguishable strings, the Myhill-Nerode Theorem says that X has no DFA. (Hardly anyone had a correct proof, though many claimed that there were infinitely many classes. A lot of people showed that Y is a regular language, which says nothing about whether X is.)
We need a Turing machine that when started on any string w, halts in an accept state if w is in X and halts in a reject state if it is not. There are two natural approaches to constructing such a Turing machine: (1) repeatedly eliminate one a and one b from the string until you can't find one of each, whereupon you accept if and only if there is a b left, or (2) construct one or two binary counters off to the right of w, then making a pass over w, updating the counter or counters for each letter in w and accepting at the end if the counters show more b's than a's. In approach (1), you need to indicate how the TM can organize the eliminations -- if you replace a's and b's with blanks you are no longer searching a string that contains only a's and b's. You could replace letters with c's rather than blanks, or just mark the limits of w at the start. In approach (2) you need to mark where you are in w when you move the head over to change the counter.
There is one λ-move, so we needn't worry about transitive closure, but we must make state 1 a final state because it has a λ-path (of one edge) to a final state. The letter move (2, a, 2) gives us itself and (1, a, 2). The letter move (2, a, 3) gives us itself and (1, a, 3). The letter move (3, b, 1) gives us itself and (3, b, 2). Finally the letter move (3, b, 3) gives us only itself.
We have an ordinary NFA N' with state set {1, 2, 3}, start state 1, final state set {1, 2}, and seven transitions: (1, a, 2), (1, a, 3), (2, a, 2), (2, a, 3), (3, b, 1), (3, b, 2), and (3, b, 3).
Some people got a correct ordinary NFA by merging states 1 and 2 to get an NFA with state set {2, 3}, start state 2, final state set {2}, and transitions (2, a, 2), (2, a, 3), (3, b, 2), and (3, b, 3). But they did not explain why this NFA is equivalent to N and thus did not get full credit.
Using the N' given above, we begin with start state {1} which has an a-move to {2, 3} and a b-move to ∅. Of course ∅ has both an a-move and a b-move to itself. The state {2, 3} has an a-move to itself and a b-move to {1, 2, 3}. The state {1, 2, 3} has an a-move to {2, 3} and a b-move to itself, so we have finished the construction finding only four of the eight possible states. The final states of D are {1}, {2, 3}, and {1, 2, 3}, since both 1 and 2 are final states of N'.
We examine the three final states {1}, {2, 3}, and {1, 2, 3}: State {1} goes to final on a and nonfinal on b, while the other two go to final on both a and b. We thus make a second partition of the states with {1} and ∅ in classes by themselves and {2, 3} and {1, 2, 3} together in a class X. Both states in X go to X on both a and b, so we can merge X into a single state and get a three-state DFA D'. The state set is {{1}, ∅, X}, the start state is {1}, the final state set is {{1}, X}, and the transition function has δ({1}, a) = δ(X, a) = δ(X, b) = X, and δ(1, b) = δ(∅, a) = δ(∅, b) = ∅.
Starting from D', we add a new final state f. (We don't need a new start state as there is no arrow into {1}.) We add transitions ({1}, λ, f) and (X, λ, f). We kill ∅, which requires no new transitions. We kill X, which creates a new transition ({1}, a(a+b)^{*}, f) which merges with the existing ({1}, λ, f) to make ({1}, λ + a(a+b)^{*}, f). From this we can read off the regular expression λ + a(a+b)^{*}.
If we instead start with N, for example, we need new start and final states i and f, with transitions (i, λ, 1) and (2, λ, f). We can kill 3 to get one new transition (2, ab^{*}b, 1). We can then kill state 1 to get two new transitions (i, λ, 2) and (2, ab^{*}b, 2) -- the latter merges with (2, a, 2) to make (2, a + ab^{*}b, 2). Finally killing state 2 gives us a single transition with label λ + (a + ab^{*}b)^{*}.
Last modified 1 May 2015