02_turing_decidability
02_turing_decidability
Algorithmic Complexity
Turing Machines and Decidability
2023
Some General Knowledge
Alan Mathison Turing
1
Turing Machines
Introduction to Turing Machines
Turing Machines and Decision Problems
Non-Determinism
Church-Turing Thesis
Decidability
Recognizable and Decidable Problems
Halting Problem and Reductions
δ : Q × Γ → Q × Γ × {L, R}
1 0 1 0 1 0 B B ...
1 0 1 0 1 0 B B ...
1 0 1 0 1 0 B B ...
1 0 1 0 1 0 B B ...
1 0 1 0 1 0 B B ...
1 0 1 0 1 0 B B ...
1 0 1 0 1 0 B B ...
1 0 1 0 1 0 0 B ...
Example
If M returns YES on inputs P ∈ N[X ] with exactly one root, then
L(M) = {P ∈ N[X ] | P is a polynomial with exactly one root }
Example
If M returns YES on inputs P ∈ N[X ] with exactly one root, then
L(M) = {P ∈ N[X ] | P is a polynomial with exactly one root }
Definition
Given M a Turing machine and δ its transition function, M is
deterministic (DTM) if δ is a mapping from any configuration (q, x) to
(at most) a single image (q 0 , x 0 , m)
Otherwise, M is non-deterministic (NDTM)
Definition
Given M a Turing machine and δ its transition function, M is
deterministic (DTM) if δ is a mapping from any configuration (q, x) to
(at most) a single image (q 0 , x 0 , m)
Otherwise, M is non-deterministic (NDTM)
Deterministic Non-Deterministic
(q0 , x0 ) (q0 , x0 )
δ δ
δ δ
(q1 , x1 ) ... (qk , xk )
(q1 , x1 ) δ
δ δ δ
...
... ...
...
δ δ
δ δ
δ
(qm , xm ) (qn , xn )
(qn , xn ) (qo , xo ) (qp , xp )
Turing completeness
A system (computing model, programming language,. . . ) is called
Turing complete if it can compute every possible computable function
J.-G. Mailly | Intro to Complexity
Outline
14
Turing Machines
Introduction to Turing Machines
Turing Machines and Decision Problems
Non-Determinism
Church-Turing Thesis
Decidability
Recognizable and Decidable Problems
Halting Problem and Reductions
Recognizability of a Problem
A problem P is called recognizable if there exists a Turing machine
M such that, for each instance i of P, M(i) answers YES iff i is a
positive instance of P
Recognizability of a Language
A language L is called recognizable if there exists a Turing machine
M such that L = L(M)
Recognizability of a Problem
A problem P is called recognizable if there exists a Turing machine
M such that, for each instance i of P, M(i) answers YES iff i is a
positive instance of P
Recognizability of a Language
A language L is called recognizable if there exists a Turing machine
M such that L = L(M)
Prime Numbers
I Is n ∈ N a prime number?
This problem/language is recognizable: we can write an algorithm
which answers YES when n is prime, and doesn’t care of non-prime
numbers
Decidability of a Problem
A problem P is called decidable if there exists a Turing machine M
such that, for each instance i of P,
I M(i) answers YES when i is a positive instance of P
I M(i) answers NO when i is a negative instance of P
Decidability of a Problem
A language L is called decidable if there exists a Turing machine M
which accepts each x ∈ L and rejects each x ∈ /L
Equivalently: L is decidable iff both L and L̄ are recognizable
Decidability of a Problem
A problem P is called decidable if there exists a Turing machine M
such that, for each instance i of P,
I M(i) answers YES when i is a positive instance of P
I M(i) answers NO when i is a negative instance of P
Decidability of a Problem
A language L is called decidable if there exists a Turing machine M
which accepts each x ∈ L and rejects each x ∈ /L
Equivalently: L is decidable iff both L and L̄ are recognizable
Prime Numbers
I Is n ∈ N a prime number?
This problem/language is decidable: we can write an algorithm which
answers YES when n is prime, and NO otherwise
J.-G. Mailly | Intro to Complexity
Complement of a Decision Problem
17
Definition
A problem P1 is called the complement of P2 L(P1 ) = L(P2 ).
Equivalently:
I P1 and P2 are defined on the same set of instances
I Positive instances of P1 are negative instances of P2
I Negative instances of P1 are positive instances of P2
Notation: P1 = P2
Definition
A problem P1 is called the complement of P2 L(P1 ) = L(P2 ).
Equivalently:
I P1 and P2 are defined on the same set of instances
I Positive instances of P1 are negative instances of P2
I Negative instances of P1 are positive instances of P2
Notation: P1 = P2
Prime Numbers
I Given n ∈ N, is there m ∈ N, m 6= 1, m 6= n, s.t. m divides n?
This problem is the complement of the prime number problem.
Functional Reduction
A functional reduction f is a total computable function from a problem
P1 to a problem P2 such that, for any instance i of P1 , i is a positive
instance iff f (i) is a positive instance of P2
Notation:
P1 ≤f P2
Functional Reduction
A functional reduction f is a total computable function from a problem
P1 to a problem P2 such that, for any instance i of P1 , i is a positive
instance iff f (i) is a positive instance of P2
Notation:
P1 ≤f P2
Theorem
If P1 ≤f P2 and P1 is undecidable, then P2 is undecidable
I P1 : Given n ∈ N, is n even?
I P2 : Given n ∈ N, is n odd?
I f : N → N is defined by f (n) = n + 1
I P1 : Given n ∈ N, is n even?
I P2 : Given n ∈ N, is n odd?
I f : N → N is defined by f (n) = n + 1
For a positive instance i of P1 , f (i) is a positive instance of P2 .
For a negative instance i of P1 , f (i) is a negative instance of P2 .
I P1 : Given n ∈ N, is n even?
I P2 : Given n ∈ N, is n odd?
I f : N → N is defined by f (n) = n + 1
For a positive instance i of P1 , f (i) is a positive instance of P2 .
For a negative instance i of P1 , f (i) is a negative instance of P2 .
So P1 ≤f P2
I P1 : Given n ∈ N, is n even?
I P2 : Given n ∈ N, is n odd?
I f : N → N is defined by f (n) = n + 1
For a positive instance i of P1 , f (i) is a positive instance of P2 .
For a negative instance i of P1 , f (i) is a negative instance of P2 .
So P1 ≤f P2
Here we also have P2 ≤f P1 ; this is trivial since these are decidable
problems.
Language
L1 = {M | M halts on }
with the empty word. Is L1 decidable?
Language
L1 = {M | M halts on }
with the empty word. Is L1 decidable?
Proof of Undecidability
We need a mapping f : (M, x) 7→ M0 s.t. (M, x) ∈ Halting iff M0 ∈ L1
Language
L1 = {M | M halts on }
with the empty word. Is L1 decidable?
Proof of Undecidability
We need a mapping f : (M, x) 7→ M0 s.t. (M, x) ∈ Halting iff M0 ∈ L1
I M0x (y ) = M(x.y ) with x.y the concatenation of words
I M0x () = M(x), so obviously:
I If M halts on x, then M0x halts on
I If M loops on x, then M0x loops on
« Algorithmic » Proof
If P1 is known to be undecidable, we can prove that P2 is undecidable
with an algorithm which computes P1 using only « simple » steps and
calls to P2
« Algorithmic » Proof
If P1 is known to be undecidable, we can prove that P2 is undecidable
with an algorithm which computes P1 using only « simple » steps and
calls to P2
Algorithm 2 Halting
Remember: L1 = {M | Input: M, x = x0 x1 . . . xn
M halts on }. Suppose if x = then
that ML1 is a Turing return ML1 (M)
Machine which decides else
L1 . x 0 = x1 . . . xn
M0 = M with q0 replaced by δ(q0 , x0 )
return Halting(M0 , x 0 )
end if
« Algorithmic » Proof
If P1 is known to be undecidable, we can prove that P2 is undecidable
with an algorithm which computes P1 using only « simple » steps and
calls to P2
Algorithm 3 Halting
Remember: L1 = {M | Input: M, x = x0 x1 . . . xn
M halts on }. Suppose if x = then
that ML1 is a Turing return ML1 (M)
Machine which decides else
L1 . x 0 = x1 . . . xn
M0 = M with q0 replaced by δ(q0 , x0 )
return Halting(M0 , x 0 )
end if
« Algorithmic » Proof
If P1 is known to be undecidable, we can prove that P2 is undecidable
with an algorithm which computes P1 using only « simple » steps and
calls to P2
Algorithm 4 Halting
Remember: L1 = {M | Input: M, x = x0 x1 . . . xn
M halts on }. Suppose if x = then
that ML1 is a Turing return ML1 (M)
Machine which decides else
L1 . x 0 = x1 . . . xn
M0 = M with q0 replaced by δ(q0 , x0 )
return Halting(M0 , x 0 )
end if
Algorithm 7 Prime
Input: n ∈ N √
for x ∈ {2, . . . , b nc} do
if ∃y ∈ N s.t. n = x × y then
return false
end if
end for
return true
J.-G. Mailly | Intro to Complexity
(Un)Decidability where we don’t expect it
24