CSC 341 Grinnell College Spring, 2014
 
Automata, Formal Languages, and Computational Complexity
 

Assignments

Quick Links:   February   March   April   May

The accompanying table indicates assignments and due dates for Computer Science 341 and are subject to the following notes.

Submission Format: Paper Only

Due to logistical considerations, all written assignments must be submitted in paper form at the start of the class that they are due.
Electronic submissions are not reviewed or graded; repeated electronic submissions may yield negative scores as nuisance email.


Due Date Collaboration Chapter Problems Notes
Mon., Jan. 27
yes
0
0.4, 0.7, 0.9, 0.11 The formal definition of a graph is a set of vertices and a set of edges. Thus, for Exercise 0.9, you need to translate the content of the given figure into the definition of appropriate sets. (Of course, explanation is needed.)
no
0
Supp. Prob. 12 Be sure to state any induction hypothesis carefully!
Mon., Feb. 3
yes
1
1.4be, 1.5ceg, 1.6aijl, 1.8ab  
no
1
Supp. Prob. 3a  
Mon., Feb. 10
yes
1
Use the instructions of 1.21 on the NFAs of 1.16; 1.53  
no
1
Supp. Prob. 3b, c, Supp. Prob. 4 For 3b and 3c, please include your NFA for 3a, so the starting point will be clear.
Mon, Feb. 17 Hour Test 1 Covers Chapters 0, 1
Mon., Feb. 24
yes
2, 3
Supp. Prob. 5, Supp. Prob. 6, Supp. Prob. 7, Supp. Prob. 9  
no
2, 3
Supp. Prob. 8, Supp. Prob. 10  
Wed., March. 3
Due at 11:30 am at my office
yes
2, 3
Supp. Prob. 11, Supp. Prob. 12ab, Supp. Prob. 13 Of course, the standard rules for quotation and citation apply. Note, however, that for problem 12, copying or slightly modifying the wording from another source will yield very few points (e.g., upper bound 0).
no
2, 3
Supp. Prob. 12cd, Supp. Prob. 14
Fri, Mar. 14 Hour Test 2 Covers Chapters 0-4
Wed., April. 8
yes
4
Supp. Prob. 15, Supp. Prob. 16  
no
4
Supp. Prob. 17  
no
Film Summary: Reasoning about Programs by Edsgar Dijkstra Film shown in class on Friday, April 4; summary should be reasonably detailed and extend at least 2/3 page. What are the main themes, how do the problems relate to those themes, and how are the themes addressed?
Mon., April. 14
yes
Supp. Prob. 18 Program binary-search-alternatives.c may be downloaded, compiled, and run to check your reasoning. However, answers to this question must focus on reasoning about loop invariants. Running the program with superficial reasoning will yield few, if any, points.
Fri., April. 18
yes
5
Supp. Prob. 19, Supp. Prob. 20  
no
5
Supp. Prob. 21  
Wed., April. 23
yes
5
Supp. Prob. 22, Supp. Prob. 23  
no
5
Supp. Prob. 24  
no
Take-home Test Distributed Covers Chapters 1-5, 7
Fri., Apr. 25
group
Class Presentations on NP Complete Problems
Mon., Apr. 28
group
Class Presentations on NP Complete Problems
Wed., Apr. 30
group
Class Presentations on NP Complete Problems
no
Take-home Test Due Covers Chapters 1-5, 7
Due Date Collaboration Chapter Problems Notes


Supplemental Problems

  1. Prove:
    12 + 22 + ... + n2 = n(n+1)(2n+1)/6
    for all positive integers n.
  2. Definition: The height of a non-empty tree is defined as the number of nodes on the longest path from a leaf of a tree to its root; the height of an empty tree is defined to be 0.

    Nodes in a Binary Tree: Suppose a binary tree T has height h. Prove that T contains at least h nodes and at most 2h - 1 nodes.

  3. Comments in Java: Java allows two types of comments:

    For the purposes of this problem, suppose all characters within a Java program are from the set {/, *, a, b, N}, where N represents the end-of-line character. (In a real Java program, of course, the characters a, b would be extended to all letters, digits, punctuation, etc., but that seems too extensive for this exercise.)

    1. Write an NFA with no more than 10 states that accepts exactly the comments in Java (within this limited alphabet).
    2. Using the construction(s) in the book, translate your NFA from part a into a DFA.
    3. Using the construction(s) in the book, translate your NFA from part a into a regular expression.
  4. Consider the alphabet Σ = {0, 1}. For a string s ∈ Σ*, define sR as the reverse of s. That is, the characters in sR are the same as the characters in s, but the characters appear in the reverse order. Is {s sR | ∈ Σ*} a regular language? Give a careful justification for your answer.

  5. Strings with complementary numbers of a's, b's, and a's: Working with the alphabet Σ = {a, b}, consider the language M that contains all strings over Σ of the form anbnan, where n is any non-negative integer.

    Determine whether or not M is a context-free language.

  6. Strings with twice the number of a's than b's: Working with the alphabet Σ = {a, b}, consider the language L that contains all strings over Σ for which the number of a's is exactly twice the number of b's .

    Determine whether or not L is a context-free language.

  7. if Statements in Pascal: Suppose the symbols Boolean-expression and statement have been defined for the Pascal language through a context-free grammar. Then, the Pascal Standard specifies the following context-free grammar for "if" statements:

       if-statement → "if"  Boolean-expression  "then"  statement
                      |   "if"  Boolean-expression  "then"  statement else-part
      
       else-part →   "else"  statement
    

    Assume both (x < 1.5) and (y > 4) are valid Boolean-expressions, and assume assignments a := 6.7 and b := -x are valid statements. Consider the Pascal code:

    if (x < 1.5)
         then if (y > 4)
           
            then   a := 6.7
    
      else 
           b := -x
    
    1. Show the formal grammar is ambiguous by giving two different derivations of this code segment.
    2. For each derivation, show the corresponding parse tree.
    3. Convert the above grammar to Chomsky Normal Form.

    Note that the Pascal standard added a note to resolve this issue for compilers. Thus, while the formal grammar was ambiguous, the interpretation in actual programs was not.

  8. Cond Statements in Scheme: Suppose the symbols condition and statement have been defined for the Scheme language through a context-free grammar.

    1. Give a context-free grammar that generates exactly the Cond statements of Scheme.
    2. Write a state diagram of a PDA that accepts exactly the Cond statements of Scheme (using condition and statement as simple input symbols).
  9. Turing Machine for 2 a's: Consider an input alphabet Σ = {a, b}, and let L = {strings w over Σ | w contains two consecutive a's}. Design a Turing machine that accepts the language L. Write out your machine in full, both using a complete transition table and using a state diagram.

    Consider the input alphabet for this problem to be {a, b}.

  10. Turing Machine for Palindromes: Design a Turing machine that reads a string s and returns the string ssR, where sR is the reverse of the string s. For example, given the string "abbaa", the Turing machine should halt after "abbaaaabba" is printed on the tape. As in Supplemental Problem 9, write out your machine in full, both using a complete transition table and using a state diagram, and consider the input alphabet to be {a, b}.

  11. Derivations of Context Free Grammars in Chomsky Normal Form:

    1. Suppose G is a context free grammar in Chomsky Normal Form, and suppose s is a string of length k that is generated by G. Show that the derivation of s will require exactly 2k-1 steps.
    2. Give an example to illustrate why a proof of part a by mathematical induction might be extremely difficult, if not impossible.
  12. Proof Summaries: Behind the proof of each theorem lies an idea. The details of a proof may require extensive exposition, but the underlying idea often can be explained in several sentences. For each of the following results, write an explanation (in your own words) of why the result is true; what is/are the main idea(s) of the proof.

    1. Theorem 3.21
    2. Theorem 4.4
    3. Theorem 3.16
    4. Theorem 4.5

    Notes:

  13. Pythagorean Triples as Roots of a Polynomial: In number theory, a Pythagorean triple consists of three positive integers (a, b, c), so that a2 + b2 = c2. Also, a polynomial of three variables p(x, y, z) is a sum of terms as described on pages 154-155. In this problem, we consider only polynomials with integer coefficients.

    Consider the language Polyint = {p(x, y, z) | p(x, y, z) is a polynomial with integer coefficients, such that there exists a Pythagorean triple (a, b, c) where p(a, b, c) = 0}

    Show that Polyint is Turing recognizable.

  14. Unions and Intersections of Context Free Languages:

    1. Give a short, simple argument to prove that the union of two context free languages is also a context free language.
    2. Show that the language {0m 1n 0m | m and n are non-negative integers} is context free. (Hint: produce a grammar.)
    3. Show that the language {0m 1m 0n | m and n are non-negative integers} is context free. (Hint: produce a grammar.)
    4. Show that the intersection of the languages for parts b and c is not a context free language. (Note that this example shows that the intersection of context free languages need not be a context free language.) (Hint: this is easy if you have studied the book.)
  15. Decidability of Whether a Regular Language is Empty: Consider the question of whether a regular language L is empty. The following proof outline claims to prove this question is decidable.

    Proof Outline:

    Exercise: Is this proof outline valid? That is

  16. Decidability of Whether a Regular Language is Infinite: Consider the question of whether a regular language L is infinite, and consider these claims. Use the same notation (L, R, c) as in the previous problem.

    Proof Outline:

    Exercise: Is this proof outline valid? That is

  17. Decidability of Whether a Context Free Language is Empty or Infinite:

    1. Can the argument of Problem 15 be modified to show a context free language is empty? (One might need to compute c in a rather different way, but can the argument be made for some computable value of c?)
    2. Can the argument of Problem 16 be modified to show a context free language is infinite? (Again, one might need to compute c in a rather different way, but can the argument be made for some computable value of c?)
  18. Binary Search and Loop Invariants: The C code distributed in class included four approaches for coding a binary search. For each approach:

  19. Verbose Turing Machines: A Turning Machine is called verbose if it contains one or more states that are never used in the processing of any input string. Formulate the collection of verbose Turing Machines as a language, and show that it is undecidable.

  20. Proof Summary for the Post Correspondence Problem: Problem 12 (above) outlines the idea of a proof summary for a result.

    1. Write a proof summary that outlines the idea behind the proof that the Post Correspondence Problem is unsolvable.
    2. To what extent is this proof valid if the alphabet Σ contains only one symbol (e.g., Σ = {a}).
  21. Twos Complement Binary Integers: Consider alphabet Σ = {0, 1}, so that strings in Σ* may be considered binary integers. In interpreting an integer, consider a leading bit of 0 to represent a non-negative integer, and a leading bit of 1 represents a negative number using twos complement notation.

    Let I = {< M > | M is a Turing Machine that accepts integer -a whenever M accepts a}. (In this description, note that a may be positive, negative, or zero.) Show that I is undecidable.

  22. EQTM: Write a proof summary for Theorem 5.30. The summary should be at least 2/3 page for the "Turing-recognizable" part of the theorem and at least 2/3 page for the "co-Turing-recognizable" part of the theorem.

  23. Class P: Suppose S and T are two languages in Class P.

    1. Let U be the union of the strings in S and T. Is it always the case that U must be in Class P? Is U sometimes in Class P and sometimes not? Is U never in Class P?
    2. Let I be the intersection of the strings in S and T. Is I always, sometimes, or never in Class P?
    3. Is ST always, sometimes, or never in Class P?
    4. Is the complement of S in Class P always, sometimes, or never?

    In each case, justify your answer.

  24. Reducibility of a Decidable Language: Suppose A is a language over an alphabet Σ. Also, suppose L is the infinite language { 0*1*} With this notation, Exercise 5.23 suggests that A is decidable if and only if A ≤m L. Rather than consider an infinite language, let w be a given string over alphabet {0, 1}, and let W be the language consisting of the one string w; that is W = {w}.

    Is it true that A is decidable if and only if A ≤m W? Justify your answer.


This document is available on the World Wide Web through the course home page at

http://www.cs.grinnell.edu/~walker/courses/341.sp14/

created 5 January 1999
revised 22 February 2012
revised 24 December 2012-10 January 2013
revised 24 December 2013-5 January 2014, 19-27 February 2014, 1-16 April 2014
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.