Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Theory of computation

Lecture 8: Turing Machines

Adnane Saoud

Tuesday, November 28, 2023

1
Summary of lecture 7
Lecture 7
• Notation for encodings and TMs
• Decidability of various problems about automata and grammars:
• Decidability for TMs.
• Diagonalization method

Lecture 8
• The Reducibility Method to prove undecidability and T-
unrecognizability.
• Mapping reducibility as a type of reducibility.

2
Decidability of TMs

3
Acceptance Problem for TMs

Let 𝐴TM = { 𝑀, 𝑤 | 𝑀 is a TM and 𝑀 accepts 𝑤}


Theorem: 𝐴TM is not decidable
Proof: Undecidability lecture.

Theorem: 𝐴TM is T-recognizable


Proof: The following TM 𝑈 recognizes 𝐴TM
𝑈 = “On input 𝑀, 𝑤
1. Simulate 𝑀 on input 𝑤.
2. Accept if 𝑀 halts and accepts.
3. Reject if 𝑀 halts and rejects.

Turing’s original “Universal Computing Machine”

Description of 𝑀, input 𝑤
𝑈
4
Acceptance Problem for TMs

Let 𝐴TM = { 𝑀, 𝑤 | 𝑀 is a TM and 𝑀 accepts 𝑤}


Today’s Theorem: 𝐴TM is not decidable
Proof uses the diagonalization method,
so we will introduce that first.

5
The Size of Infinity

How to compare the relative sizes of infinite sets?


Cantor (~1890s) had the following idea.
Definition: Say that set 𝐴 and 𝐵 have the same size if there is
bijective function 𝑓: 𝐴 → 𝐵
𝑥≠𝑦→
Range (𝑓) = 𝐵
𝑓 𝑥 ≠𝑓 𝑦
“surjective”
“injective”

Informally, two sets have the same size if we can pair up their members.
This definition works for finite sets.
Apply it to infinite sets too.

6
Countable Sets

Let ℕ = {1,2,3, … } and let ℤ = {… , −2, −1,0,1,2, … }


Show ℕ and ℤ have the same size 𝑛 𝑓(𝑛)
ℕ 1 0 ℤ
2 -1
3 1
4 -2
5 2

Let ℚ# = $⁄ 6 -3
% 𝑚, 𝑛 ∈ ℕ} 7 3
Show ℕ and ℚ! have the same size ⋮ ⋮

Definition: A set is countable if it is


finite or it has the same size as ℕ.
Both ℤ and ℚ# are countable.
7
ℝ is Uncountable – Diagonalization

Let ℝ = all real numbers (expressible by infinite decimal expansion)


Theorem: ℝ is uncountable
Proof by contradiction via diagonalization: Assume ℝ is countable
So there is a 1-1 correspondence 𝑓: ℕ → ℝ

𝑛 𝑓(𝑛) Demonstrate a number 𝑥 ∈ ℝ that is missing from the list.


1 2.718281828…
2 3.141592653… differs from the 𝑛th number in the 𝑛th digit
3 0.000000000… so cannot be the 𝑛th number for any 𝑛.
4 1.414213562… Hence 𝑥 is not paired with any 𝑛. It is missing from the list.
5 0.142857242… Therefore 𝑓 is not a 1-1 correspondence.
6 0.207879576…
7 1.234567890…
⋮ ⋮ Diagonalization
8
𝐴TM is undecidable

Recall 𝐴TM = { 𝑀, 𝑤 | 𝑀 is a TM and 𝑀 accepts 𝑤}


Theorem: 𝐴TM is not decidable
Proof by contradiction: Assume some TM 𝐻 decides 𝐴TM.
Accept if 𝑀 accepts 𝑤
So 𝐻 on 𝑀, 𝑤 = 9
Reject if not
Use 𝐻 to construct TM 𝐷
𝐷 = “On input 〈𝑀〉
1. Simulate 𝐻 on input 〈𝑀, 𝑀 〉
2. Accept if 𝐻 rejects. Reject if 𝐻 accepts.”

𝐷 accepts 〈𝑀〉 iff 𝑀 doesn’t accept 𝑀 .


𝐷 accepts 〈𝐷〉 iff 𝐷 doesn’t accept 𝐷 .
Contradiction.

9
𝐴TM is undecidable

Recall 𝐴TM = { 𝑀, 𝑤 | 𝑀 is a TM and 𝑀 accepts 𝑤}


Theorem: 𝐴TM is not decidable
Proof by contradiction: Assume some TM 𝐻 decides 𝐴TM.
𝐷 accepts 〈𝐷〉 iff 𝐷 doesn’t accept 𝐷 .
Why is this proof a diagonalization?
All All TM descriptions:
TMs 〈𝑀 〉 〈𝑀 〉 〈𝑀 〉 〈𝑀 〉 ... 〈𝐷〉
# $ % &

𝑀# acc rej acc acc ...


𝑀$ rej rej rej rej
𝑀% acc acc acc acc ...
𝑀& rej rej acc acc
⋮ ⋮
𝐷 rej acc rej rej ?
10
𝐴TM is T-unrecognizable
Theorem: If 𝐴 and 𝐴 are T-recognizable then 𝐴 is decidable
Proof: Let TM 𝑀" and 𝑀# recognize 𝐴 and 𝐴.
Construct TM 𝑇 deciding 𝐴.
𝑇 = “On input 𝑤
1. Run 𝑀" and 𝑀# on 𝑤 in parallel until one accepts.
2. If 𝑀" accepts then accept.
If 𝑀# accepts then reject.”
Complement of
T-recognizable =
Corollary: 𝐴TM is T-unrecognizable co-T-recognizable T-recognizable
Proof: 𝐴TM is T-recognizable but also undecidable

𝐴TM 𝐴TM

decidable

11
𝐴TM is T-unrecognizable

Exercise:
From what we’ve learned, which closure properties
can we prove for the class of T-recognizable languages?
Choose all that apply.
(a) Closed under union.
(b) Closed under intersection.
(c) Closed under complement.
(d) Closed under concatenation.
(e) Closed under star.

12
Reducibility

13
The Reducibility Method

Use our knowledge that 𝐴TM is undecidable to show other


problems are undecidable.
Defn: 𝐻𝐴𝐿𝑇TM = 𝑀, 𝑤 𝑀 halts on input 𝑤}
Theorem: 𝐻𝐴𝐿𝑇TM is undecidable
Proof by contradiction, showing that 𝐴TM is reducible to 𝐻𝐴𝐿𝑇TM:
Assume that 𝐻𝐴𝐿𝑇TM is decidable and show that 𝐴TM is decidable (false!).
Let TM 𝑅 decide 𝐻𝐴𝐿𝑇TM.
Construct TM 𝑆 deciding 𝐴TM.
𝑆 = “On input 𝑀, 𝑤
1. Use 𝑅 to test if 𝑀 on 𝑤 halts. If not, reject.
2. Simulate 𝑀 on 𝑤 until it halts (as guaranteed by 𝑅).
3. If 𝑀 has accepted then accept.
If 𝑀 has rejected then reject.
TM 𝑆 decides 𝐴TM, a contradiction. Therefore 𝐻𝐴𝐿𝑇TM is undecidable.

14
Reducibility – Concept

If we have two languages (or problems) 𝐴 and 𝐵, then


𝐴 is reducible to 𝐵 means that we can use 𝐵 to solve 𝐴.
Example 1: Measuring the area of a rectangle
is reducible to measuring the lengths of its sides.
Example 2: We showed that 𝐴NFA is reducible to 𝐴DFA .
If 𝐴 is reducible to 𝐵 then solving 𝐵 gives a solution to 𝐴.
- then 𝐵 is easy → 𝐴 is easy.
- then 𝐴 is hard → 𝐵 is hard.
this is the form we will use

15
𝐸TM is undecidable
Let 𝐸TM = { 𝑀 | 𝑀 is a TM and 𝐿 𝑀 = ∅ }
Theorem: 𝐸TM is undecidable
Proof by contradiction. Show that 𝐴TM is reducible to 𝐸TM.
Assume that 𝐸TM is decidable and show that 𝐴TM is decidable (false!).
Let TM 𝑅 decide 𝐸TM.
Construct TM 𝑆 deciding 𝐴TM.
𝑆 = “On input 𝑀, 𝑤
1. Transform 𝑀 to new TM 𝑀$ = “On input 𝑥
1. If 𝑥 ≠ 𝑤, reject.
2. else run 𝑀 on 𝑤
3. Accept if 𝑀 accepts.”
2. Use 𝑅 to test whether 𝐿(𝑀$ ) = ∅
3. If YES [so 𝑀 rejects 𝑤] then reject. 𝑀$ works like 𝑀 except that it
If NO [so 𝑀 accepts 𝑤] then accept. always rejects strings 𝑥 where 𝑥 ≠ 𝑤.
𝑤 if 𝑀 accepts 𝑤
So 𝐿 𝑀$ = 9
∅ if 𝑀 rejects 𝑤
16
Mapping Reducibility

17
Mapping Reducibility
Definition: Function 𝑓: Σ ∗ → Σ ∗ is computable if there is a TM 𝐹
where 𝐹 on input 𝑤 halts with 𝑓(𝑤) on its tape, for all strings 𝑤.
Definition: 𝐴 is mapping-reducible to 𝐵 (𝐴 ≤. 𝐵) if there is
a computable function 𝑓 where 𝑤 ∈ 𝐴 iff 𝑓 𝑤 ∈ 𝐵.
𝑤 𝑓 𝑤

𝐴 𝑓 𝐵

18
Mapping Reducibility
Definition: Function 𝑓: Σ ∗ → Σ ∗ is computable if there is a TM 𝐹
where 𝐹 on input 𝑤 halts with 𝑓(𝑤) on its tape, for all strings 𝑤.
Definition: 𝐴 is mapping-reducible to 𝐵 (𝐴 ≤. 𝐵) if there is
a computable function 𝑓 where 𝑤 ∈ 𝐴 iff 𝑓 𝑤 ∈ 𝐵.

Example: 𝐴TM ≤. 𝐸TM


The computable reduction function 𝑓 is 𝑓( 𝑀, 𝑤 ) = 𝑀0
Because 𝑀, 𝑤 ∈ 𝐴TM iff 𝑀0 ∈ 𝐸TM
( 𝑀 accepts 𝑤 iff 𝐿 𝑀0 ≠ ∅ )
Recall TM 𝑀$ = “On input 𝑥
1. If 𝑥 ≠ 𝑤, reject.
2. else run 𝑀 on 𝑤
3. Accept if 𝑀 accepts.”
19
Summary

1. Mapping reducibility as a type of reducibility.


2. 𝐸TM is undecidable.
3. 𝐸TM is T-unrecognizable.

20

You might also like