CMPSCI 250: Introduction to Computation

Solutions to Final Exam

David Mix Barrington

18 December 2015

Directions:

  Q1: 10 points
  Q2: 20 points
  Q3: 20 points
  Q4: 30+10 points
  Q5: 40 points
Total: 120+10 points

Question text is in black, solutions in blue.

Correction in green made 20 April 2016.

Question 3 deals with a set D of dogs, containing the three distinct dogs Ali (a), Cardie (c), and Duncan (d), and possibly others, and a set of exactly four commands C, consisting of "come here" (ch), "fetch" (f), "roll over" (r), and "sit" (s). The predicate O(x, y) means "dog x obeys command y".

Question 3 also refers to the following five statements, where the variables are of type "dog" or type "command":

N is the set of naturals (non-negative integers), {0, 1, 2, 3,...}, and Z is the set of all integers, {..., -3, -2, -1, 0, 1, 2, 3,...}.

Question 4 uses a recursive function from strings to integers. Let Σ be the alphabet {a, b, c}. Define a function f from Σ* to Z recursively by the rules f(λ) = 0, f(wa) = 3f(w) - 1, f(wb) = 3f(w), and f(wc) = 3f(w) + 1.

Question 5 begins with the following λ-NFA N. The alphabet is {a, b}, the state set is {1, 2, 3}, the start state is 1, the final state set is {1}, and the transition relation Δ is

{(1, a, 2), (2, b, 3), (3, a, 1), (3, λ, 1)}.

Here is a diagram of N, with "L" meaning λ. Note that there are two parallel edges from 3 to 1. There is no state at the southeast corner of the diagram -- the edge from 2 to 3 turns a corner there.



        a
>((1)) - - - - - > (2)
   ^                |          
   |                |
   |                |            
   |a, L            |
   |                | b
   |                |
  (3)< - - - - - - <

Last modified 20 April 2016