Q1: 30 points Q2: 30 points Q3: 25 points Q4: 35 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.
Remember that the scope of any quantifier is always to the end of the statement it is in.
Remember that a natural is a non-negative integer, so that the set N or all naturals is {0, 1, 2, 3,...}.
Question 2 deals with the following scenario. All of the dogs in my neighborhood are avid birdwatchers. One day, a set of five dogs met after their morning walks to compare their observations of five possible bird species. The set D of dogs consists exactly of Arly (a), Cardie (c), Duncan (d), Mia (m), and Whistle (w). The set S of species consists exactly of Bluebird (B), Crow (C), Heron (H), Mallard (M), and Woodpecker (W). The relation R ⊆ (D × S) is defined so that (x, y) ∈ R means "dog x observed a bird of species y".
Question 2 also refers to the following five statements, where the variables are of type "dog" or of type "bird species".
The statements are:
Question 3 uses a recursive function f from N to N defined by the rules f(0) = 1, f(1) = 1, and for n ≥ 1, f(n+1) = f(n) + 2f(n-1).
Questions 3 and 4 both use a language X over the alphabet {a, b, c}, which is denoted by the regular expression (a+ab+ac)*.
Question 3 uses the function g from N to N, defined so that g(n) is the number of strings of length n in the language X.
Question 4 also uses the following ordinary NFA N, which has state set {p, q, r}, start state p, final state set {p}, and transition relation Δ = {(p, a, p), (p, a, q), (p, a, r), (q, b, p), (r, c, p)}.
The ordinary NFA N:
---
| | a
| V a
>((p)) -----> (q)
^ | <-----
| | b
c| |a
| |
| V
(r)
FALSE. This would be true if x, y, and z were pairwise relatively prime. We could have x = 2, y = 3, and z = 4, which have no factor common to all three but are not pairwise relatively prime. Then if a were 0 and c were 1, there would be no common solution.
FALSE. If p, q, and r are all false, those three implications are all true.
TRUE. The statement says that Duncan saw all of Cardie's species plus at least one more, which is the definition of Cardie's species being a proper subset.
FALSE. Q(x, y) might true when x = y and false otherwise, and all the given conditions would still be true.
TRUE. The given conditions suffice to prove P(x) for all positive naturals, either by odd/even induction or by string induction, once we use the last condition to prove P(2).
TRUE. BFS always finds a path if one exists, when the graph has only finitely many nodes, even if we don't recognize previously seen nodes.
TRUE. Such edges will have destinations that are neither ancestors nor descendants of their sources in the DFS forest. This is because the destinations will be in the first tree of the forest, and the sources will be in subsequent trees.
TRUE. In fact, whenever the heuristic is admissible and consistent, and A* returns a path, it will be the same length as the path found by uniform-cost search.
TRUE. An optimal White wil move Left on the first move, whereupon an optimal Black will move Right to get payoff for White. If White moved Right on the first move, Black would move Left to force a payoff smaller than -1, so an optimal White will not do this.
TRUE. Neither string can be made into a member of X by appending any string at all.
FALSE. It might get stuck in a loop, where it continues to compute forever without ever halting or hanging.
TRUE. The machine is in state q and sees an a, so by the given rule it changes to state p, prints a b over the a it was looking at, and moves left. The tape contents change from aab to abb, and the machine is looking at the first character after the step, in state p.
TRUE. We could build a new TM that would run recognizers for Y and Z, in parallel, on the given input. If either recognizer accepts, it will accept. If both reject, the new TM may reject, but otherwise it will run forever, which is fine because the input is not in Y ∪ Z.
FALSE. If M never halts on some string, it will be in neither L(M) nor L(M'). So L(M) and L(M') will not be complements in that case because their union will fail to include all possible strings.
TRUE. We proved in lecture that this language BT is not Turing decidable. But if this enumerator existed, we could decide membership in BT for an arbitrary string w. We would run the enumerator until it either output w (whereupon we would accept) or output a string longer than w (whereupon we would reject). One of these has to happen because there are arbitrarily long strings in BT and the enumerator must get to all of them.
∃y: ∀x:R(x, y)
For every species, Arly observed that species if and only if it was Crow. Equivalently, Arly observed crows and only crows.
∀x: (x ≠ a) → (∃y:∃z:R(x, y) ∧ R(x, z) ∧ (y ≠ z)). It's important to specify that the two species observed are not the same.
If any dog is neither Arly nor Cardie, then it observed all the species that Cardie observed, and observed at least one species that Cardie did not.
∀x: (R(x, W) ↔ (x = d)) ∧ (R(x, B) ↔ (x = w))
The simplest proof is to note that Mia must have seen at
least three species, since Cardie (who is not Arly) observed at
least two by III and Mia (who is neither Arly nor Cardie) observed
those two plus at least one more by IV. Since by V those three
species cannot have included Woodpecker or Bluebird, they must
have been Crow, Heron, and Mallard, and thus Mia saw a Heron.
If we just gather information from the earlier statements, we
can get to the same conclusion. The species observed by all the
dogs in I must have been Crow by II, since Arly saw no other
species. Specializing III to Cardie, we find that she has seen
some species other than Crow. This cannot have been Woodpecker
or Bluebird by V, so it must have been Heron or Mallard. If it
was Heron, we are done. If it was Mallard, we can specify III
to Mia and look at the species she saw that Cardie did not. This
cannot have been Crow or Mallard (which Cardie saw) or Woodpecker
or Bluebird (which Mia did not see) so it must have been the Heron.
In either case we get ∃x:R(x, H) by Existence.
Base case n = 0: (20+1 + (-1)0)/3 = (2+1)/3 = 1.
Base case n = 1 (21+1 + (-1)1)/3 = (4-1)/3 = 1.
Inductive case for strong induction:
We are given that f(n+1 = f(n) + 2f(n-1). By the strong IH, since
n ≥ 1, f(n) = (2n+1n)/3 and
f(n-1) = (2n-1+1 + (-1)n-1)/3. So f(n+1) =
(2n+1 + (-1)n +
2(2n + (-1)n-1))/3 =
(2n+2 + (-1)n+1)/3.
n = 0: f(n) = 1 given, only string is λ.
n = 1: f(n) = 1 given, only string is a.
n = 2: f(2) = f(1) + 2f(0) = 1 + 2 = 3, strings are aa, ab, ac.
n = 3: f(3) = f(2) + 2f(1) = 3 + 2 = 5, strings are
aaa, aab, aac, aba, aca.
n = 4: f(4) = f(3) + 2f(2) = 5 + 6 = 11, strings are
aaaa, aaab, aaac, aaba, aaca, abaa, abab, abac, acaa, acab, acac.
The base cases of n = 0 and n = 1 were verified in part (b). Assume that f(n) = g(n) and that f(n-1) = g(n-1), using the strong IH. Then g(n+1) is the number of strings of length n+1 in X. These strings may be formed either by appending an a to a string in X of length n, or by appending an ab or an ac to a string in X of length n-1. There is no double counting since the first set of strings each end in a and the second does not. So we have g(n) = f(n) strings of the first kind and 2g(n) = 2f(n) of the second kind. By definition, f(n+1) is equal to f(n) + 2f(n-1), and by this analysis g(n) is also equal to that.
The λ-NFA from the construction has six states. There is a start state i with λ-arrow to state p. State p has a-arrows to states q, r, and s, and a λ-arrow to s. State q has a b-arrow to s, and state r has a c-arrow to s. State s has λ-arrows to p and to state f. There are no other arrows, and f is the only final state.
A string is in L(N) if and only if it can label a path in N from state p to itself. Such a path must consist of zero or more phases between visits to p, and thus of zero or more subpaths labeled by a, ab, or ac. A string is in (a+ab+ac)*, by definition, if and only if it is the concatenation of zero or more strings, each of which is either a, ab, or ac.
We have start state {p}, which is final since p is final in N.
The a-arrow from {p} goes to {p, q, r}, which is a final state.
The b-arrow and c-arrow from {p} both go to ∅, a non-final state,
since there is no b-arrow or c-arrow from p in N.
From {p, q, r}, the a-arrow goes to {p, q, r} and the b-arrow and
c-arrow both go to {p}.
From ∅, all three arrows go to ∅.
The process is complete with three states in the DFA.
This DFA is minimal, because the two final states are separated by b (since b takes {p} to a non-final state but takes {p, q, r} to a final state). So they cannot be merged, and any correct DFA must have at least two final states and at least one non-final state.
We add a new start state i and a new final state f, adding
&-moves from i to {p}, from {p} to f, and from {p, q, r} to f.
We eliminate ∅, which produces no new arrows since there
are no arrows out of ∅.
We then eliminate {p}, which produces moves
(i, λ, f), (i, a, {p, q, r}),
({p, q, r}, (b+c)a, {p, q, r}), and ({p, q, r}, b+c, f).
Then eliminating {p, q, r} produces the final regular
expression λ + a(a+ba+ca)*(λ+b+c).
Though it looks a bit different, this is equivalent to
(a+ab+ac)*, since any non-empty string in the
latter can be divided into an a, zero or more a's, ba's and
ca's, and an optional b or c.
Last modified 20 July 2017