Decidability
The diagonalization method
Undecidability
fig2
Countable and Uncountable Sets
- The natural numbers
N={1,2,3,…} are countable. Definition: a set
S is countable if it is finite, or it is infinite and there is a bijectionf: N→SThe positive rational numbers
Q={m /n |m,n∈N} are countable.-
Theorem: The real numbers
R are uncountable. (Cantor diagonalization)
Non-RE Languages
Theorem: there exist languages that are not Recursively Enumerable.
Proof outline:
- the set of all TMs is countable
- the set of all languages is uncountable
- the function
L : {TM’s} → {languages}$ cannot be onto
Proof:
The halting problem is undecidable
The Halting Problem
Definition:
HALT ={<M,x> | TMM halts on inputx} -
Theorem: HALT is not decidable (undecidable).
- Proof:、
- Suppose TM
H decides HALT- if
M halts onx ,H accept - if
M does not halt onx ,H reject
- if
- Define new TM
H′ : on input<M> - if
H accepts<M,<M>> , then loop - if
H rejects<M,<M>> , then halt
- if
- Consider
H′ on input<H′> :- if it halts, then
H rejects<H′,<H′>> , which implies it cannot halt - if it loops, then
H accepts<H′,<H′>> , which implies it must halt
- if it halts, then
- Contradiction. Thus neither
H norH′ can exist
RE and co-RE
The complement of a RE language is called a co-RE language.
Theorem: a language L is decidable if and only if L is RE and L is co-RE.
Proof:
- If L is decidable, then complement of L is decidable by flipping accept/reject.
- So L is in co-RE.
- On input x, simulate
M ,M′ in parallel. - If
M accepts, accept; ifM′ accepts, reject.
A natural non-RE Language
Theorem: the complement of HALT is not recursively enumerable.
Proof:
we know thatHALT is RE
suppose complement ofHALT is RE
thenHALT is co-RE
impliesHALT is decidable.
Contradiction.
Complexity
Analyze Algorithms
Worst-Case Analysis
Time Complexity
Measure Time Complexity
Asymptotic Notation
Asymptotic Notation Facts
- logarithmic: O(log n)
-
- so
- polynomial:
also:
- exponential:
Time Complexity Class
TIME
- Regular Languages,
- Context-Free Languages,
- Decidable Languages,
- RE Languages,
- co-RE languages
Multitape TMs
Theorem: Let
Polynomial Time Class P
Definition: P or polynomial-time is the class of languages that are decidable in polynomial time on a deterministic single-tape Turing Machine.
Any reasonable deterministic computational models are polynomially equivalent.
Example:
PATH =
RELPRIME =
Nondeterministic Polynomial Time Class NP
Recall: Nondeterministic TM
Visualize computation of a NTM M as a tree.
Definition:
NTIME(t(n)) = {L | there exists a NTM M that decides L in time
NP =
Poly-Time Verifiers
Theorem: language
Poly-time TM
Example:
HAMPATH={
HAMPATH={
R={ <
- p is a certificate to verify that
<G,s,t> is in HAMPATH. - R is decidable in poly-time.
Proof: construct an NTM N to decide CLIQUE in poly-time
N =
1. Nondeterministically select a subset c of k nodes of G.
2. Test whether G contains all edges connecting nodes in c.
3. If yes, accept; otherwise, reject.
Examples of Languages in NP
A clique in an undirected graph is a subgraph, wherein every two nodes are connected.
CLIQUE =
CLIQUE is NP
Proof: construct an NTM N to decide CLIQUE in poly-time
N =
" On input<G,k> , where G is a graph:
1. Nondeterministically select a subset c of k nodes of G.
2. Test whether G contains all edges connecting nodes in c.
3. If yes, accept; otherwise, reject."
Alternative Proof:
CLIQUE is expressible as
CLIQUE ={<G,k> |c for which<<G,k>,c>∈ R},R=
{<<G,k>,c> |c is a set of k nodes in G, and all the k nodes are connected in G}R is decidable in poly-time
NP in relation to P and EXP
We do not know if either inclusion is proper.
Reduce P NP NPC
Reductions
A reduction is a way of converting one problem into another such that a solution to the second problem can be used to solve the first problem.
关于规约的方向,引用某高水平同学的解释,
“把考试题规约到作业题,作业题的解法就可以用来解决考试题。”
Reductions are one of the most important and widely used techniques in TCS, especially for proving problems hard.
Example 1
Try to prove undecidable:
We know this language is undecidable:
HALT = {
Idea:
Suppose
Show that we can use
- On input
<M,w> - Check if
<M,w>∈ ATM - if yes, the
M halts onw ; ACCEPT - if no, then
M either rejects w or it loops on w
- if yes, the
- Construct
M′ by swappingqaccept/qreject in M - Check if
<M′,w>∈ ATM - if yes, then
M′ acceptsw , soM rejectsw ; ACCEPT - if no, then
M neither accepts nor rejectsw ; REJECT
- if yes, then
Conclude HALT is decidable. Contradiction.
Example 2
Try to prove undecidable:
Suppose
We showed how to use
- on input
<M,w> - construct
M′ from description ofM - on input x, if x
≠ w, then reject - else simulate
M onx , and accept ifM does.
- on input x, if x
- check if <
M′ >∈ ETM - if no, M must accept w; ACCEPT
- if yes, M cannot accept w; REJECT
- Conclude
ATM is decidable. Contradiction.
Definition of Reduction
A is mapping reducible to B, written
“Yes maps to yes and no maps to no” means:
w∈A maps tof(w)∈B &w∈A maps tof(w)∈B
Using Reductions
Theorem: if
Main use: Given language NEW, prove it is undecidable by showing OLD
Theorem: if A
Main use: Given language NEW, prove it is not RE by showing OLD
Rice Therom
A TM property is a language P for which
if
TM property P is nontrivial if
- there exists a TM
M1 for which <M1 >∈ P, and - there exists a TM
M2 for which <M2 >∉ P.
Rice's Theorem: Every nontrivial TM property is undecidable.
Poly-Time Reductions
Function
Definition: f : Σ→ Σ is poly-time computable if for some
Poly-Time computable function
Definition: A
as before, condition equivalent to: YES maps to YES and NO maps to NO
as before, meaning is: B is at least as
Theorem: if A
Proof:
A poly-time algorithm for deciding A:
- on input
w , computef(w) in poly-time. - run poly-time algorithm to decide if
f(w)∈B - if it says yes, output yes
- if it says no, output no
NP-Completeness
Definition:
A language B is NP-complete if it satisfies two conditions:
- B is in NP, and
- every A in NP is polynomial time reducible to B.
B is called NP-hard if we omit the first condition.
- language L is C-hard if every problem in C reduces to L
- language L is C-complete if L is C-hard and L is in C.
Theorem: If B is NP-complete and
Theorem: If B is NP-complete and
Theorem: The following are equivalent.
- P = NP.
- Every NP-complete language is in P.
- Some NP-complete language is in P.
SAT
A Boolean formula is satisfiable if some assignment of TRUE/FALSE to the variables makes the formula evaluate to TRUE.
SAT = {<φ> | φ is a satisfiable Boolean formula}
Theorem: SAT is NP-complete.
Proof:
- SAT is in NP
- guess an assignment to the variables, check the assignment
- A
≤P SAT (for any A∈ NP)- let M be a NTM that decides A in
nk time. For any input stringw , we construct a Boolean formulaϕM,w which is satisfiable iffM acceptsw .
- let M be a NTM that decides A in
Example: 3SAT is in NP.
- 3SAT is a special case of SAT, and is therefore clearly in NP.
Complexity
Definition: the time complexity of a TM
Definition: the space complexity of a TM
Definition:
TIME(t(n)) = {L : there exists a TM
P =
∪k≥1 TIME(nk)
EXP =∪k≥1 TIME(2nk)
Definition:
SPACE(t(n)) = {L : there exists a TM
PSPACE =
∪k≥1 SPACE(nk)
Definition:
NTIME(t(n)) = {L : there exists a NTM
NP =
∪k≥1 NTIME(nk)
Theorem:
P
P
Don't know if any of the containments are proper.
The Church-Turing Thesis
Everything we can compute on a physical computer
can be computed on a Turing Machine
The extended Church-Turing Thesis
Everything we can compute in time