CMPSCI 250: Introduction to Computation

Solutions to Final Exam Spring 2018

David Mix Barrington

Exam given 8 May 2018

Solutions posted 18 May 2018

Directions:

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

Exam 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:

Many of the dogs in my neighborhood are fans of rap music. One day a set D of four dogs: Cardie (c), Duncan (d), Rio (r), and Scout (s) met to discuss their preferences among a set R of four rap artists: Cardi B (CB), Drake (DR), Kendrick Lamar (KL), and Kanye West (KW).

Note that variables and constants with lower case letters denote dogs, and those with capital letters denote rappers. Note also that Cardie the dog is spelled differently from Cardi B the rapper.

The predicate P(x, Y, Z) means "dog x prefers rapper Y to rapper Z". Each dog's preferences establish a total order on the rappers, so that for each dog x the predicate "(Y = Z) ∨ P(x, Y, Z)" is reflexive, antisymmetric, transitive, and total.

Question 1 also refers to the following five statements, where the variables are of type "dog" or type "rapper".

The statements are:

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

Question 2 uses a recursive function f from N to N defined by the rules f(0) = 1, and for n ≥ 0, f(n+1) = f(n) + n2 + n - 1.

Question 2 also refers to the language L, over the alphabet {a, b, c}, which is denoted by the regular expression (∅* + b + bb)(a + ab + abb + acc)*. Note that a similar but different regular language is the subject of Question 3.

Question 2 also uses a recursive function g from N to N, defined by the rules g(0) = 1, g(1) = 2, g(2) = 4, and, for n ≥ 2, g(n+1) = g(n) + g(n-1) + 2g(n-2).

Question 3 uses the following λ-NFA N, which has state set {1, 2, 3, 4}, start state 1, final state set {1}, alphabet {a, b, c}, and transition relation Δ = {(1, a, 2), (2, λ, 1), (2, b, 3), (2, c, 4), (3, b, 1), (3, λ, 1), and (4, c, 1)}.

Here is a diagram of N, with "L" representing λ:



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