Wednesday: Computational Problems

The Church-Turing thesis posits that each algorithm can be implemented by some Turing machine.

Describing algorithms (Sipser p. 185) To define a Turing machine, we could give a

Formatted inputs to Turing machine algorithms

The input to a Turing machine is always a string. The format of the input to a Turing machine can be checked to interpret this string as representing structured data (like a csv file, the formal definition of a DFA, another Turing machine, etc.)

This string may be the encoding of some object or list of objects.

Notation: \(\langle O \rangle\) is the string that encodes the object \(O\). \(\langle O_1, \ldots, O_n \rangle\) is the string that encodes the list of objects \(O_1, \ldots, O_n\).

Assumption: There are algorithms (Turing machines) that can be called as subroutines to decode the string representations of common objects and interact with these objects as intended (data structures). These algorithms are able to “type-check” and string representations for different data structures are unique.

For example, since there are algorithms to answer each of the following questions, by Church-Turing thesis, there is a Turing machine that accepts exactly those strings for which the answer to the question is “yes”

A computational problem is decidable iff language encoding its positive problem instances is decidable.

The computational problem “Does a specific DFA accept a given string?” is encoded by the language \[\begin{aligned} &\{ \textrm{representations of DFAs $M$ and strings $w$ such that $w \in L(M)$}\} \\ =& \{ \langle M, w \rangle \mid M \textrm{ is a DFA}, w \textrm{ is a string}, w \in L(M) \} \end{aligned}\]

The computational problem “Is the language generated by a CFG empty?” is encoded by the language \[\begin{aligned} &\{ \textrm{representations of CFGs $G$ such that $L(G) = \emptyset$}\} \\ =& \{ \langle G \rangle \mid G \textrm{ is a CFG}, L(G) = \emptyset \} \end{aligned}\]

The computational problem “Is the given Turing machine a decider?” is encoded by the language \[\begin{aligned} &\{ \textrm{representations of TMs $M$ such that $M$ halts on every input}\} \\ =& \{ \langle M \rangle \mid M \textrm{ is a TM and for each string } w, \textrm{$M$ halts on $w$} \} \end{aligned}\]

Note: writing down the language encoding a computational problem is only the first step in determining if it’s recognizable, decidable, or …

Deciding a computational problem means building / defining a Turing machine that recognizes the language encoding the computational problem, and that is a decider.

Friday: Decidable Problems about Regular Languages

Some classes of computational problems will help us understand the differences between the machine models we’ve been studying. (Sipser Section 4.1)

Acceptance problem
…for DFA \(A_{DFA}\) \(\{ \langle B,w \rangle \mid \text{$B$ is a DFA that accepts input string $w$}\}\)
…for NFA \(A_{NFA}\) \(\{ \langle B,w \rangle \mid \text{$B$ is a NFA that accepts input string $w$}\}\)
…for regular expressions \(A_{REX}\) \(\{ \langle R,w \rangle \mid \text{$R$ is a regular expression that generates input string $w$}\}\)
…for CFG \(A_{CFG}\) \(\{ \langle G,w \rangle \mid \text{$G$ is a context-free grammar that generates input string $w$}\}\)
…for PDA \(A_{PDA}\) \(\{ \langle B,w \rangle \mid \text{$B$ is a PDA that accepts input string $w$}\}\)
Language emptiness testing
…for DFA \(E_{DFA}\) \(\{ \langle A \rangle \mid \text{$A$ is a DFA and $L(A) = \emptyset$\}}\)
…for NFA \(E_{NFA}\) \(\{ \langle A\rangle \mid \text{$A$ is a NFA and $L(A) = \emptyset$\}}\)
…for regular expressions \(E_{REX}\) \(\{ \langle R \rangle \mid \text{$R$ is a regular expression and $L(R) = \emptyset$\}}\)
…for CFG \(E_{CFG}\) \(\{ \langle G \rangle \mid \text{$G$ is a context-free grammar and $L(G) = \emptyset$\}}\)
…for PDA \(E_{PDA}\) \(\{ \langle A \rangle \mid \text{$A$ is a PDA and $L(A) = \emptyset$\}}\)
Language equality testing
…for DFA \(EQ_{DFA}\) \(\{ \langle A, B \rangle \mid \text{$A$ and $B$ are DFAs and $L(A) =L(B)$\}}\)
…for NFA \(EQ_{NFA}\) \(\{ \langle A, B \rangle \mid \text{$A$ and $B$ are NFAs and $L(A) =L(B)$\}}\)
…for regular expressions \(EQ_{REX}\) \(\{ \langle R, R' \rangle \mid \text{$R$ and $R'$ are regular expressions and $L(R) =L(R')$\}}\)
…for CFG \(EQ_{CFG}\) \(\{ \langle G, G' \rangle \mid \text{$G$ and $G'$ are CFGs and $L(G) =L(G')$\}}\)
…for PDA \(EQ_{PDA}\) \(\{ \langle A, B \rangle \mid \text{$A$ and $B$ are PDAs and $L(A) =L(B)$\}}\)

Example strings in \(A_{DFA}\)

Example strings in \(E_{DFA}\)

Example strings in \(EQ_{DFA}\)

\(M_1 =\) “On input \(\langle M,w\rangle\), where \(M\) is a DFA and \(w\) is a string:

  1. Type check encoding to check input is correct type. If not, reject.

  2. Simulate \(M\) on input \(w\) (by keeping track of states in \(M\), transition function of \(M\), etc.)

  3. If the simulations ends in an accept state of \(M\), accept. If it ends in a non-accept state of \(M\), reject. "

What is \(L(M_1)\)?

Is \(M_1\) a decider?

Alternate description: Sometimes omit step 0 from listing and do implicit type check.

Synonyms: “Simulate”, “run”, “call”.

True / False: \(A_{REX} = A_{NFA} = A_{DFA}\)

True / False: \(A_{REX} \cap A_{NFA} = \emptyset\), \(A_{REX} \cap A_{DFA} = \emptyset\), \(A_{DFA} \cap A_{NFA} = \emptyset\)

A Turing machine that decides \(A_{NFA}\) is:

A Turing machine that decides \(A_{REX}\) is:

\(E_{DFA} = \{ \langle A \rangle \mid \text{$A$ is a DFA and $L(A) = \emptyset$}\}\). True/False: A Turing machine that decides \(E_{DFA}\) is

\(M_2 =\)“On input \(\langle M\rangle\) where \(M\) is a DFA,

  1. For integer \(i = 1, 2, \ldots\)

  2. Let \(s_i\) be the \(i\)th string over the alphabet of \(M\) (ordered in string order).

  3. Run \(M\) on input \(s_i\).

  4. If \(M\) accepts, \(\underline{\phantom{FILL IN BLANK}}\). If \(M\) rejects, increment \(i\) and keep going."

Choose the correct option to help fill in the blank so that \(M_2\) recognizes \(E_{DFA}\)

\(M_3 =\) “ On input \(\langle M \rangle\) where \(M\) is a DFA,

  1. Mark the start state of \(M\).

  2. Repeat until no new states get marked:

  3. Loop over the states of \(M\).

  4. Mark any unmarked state that has an incoming edge from a marked state.

  5. If no accept state of \(A\) is marked, \(\underline{\phantom{FILL IN BLANK}}\); otherwise, \(\underline{\phantom{FILL IN BLANK}}\)".

To build a Turing machine that decides \(EQ_{DFA}\), notice that \[L_1 = L_2 \qquad\textrm{iff}\qquad (~(L_1 \cap \overline{L_2}) \cup (L_2 \cap \overline L_1)~) = \emptyset\] There are no elements that are in one set and not the other

\(M_{EQDFA} =\)

Summary: We can use the decision procedures (Turing machines) of decidable problems as subroutines in other algorithms. For example, we have subroutines for deciding each of \(A_{DFA}\), \(E_{DFA}\), \(EQ_{DFA}\). We can also use algorithms for known constructions as subroutines in other algorithms. For example, we have subroutines for: counting the number of states in a state diagram, counting the number of characters in an alphabet, converting DFA to a DFA recognizing the complement of the original language or a DFA recognizing the Kleene star of the original language, constructing a DFA or NFA from two DFA or NFA so that we have a machine recognizing the language of the union (or intersection, concatenation) of the languages of the original machines; converting regular expressions to equivalent DFA; converting DFA to equivalent regular expressions, etc.

Week 7 at a glance

Textbook reading: Sections 3.3, 4.1

No lecture on Monday in observance of Presidents Day

For Wednesday: Example 3.23 on page 185

For Friday: Decidable problems concerning regular languages, Sipser pages 194-196.

For Monday of Week 8: An undecidable language, Sipser pages 207-209.

Make sure you can:

TODO:

Review quizzes based on class material each day.

Project due this Thursday.

Homework assignment 4 due next Thursday.


  1. An introduction to ASCII is available on the w3 tutorial here.↩︎