Whether a problem is solvable by an algorithm.
Decidable Problem
A problem is decidable iff a TM decider exists that halts with correct yes/no for every input.
A problem is undecidable iff no such TM exists.
Connected Graph Example
marks the first node, then marks any node adjacent to a marked node. Accepts if all nodes are marked; rejects otherwise. Always halts. is decidable.
Why Undecidable Problems Exist
TMs can be encoded as strings. The set of all TMs is countable.
All languages over form the power set , which is uncountable and strictly larger than the set of TMs.
Since there are more languages than TMs, most languages have no TM that accepts them.
Cardinality
Cardinality measures the size of a set. 2 sets have equal cardinality iff a bijection exists between them.
- Injective
No 2 elements in map to the same element in . - Surjective
Every has a preimage in . - Bijective
Both injective and surjective. Exact pairing between 2 sets.
Diagonalization
Technique for showing 2 sets have unequal cardinality by proving no bijection can exist.
Applied to : assume a complete listing of all reals. Construct a number differing from the -th real at the -th decimal digit. That number is not in the listing. Contradiction. is uncountable.
Applied to languages: any enumeration of TMs leaves languages unaccounted for. Some languages have no TM.
Language Hierarchy
Nested hierarchy (innermost outermost):
Regular
⊂ Context-free
⊂ Decidable (aka Recursive)
⊂ Turing-acceptable (aka RE, Recursively Enumerable)
⊂ Universe of all languages
- Decidable
TM decider exists. Always halts with accept/reject. - Turing-acceptable
TM acceptor exists. May loop forever on non-members. - Outside RE
No TM accepts these languages at all.
Reduction
Reduction converts instances of one problem into instances of another. (” reduces to ”) means is at least as hard as .
iff a Turing-computable exists such that:
converts any instance of into an equivalent instance of .
Consequences:
- decidable decidable.
- undecidable undecidable.
To prove is undecidable: find a known undecidable and show .
Undecidable Problems
Self-Accepting Problem
Given TM , does accept its own encoding ?
Undecidable. Proved by diagonalization: assume a decider exists, construct a TM that contradicts it when run on its own encoding.
Accepts Problem
Given TM and string , does accept ?
Undecidable. Direct simulation fails if loops forever on .
Proved by reducing Self-Accepting to Accepts: given any TM , construct that ignores its input and runs on . If Accepts were decidable, Self-Accepting would be too. Contradiction.
Halting Problem
Given TM and string , does halt on input ?
Undecidable. Proof by contradiction:
- Assume a halting decider exists. takes any TM and input , outputs YES if halts on , NO otherwise.
- Construct . takes , passes to :
- outputs YES loops forever.
- outputs NO halts with “OK”.
- Run on itself ():
- outputs YES ( halts on ) loops. Contradiction.
- outputs NO ( loops on ) halts. Contradiction.
- cannot exist.
Post Correspondence Problem
Formulated by Emile Post in 1946.
A domino is a tile with top string and bottom string .
A match is a sequence of dominos (repetition allowed) where concatenating tops equals concatenating bottoms.
Determining whether a match exists is undecidable.
Hilbert’s 10th Problem
Determine whether a polynomial has an integral root.
Posed in 1900 by David Hilbert. Shown undecidable in 1970 (Matiyasevich et al.).
Single-variable case: search terminates within computable bounds. Decidable.
Multivariable case: no computable bound exists. Turing-acceptable but undecidable.
Other Undecidable Problems
For any programming language:
- Whether a program loops forever on some input.
- Whether a program ever produces output.
- Whether a program halts on a specific input.
For formal languages:
- Equivalence of 2 context-free grammars.
- Emptiness of a context-sensitive language.
- Membership of a string in a Type-0 language.
Intractable Problems
Decidable problems can still be practically unsolvable if no efficient algorithm exists.
A tractable problem has worst-case complexity for fixed .
An intractable problem has no known polynomial algorithm. Best-known algorithms are exponential.
Class P
is the class of decision problems solvable by a deterministic algorithm in polynomial time.
Finding the answer is fast.
Class NP
is the class of decision problems whose solutions are verifiable in polynomial time by a deterministic algorithm.
Finding the answer may be slow. Checking a given answer is fast.
. Every problem solvable fast is also verifiable fast. Whether is open.
Equivalently: solvable by a polynomially bounded nondeterministic algorithm with 3 phases:
- Guessing
Writes an arbitrary string into memory. - Verifying
Deterministic check of input and . Returns true or false. - Output
Outputs yes iff verifying returns true.
NP Problems
- Clique
Given and integer , does a clique of size exist? - Graph Coloring
Given and integer , is -colorable? - Subset Sum
Given set of positive integers and integer , does a subset exist with ? - Satisfiability
Given a Boolean formula, does a assignment exist that evaluates it to 1?- CNF: AND of clauses; each clause is OR of literals.
- 3-CNF-SAT: satisfiability restricted to CNF with exactly 3 literals per clause.
- Hamiltonian Path
Does a graph contain a path visiting every vertex exactly once? - Traveling Salesperson
Given a weighted complete graph and integer , does a Hamiltonian cycle with total weight exist?
NP-Completeness
NP-complete problems are the hardest problems in NP. Every other NP problem reduces to them.
is NP-hard iff every is polynomially reducible to .
is NP-complete iff and is NP-hard.
If any NP-complete problem is in , then .
Examples: SAT, clique, graph coloring, Hamiltonian path, subset sum, TSP.
Polynomial-time Reduction
iff a polynomial-time computable transformation exists such that:
is at least as hard as . If and , then .
Proving NP-Completeness
- Show : give a polynomial-time verifier.
- Select a known NP-complete problem .
- Show : construct a polynomial-time transformation.
- By transitivity, all NP problems reduce to .
Historical Results
Cook’s Theorem: SAT is NP-complete.
Karp’s reductions: decision versions of many optimization problems proved NP-complete via reductions from SAT.