CSC444 - Formal Grammars and Automata
Quiz#1


  1. Relations.
    1. Give a relation on the set {1,2,3,4} which is transitive and reflexive, but not symmetric.
    2. A = {-1, 0, 1}, S = A x A and P = S x S. How many elements are in P?
    3. R is the subset of P defined by:
      R = {( (a1,b1), (a2,b2) ) | 
                abs(a1) = abs(a2) and abs(b1) = abs(b2) }
      

      where abs(x) is the absolute value of x.

      Is R a symmetric relation on S?

    4. Is R a transitive relation on S?
    5. Is R a reflexive relation on S?
  2. Prove P = (P - Q) ∪ (P ∩ Q) for all sets P and Q. (You don't get to choose P and Q; your proof has to work for all choices of P and Q.) Hint: Split the proof into two parts.

    To show that X = Y for two sets X and Y, it is enough to show X ⊆ Y and Y ⊆ X. To show that X ⊆ Y, you must show that for any a, if a ∈ X, then it is also true that a ∈ Y.

    Also note that A - B = { x | (x in A) and (x not in B) }

    As an example of the kind of proof that is acceptable, here is a proof that
    A ∩ (B ∪ C) ⊆ (A ∩ B) ∪ (A ∩ C):

    For any x,
    x ∈ A ∩ (B ∪ C) 
    => x ∈ A and x ∈ (B ∪ C) 
    => x ∈ A and (x ∈ B or x ∈ C) 
    => (x ∈ A and x ∈ B) or (x ∈ A and x ∈ C)
    => x ∈ (A ∩ B) or x ∈ (A ∩ C) 
    => x ∈ (A ∩ B) ∪ (A ∩ C)
    
    So A ∩ (B ∪ C) ⊆ (A ∩ B) ∪ (A ∩ C)
    
  3. Prove the following statement.

    Proposition: For any y in R = {0,1,2,...,30}, the equation
       y = 6 * x % 31 (where % is the mod operator)
    
    has a solution x in R.

    For example, for y = 11, there must be an x such that

          11 = 6*x % 31 
          (The answer is x = 7.) 
    

    However, you don't get to choose y. You are trying to show this is true for every y in R. Hint: You may use the following fact.

    Since 31 is prime, for any x1 and x2 in R = {0,1,2,...,30}, if

    x1 ≠ x2

    then

    6*x1 % 31 ≠ 6* x2 % 31

    For example, for x = 0,1,2,...,7, the corresponding values of 6 * x % 31 are all distinct:

    x 6*x % 31
    0 0
    1 6
    2 12
    3 18
    4 24
    5 30
    6 5
    7 11
  4. Give an NFA for L = { w: w has an even number of 0's or exactly two 1's }. E.g. L contains 0010110 and 01001, but not 00101100 or 0100

  5. Give a regular expression for the language L of the previous problem.

  6. Show that the following set is not regular. You may use the pumping lemma and the closure of the class of regular languages under union, intersection, and complement.

    L = { 0nw | n >= 0, w ∈ {0,1}* and w contains exactly n 1's and 0 or more 0's }

     

  7. Use the pumping lemma to show that the following language is not regular.

    L = { 0n1m0n | n >= 0 and m > 0}