Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Lecture 8

In-class notes: CS 505 Spring 2025 Lecture 8

NP-Intermediate Languages

So far, we’ve looked at many NP problems that also happen to be NP-complete. Thus, it is a natural question to ask whether all languages in NP are NP-complete. It turns out, under the widely believed conjecture that .

Theorem. If , then there exists such that is not NP-complete.

In other words: if all languages are NP-complete, then .

Example

Two examples of languages we believe to not be NP complete are factoring and graph isomorphism. Factoring asks if an integer has prime factors , and graph isomorphism asks if two graphs are isomorphic. This means that there exists a permutation such that for two graphs , if , then .

Oracle Machines

When we showed , we utilized diagonalization. In the proof, we had a decider for some language , and by contradiciton, we assumed we had a machine which decided in time . In the machine , we received as input and simulated it.

At a high-level, diagonalization is possible because of two key properties.

  1. Turing machines always have efficient representations as strings.
  2. The universal simulation of any Turing machine given its efficient representation as a bit string does not examine the inner workings of the machine.

In the machines and above, the machine simulates obliviously: it does not even need to look at what is doing, it does not care about the internal mechanisms of . Thus, is treating as a black-box: it gives some input and gives some output.

Oracle Turing Machines

We can abstract these two properties and define oracle Turing machines. These are special Turing machines with an additional oracle tape, and access to some oracle . We denote this as . The machine can query for any input in a single computation step, and writes the output to the special oracle tape in this single computation step.

For a language , we let denote an oracle Turing machine with an oracle to a decider for the language . This allows us to define oracle complexity classes.

  • is the set of all languages decidable in deterministic polynomial time relative to the oracle/language .
  • is the set of all languages decidable in non-deterministic polynomial time relative to the oracle/language .

As a concrete example, is the set of all languages decidable by a deterministic polynomial-time oracle Turing machine with oracle access to a decider for SAT. That is, if and only if is a satisfiable formula. Recall the complement language of SAT: is the set of all unsatisfiable formula .

Lemma. .

Proof. We build a deterministic polynomial time Turing machine that is given oracle access to such that if and only if is not satisfiable. The machine is simple. On input , queries and outputs the opposite answer. Since if and only if is satisfiable, clearly decides . Moreover, this is polynomial time.

Actually, we can show a stronger result.

Lemma. for any NP-complete language .

At a high-level, given a formula as input, we simply perform a polynomial-time reduction from to the language . For example, we can reduce to a instance, then reduce the instance to (or simply do a direct reduction).

As another result, we know that oracles in do not grant us more power for languages in .

Theorem. For any , we have .

Proof. is immediate since every language in is decidable in polynomial time without an oracle. For , since , we can convert any polynomial time Turing machine with oracle access to to another Turing machine which decides the same language but simply simulates . This simulation is polynomial time, so the final time is polynomial.

Note there are powerful oracles for which and are equal relative to this oracle. One such oracle is for the language , which we define as the set of all tuples where within steps.

Lemma. .

Proof. First, is immediate since any machine with oracle access to can check if an exponential time Turing machine outputs in at most steps. So an exponential time computation can be done in constant time.

Second, is trivially true since .

Third, we show that . Suppose that and is decidable on NTM in time . We construct machine that decides in at most time. is given the description of and deterministically simulates on any input by simulating all possible computation paths. outputs accept if and only if there is at least one accepting computation path, and outputs reject otherwise. Since runs in non-deterministic time , this simulation takes at most time. Finally, whenever calls the oracle on input for some , the machine simply runs the machine for at most steps and returns the result.

Limits of Diagonalization

Oracle machines help us quantify the limits of diagonalization. Diagonalization is quite a powerful, and general technique, so naturally we’d like to resolve vs. using it. Unfortunately, this is impossible.

Theorem. There exists oracle and such that

  1. ; and
  2. .

Proof. Setting (the oracle), we have (1) of the theorem by our previous lemma.

Now we construct an oracle to prove (2). Interestingly enough, we will use diagonalization to construct this oracle. First, let be any language. Define a new language as

Notice that for any language . To see this, define machine which (1) guesses ; (2) outputs oracle query . By definition, if and only if ; otherwise it outputs . Clearly, this non-deterministic machine decides .

Now, we construct a new language such that . Then, we will set , completing the proof. We’ll define the language inductively, first by setting . We’ll also have two helper sets (i.e., helper variables) and .

  1. Step 1.
    1. Let be the deterministic oracle Turing machine defined by the bit string . For simplicity, we assume that runs in time .
    2. Choose such that .
    3. Run .
      1. Whenever queries oracle at string , reply with /reject. Update .
    4. If :
      1. Update . That is, add all -bit strings to the set . Here, is representing the set of all strings that are not in .
    5. If :
      1. Find such that .
      2. Update .
      3. Update .
  2. For :
    1. Assume machine runs in time for inputs of length .
    2. Choose such that .
    3. Run .
      1. Whenever queries oracle at string , update .
      2. If , reply /reject.
      3. If , reply /accept.
    4. If
      1. Update .
    5. If
      1. Find such that .
      2. Update .
      3. Update .

Now, we claim that for this language , we have . First, clearly since an NTM can simply guess a correct string in the language . Now, let be any deterministic oracle Turing machine and suppose by way of contradiction that decides . Notice that for each , there are an infinite number of equivalent descriptions for . In particular, there exists some such that . Now, consider . If , it is saying that there exists such that . However, in this case, by construction of (and, in particular, step 2.4.1), we know that all strings of length are in the set and are not in the set . So should output in this case. Similarly, if , then by construction of , we know there exists some length string , so should output in this case. Both cases lead to a contradiction, so .

Intuitively, in the above diagonalization proof, we are exploiting two key facts: (1) there are an infinite number of equivalent Turing machine descriptions; and (2) deterministic Turing machines cannot search an exponential space in polynomial time. (1) allows us to say that if we are given some decider, then there is some for which is the same machine, which means we have considered it in our construction of . (2) allows us to diagonalize. In particular, must produce an output by only making a polynomial number of queries (at most ). Since for large enough , we know that could not have possibly queried the entire set of length bit strings. So, intuitively, the deterministic machine is making a decision with incomplete information.

We exploit this. If , we declare all length strings to not be in the language. Since could not have queried all length strings before outputting its decision, the lack of information leads it to make a wrong decision. Similarly, if , then again there is no way could have queries all length bit strings. So we explicitly find one that was not queried and add it to the set . This again causes to output erroneously. Thus, we cannot decide the language in deterministic polynomial time when given an oracle to .