# Final Exam Spring 2017

### Directions:

• Answer the problems on the exam pages.
• There are four problems, each with multiple parts, for 120 total points. Actual scale was A = 105, C = 70.
• Some useful definitions precede the questions below.
• No books, notes, calculators, or collaboration.
• In case of a numerical answer, an arithmetic expression like "217 - 4" need not be reduced to a single integer.

```  Q1: 30 points
Q2: 30 points
Q3: 25 points
Q4: 35 points
Total: 120 points
```

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:

• Statement I: There is a species that was observed by all the dogs.

• Statement II: ∀z: R(a, z) ↔ (z = C)

• Statement III: Every dog other than Arly observed at least two different species of bird.

• Statement IV: ∀x: [(x ≠ a) ∧ (x ≠ c)] → [(∀y:R(c, y) → R(x, y)) ∧ (∃z: R(x, z) ∧ ¬R(c, z))]

• Statement V: Duncan was the one and only dog who observed a Woodpecker, and Whistle was the one and only dog who observed a Bluebird.

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)
``````

• Question 1 (30): Identify each of the following fifteen statements as true or false. There are two points for each correct answer, with no explanation needed or wanted. Note that there is no penalty for guessing. Some of these statements refer to terms on the supplementary sheet.

• (a) Let x, y, and z be three positive integers such that there is no positive integer d, with d > 1, that divides all three. Let a, b, and c be any three integers. Then the congruences n ≡ a (mod x), n ≡ b (mod y), and n ≡ c (mod z) must have a common solution.

• (b) Let p, q, and r be three propositions. If p → q, q → r, and r → p are all true, then p, q, and r must all be true.

• (c) Statement IV above implies that the species observed by Cardie are a proper subset of the species observed by Duncan.

• (d) Let Q(x, y) be a binary predicate on naturals. If Q(0, 0) and ∀x: ∀y: Q(x, y) → Q(x+1, y+1) are both true, then ∀x: ∀y: Q(x, y) must be true.

• (e) Let P(x) be a unary predicate on naturals. If P(1), ∀x: P(x) → P(x+2), and ∀x: P(x) → P(2x) are all true, then P(x) must be true for all positive x, but P(0) may be false.

• (f) Let G be a directed graph with finitely many nodes and let s and t be nodes of G. If we perform a breadth-first search of G starting from s, without recognizing previously seen nodes, and there is a path from s to t, then the search will discover node t.

• (g) Let G be a directed graph. Suppose we carry out a depth-first search of G from some start node s, recognizing previously seen nodes, and the open list becomes empty after we have seen a proper subset S of the nodes of G. If we restart the search at a node outside of S, then any edges we find with destinations in S will become cross edges.

• (h) There exist weighted directed graphs, and admissible and consistent heuristic functions, for which A* search produces a path that is no shorter than the path produced by a uniform-cost search with the same start and goal node.

• (i) Consider the following two-player deterministic zero-sum game. White chooses to move Right or Left, then Black chooses to move Right or Left. If the sequence of moves is LL, White gets a payoff of 2. If it is LR, White gets -1. If it is RL, White gets 3, and if it is RR, White gets -2. Then if both players play optimally, White will get -1.

• (j) Let X be the language denoted by the regular expression (a+ab+ac)*. Then the strings acba and acbac are X-equivalent in the sense of the Myhill-Nerode Theorem.

• (k) A two-way DFA, when started on any string over its alphabet, always either accepts, rejects, or hangs after a finite number of steps.

• (l) Let M be a Turing machine with transition function δ, and let δ(q, a) be (p, b, L). Then if the configuration of M is aqab on one time step, it will be pabb on the next time step.

• (m) Let Y and Z be any two Turing recognizable languages. Then the language Y ∪ Z is also Turing recognizable.

• (n) Let M be a Turing machine with exactly two final states, one accepting and one rejecting. Recall that for such a TM, L(M) is the set of strings accepted by M. Let M' be the Turing machine made from M by switching the roles of the accepting and rejecting states, Then L(M') is the complement of L(M).

• (o) Let BT be the set of strings representing Turing machines that accept on blank input, that is, BT = {(M): λ ∈ L(M)|. Then there cannot exist an enumerator that outputs exactly the strings in BT, in order of length, with strings of the same length in alphabetical order.

• Question 2 (30): This question deals with the scenario described above, and with the five statements about a set of dogs D, consisting of exactly the five dogs Arly (a), Cardie (c), Duncan (d), Mia (m), and Whistle (w), and a set of five bird species S, consisting of Bluebird (B), Crow (C), Heron (H), Mallard (M), and Woodpecker (W). The relation R ⊆ (D × S) is defined so that for any dog x and any species y, (x, y) ∈ R if and only if dog x observed a bird of species y.

• (a, 10) Translate each of these five statements as indicated.

• Statement I: (to symbols) There is a species that was observed by all the dogs.

• Statement II: (to English) ∀z: R(a, z) ↔ (z = C)

• Statement III: (to symbols) Every dog other than Arly observed at least two different species of bird.

• Statement IV: (to English) ∀x: [(x ≠ a) ∧ (x ≠ c)] → [(∀y:R(c, y) → R(x, y)) ∧ (∃z: R(x, z) ∧ ¬R(c, z))]

• Statement V: ( to symbols) Duncan was the one and only dog who observed a Woodpecker, and Whistle was the one and only dog who observed a Bluebird.

• (b, 20) Assuming that Statements I-V are all true, prove that some dog observed a Heron. You may use either English or symbols, but make your use of quantifier rules clear.

• Question 3 (25): This question uses the language X and the functions f and g defined above. X is the language of the regular expression (a+ab+ac)*. The rules defining f are f(0) = 1, f(1) = 1, and for any n with n ≥ 1, f(n+1) = f(n) + 2(f(n-1). The function g is defined so that g(n) is the number of strings of length n in the language X.

• (a, 10) Prove by strong induction on all naturals n that f(n) = (2n+1 + (-1)n)/3. You will need base cases for n = 0 and n = 1.

• (b, 5) Compute the values of f(n) for all n with 0 ≤ n ≤ 4. By listing strings in X, show that f(n) = g(n) for these values of n.

• (c, 10) Prove by strong induction on all naturals n that f(n) = g(n). You may use part (b) for your base cases. For the general case, note that your argument must refer to strings and the regular expression defining X.

• Question 4 (35): This question is the usual one about Kleene's Theorem constructions, using both the regular expression (a+ab+ac)* and the NFA N given above.

• (a, 5) Use the construction from lecture and the text to find a λ-NFA whose language is denoted by the regular expression (a+ab+ac)*. (N is such a λ-NFA, but I want the one from the construction.)

• (b, 5) Explain informally (but convincingly) why L(N) = X.

• (c, 10) Using the Subset Construction on N, find a DFA D such that L(D) = L(N).

• (d, 5) Is your D minimal? Prove your answer. If it is not minimal, you are not required to minimize it, but just to show that it is not minimal.

• (e, 10) Use the construction from lecture and the text to obtain a regular expression denoting the language of your original D (from the Subset Construction in part (c)). Do not simplify your expression -- I want the one from the construction.