Docsity

Undecidable Languages: The Halting Problem and Infinite Sets, Study notes of Computer Science

Partial preview of the text

Download Undecidable Languages: The Halting Problem and Infinite Sets and more Study notes Computer Science in PDF only on Docsity!

Theory of Computation

Lecture 13: Undecidable Languages

Max Alekseyev

University of South Carolina

March 3, 2009

Decidable vs. Undecidable Languages

EQDFA = {〈A, B〉 | A, B are DFAs and L(A) = L(B)}

EQCFG = {〈G , H〉 | G , H are CFGs and L(G ) = L(H)}

We proved that EQDFA is decidable. In contrast to EQDFA, it is not clear how to prove that EQCFG is decidable.

Decidable vs. Undecidable Languages

ACFG = {〈G , w 〉 | G is a CFG that generates string w }

ATM = {〈M, w 〉 | M is a TM and M accepts w }

We proved that ACFG is decidable and that was used to prove that

every context-free language is decidable (by simulating a TM for ACFG ).

Q: What would happen if we prove that ATM is decidable?

Decidable vs. Undecidable Languages

ACFG = {〈G , w 〉 | G is a CFG that generates string w }

ATM = {〈M, w 〉 | M is a TM and M accepts w }

We proved that ACFG is decidable and that was used to prove that

every context-free language is decidable (by simulating a TM for ACFG ).

Q: What would happen if we prove that ATM is decidable?

If ATM were decidable, the language of any TM machine would be decidable. In particular, recognizable languages would coincide with decidable languages (which is very unrealistic!). So, it is natural to expect that ATM is NOT decidable.

Halting Problem

It is easy to establish that ATM is recognizable: for a given pair 〈M, w 〉 we need simply to simulate M on the input w , and accept or reject depending on whether M accepts or rejects. Note that M may loop in which case our simulation will loop as well, making it just a recognizer not a decider.

If we were able to determine whether M would ever stop on a given input w , a TM for ATM could reject given 〈M, w 〉 as soon as it determined that M would loop on w. In this case it would be a decider for ATM (which accepts if M accepts; and rejects if M rejects or loops).

Halting Problem

It is easy to establish that ATM is recognizable: for a given pair 〈M, w 〉 we need simply to simulate M on the input w , and accept or reject depending on whether M accepts or rejects. Note that M may loop in which case our simulation will loop as well, making it just a recognizer not a decider.

If we were able to determine whether M would ever stop on a given input w , a TM for ATM could reject given 〈M, w 〉 as soon as it determined that M would loop on w. In this case it would be a decider for ATM (which accepts if M accepts; and rejects if M rejects or loops).

Therefore, the crucial point is determination of whether M would ever stop on a given input w , giving the name halting problem to ATM. In these new terms, our goal is to prove that the halting problem is undecidable.

Sets and their cardinalities

It is easy to tell whether two given finite sets (such as { 5 , 7 , 23 } and {a, b, c}) have the same size — just count up their elements and compare the counts. But is there a way to compare sizes of two infinite sets? Obviously, counting elements won’t help as it would never end. But can we determine that two sets have equal sizes without counting their elements?

The idea is to set up a mapping between the elements of two sets such that each element of one set is mapped to an element of the other, and vice versa. This idea works equally well for finite and infinite sets. For example, we can map elements of the two sets above as follows: 5 ↔ a, 7 ↔ b, and 23 ↔ c; implying that these sets are the same size.

One-to-one, onto, correspondence

Let A, B be two sets and f : A → B be a function from A to B.

Definition

f is called one-to-one (injective) if it maps different elements of A to different elements of B.

Definition

f is called onto (surjective) if for every elements b ∈ B, there exists a ∈ A such that f (a) = b.

Definition

f is called correspondence (bijective) if it is one-to-one and onto.

Two set are of the same size if there exists a correspondence between them.

Examples

The set E = { 2 , 4 , 6 ,... } of even positive integers and the set N = { 1 , 2 , 3 ,... } of natural numbers are the same size. Q: Why?

Define f : N → E such that f (n) = 2n for every n ∈ N. It is one-to-one since for n 6 = m we have 2n 6 = 2m. It is onto since for k ∈ E, k/2 is a natural number and f (k/2) = k. Hence, f is a correspondence between E and N , implying that they are the same size.

Examples

The set E = { 2 , 4 , 6 ,... } of even positive integers and the set N = { 1 , 2 , 3 ,... } of natural numbers are the same size. Q: Why?

Define f : N → E such that f (n) = 2n for every n ∈ N. It is one-to-one since for n 6 = m we have 2n 6 = 2m. It is onto since for k ∈ E, k/2 is a natural number and f (k/2) = k. Hence, f is a correspondence between E and N , implying that they are the same size.

Definition

A set is called countable if either it is finite or has the same size as N.

Coutability of Languages and TMs

Let Σ be an alphabet (which is a finite set). The set Σ∗^ of all strings over Σ can be viewed as:

Σ∗^ =

k≥ 0

{w | w ∈ Σ∗^ ∧ |w | = k}

is infinite and countable.

In particular, the set of all TMs is countable (as they can be viewed as strings over some alphabet).

Coutability of Languages and TMs

Let Σ be an alphabet (which is a finite set). The set Σ∗^ of all strings over Σ can be viewed as:

Σ∗^ =

k≥ 0

{w | w ∈ Σ∗^ ∧ |w | = k}

is infinite and countable.

In particular, the set of all TMs is countable (as they can be viewed as strings over some alphabet).

The set of all languages over Σ is the power set of Σ∗, and thus is uncountable.

Theorem

Some languages are not Turing-recognizable.

Turing-Unrecognizable languages

Theorem

A language is decidable iff it is Turing-recognizable and co-Turing-recognizable (i.e., its complement is Turing-recognizable).

Turing-Unrecognizable languages

Theorem

A language is decidable iff it is Turing-recognizable and co-Turing-recognizable (i.e., its complement is Turing-recognizable).

Corollary

ATM is not Turing-recognizable.