CS 301 Lecture 19 Diagonalization and undecidable languages - - PowerPoint PPT Presentation

cs 301
SMART_READER_LITE
LIVE PREVIEW

CS 301 Lecture 19 Diagonalization and undecidable languages - - PowerPoint PPT Presentation

CS 301 Lecture 19 Diagonalization and undecidable languages Stephen Checkoway April 4, 2018 1 / 26 Sizes of sets Two sets X and Y have the same size if there is a bijection between them, f X Y Whats a bijection? 2 / 26 Sizes


slide-1
SLIDE 1

CS 301

Lecture 19 – Diagonalization and undecidable languages Stephen Checkoway April 4, 2018

1 / 26

slide-2
SLIDE 2

Sizes of sets

Two sets X and Y have the same size if there is a bijection between them, f ∶ X → Y What’s a bijection?

2 / 26

slide-3
SLIDE 3

Sizes of sets

Two sets X and Y have the same size if there is a bijection between them, f ∶ X → Y What’s a bijection? Recall f ∶ X → Y is a bijection if

1 for all a, b ∈ X, f(a) = f(b) implies a = b (injective) 2 for all y ∈ Y , there exists x ∈ X such that y = f(x) (surjective)

2 / 26

slide-4
SLIDE 4

Example

The natural numbers and the integers have the same size f ∶ Z → N f(x) = {2x if x ≥ 0 −2x − 1 if x < 0

3 / 26

slide-5
SLIDE 5

Example

The natural numbers and the integers have the same size f ∶ Z → N f(x) = {2x if x ≥ 0 −2x − 1 if x < 0 ⋮ −2 ↦ 3 −1 ↦ 1 0 ↦ 0 1 ↦ 2 2 ↦ 4 ⋮

3 / 26

slide-6
SLIDE 6

Example

The integers and the rational numbers have the same size

4 / 26

slide-7
SLIDE 7

Example

The integers and the rational numbers have the same size The fundamental theorem of arithmetic tells us that every positive integer can be expressed uniquely as a product of prime powers pn1

1 pn2 2 pn3 3 ⋯

where pi are the primes in order (2, 3, 5, 7, etc.) and ni ∈ N and finitely many ni are nonzero

4 / 26

slide-8
SLIDE 8

Example

The integers and the rational numbers have the same size The fundamental theorem of arithmetic tells us that every positive integer can be expressed uniquely as a product of prime powers pn1

1 pn2 2 pn3 3 ⋯

where pi are the primes in order (2, 3, 5, 7, etc.) and ni ∈ N and finitely many ni are nonzero Similarly, every positive rational number can be expressed uniquely as a product of prime powers pn1

1 pn2 2 pn3 3 ⋯

where pi are the primes in order and ni ∈ Z and finitely many ni are nonzero

4 / 26

slide-9
SLIDE 9

Example continued

Let f ∶ Z → N be our bijection from before Define g ∶ Q+ → Z+ by g(pn1

1 pn2 2 pn3 3 ⋯ ) = p f(n1) 1

p

f(n2) 2

p

f(n3) 3

⋯ Note that we’re mapping the integer exponents to natural number exponents and the (infinitely many) 0 exponents remain 0 because f(0) = 0

5 / 26

slide-10
SLIDE 10

Example continued

Let f ∶ Z → N be our bijection from before Define g ∶ Q+ → Z+ by g(pn1

1 pn2 2 pn3 3 ⋯ ) = p f(n1) 1

p

f(n2) 2

p

f(n3) 3

⋯ Note that we’re mapping the integer exponents to natural number exponents and the (infinitely many) 0 exponents remain 0 because f(0) = 0 Since f is a bijection, g is a bijection (this isn’t hard to show)

5 / 26

slide-11
SLIDE 11

Example continued

Let f ∶ Z → N be our bijection from before Define g ∶ Q+ → Z+ by g(pn1

1 pn2 2 pn3 3 ⋯ ) = p f(n1) 1

p

f(n2) 2

p

f(n3) 3

⋯ Note that we’re mapping the integer exponents to natural number exponents and the (infinitely many) 0 exponents remain 0 because f(0) = 0 Since f is a bijection, g is a bijection (this isn’t hard to show) Finally, let’s define our bijection h ∶ Q → Z h(x) = ⎧ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎩ g(x) if x > 0 if x = 0 −g(−x) if x < 0

5 / 26

slide-12
SLIDE 12

Example continued

Let f ∶ Z → N be our bijection from before Define g ∶ Q+ → Z+ by g(pn1

1 pn2 2 pn3 3 ⋯ ) = p f(n1) 1

p

f(n2) 2

p

f(n3) 3

⋯ Note that we’re mapping the integer exponents to natural number exponents and the (infinitely many) 0 exponents remain 0 because f(0) = 0 Since f is a bijection, g is a bijection (this isn’t hard to show) Finally, let’s define our bijection h ∶ Q → Z h(x) = ⎧ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎩ g(x) if x > 0 if x = 0 −g(−x) if x < 0 And just for fun, f ◦ h ∶ Q → N is a bijection

5 / 26

slide-13
SLIDE 13

Countable

A set X is countable if it is finite or it has the same size as N

6 / 26

slide-14
SLIDE 14

Countable

A set X is countable if it is finite or it has the same size as N Countably infinite sets include N, Z, and Q

6 / 26

slide-15
SLIDE 15

Countable

A set X is countable if it is finite or it has the same size as N Countably infinite sets include N, Z, and Q Subsets of countable sets are countable (intuitively true but a hassle to prove without some additional math or an alternative, but equivalent definition of countability)

6 / 26

slide-16
SLIDE 16

Each language is a countable set

Given an alphabet Σ, the language Σ∗ is countably infinite. How do we show this?

7 / 26

slide-17
SLIDE 17

Each language is a countable set

Given an alphabet Σ, the language Σ∗ is countably infinite. How do we show this? List the strings in lexicographic order to construct the mapping E.g., f ∶ {0, 1}∗ → N given by ε ↦ 0 0 ↦ 1 1 ↦ 2 00 ↦ 3 01 ↦ 4 10 ↦ 5 11 ↦ 6 000 ↦ 7 ⋮

7 / 26

slide-18
SLIDE 18

Each language is a countable set

Given an alphabet Σ, the language Σ∗ is countably infinite. How do we show this? List the strings in lexicographic order to construct the mapping E.g., f ∶ {0, 1}∗ → N given by ε ↦ 0 0 ↦ 1 1 ↦ 2 00 ↦ 3 01 ↦ 4 10 ↦ 5 11 ↦ 6 000 ↦ 7 ⋮ Every language L ⊆ Σ∗ is thus countable

7 / 26

slide-19
SLIDE 19

Diagonalization: infinite sequences over {0, 1}

Theorem

The set S of all infinite sequences over {0, 1} is uncountable

8 / 26

slide-20
SLIDE 20

Diagonalization: infinite sequences over {0, 1}

Theorem

The set S of all infinite sequences over {0, 1} is uncountable

Proof.

Assume S is countable so there’s a bijection f ∶ N → S We can construct a new infinite sequence b = b0, b1, . . . that differs from every sequence in S.

n f(n) 0 0 1 0 1 ⋯ 1 1 0 0 0 1 ⋯ 2 0 1 1 0 0 ⋯ 3 1 1 0 1 0 ⋯ ⋮ ⋮

8 / 26

slide-21
SLIDE 21

Diagonalization: infinite sequences over {0, 1}

Theorem

The set S of all infinite sequences over {0, 1} is uncountable

Proof.

Assume S is countable so there’s a bijection f ∶ N → S We can construct a new infinite sequence b = b0, b1, . . . that differs from every sequence in S. In particular, bi will differ from f(i) in position i bi = {0 if the ith element of f(i) is 1 1 if the ith element of f(i) is 0

n f(n) 0 0 1 0 1 ⋯ 1 1 0 0 0 1 ⋯ 2 0 1 1 0 0 ⋯ 3 1 1 0 1 0 ⋯ ⋮ ⋮

b = 1100⋯

8 / 26

slide-22
SLIDE 22

Diagonalization: infinite sequences over {0, 1}

Theorem

The set S of all infinite sequences over {0, 1} is uncountable

Proof.

Assume S is countable so there’s a bijection f ∶ N → S We can construct a new infinite sequence b = b0, b1, . . . that differs from every sequence in S. In particular, bi will differ from f(i) in position i bi = {0 if the ith element of f(i) is 1 1 if the ith element of f(i) is 0 Now b ∈ S but for all i, f(i) ≠ b which is a contradiction so S must not be countable

n f(n) 0 0 1 0 1 ⋯ 1 1 0 0 0 1 ⋯ 2 0 1 1 0 0 ⋯ 3 1 1 0 1 0 ⋯ ⋮ ⋮

b = 1100⋯

8 / 26

slide-23
SLIDE 23

There are a countable number of Turing machines

Consider any fixed binary representation of a TM E.g., given Q = {1, 2, . . . , k} Σ = {1, 2, . . . , m} Γ = {1, 2, . . . , n} δ ∶ Q × Γ → Q × Γ × {1, 2} where 1 = L and 2 = R M = (Q, Σ, Γ, δ, q0, qaccept, qreject) here’s one possible representation ⟨δ(q, a)⟩ = 0r10b10d where δ(q, a) = (r, b, d) ⟨δ⟩ = ⟨δ(1, 1)⟩ 11 ⟨δ(1, 2)⟩ 11 ⋯ 11 ⟨δ(k, n)⟩ ⟨M⟩ = 0k 111 0m 111 0n 111 ⟨δ⟩ 111 0qaccept 111 0qreject Thus ⟨M⟩ is an element of {0, 1}∗

9 / 26

slide-24
SLIDE 24

There are a countable number of Turing machines continued

For simplicity, for all x ∈ {0, 1}∗ such that x is not a valid encoding of a TM, define x to be a TM with q0 = qreject

10 / 26

slide-25
SLIDE 25

There are a countable number of Turing machines continued

For simplicity, for all x ∈ {0, 1}∗ such that x is not a valid encoding of a TM, define x to be a TM with q0 = qreject Now every binary string is a valid encoding of a TM, i.e., {0, 1}∗ = {⟨M⟩ ∣ ⟨M⟩ is is a TM}

10 / 26

slide-26
SLIDE 26

There are a countable number of Turing machines continued

For simplicity, for all x ∈ {0, 1}∗ such that x is not a valid encoding of a TM, define x to be a TM with q0 = qreject Now every binary string is a valid encoding of a TM, i.e., {0, 1}∗ = {⟨M⟩ ∣ ⟨M⟩ is is a TM} Since {0, 1}∗ is countable, there are a countable number of Turing machines

10 / 26

slide-27
SLIDE 27

There are an uncountable number of languages

Theorem

For every alphabet Σ, the set of all languages over Σ is uncountable

11 / 26

slide-28
SLIDE 28

There are an uncountable number of languages

Theorem

For every alphabet Σ, the set of all languages over Σ is uncountable

Proof.

We proved that Σ∗ is countably infinite; let f ∶ N → Σ∗ be a bijection For each language L over Σ, define an infinite sequence b = b0, b1, . . . over {0, 1} where bi = {0 if f(i) ∉ L 1 if f(i) ∈ L b is called the characteristic sequence of L

11 / 26

slide-29
SLIDE 29

There are an uncountable number of languages

Theorem

For every alphabet Σ, the set of all languages over Σ is uncountable

Proof.

We proved that Σ∗ is countably infinite; let f ∶ N → Σ∗ be a bijection For each language L over Σ, define an infinite sequence b = b0, b1, . . . over {0, 1} where bi = {0 if f(i) ∉ L 1 if f(i) ∈ L b is called the characteristic sequence of L Each characteristic sequence defines a language and each language has a unique characteristic sequence We proved that there are uncountably many infinite binary sequences so there are uncountably many languages over Σ

11 / 26

slide-30
SLIDE 30

A simple corollary

There are (uncountably many) languages that are not Turing-recognizable (and thus not decidable)

12 / 26

slide-31
SLIDE 31

An explicit undecidable language

Theorem

The language Diag = {⟨M⟩ ∣ M is a TM and does not accept ⟨M⟩} is undecidable

13 / 26

slide-32
SLIDE 32

An explicit undecidable language

Theorem

The language Diag = {⟨M⟩ ∣ M is a TM and does not accept ⟨M⟩} is undecidable

Proof.

Assume that D is a TM that decides Diag Is ⟨D⟩ ∈ Diag?

13 / 26

slide-33
SLIDE 33

An explicit undecidable language

Theorem

The language Diag = {⟨M⟩ ∣ M is a TM and does not accept ⟨M⟩} is undecidable

Proof.

Assume that D is a TM that decides Diag Is ⟨D⟩ ∈ Diag? Two options

  • If ⟨D⟩ ∈ Diag, then since D decides Diag, D must accept ⟨D⟩ but then by

definition of Diag, ⟨D⟩ ∉ Diag

13 / 26

slide-34
SLIDE 34

An explicit undecidable language

Theorem

The language Diag = {⟨M⟩ ∣ M is a TM and does not accept ⟨M⟩} is undecidable

Proof.

Assume that D is a TM that decides Diag Is ⟨D⟩ ∈ Diag? Two options

  • If ⟨D⟩ ∈ Diag, then since D decides Diag, D must accept ⟨D⟩ but then by

definition of Diag, ⟨D⟩ ∉ Diag

  • If ⟨D⟩ ∉ Diag, then since D decides Diag, D must reject ⟨D⟩ but if D rejects

⟨D⟩, then by definition, ⟨D⟩ ∈ Diag Either option leads to a contradiction so Diag must not be decidable

13 / 26

slide-35
SLIDE 35

An explicit undecidable language

Theorem

The language Diag = {⟨M⟩ ∣ M is a TM and does not accept ⟨M⟩} is undecidable

Proof.

Assume that D is a TM that decides Diag Is ⟨D⟩ ∈ Diag? Two options

  • If ⟨D⟩ ∈ Diag, then since D decides Diag, D must accept ⟨D⟩ but then by

definition of Diag, ⟨D⟩ ∉ Diag

  • If ⟨D⟩ ∉ Diag, then since D decides Diag, D must reject ⟨D⟩ but if D rejects

⟨D⟩, then by definition, ⟨D⟩ ∈ Diag Either option leads to a contradiction so Diag must not be decidable Replacing “reject” with “does not accept” in the proof shows that Diag is not only not decidable, it’s not even Turing-recognizable!

13 / 26

slide-36
SLIDE 36

Acceptance problem for TMs

Theorem

The language ATM = {⟨M, w⟩ ∣ M is a TM and w ∈ L(M)} is undecidable How should we approach problems like this?

14 / 26

slide-37
SLIDE 37

Proving that a language is not decidable

To prove that a language A is undecidable,

1 Assume that A is decidable and let R be a TM that decides A 2 Select an undecidable language B 3 Construct a new TM D that decides B and that uses R as a subroutine 4 Since B is undecidable but D is a decider, this is a contradiction and our

assumption in step 1 must be wrong so A is undecidable Steps 2 and 3 are the hard steps that require some cleverness

15 / 26

slide-38
SLIDE 38

Proof

Proof that ATM is undecidable.

Assume that ATM is decidable with decider R. Let’s build a TM D that decides Diag.

16 / 26

slide-39
SLIDE 39

Proof

Proof that ATM is undecidable.

Assume that ATM is decidable with decider R. Let’s build a TM D that decides Diag. D = “On input ⟨M⟩,

1 Run R on ⟨M, ⟨M⟩⟩ 2 If R accepts, reject; otherwise accept.”

We need to show that L(D) = Diag and that D is a decider.

16 / 26

slide-40
SLIDE 40

Proof

Proof that ATM is undecidable.

Assume that ATM is decidable with decider R. Let’s build a TM D that decides Diag. D = “On input ⟨M⟩,

1 Run R on ⟨M, ⟨M⟩⟩ 2 If R accepts, reject; otherwise accept.”

We need to show that L(D) = Diag and that D is a decider. By assumption, R is a decider so it halts on ⟨M, ⟨M⟩⟩ and thus D halts on all input so it is a decider

16 / 26

slide-41
SLIDE 41

Proof

Proof that ATM is undecidable.

Assume that ATM is decidable with decider R. Let’s build a TM D that decides Diag. D = “On input ⟨M⟩,

1 Run R on ⟨M, ⟨M⟩⟩ 2 If R accepts, reject; otherwise accept.”

We need to show that L(D) = Diag and that D is a decider. By assumption, R is a decider so it halts on ⟨M, ⟨M⟩⟩ and thus D halts on all input so it is a decider If ⟨M⟩ ∈ Diag, then ⟨M⟩ ∉ L(M) so R rejects and D accepts so ⟨M⟩ ∈ L(D).

16 / 26

slide-42
SLIDE 42

Proof

Proof that ATM is undecidable.

Assume that ATM is decidable with decider R. Let’s build a TM D that decides Diag. D = “On input ⟨M⟩,

1 Run R on ⟨M, ⟨M⟩⟩ 2 If R accepts, reject; otherwise accept.”

We need to show that L(D) = Diag and that D is a decider. By assumption, R is a decider so it halts on ⟨M, ⟨M⟩⟩ and thus D halts on all input so it is a decider If ⟨M⟩ ∈ Diag, then ⟨M⟩ ∉ L(M) so R rejects and D accepts so ⟨M⟩ ∈ L(D). If ⟨M⟩ ∉ Diag, then ⟨M⟩ ∈ L(M) so R accepts and D rejects so ⟨M⟩ ∉ L(D).

16 / 26

slide-43
SLIDE 43

Proof

Proof that ATM is undecidable.

Assume that ATM is decidable with decider R. Let’s build a TM D that decides Diag. D = “On input ⟨M⟩,

1 Run R on ⟨M, ⟨M⟩⟩ 2 If R accepts, reject; otherwise accept.”

We need to show that L(D) = Diag and that D is a decider. By assumption, R is a decider so it halts on ⟨M, ⟨M⟩⟩ and thus D halts on all input so it is a decider If ⟨M⟩ ∈ Diag, then ⟨M⟩ ∉ L(M) so R rejects and D accepts so ⟨M⟩ ∈ L(D). If ⟨M⟩ ∉ Diag, then ⟨M⟩ ∈ L(M) so R accepts and D rejects so ⟨M⟩ ∉ L(D). Thus D decides Diag. This is a contradiction so ATM must not be decidable.

16 / 26

slide-44
SLIDE 44

Halting problem for TMs

Theorem

The language HaltTM = {⟨M, w⟩ ∣ M is a TM and M halts when run on w} is undecidable Assume that HaltTM is decided by TM H. How do we use H to construct a decider D for ATM?

17 / 26

slide-45
SLIDE 45

Proof

Proof.

Assume H is a decider for HaltTM and build a decider D for ATM. D = “On input ⟨M, w⟩,

1 Run H on ⟨M, w⟩ and if H rejects, reject. 2 Run M on w and if M accepts, accept; otherwise reject.”

D is a decider because if M loops on w, then H and D will reject. Otherwise, M will halt on w so D will halt. If w ∈ L(M), then M halts on w so H will accept and then D will accept. If w ∉ L(M), then there are two options. If M loops on w, then H and thus D will

  • reject. If M rejects w, then H will accept but D will reject.

18 / 26

slide-46
SLIDE 46

Co-Turing-recognizable (CoRE)

A language L is co-Turing-recognizable (coRE) if L is Turing-recognizable (RE)

19 / 26

slide-47
SLIDE 47

Co-Turing-recognizable (CoRE)

A language L is co-Turing-recognizable (coRE) if L is Turing-recognizable (RE)

Theorem

A language L is decidable ⟺ L is RE and L is coRE

19 / 26

slide-48
SLIDE 48

Co-Turing-recognizable (CoRE)

A language L is co-Turing-recognizable (coRE) if L is Turing-recognizable (RE)

Theorem

A language L is decidable ⟺ L is RE and L is coRE To prove this, we need to prove three things

1 If L is decidable, then L is RE 2 If L is decidable, then L is coRE 3 If L is RE and coRE, then L is decidable

Parts 1 and 2 together show the ⟹ direction and part 3 shows the ⟸ direction

19 / 26

slide-49
SLIDE 49

Proof

Proof.

⟹ : If L is decidable, then there is some decider M such that L(M) = L. Thus L is RE.

20 / 26

slide-50
SLIDE 50

Proof

Proof.

⟹ : If L is decidable, then there is some decider M such that L(M) = L. Thus L is RE. By swapping the accept and reject states of M, we get a new decider M′ that decides

  • L. Thus L is coRE.

20 / 26

slide-51
SLIDE 51

Proof

Proof.

⟹ : If L is decidable, then there is some decider M such that L(M) = L. Thus L is RE. By swapping the accept and reject states of M, we get a new decider M′ that decides

  • L. Thus L is coRE.

⟸: If L is RE, then there is some TM M1 that recognizes it If L is coRE, then there is some TM M2 that recognizes L Build M = “On input w,

1 Run M1 and M2 on w simultaneously (e.g., with 2 tapes) 2 If M1 accepts, accept. If M2 accepts, reject.”

One of M1 or M2 must accept, so M will halt on any input and thus decides L.

20 / 26

slide-52
SLIDE 52

ATM is RE but not coRE

Theorem

ATM is RE but not coRE

Proof.

Since ATM is not decidable, if we show that it is RE, then it can’t be coRE because then it would be decidable. We can build R to recognize ATM as follows. R = “On input ⟨M, w⟩,

1 Run M on w. 2 If M accepts, accept; if M rejects, reject.”

21 / 26

slide-53
SLIDE 53

ATM is RE but not coRE

Theorem

ATM is RE but not coRE

Proof.

Since ATM is not decidable, if we show that it is RE, then it can’t be coRE because then it would be decidable. We can build R to recognize ATM as follows. R = “On input ⟨M, w⟩,

1 Run M on w. 2 If M accepts, accept; if M rejects, reject.”

Note that if M loops on w, then R will loop, but this is okay because R just needs to recognize ATM, not decide it

21 / 26

slide-54
SLIDE 54

Proof continued

There are three cases

1 ⟨M, w⟩ ∈ ATM. M will accept w so R will accept.

22 / 26

slide-55
SLIDE 55

Proof continued

There are three cases

1 ⟨M, w⟩ ∈ ATM. M will accept w so R will accept. 2 ⟨M, w⟩ ∉ ATM. M will either loop on w or reject and R will do the same.

22 / 26

slide-56
SLIDE 56

Proof continued

There are three cases

1 ⟨M, w⟩ ∈ ATM. M will accept w so R will accept. 2 ⟨M, w⟩ ∉ ATM. M will either loop on w or reject and R will do the same. 3 The input isn’t a valid encoding of ⟨M, w⟩. R will reject before step 1.

22 / 26

slide-57
SLIDE 57

Proof continued

There are three cases

1 ⟨M, w⟩ ∈ ATM. M will accept w so R will accept. 2 ⟨M, w⟩ ∉ ATM. M will either loop on w or reject and R will do the same. 3 The input isn’t a valid encoding of ⟨M, w⟩. R will reject before step 1.

Thus L(R) = ATM so ATM is RE.

22 / 26

slide-58
SLIDE 58

Emptiness problem for TMs

Theorem

The language ETM = {⟨M⟩ ∣ M is a TM and L(M) = ∅} is coRE. To prove this, we need only give a TM that recognizes ETM

23 / 26

slide-59
SLIDE 59

Emptiness problem for TMs

Theorem

The language ETM = {⟨M⟩ ∣ M is a TM and L(M) = ∅} is coRE. To prove this, we need only give a TM that recognizes ETM

Proof.

Let R = “On input w,

1 If w ≠ ⟨M⟩ for some TM M, accept. 2 For n = 0 up to ∞ 3

For each string w ∈ Σ∗ of length at most n

4

Simulate M on w for at most n steps.

5

If M accepts w, accept.”

23 / 26

slide-60
SLIDE 60

Emptiness problem for TMs

Theorem

The language ETM = {⟨M⟩ ∣ M is a TM and L(M) = ∅} is coRE. To prove this, we need only give a TM that recognizes ETM

Proof.

Let R = “On input w,

1 If w ≠ ⟨M⟩ for some TM M, accept. 2 For n = 0 up to ∞ 3

For each string w ∈ Σ∗ of length at most n

4

Simulate M on w for at most n steps.

5

If M accepts w, accept.” If L(M) ≠ ∅, then there is some w that M will accept so R will accept ⟨M⟩.

23 / 26

slide-61
SLIDE 61

Emptiness problem for TMs

Theorem

The language ETM = {⟨M⟩ ∣ M is a TM and L(M) = ∅} is coRE. To prove this, we need only give a TM that recognizes ETM

Proof.

Let R = “On input w,

1 If w ≠ ⟨M⟩ for some TM M, accept. 2 For n = 0 up to ∞ 3

For each string w ∈ Σ∗ of length at most n

4

Simulate M on w for at most n steps.

5

If M accepts w, accept.” If L(M) ≠ ∅, then there is some w that M will accept so R will accept ⟨M⟩. If L(M) = ∅, then M will never accept so R will loop on ⟨M⟩. Thus L(R) = ETM so ETM is coRE.

23 / 26

slide-62
SLIDE 62

Emptiness problem for TMs is undecidable

Theorem

The language ETM is undecidable.

24 / 26

slide-63
SLIDE 63

Emptiness problem for TMs is undecidable

Theorem

The language ETM is undecidable.

Corollary

The language ETM is not RE.

24 / 26

slide-64
SLIDE 64

Emptiness problem for TMs is undecidable

Theorem

The language ETM is undecidable.

Corollary

The language ETM is not RE.

Proof of the corollary.

Since ETM is coRE, if it were RE, then it would be decidable, contradicting the theorem.

24 / 26

slide-65
SLIDE 65

Proof idea for showing ETM is undecidable

  • Assume E decides ETM
  • Build a decider for ATM using E
  • Along the way, we’re going to construct an entirely new TM Mw and we’re going

to run E on ⟨Mw⟩ We’ll use the idea of constructing new TMs in a bunch of different proofs

25 / 26

slide-66
SLIDE 66

Proof

Proof.

Assume that E decides ETM. Build D to decide ATM. D = “On input ⟨M, w⟩,

1 Construct a new TM Mw = ‘On any input x, 1 Replace x on the tape with w and run M on w. 2 If M accepts, accept; if M rejects, reject.’ 2 Run E on ⟨Mw⟩. 3 If E accepts, reject; otherwise accept.”

Note that Mw is never run. It is only constructed so that ⟨Mw⟩ can be given as input to decider E.

26 / 26

slide-67
SLIDE 67

Proof

Proof.

Assume that E decides ETM. Build D to decide ATM. D = “On input ⟨M, w⟩,

1 Construct a new TM Mw = ‘On any input x, 1 Replace x on the tape with w and run M on w. 2 If M accepts, accept; if M rejects, reject.’ 2 Run E on ⟨Mw⟩. 3 If E accepts, reject; otherwise accept.”

Note that Mw is never run. It is only constructed so that ⟨Mw⟩ can be given as input to decider E. If w ∈ L(M), then L(Mw) = Σ∗ ≠ ∅ so E rejects and D accepts.

26 / 26

slide-68
SLIDE 68

Proof

Proof.

Assume that E decides ETM. Build D to decide ATM. D = “On input ⟨M, w⟩,

1 Construct a new TM Mw = ‘On any input x, 1 Replace x on the tape with w and run M on w. 2 If M accepts, accept; if M rejects, reject.’ 2 Run E on ⟨Mw⟩. 3 If E accepts, reject; otherwise accept.”

Note that Mw is never run. It is only constructed so that ⟨Mw⟩ can be given as input to decider E. If w ∈ L(M), then L(Mw) = Σ∗ ≠ ∅ so E rejects and D accepts. If w ∉ L(M), then L(Mw) = ∅ so E accepts and D rejects. Thus L(D) = ETM.

26 / 26

slide-69
SLIDE 69

Proof

Proof.

Assume that E decides ETM. Build D to decide ATM. D = “On input ⟨M, w⟩,

1 Construct a new TM Mw = ‘On any input x, 1 Replace x on the tape with w and run M on w. 2 If M accepts, accept; if M rejects, reject.’ 2 Run E on ⟨Mw⟩. 3 If E accepts, reject; otherwise accept.”

Note that Mw is never run. It is only constructed so that ⟨Mw⟩ can be given as input to decider E. If w ∈ L(M), then L(Mw) = Σ∗ ≠ ∅ so E rejects and D accepts. If w ∉ L(M), then L(Mw) = ∅ so E accepts and D rejects. Thus L(D) = ETM. Constructing Mw can’t loop and E is a decider so D is a decider.

26 / 26