CS 3800: Theory of Computing Undecidability
Fall 2016 Instructor: Daniel Wichs
Outline
• Show: exist languages which are not decidable. – Proof by counting: # of languages > # of TMs.
– Some infinities are bigger than others!
• Show: the following language is not decidable: ATM = {
• A way to show that other languages L are undecidable via a reduction.
Infinity • There are many infinite sets:
– Natural numbers: – Even numbers:
– Rational numbers:
– Realnumbers: – Strings:
– Languages:
1, 2, 3, 4, … 2,4,6,8,…
1, 1/2, 1/3, 2/3 … 1,7/8, 2 ,𝑒, 𝜋,
𝜀, 01, 101, 011001, …
{ {0n1n : n≥0 }, {0*}, … }
Georg Cantor 1870s
(source: wikipedia)
• Are they all the “same size”? • What does that even mean?
Comparing Infinities
S
b2 c3 d4
a1T
5
Let S, T be sets, possibly infinite.
• A function f : S → T is one-to-one if for any a,b ∈ S
such that a ≠ b we have f(a) ≠ f(b).
• Define: |T| ≥ |S| if ∃ f : S → T which is one-to-one. • Define: |T|=|S|if|T|≥|S| and|S|≥|T|.
Comparing Infinities Check: If |T| ≥ |S| ≥ |R| then |T| ≥ |R|.
If f: S→T andg: R→S areone-to-onethen h : R → T defined as h(x) = f(g(x)) is one-to-one.
Comparing Infinities
f
Even Natural Numbers Numbers
g
𝔼 = {2,4,6,8, …}
N = {1,2,3,4, …}
• f : 𝔼 → N : f(x) = x is one-to-one. | N | ≥ | 𝔼 |. • g : N → 𝔼 : g(x) = 2x is one-to-one. | 𝔼 | ≥ | N |. • So | N | = |𝔼|
The Smallest Infinity
Any infinite set A
Natural Numbers
g
N = {1,2,3,4, …}
Natural numbers are the “smallest” infinity: | N | ≤ |A|.
An infinite set A is countable if |A| = | N |. Sufficient to show |A| ≤ | N |.
A
Strings
Natural Numbers
Strings Over {0,1}
N = {1,2,3,4, …}
{0,1}* = {𝜀, 0, 1, 00,…} g : {0,1}* → N : g(x) = 1x (# in binary).
So |{0,1}*| = | N | and {0,1}* is countable.
Strings
Natural Numbers
Strings Over Σ
N = {1,2,3,4, …}
Σ*
Same idea works for Σ* with any finite alphabet Σ. Σ* is countable
Rational Numbers
Natural Numbers
N = {1,2,3,4, …}
Q = { m/n :
Rational Numbers
m, n ∈ N }
Show | Q |≤ |Σ*| ≤ | N | where Σ = {0,…,9,/}. f : Q → Σ* : f(x) = write m/n as a string.
where x = m/n is reduced to lowest terms.
Sets of “Finite Objects”
• Let A be any infinite set of objects where each object has a “finite description” – can uniquely represent it as a string over a finite alphabet Σ .
• Then |A|≤|Σ*|≤ |N|. SoAiscountable.
• Countable Sets:
– All integers Z= { …, -2, -1, 0, 1, 2,… }.
– Tuples: T = { (a1, …,an) : n ≥ 0, ai ∈ N }
– Set of all Turing Machines (or DFAs, PDAs,…)
Uncountable
Are there infinite sets that are not countable?
• Show: set 𝕊 of all infinite (binary) sequences is uncountable.
– An infinite sequence consists of a1,a2, a3,… where ai ∈ {0,1} for all i ∈ N.
– Let 𝕊 = { s : s is an infinite sequence }.
– Note: 𝕊 is not the same as set of strings {0,1}*
Theorem: set 𝕊 of all infinite sequences is uncountable. Proof (by contradiction): Assume 𝕊 countable.
There is a one-to-one function f : 𝕊 → N.
There is a list s1, s2, s3 ,… that enumerates all sequences. si = unique s s.t. f(s) = i, or si = all 0s if s doesn’t exist.
s1 : a11 , a21 , a31 , a41 …
s2 : a12 , a22 , a32 , a42 …
s3 : a13 , a23 , a33 , a4 … …
Define a sequence s* : b1 , b2 , b3 ,… where bi ≠ aii. Then s* is not on the list! Contradiction.
More Uncountable Sets To show A is uncountable, enough to show |B| ≤ |A|
where B is uncountable.
• The real numbers R are uncountable: |𝕊| ≤|R|. One-to-one function f : 𝕊 → R defined by
f(s) = .a1a2a3 … (# in decimal) where s = a1, a2, a3 …
• The set P = PowerSet(N) is uncountable: |𝕊| ≤| P | (Problem Set)
• The set 𝕃 of all languages over {0,1} is uncountable: |𝕊| ≤|𝕃|. One-to-one function f : 𝕊 → 𝕃 defined by
f(s) = { : ai = 1} for s = a1, a2, a3 …
Undecidability: # Languages > # TMs
Saw:
• The set 𝕃 of all languages is uncountable. • The set 𝕄 of all TMs is countably infinite.
Theorem: Some language L ∈ 𝕃 is not decidable or even recognizable.
Proof: Assume otherwise that each L is recognizable. Let f : 𝕃 → 𝕄 be a one-to-one function defined by
f(L) = smallest TM M that recognizes L So |𝕃| ≤ |𝕄|. Contradiction.
Specific Undecidable Problems
We saw that there exist undecidable languages.
• But are these languages we care about?
• Can we find a specific language and show it is undecidable?
• Yes! Most problems that require you to reason about the language of a TM M given its code
Specific Undecidable Problems
Given a description
• Decide if M halts on the input w.
• Decide if M halts on the empty input 𝜀.
• Decide if L(M) = ∅. • ….
All are undecidable!
The TM Self-Acceptance Problem
“TM Self-Acceptance”
SATM = {
“TM Self-Unacceptance”
• •
•
SUTM = {
A Turing Machine M is “self-accepting” if it accepts given the
string
To decide the language SATM need to design an algorithm that looks at some code
SATM , SUTM are complements of each other (assume every string denotes some TM). One is decidable iff the other is.
Theorem: SUTM is an undecidable language.
SUTM = {
Proof: By contradiction. Assume we have a “decider” D (a TM that always halts) for SUTM.
D accepts
D accepts
The TM Acceptance Problem “TM Acceptance” problem:
ATM = {
Recall we showed STM is undecidable:
SATM = {
Theorem: The language ATM is undecidable. Proof: If we had a decider DA for ATM we could
construct a decider for DS for SATM : DS(
Reductions Reduce a problem A to a problem B:
Show how to solve A given a way to solve B.
(Tells us that solving B cannot be “much easier” than solving A. )
If A and B are languages, we reduce A to B
by constructing decider DA for A using a hypothetical decider DB for B as a “subroutine”.
By reducing A to B we show:
• If B decidable then A decidable. (algorithms class)
• If A undecidable then B undecidable. (this class)
Reduce SATM to ATM
ATM = {
SATM = {
Previously showed that SATM undecidable.
To show ATM undecidable reduce SATM to ATM.
Construct a decider DS for SATM using a “supposed” decider DA for ATM as a subroutine:
DSTM(
Halting Problem
H = {
Theorem: H is undecidable. Proof:ReduceATM toHwhere
ATM = {
Construct decider DATM using decider DH as a subroutine. DATM(
Run DH(
Else run M(w) and output whatever it outputs. }
Another Reduction Definition: Acceptance of empty string
ETM = {
Theorem: ETM is undecidable. Proof: Reduce ATM to ETM where
ATM = {
DATM(
Output DETM(
M’w(x) { // ignores x Run M(w) and output what it outputs; }
Key point: M’w(𝜀) accepts iff M(w) accepts.
One More Reduction
R = {
Proof: Reduce ATM to R by constructing a decider DATM using a decider DR as a subroutine.
DATM(
Run DR(M’w); }
M’w(x) {
If x is of form 0n1n
output accept; else output M(w); }
Key point: L(M’w) is regular iff M(w) = accept
Rice’s Theorem
Informal: Any non-trivial property of the language of a TM is undecidable.
Theorem:
Let P be some set of TMs such that:
• P contains some but not all TMs: ∃ M ∈ P and ∃ M ∉ P
• Whenever L(M) = L(M’) then M ∈ P ⇔ M’ ∈ P. In other words, only depends on language.
Then the language L = {
Undecidability in Logic Given a first-order logic statement in number theory
Th(N, + , x) decide if the statement is true or not.
Variables x, y, z… take values in N = {1,2,3,…}
Operations: +, ×
Equality Relation: = (can also give < , > )
Logical quantifiers ∃, ∀ and connectives Λ , V, ¬
Undecidability in Logic
Given a first-order logic statement in number theory Th(N, + , x) decide if the statement is true or not.
•
•
•
∀ x, y ∃ z : x + z = y
– False; if x = 7, y = 5 then no such z exists.
∀ q ∃ p ∀ x, y : (p > q ) ∧ (x,y > 1 ⇒ xy ≠ p) – True; says there are infinitely many primes.
∀ q ∃ p ∀ x, y :
(p > q ) ∧ (x,y > 1 ⇒ (xy ≠ p ∧ xy ≠ p+2 ) ) – Twin Prime Conjecture; remains open!
Theorem: Th(N, + , x) is undecidable. Proof Sketch:
Reduce ATM to Th(N, + , x).
Gödel Church Turing Algorithm gets
𝜑𝑀,𝑤 which is true if and only if M accepts w.
• Design a way to encode TM computations as natural numbers x.
• Design a formula 𝜓𝑀,𝑤(x) = “x represents an accepting computation of M on w.”
• Set𝜑𝑀,𝑤 = ∃x :𝜓𝑀,𝑤(x)
Corollary:
There is no decidable “set of axioms” A for Th(N, + , x).
– Can decide if a ∈ A
– Any true statement 𝜑 can be proved from the axioms.
Proof Sketch:
If there was a decidable set of axioms A for Th(N, + , x), then
could decide if 𝜑 is true:
• Try all strings 𝜋 one-by-one
– Check if 𝜋 is a valid proof of 𝜑 using axioms a ∈ A. If so, accept. – Check if 𝜋 is a valid proof of ¬𝜑 using axioms a ∈ A. If so, reject.
Undecidability in Logic
But people solve undecidable problems all the time (e.g., prove theorems in number theory).
Aren’t they just applying some complex algorithm?
• Even if a problem is undecidable: some algorithms can solve some instances, but no algorithm can solve all the instances.
• There is much research on “heuristics” that solve many useful instances of undecidable problems:
– program verification, virus checkers, theorem provers…
Hilbert’s 10th Problem
Posed by Hilbert in 1900: Design an algorithm which is given a multivariate polynomial p, and decides if p has an integer root or not.
e.g. p(x,y,z) = 6x3yz + 3xy2 – x3 – 10 has a root x=5, y=3, z =0
Decide the language:
H10 = {
: p polynomial with integer root }
Theorem [Matijasevic 1970]: H10 is undecidable. Proof: A complicated reduction.
Summary
• There are more languages than Turing Machines (uncountable vs. countable infinity) so some languages must be undecidable.
• Most problems where you’re given a TM and need to figure out something about the language of the TM are undecidable.
• Some important problems in mathematics are undecidable.
• Reduce an undecidable problem A to another problem B to
show B undecidable.
– Surprising connections between seemingly unrelated problems.