### Notations

*• Suppose M is a TM accepting L.*

*• Write L(M) = L.*

**– In particular, if M (x) =** for all x, then L(M) = ∅.

*• If M(x) is never “yes” nor (as required by the*
*deﬁnition of acceptance), we also let L(M ) =* *∅.*

### Nontrivial Properties of Sets in RE

* • A property of the recursively enumerable languages*
can be deﬁned by the set

*C of all the recursively*

enumerable languages that satisfy it.

* – The property of finite recursively enumerable*
languages is

*{ L : L = L(M) for a TM M, L is ﬁnite }.*

**• A property is trivial if C = RE or C = ∅.**

**– Answer to a trivial property is always “yes”or always**

“no.”

### Nontrivial Properties of Sets in RE (concluded)

*• Here is a trivial property (always yes): Does the TM*
accept a recursively enumerable language?^{a}

**• A property is nontrivial if C = RE and C = ∅.**

**– In other words, answer to a nontrivial property is**

“yes” for some TMs and “no” for others.

*• Here is a nontrivial property: Does the TM accept an*
empty language?^{b}

*• Up to now, all nontrivial properties (of recursively*

enumerable languages) are undecidable (pp. 156–157).

*• In fact, Rice’s theorem conﬁrms that.*

a*Or, L(M )* *∈ RE?*

b*Or, L(M ) =* *∅?*

### Rice’s Theorem

**Theorem 13 (Rice, 1956) Suppose***C = ∅ is a proper*
*subset of the set of all recursively enumerable languages.*^{a}
*Then the question “L(M )* *∈ C?” is undecidable.*

*• Note that the input is a TM program M.*

*• Assume that ∅ ∈ C (otherwise, repeat the proof for the*
*class of all recursively enumerable languages not in* *C).*

*• Let L ∈ C be accepted by TM M** ^{L}* (recall that

*C = ∅).*

*• Let M**H* *accept the undecidable language H.*

**–** *M** _{H}* exists (p. 139).

aA nontrivial property, i.e.

### The Proof (continued)

*• Construct machine M**x**(y):*

**if** *M*_{H}**(x) = “yes” then M**_{L}**(y) else**

*• On the next page, we will prove that*

*x ∈ H if and only if L(M** ^{x}*)

*∈ C.*(1)

**– As a result, the halting problem is reduced to**

*deciding L(M** _{x}*)

*∈ C.*

**– Hence L(M*** _{x}*)

*∈ C must be undecidable, and we are*done.

### The Proof (concluded)

*• Suppose x ∈ H, i.e., M*^{H}*(x) = “yes.”*

**–** *M*_{x}*(y) determines this, and it either accepts y or*
*never halts, depending on whether y* *∈ L.*

**– Hence L(M**_{x}*) = L* *∈ C.*

*• Suppose M*^{H}*(x) =.*

**–** *M** _{x}* never halts.

**–** *L(M** _{x}*) =

*∅ ∈ C.*

### Comments

*• C must be arbitrary.*

*• The following M**x**(y), though similar, will not work:*

**if** *M*_{L}**(y) = “yes” then M**_{H}**(x) else***.*

*• Rice’s theorem is about properties of the languages*
accepted by Turing machines.

*• It then says any nontrivial property is undecidable.*

*• Rice’s theorem is not about Turing machines*

themselves, such as ”Does a TM contain 5 states?”

### Consequences of Rice’s Theorem

**Corollary 14 The following properties of recursively***enumerative sets are undecidable.*

*• Emptiness.*

*• Finiteness.*

*• Recursiveness.*

*• Σ*^{∗}*.*

*• Regularity.*^{a}

*• Context-freedom.*^{b}

aIs it a regular language?

bIs it a context-free language?

### Undecidability in Logic and Mathematics

*• First-order logic is undecidable (answer to Hilbert’s*
*(1928) Entscheidungsproblem).*^{a}

*• Natural numbers with addition and multiplication is*
undecidable.^{b}

*• Rational numbers with addition and multiplication is*
undecidable.^{c}

aChurch (1936).

bRosser (1937).

cRobinson (1948).

### Undecidability in Logic and Mathematics (concluded)

*• Natural numbers with addition and equality is decidable*
and complete.^{a}

*• Elementary theory of groups is undecidable.*^{b}

aPresburger’s Master’s thesis (1928), his only work in logic. The direction was suggested by Tarski. Moj¯zesz Presburger (1904–1943) died in a concentration camp during World War II.

bTarski (1949).

### Julia Hall Bowman Robinson (1919–1985)

### Alfred Tarski (1901–1983)

*Boolean Logic*

Christianity is either false or true.

— Girolamo Savonarola (1497) Both of us had said the very same thing.

Did we both speak the truth

—or one of us did

—or neither?

— Joseph Conrad (1857–1924),
*Lord Jim (1900)*

### Boolean Logic

^{a}

**Boolean variables:** *x*1*, x*2*, . . ..*

**Literals:** *x**i**, ¬x**i*.

**Boolean connectives:** *∨, ∧, ¬.*

**Boolean expressions: Boolean variables, ¬φ (negation),***φ*1 *∨ φ*2 * (disjunction), φ*1

*∧ φ*2

**(conjunction).**

*•* _{n}

*i=1* *φ**i* *stands for φ*1 *∨ φ*2 *∨ · · · ∨ φ**n*.

*•* _{n}

*i=1* *φ**i* *stands for φ*1 *∧ φ*2 *∧ · · · ∧ φ**n*.

**Implications:** *φ*1 *⇒ φ*2 *is a shorthand for ¬φ*1 *∨ φ*2.

**Biconditionals:** *φ*1 *⇔ φ*2 is a shorthand for
*(φ*1 *⇒ φ*2*) ∧ (φ*2 *⇒ φ*1).

aGeorge Boole (1815–1864) in 1847.

### Truth Assignments

**• A truth assignment T is a mapping from boolean****variables to truth values** true and false.

**• A truth assignment is appropriate to boolean***expression φ if it deﬁnes the truth value for every*
*variable in φ.*

**–** *{ x*1 = *true, x*2 = *false } is appropriate to x*1 *∨ x*2.
**–** *{ x*2 = *true, x*3 = *false } is not appropriate to*

*x*_{1} *∨ x*2.

### Satisfaction

*• T |= φ means boolean expression φ is true under T ; in*
**other words, T satisfies φ.**

*• φ*1 *and φ*_{2} **are equivalent, written**
*φ*_{1} *≡ φ*2*,*

*if for any truth assignment T appropriate to both of*
*them, T* *|= φ*1 *if and only if T* *|= φ*2.

### Truth Table

^{a}

*• Suppose φ has n boolean variables.*

**• A truth table contains 2*** ^{n}* rows.

*• Each row corresponds to one truth assignment of the n*
*variables and records the truth value of φ under it.*

*• A truth table can be used to prove if two boolean*
expressions are equivalent.

**– Just check if they give identical truth values under all**
appropriate truth assignments.

aPost (1921); Wittgenstein (1922). Here, 1 is used to denote true; 0
is used to denote **false. This is called the standard representation**
(Beigel, 1993).

### A Truth Table

*p* *q* *p ∧ q*

0 0 0

0 1 0

1 0 0

1 1 1

### A Second Truth Table

*p* *q* *p ∨ q*

0 0 0

0 1 1

1 0 1

1 1 1

### A Third Truth Table

*p* *¬p*

0 1

1 0

### Proof of Equivalency by the Truth Table:

*p ⇒ q ≡ ¬q ⇒ ¬p*

*p* *q* *p ⇒ q ¬q ⇒ ¬p*

0 0 1 1

0 1 1 1

1 0 0 0

1 1 1 1

### De Morgan’s Laws

^{a}

**• De Morgan’s laws state that**

*¬(φ*1 *∧ φ*2) *≡ ¬φ*1 *∨ ¬φ*2*,*

*¬(φ*^{1} *∨ φ*^{2}) *≡ ¬φ*^{1} *∧ ¬φ*^{2}*.*

*• Here is a proof of the ﬁrst law:*

*φ*_{1} *φ*_{2} *¬(φ*1 *∧ φ*2) *¬φ*1 *∨ ¬φ*2

0 0 1 1

0 1 1 1

1 0 1 1

1 1 0 0

aAugustus DeMorgan (1806–1871) or William of Ockham (1288–

### Conjunctive Normal Forms

**• A boolean expression φ is in conjunctive normal****form (CNF) if**

*φ =*

*n*
*i=1*

*C*_{i}*,*

**where each clause C*** _{i}* is the disjunction of zero or more
literals.

^{a}

**– For example,**

*(x*_{1} *∨ x*2) *∧ (x*1 *∨ ¬x*2) *∧ (x*2 *∨ x*3*).*

*• Convention: An empty CNF is satisﬁable, but a CNF*
containing an empty clause is not.

aImproved by Mr. Aufbu Huang (R95922070) on October 5, 2006.

### Disjunctive Normal Forms

**• A boolean expression φ is in disjunctive normal form****(DNF) if**

*φ =*

*n*
*i=1*

*D*_{i}*,*

**where each implicant**^{a} **or simply term D*** _{i}* is the
conjunction of zero or more literals.

**– For example,**

*(x*_{1} *∧ x*2) *∨ (x*1 *∧ ¬x*2) *∨ (x*2 *∧ x*3*).*

a*D*_{i}*implies φ, thus the term.*

### Clauses and Implicants

*• The*

of clauses yields a clause.

**– For example,**

*(x*_{1} *∨ x*2) *∨ (x*1 *∨ ¬x*2) *∨ (x*2 *∨ x*3)

= *x*_{1} *∨ x*2 *∨ x*1 *∨ ¬x*2 *∨ x*2 *∨ x*3*.*

*• The*

of implicants yields an implicant.

**– For example,**

*(x*_{1} *∧ x*2) *∧ (x*1 *∧ ¬x*2) *∧ (x*2 *∧ x*3)

= *x*_{1} *∧ x*2 *∧ x*1 *∧ ¬x*2 *∧ x*2 *∧ x*3*.*

*Any Expression φ Can Be Converted into CNFs and DNFs*
*φ = x*_{j}**:**

*• This is trivially true.*

*φ = ¬φ*1 **and a CNF is sought:**

*• Turn φ*1 into a DNF.

*• Apply de Morgan’s laws to make a CNF for φ.*

*φ = ¬φ*1 **and a DNF is sought:**

*• Turn φ*1 into a CNF.

*• Apply de Morgan’s laws to make a DNF for φ.*

*Any Expression φ Can Be Converted into CNFs and DNFs*
(continued)

*φ = φ*_{1} *∨ φ*^{2} **and a DNF is sought:**

*• Make φ*1 *and φ*_{2} DNFs.

*φ = φ*_{1} *∨ φ*2 **and a CNF is sought:**

*• Turn φ*1 *and φ*_{2} into CNFs,^{a}
*φ*_{1} =

*n*_{1}

*i=1*

*A*_{i}*,* *φ*_{2} =

*n*_{2}

*j=1*

*B*_{j}*.*

*• Set*

*φ =*

*n*_{1}

*i=1*
*n*_{2}

*j=1*

*(A*_{i}*∨ B*^{j}*).*

aCorrected by Mr. Chun-Jie Yang (R99922150) on November 9, 2010.

*Any Expression φ Can Be Converted into CNFs and DNFs*
(concluded)

*φ = φ*_{1} *∧ φ*2 **and a CNF is sought:**

*• Make φ*1 *and φ*_{2} CNFs.

*φ = φ*_{1} *∧ φ*2 **and a DNF is sought:**

*• Turn φ*1 *and φ*_{2} into DNFs,
*φ*_{1} =

*n*_{1}

*i=1*

*A*_{i}*,* *φ*_{2} =

*n*_{2}

*j=1*

*B*_{j}*.*

*• Set*

*φ =*

*n*_{1}

*i=1*
*n*_{2}

*j=1*

*(A*_{i}*∧ B**j**).*

*An Example: Turn ¬((a ∧ y) ∨ (z ∨ w)) into a DNF*

*¬((a ∧ y) ∨ (z ∨ w))*

*¬(CNF∨CNF)*

= *¬(((a) ∧ (y)) ∨ ((z ∨ w)))*

*¬(CNF)*

= *¬((a ∨ z ∨ w) ∧ (y ∨ z ∨ w))*

de Morgan

= *¬(a ∨ z ∨ w) ∨ ¬(y ∨ z ∨ w)*

de Morgan

= (*¬a ∧ ¬z ∧ ¬w) ∨ (¬y ∧ ¬z ∧ ¬w).*

### Functional Completeness

**• A set of logical connectives is called functionally**

**complete if every boolean expression is equivalent to**
one involving only these connectives.

*• The set { ¬, ∨, ∧ } is functionally complete.*

**– Every boolean expression can be turned into a CNF,**
which involves only *¬, ∨, and ∧.*

*• The sets { ¬, ∨ } and { ¬, ∧ } are functionally complete.*^{a}
**– By the above result and de Morgan’s laws.**

*• { nand } and { nor } are functionally complete.*^{b}

aPost (1921).

bPeirce (c. 1880); Sheﬀer (1913).

### Satisfiability

**• A boolean expression φ is satisfiable if there is a truth***assignment T appropriate to it such that T* *|= φ.*

**• φ is valid or a tautology,**^{a} written *|= φ, if T |= φ for all*
*T appropriate to φ.*

aWittgenstein (1922). Wittgenstein is one of the most important philosophers of all time. Russell (1919), “The importance of ‘tautology’

for a deﬁnition of mathematics was pointed out to me by my former pupil Ludwig Wittgenstein, who was working on the problem. I do not know whether he has solved it, or even whether he is alive or dead.”

“God has arrived,” the great economist Keynes (1883–1946) said of him on January 18, 1928, “I met him on the 5:15 train.”

### Satisfiability (concluded)

* • φ is unsatisfiable or a contradiction if φ is false*
under all appropriate truth assignments.

**– Or, equivalently, if** *¬φ is valid (prove it).*

* • φ is a contingency if φ is neither a tautology nor a*
contradiction.

### Ludwig Wittgenstein (1889–1951)

Wittgenstein (1922),

“Whereof one cannot speak, thereof one must be silent.”

### satisfiability (sat)

* • The length of a boolean expression is the length of the*
string encoding it.

*• satisfiability (sat): Given a CNF φ, is it satisﬁable?*

*• Solvable in exponential time on a TM by the truth table*
method.

*• Solvable in polynomial time on an NTM, hence in NP*
(p. 121).

*• A most important problem in settling the “P* = NP”^{?}
problem (p. 323).

### unsatisfiability (unsat or sat complement) and validity

*• unsat (sat complement): Given a boolean expression*
*φ, is it unsatisﬁable?*

*• validity: Given a boolean expression φ, is it valid?*

**–** *φ is valid if and only if ¬φ is unsatisﬁable.*

**–** *φ and ¬φ are basically of the same length.*

**– So unsat and validity have the same complexity.**

*• Both are solvable in exponential time on a TM by the*
truth table method.

### Relations among sat, unsat, and validity

Contingent

Valid Unsatisfiable

*• The negation of an unsatisﬁable expression is a valid*
expression.

*• None of the three problems—satisﬁability,*

unsatisﬁability, validity—are known to be in P.

### Boolean Functions

*• An n-ary boolean function is a function*

*f : { true, false }*^{n}*→ { true, false }.*

*• It can be represented by a truth table.*

*• There are 2*^{2}* ^{n}* such boolean functions.

**– We can assign** *true or false to f for each of the 2** ^{n}*
truth assignments.

### Boolean Functions (continued)

Assignment Truth value 1 true or false 2 true or false

... ...

2* ^{n}* true or false

*• A boolean expression expresses a boolean function.*

**– Think of its truth values under all possible truth**
assignments.

### Boolean Functions (continued)

*• A boolean function expresses a boolean expression.*

**–**

*T |= φ, literal y**i* *is true in “row” T* *(y*_{1} *∧ · · · ∧ y**n*).^{a}

*∗ The implicant y*1 *∧ · · · ∧ y**n* **is called the minterm**
over *{ x*1*, . . . , x*_{n}*} for T .*

**– The size**^{b} is *≤ n2*^{n}*≤ 2** ^{2n}*.

**– This DNF is optimal for the parity function, for**
example.^{c}

a**Similar to programmable logic array. This is called the table**
**lookup representation (Beigel, 1993).**

bWe count only the literals here.

cDu & Ko (2000).

### Boolean Functions (continued)

*x*_{1} *x*_{2} *f(x*_{1}*, x*_{2})

0 0 1

0 1 1

1 0 0

1 1 1

The corresponding boolean expression:

(*¬x*^{1} *∧ ¬x*^{2}) *∨ (¬x*^{1} *∧ x*^{2}) *∨ (x*^{1} *∧ x*^{2}*).*

### Boolean Functions (concluded)

**Corollary 15 Every n-ary boolean function can be***expressed by a boolean expression of size O(n2*^{n}*).*

*• In general, the exponential length in n cannot be*
avoided (p. 212).

*• The size of the truth table is also O(n2** ^{n}*).

^{a}

aThere are 2^{n}*n-bit strings.*

### Boolean Circuits

**• A boolean circuit is a graph C whose nodes are the****gates.**

*• There are no cycles in C.*

*• All nodes have indegree (number of incoming edges)*
equal to 0, 1, or 2.

**• Each gate has a sort from**

*{ true, false, ∨, ∧, ¬, x*^{1}*, x*_{2}*, . . . }.*

**– There are n + 5 sorts.**

### Boolean Circuits (concluded)

*• Gates with a sort from { true, false, x*1*, x*_{2}*, . . . } are the*
**inputs of C and have an indegree of zero.**

**• The output gate(s) has no outgoing edges.**

*• A boolean circuit computes a boolean function.*

*• A boolean function can be realized by infinitely many*
equivalent boolean circuits.

### Boolean Circuits and Expressions

*• They are equivalent representations.*

*• One can construct one from the other:*

¬ [_{L} ¬

[_{L}

[_{L} ∨ [_{M} ∨

[_{L} [_{M}

[_{L} ∧ [_{M} ∧

[_{L} [_{M}

### An Example

*((x*_{1} * x*_{2} *) (x*_{3} *x*_{4})) *(x*_{3} *x*_{4}))

*x*_{1} *x*_{2} *x*_{3} *x*_{4}

*• Circuits are more economical because of the possibility*
of “sharing.”

### circuit sat and circuit value

**circuit sat: Given a circuit, is there a truth assignment**
such that the circuit outputs true?

*• circuit sat ∈ NP: Guess a truth assignment and then*
evaluate the circuit.^{a}

**circuit value: The same as circuit sat except that the**
circuit has no variable gates.

*• circuit value ∈ P: Evaluate the circuit from the input*
gates gradually towards the output gate.

aEssentially the same algorithm as the one on p. 121.

### Some

^{a}

### Boolean Functions Need Exponential Circuits

^{b}

**Theorem 16 For any n***≥ 2, there is an n-ary boolean*
*function f such that no boolean circuits with 2*^{n}*/(2n) or*
*fewer gates can compute it.*

*• There are 2*^{2}^{n}*diﬀerent n-ary boolean functions (p. 202).*

*• So it suﬃces to prove that the number of boolean*
circuits with 2^{n}*/(2n) or fewer gates is less than 2*^{2}* ^{n}*.

aCan be strengthened to “Almost all.”

bRiordan & Shannon (1942); Shannon (1949).

### The Proof (concluded)

*• There are at most ((n + 5) × m*^{2})* ^{m}* boolean circuits with

*m or fewer gates (see next page).*

*• But ((n + 5) × m*^{2})^{m}*< 2*^{2}^{n}*when m = 2*^{n}*/(2n):*

*m log*_{2}*((n + 5)* *× m*^{2})

= 2^{n}

1 *−* log_{2} _{n+5}^{4n}^{2}
*2n*

*< 2*^{n}*for n* *≥ 2.*

*m choices*

*n+5 choices*

*m choices*

### Claude Elwood Shannon (1916–2001)

Howard Gardner (1987), “[Shan- non’s master’s thesis is] possibly the most important, and also the most famous, master’s thesis of the cen- tury.”

### Comments

*• The lower bound 2*^{n}*/(2n) is rather tight because an*
*upper bound is n2** ^{n}* (p. 204).

*• The proof counted the number of circuits.*

**– Some circuits may not be valid at all.**

**– Diﬀerent circuits may also compute the same**
function.

*• Both are ﬁne because we only need an upper bound on*
the number of circuits.

*• We do not need to consider the outgoing edges because*
they have been counted as incoming edges.^{a}

aIf you prove the theorem by considering outgoing edges, the bound will not be good. (Try it!)

*Relations between Complexity Classes*

It is, I own, not uncommon to be wrong in theory and right in practice.

— Edmund Burke (1729–1797),
*A Philosophical Enquiry into the Origin of Our*
*Ideas of the Sublime and Beautiful (1757)*
The problem with QE is
it works in practice,
but it doesn’t work in theory.

— Ben Bernanke (2014)

### Proper (Complexity) Functions

**• We say that f : N → N is a proper (complexity)****function if the following hold:**

**–** *f is nondecreasing.*

**– There is a k-string TM M*** _{f}* such that

*M*

_{f}*(x) =*

^{f(| x |)}*for any x.*

^{a}

**–** *M*_{f}*halts after O(| x | + f(| x |)) steps.*

**–** *M*_{f}*uses O(f (| x |)) space besides its input x.*

*• M**f*’s behavior depends only on *| x | not x’s contents.*

*• M**f**’s running time is bounded by f (n).*

aThe textbook calls “*” the quasi-blank symbol. The use of M*_{f}*(x)*
will become clear in Proposition 17 (p. 222).

### Examples of Proper Functions

*• Most “reasonable” functions are proper: c, log n,*
*polynomials of n, 2** ^{n}*,

*√n , n!, etc.*

*• If f and g are proper, then so are f + g, fg, and 2** ^{g}*.

^{a}

*• Nonproper functions when serving as the time bounds*
for complexity classes spoil “theory building.”

**– For example, TIME(f (n)) = TIME(2*** ^{f(n)}*) for some

**recursive function f (the gap theorem).**^{b}

*• Only proper functions f will be used in TIME(f(n)),*
*SPACE(f (n)), NTIME(f (n)), and NSPACE(f (n)).*

a*For f (g(n)), we need to add f (n)* *≥ n.*

bTrakhtenbrot (1964); Borodin (1972). Theorem 7.3 on p. 145 of the textbook proves it.

### Precise Turing Machines

**• A TM M is precise if there are functions f and g such***that for every n* *∈ N, for every x of length n, and for*
*every computation path of M ,*

**–** *M halts after precisely f(n) steps,*^{a} and

**– All of its strings are of length precisely**^{b} *g(n) at*
halting.^{c}

*∗ Recall that if M is a TM with input and output,*
we exclude the ﬁrst and last strings.

*• M can be deterministic or nondeterministic.*

aFully time constructible (Hopcroft & Ullman, 1979).

bThis strong requirement does not seem needed later.

cFully space constructible (Hopcroft & Ullman, 1979).

### Precise TMs Are General

**Proposition 17 Suppose a TM**^{a} *M decides L within time*
*(space) f (n), where f is proper. Then there is a precise TM*
*M*^{}*which decides L in time O(n + f (n)) (space O(f (n)),*
*respectively).*

*• M*^{}*on input x ﬁrst simulates the TM M** _{f}* associated

*with the proper function f on x.*

*• M*^{f}*’s output, of length f (| x |), will serve as a*

“yardstick” or an “alarm clock.”

aIt can be deterministic or nondeterministic.

### The Proof (continued)

*• Then M*^{}*simulates M (x).*

*• M*^{}*(x) halts when and only when the alarm clock runs*
*out—even if M halts earlier.*

*• If f is a time bound:*

* – The simulation of each step of M on x is matched by*
advancing the cursor on the “clock” string.

**– Because M*** ^{}* stops at the moment the “clock” string

*is exhausted—even if M (x) stops earlier, it is precise.*

**– The time bound is therefore O(**| x | + f(| x |)).

### The Proof (concluded)

*• If f is a space bound (sketch):*

**–** *M*^{}*simulates M on the quasi-blanks of M** _{f}*’s output
string.

^{a}

**– The total space, not counting the input string, is**
*O(f(n)).*

**– But we still need a way to make sure there is no**
*inﬁnite loop even if M does not halt.*^{b}

aThis is to make sure the space bound is precise.

bSee the proof of Theorem 24 (p. 241).

### Important Complexity Classes

*• We write expressions like n** ^{k}* to denote the union of all

*complexity classes, one for each value of k.*

*• For example,*

*NTIME(n** ^{k}*) =

^{Δ}

*j>0*

*NTIME(n*^{j}*).*

### Important Complexity Classes (concluded)

P =^{Δ} *TIME(n*^{k}*),*
NP =^{Δ} *NTIME(n*^{k}*),*
PSPACE =^{Δ} *SPACE(n*^{k}*),*
NPSPACE =^{Δ} *NSPACE(n*^{k}*),*

E =^{Δ} TIME(2^{kn}*),*
EXP =^{Δ} TIME(2^{n}^{k}*),*
NEXP =^{Δ} NTIME(2^{n}^{k}*),*

L =^{Δ} *SPACE(log n),*
NL =^{Δ} *NSPACE(log n).*

### Complements of Nondeterministic Classes

*• Recall that the complement of L, or ¯L, is the language*
Σ^{∗}*− L.*

**– sat complement is the set of unsatisﬁable boolean**
expressions.

*• R, RE, and coRE are distinct (p. 161).*

**– Again, coRE contains the complements of languages***in RE, not languages that are not in RE.*

*• How about coC when C is a complexity class?*

### The Co-Classes

*• For any complexity class C, coC denotes the class*
*{ L : ¯L ∈ C }.*

*• Clearly, if C is a deterministic time or space complexity*
*class, then* *C = coC.*

**– They are said to be closed under complement.**

* – A deterministic TM deciding L can be converted to*
one that decides ¯

*L within the same time or space*bound by reversing the “yes” and “no” states.

^{a}

*• Whether nondeterministic classes for time are closed*
under complement is not known (see p. 113).

aSee p. 158.

### Comments

*• As*

co*C = { L : ¯L ∈ C },*
*L ∈ C if and only if ¯L ∈ coC.*

*• But it is not true that L ∈ C if and only if L ∈ coC.*

**– co***C is not deﬁned as ¯C.*

*• For example, suppose C = {{ 2, 4, 6, 8, 10, . . . }, . . . }.*

*• Then coC = {{ 1, 3, 5, 7, 9, . . . }, . . . }.*

*• But ¯C = 2**{ 1,2,3,... }* *− {{ 2, 4, 6, 8, 10, . . . }, . . . }.*

### The Quantified Halting Problem

*• Let f(n) ≥ n be proper.*

*• Deﬁne*

*H** _{f}* =

^{Δ}

*{ M; x : M accepts input x*

*after at most f (| x |) steps },*

*where M is deterministic.*

*• Assume the input is binary as usual.*

*H*

*f*

*∈ TIME(f(n)*

^{3}

### )

*• For each input M; x, we simulate M on x with an alarm*
*clock of length f (| x |).*

**– Use the single-string simulator (p. 85), the universal**
TM (p. 137), and the linear speedup theorem (p. 95).

**– Our simulator accepts M ; x if and only if M accepts***x before the alarm clock runs out.*

*• From p. 92, the total running time is O(**M**k*_{M}^{2} *f(n)*^{2}),
*where ** _{M}* is the length to encode each symbol or state of

*M and k*

_{M}*is M ’s number of strings.*

*• As **M**k*_{M}^{2} *= O(n), the running time is O(f (n)*^{3}), where
*the constant is independent of M .*

*H*

*f*

*∈ TIME(f(n/2))*

*• Suppose TM M**H*_{f}*decides H*_{f}*in time f (n/2).*

*• Consider machine:*

*D*_{f}*(M )* *{*

**if** *M*_{H}_{f}*(M ; M ) = “yes”*

**then “no”;**

**else “yes”;**

*}*

### The Proof (continued)

*• M**H*_{f}*(M ; M ) runs in time f (*^{2n+1}_{2} *) = f(n), where*
*n = | M |.*^{a}

*• By construction, D*^{f}*(M ) runs in the same amount of*
*time as M*_{H}_{f}*(M ; M ), i.e., f (n), where n =* *| M |.*

aMr. Hsiao-Fei Liu (F92922019) and Mr. Hong-Lung Wang
(F92922085) pointed out on October 6, 2004, that this estimation (and
*the text’s Lemma 7.2) forgets to include the time to write down M ; M .*

### The Proof (concluded)

*• First, suppose D*^{f}*(D** _{f}*) = “yes”.

*• This implies*

*D*_{f}*; D*_{f}*∈ H*^{f}*.*

*• Thus D*^{f}*does not accept D*_{f}*within time f (| D*^{f}*|).*

*• But D*^{f}*(D*_{f}*) stops in time f (| D*^{f}*|) with an answer.*

*• Hence D**f**(D** _{f}*) = “no”, a contradiction

*• Similarly, D**f**(D** _{f}*) = “no”

*⇒ D*

*f*

*(D*

*) = “yes.”*

_{f}### The Time Hierarchy Theorem

**Theorem 18 If f (n)***≥ n is proper, then*

*TIME(f (n))* * TIME(f(2n + 1)*^{3}*).*

*• The quantiﬁed halting problem makes it so.*

**Corollary 19 P** * E.*

*• P ⊆ TIME(2*^{n}*) because poly(n)* *≤ 2*^{n}*for n large enough.*

*• But by Theorem 18,*

TIME (2* ^{n}*) TIME

(2* ^{2n+1}*)

^{3}

*⊆ E.*

*• So P E.*

### The Space Hierarchy Theorem

**Theorem 20 (Hennie & Stearns, 1966) If f (n) is***proper, then*

*SPACE(f (n))* * SPACE(f(n) log f(n)).*

**Corollary 21 L** * PSPACE.*

### Nondeterministic Time Hierarchy Theorems

**Theorem 22 (Cook, 1973) NTIME(n*** ^{r}*)

*NTIME(n*

*)*

^{s}*whenever 1*

*≤ r < s.*

**Theorem 23 (Seiferas, Fischer, & Meyer, 1978) If***T*_{1}*(n) and T*_{2}*(n) are proper, then*

*NTIME(T*_{1}*(n))* * NTIME(T*2*(n))*
*whenever T*_{1}*(n + 1) = o(T*_{2}*(n)).*