Exercises
Automata, formal languages, and computational complexity
CSC 341 · Spring, 2011 · Department of Computer Science · Grinnell College

Exercise set 8

A. Give an example of an unsatisfiable 3cnf-formula, and prove that it is unsatisfiable.

B. A triangle in a graph is a clique of size 3: a set of three vertices in which every pair is connected by an edge of the graph. Prove that {⟨G⟩ | G does not contain a triangle} ∈ P.

C. A 2-coloring of a graph labels each edge of the graph with one of two colors, say red and blue. A subgraph of a 2-colored graph is monochromatic if all of its edges are the same color. Prove that MONO = {⟨G⟩ | There is some 2-coloring of G such that G does not contain a monochromatic triangle} ∈ NP and that 3SAT ≤P MONO.

Exercise set 7

A. Construct two different Turing machines, M and N, such that, given any input string s, M outputs ⟨Ns⟩ and N outputs ⟨Ms⟩.

B. Prove that EQTM ≤T ATM.

C. Prove that the set of incompressible strings is undecidable. (Hint: A proof by contradiction is likely to be easier to find than a proof by reduction, in this particular case.)

Exercise set 6

A. Define a singulary, primitive recursive function gir that, given the encoding for a computation as input, determines the greatest number that resulted from any of its subcomputations. (“gir” stands for “greatest intermediate result.”) If the input to gir does not encode a computation, gir should output 0.

B. Define a binary, partial recursive function tape-usage that takes as inputs the encoding for a Turing machine and the encoding for a string in that Turing machine's input alphabet, and returns the number of the rightmost tape cell that the Turing machine's head reaches as it processes the given string. (If the first input does not validly encode a Turing machine, tape-usage should return 0. If the Turing machine never halts on the given string, tape-usage should be undefined for the given inputs.)

C. Prove that, for any singulary recursive function f, there is some natural number n such that n and f(n) encode the same partial recursive function. (Hint: This is the fixed-point version of the recursion theorem within recursive function theory.)

Exercise set 5

A. Prove that every polynomial in which the coefficients are all natural numbers expresses a primitive recursive function.

B. The reverse-list function inputs the encoding for a list and outputs the encoding for a list with the same elements, arranged in the opposite order. Prove that reverse-list is primitive recursive.

C. Use course-of-values recursion to define the fibonacci function, which inputs a natural number denoting a (zero-based) position in the Fibonacci sequence 0, 1, 1, 2, 3, 5, 8, ... and outputs the natural number that occupies that position.

Exercise set 4

A. Design and implement a Turing machine with the input alphabet {0, 1} that accepts every string except the null string and, in addition, leaves on its tape the string 1n, where n is the value of the input string, interpreted as a binary numeral. (For instance, given the input 0010001, your Turing machine should leave the string 11111111111111111 on its tape when it reaches its accept state and halts.)

I am indebted to Isaac Wilder for pointing out a typographical error in an earlier version of this exercise.

B. Suppose we extend the nondeterministic pushdown-automaton model, giving the extended machine a second stack and allowing it to push a symbol onto and/or pop a symbol from each of the two stacks on each transition. So clause 4 of Definition 2.13 on page 111 of the textbook would be replaced with

δ: Q × Σɛ × Γɛ × Γɛ → ℘(Q × Γɛ × Γɛ )

Show that, for any deterministic Turing machine, there is a two-stack pushdown automaton that recognizes the same language and halts on a given input if, and only if, the Turing machine halts on the same input.

C. Let's say that a regular expression e1 includes another regular expression e2 if, and only if, e1 matches every string that e2 matches. Show that {⟨e1e2⟩ | e1 includes e2} is decidable.

Exercise set 3

A. Prove that, if L is a context-free language with the alphabet Σ, then {w | wx ∈ L for some x ∈ Σ*} is also a context-free language.

B. Suppose that we extend the pushdown-automaton model of computation so that, instead of pushing a symbol onto its stack as part of one step, the automaton can store the state it is currently in onto the stack. We adopt the convention that, whenever a state-storing automaton pops a state from its stack, it re-enters that state (but still pushes a symbol onto the stack, if its transition function so specifies). Show informally that state-storing pushdown automata still recognize only context-free languages, so that this extension does not result in any increase in problem-solving power.

I am indebted to Russel Steinbach for determining that both versions of the exercise that originally appeared here as C were fatally flawed. I have withdrawn the exercise.

D. Use the pumping lemma for context-free languages to prove that the language {aibjck | i ≤ j ≤ k} is not context-free.

Exercise set 2

A. Consider a deterministic finite automaton with states {q0, q1}, alphabet {0, 1, R}, the transition function δ shown in the table below, start state q0, and accept states {q0}.

0 1 R
q0 q0 q1 q0
q1 q1 q0 q0

This automaton will keep track of whether the number of occurrences of 1 that it has seen is even or odd, except that the tally is reset to zero every time the symbol R is encountered.

Construct a regular expression whose value is the language that this automaton recognizes.

B. Let's say that a set S of natural numbers is finitely specified by a deterministic finite automaton that recognizes {an |  n ∈ S}. Prove that no DFA finitely specifies the set {1, 2, 4, 8, ...} of exact powers of 2.

C. Let's say that the left rotation of a string w = w1w2...wn is the string formed by moving the leftmost symbol, w1, to the right end: w2...wnw1. To resolve any ambiguity, let's stipulate that the null string is its own left rotation, and that any string of length 1 is also its own left rotation.

Further, let's say that the left rotation LLR of a language L is the set of left rotations of the strings in L.

Is the class of regular languages closed under left rotation? In other words, is the left rotation of every regular language regular? If so, prove it; if not, find a counter-example (and prove that it is regular and that its left rotation is not).

Exercise set 1

A. Describe a deterministic finite automaton that recognizes the language of base-ten numerals for positive integers divisible by 7. All input strings with leading zeroes should be rejected (e.g., the automaton should reject 0028 even though it accepts 28), as should the null string.

B. A Bowdlerized version of a string w is a string with the same length as w in which any symbol that does not match the corresponding symbol in w is an asterisk. So, for example, there are eight Bowdlerized versions of the string red: red itself, re*, r*d, r**, *ed, *e*, **d, and ***. Prove that, for any regular language L, {v | v is a Bowdlerized version of some member of L} is also regular.

I am indebted to Charles Frantz for calling my attention to a typographical error in an earlier version of this exercise.

C. Prove that every finite language is regular.

· ·
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.

This text is available on the World Wide Web as

http://www.cs.grinnell.edu/~stone/courses/automata/exercises.html


John David Stone · stone@cs.grinnell.edu