tddc95 introduction to the theory of computation - lecture 6

Post on 03-Feb-2022

2 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

TDDC95Introduction to the Theory of Computation

Lecture 6

Gustav NordhDepartment of Computer and Information Science

gusno@ida.liu.se

2009-09-18

Outline

Undecidability of the halting problemReductionsSummary of ComputabilityTime Complexity

Undecidability of the halting problem

Construct a tool/debugger that can tell whether a Javaprogram will go into an infinite loop on input w .

Impossible! This problem is undecidableThere is no Turing machine U that given a Turing machineM and string w can determine whether M will loop on inputw

Undecidability of the halting problem

Construct a tool/debugger that can tell whether a Javaprogram will go into an infinite loop on input w .Impossible! This problem is undecidable

There is no Turing machine U that given a Turing machineM and string w can determine whether M will loop on inputw

Undecidability of the halting problem

Construct a tool/debugger that can tell whether a Javaprogram will go into an infinite loop on input w .Impossible! This problem is undecidableThere is no Turing machine U that given a Turing machineM and string w can determine whether M will loop on inputw

Undecidability of the halting problem

ATM = {〈M, w〉 | M is a Turing machine that accepts w}

TheoremATM is Turing-recognizable

Proof.Let U be a Turing machine that works as follows:

1 Check that the input 〈M, w〉 is a legal encoding of a Turingmachine M and string w (otherwise reject)

2 Simulate M on input w3 If M enters the accept state, then U accepts 〈M, w〉4 If M enters the reject state, then U rejects 〈M, w〉

Undecidability of the halting problem

ATM = {〈M, w〉 | M is a Turing machine that accepts w}

TheoremATM is Turing-recognizable

Proof.Let U be a Turing machine that works as follows:

1 Check that the input 〈M, w〉 is a legal encoding of a Turingmachine M and string w (otherwise reject)

2 Simulate M on input w3 If M enters the accept state, then U accepts 〈M, w〉4 If M enters the reject state, then U rejects 〈M, w〉

Undecidability of the halting problem

ATM = {〈M, w〉 | M is a Turing machine that accepts w}

TheoremATM is Turing-recognizable

Proof.Let U be a Turing machine that works as follows:

1 Check that the input 〈M, w〉 is a legal encoding of a Turingmachine M and string w (otherwise reject)

2 Simulate M on input w3 If M enters the accept state, then U accepts 〈M, w〉4 If M enters the reject state, then U rejects 〈M, w〉

Undecidability of the halting problem

ATM = {〈M, w〉 | M is a Turing machine that accepts w}

TheoremATM is undecidable

Proof.1 Assume that ATM is decidable by a Turing machine H2 Construct a new Turing machine D which takes 〈M〉 as

input and works as follows:Run H on 〈M, 〈M〉〉 and output the opposite of what Houtputs

3 Running D on input 〈D〉 results in a contradiction becauseD rejects 〈D〉 if D accepts 〈D〉

Undecidability of the halting problem

ATM = {〈M, w〉 | M is a Turing machine that accepts w}

TheoremATM is undecidable

Proof.1 Assume that ATM is decidable by a Turing machine H2 Construct a new Turing machine D which takes 〈M〉 as

input and works as follows:Run H on 〈M, 〈M〉〉 and output the opposite of what Houtputs

3 Running D on input 〈D〉 results in a contradiction becauseD rejects 〈D〉 if D accepts 〈D〉

Undecidability of the halting problem

ATM = {〈M, w〉 | M is a Turing machine that accepts w}

TheoremATM is undecidable

Proof.1 Assume that ATM is decidable by a Turing machine H2 Construct a new Turing machine D which takes 〈M〉 as

input and works as follows:Run H on 〈M, 〈M〉〉 and output the opposite of what Houtputs

3 Running D on input 〈D〉 results in a contradiction becauseD rejects 〈D〉 if D accepts 〈D〉

An explicit language which is not Turing-recognizable

ATM = {w | w /∈ ATM}

Theorem

ATM is not Turing-recognizable

Proof.1 Assume with the aim of reaching a contradiction that ATM

is Turing-recognizable.2 Let M1 be a Turing machine recognizing ATM and M2 a

Turing machine recognizing ATM .3 On input w run both M1 and M2 on w in parallel4 If M1 accepts, then reject. If M2 accepts, then accept.5 This shows that ATM is decidable, which is a contradiction

An explicit language which is not Turing-recognizable

ATM = {w | w /∈ ATM}

Theorem

ATM is not Turing-recognizable

Proof.1 Assume with the aim of reaching a contradiction that ATM

is Turing-recognizable.2 Let M1 be a Turing machine recognizing ATM and M2 a

Turing machine recognizing ATM .3 On input w run both M1 and M2 on w in parallel4 If M1 accepts, then reject. If M2 accepts, then accept.5 This shows that ATM is decidable, which is a contradiction

An explicit language which is not Turing-recognizable

ATM = {w | w /∈ ATM}

Theorem

ATM is not Turing-recognizable

Proof.1 Assume with the aim of reaching a contradiction that ATM

is Turing-recognizable.

2 Let M1 be a Turing machine recognizing ATM and M2 aTuring machine recognizing ATM .

3 On input w run both M1 and M2 on w in parallel4 If M1 accepts, then reject. If M2 accepts, then accept.5 This shows that ATM is decidable, which is a contradiction

An explicit language which is not Turing-recognizable

ATM = {w | w /∈ ATM}

Theorem

ATM is not Turing-recognizable

Proof.1 Assume with the aim of reaching a contradiction that ATM

is Turing-recognizable.2 Let M1 be a Turing machine recognizing ATM and M2 a

Turing machine recognizing ATM .

3 On input w run both M1 and M2 on w in parallel4 If M1 accepts, then reject. If M2 accepts, then accept.5 This shows that ATM is decidable, which is a contradiction

An explicit language which is not Turing-recognizable

ATM = {w | w /∈ ATM}

Theorem

ATM is not Turing-recognizable

Proof.1 Assume with the aim of reaching a contradiction that ATM

is Turing-recognizable.2 Let M1 be a Turing machine recognizing ATM and M2 a

Turing machine recognizing ATM .3 On input w run both M1 and M2 on w in parallel

4 If M1 accepts, then reject. If M2 accepts, then accept.5 This shows that ATM is decidable, which is a contradiction

An explicit language which is not Turing-recognizable

ATM = {w | w /∈ ATM}

Theorem

ATM is not Turing-recognizable

Proof.1 Assume with the aim of reaching a contradiction that ATM

is Turing-recognizable.2 Let M1 be a Turing machine recognizing ATM and M2 a

Turing machine recognizing ATM .3 On input w run both M1 and M2 on w in parallel4 If M1 accepts, then reject. If M2 accepts, then accept.5 This shows that ATM is decidable, which is a contradiction

Reductions

DefinitionA function f : Σ∗ → Σ∗ is computable if some Turing machine Mon every input w halts with f (w) on its tape

Reductions

DefinitionA function f : Σ∗ → Σ∗ is computable if some Turing machine Mon every input w halts with f (w) on its tape

Reductions

DefinitionLanguage A is mapping reducible to language B if there is acomputable function f : Σ∗ → Σ∗ such that for every w

w ∈ A iff f (w) ∈ B

The function f is called a reduction from A to BIf A is mapping reducible to B then we write A ≤m B

Reductions

TheoremIf B is decidable and A ≤m B, then A is decidable

Proof.Let MB be a Turing machine that decides B and f the reductionfrom A to B. Given input w :

1 Compute f (w)

2 Run MB on f (w), accept if MB accepts f (w), and reject ifMB rejects f (w)

Reductions

TheoremIf B is decidable and A ≤m B, then A is decidable

Proof.Let MB be a Turing machine that decides B and f the reductionfrom A to B. Given input w :

1 Compute f (w)

2 Run MB on f (w), accept if MB accepts f (w), and reject ifMB rejects f (w)

Reductions

TheoremIf A is undecidable and A ≤m B, then B is undecidable

Proof.Assume with the aim of reaching a contradiction that B isdecidable. Let MB be a Turing machine that decides B and f thereduction from A to B. Given input w :

1 Compute f (w)

2 Run MB on f (w), accept if MB accepts f (w), and reject ifMB rejects f (w)

3 This shows that A is decidable, which is a contradiction

Reductions

TheoremIf A is undecidable and A ≤m B, then B is undecidable

Proof.Assume with the aim of reaching a contradiction that B isdecidable. Let MB be a Turing machine that decides B and f thereduction from A to B. Given input w :

1 Compute f (w)

2 Run MB on f (w), accept if MB accepts f (w), and reject ifMB rejects f (w)

3 This shows that A is decidable, which is a contradiction

Reductions

TheoremIf B is Turing-recognizable and A ≤m B, then A isTuring-recognizable

Reductions

TheoremIf A is not Turing-recognizable and A ≤m B, then B is notTuring-recognizable

Reductions

ETM = {〈M〉 | M is a Turing machine and L(M) = ∅}

TheoremETM is undecidable

Proof.ATM ≤m ETM (Theorem 5.2 in Sipser)

Reductions

ETM = {〈M〉 | M is a Turing machine and L(M) = ∅}

TheoremETM is undecidable

Proof.ATM ≤m ETM (Theorem 5.2 in Sipser)

Reductions

ETM = {〈M〉 | M is a Turing machine and L(M) = ∅}

TheoremETM is undecidable

Proof.ATM ≤m ETM (Theorem 5.2 in Sipser)

Reductions

EQTM = {〈M1, M2〉 | M1 and M2 are TMs and L(M1) = L(M2)}

TheoremEQTM is undecidable

Proof.ETM ≤m EQTM :

1 Let M2 be a Turing machine such that L(M2) = ∅2 Given a Turing machine M, let f (〈M〉) = 〈M, M2〉3 〈M〉 ∈ ETM iff L(M) = ∅ iff L(M) = L(M2) iff〈M, M2〉 ∈ EQTM

Reductions

EQTM = {〈M1, M2〉 | M1 and M2 are TMs and L(M1) = L(M2)}

TheoremEQTM is undecidable

Proof.ETM ≤m EQTM :

1 Let M2 be a Turing machine such that L(M2) = ∅2 Given a Turing machine M, let f (〈M〉) = 〈M, M2〉3 〈M〉 ∈ ETM iff L(M) = ∅ iff L(M) = L(M2) iff〈M, M2〉 ∈ EQTM

Reductions

EQTM = {〈M1, M2〉 | M1 and M2 are TMs and L(M1) = L(M2)}

TheoremEQTM is undecidable

Proof.ETM ≤m EQTM :

1 Let M2 be a Turing machine such that L(M2) = ∅2 Given a Turing machine M, let f (〈M〉) = 〈M, M2〉3 〈M〉 ∈ ETM iff L(M) = ∅ iff L(M) = L(M2) iff〈M, M2〉 ∈ EQTM

Reductions

EQTM = {〈M1, M2〉 | M1 and M2 are TMs and L(M1) = L(M2)}

TheoremEQTM is undecidable

Proof.ETM ≤m EQTM :

1 Let M2 be a Turing machine such that L(M2) = ∅

2 Given a Turing machine M, let f (〈M〉) = 〈M, M2〉3 〈M〉 ∈ ETM iff L(M) = ∅ iff L(M) = L(M2) iff〈M, M2〉 ∈ EQTM

Reductions

EQTM = {〈M1, M2〉 | M1 and M2 are TMs and L(M1) = L(M2)}

TheoremEQTM is undecidable

Proof.ETM ≤m EQTM :

1 Let M2 be a Turing machine such that L(M2) = ∅2 Given a Turing machine M, let f (〈M〉) = 〈M, M2〉

3 〈M〉 ∈ ETM iff L(M) = ∅ iff L(M) = L(M2) iff〈M, M2〉 ∈ EQTM

Reductions

EQTM = {〈M1, M2〉 | M1 and M2 are TMs and L(M1) = L(M2)}

TheoremEQTM is undecidable

Proof.ETM ≤m EQTM :

1 Let M2 be a Turing machine such that L(M2) = ∅2 Given a Turing machine M, let f (〈M〉) = 〈M, M2〉3 〈M〉 ∈ ETM iff L(M) = ∅ iff L(M) = L(M2) iff〈M, M2〉 ∈ EQTM

Incompleteness Theorem from Undecidability

Kurt Gödel (1906-1978)

Incompleteness Theorem from Undecidability (S, 6.2)

Theorem(Informally) There are true mathematical statements thatcannot be proved

Proof idea.1 The language of all true mathematical statements is

undecidable (by reduction from ATM )2 The language of all provable statements is Turing

recognizable by a Turing machine M3 Assume that all true statements are provable4 Given a statement Φ, run M in parallel on Φ and ¬Φ. One

of them is true and thus (by assumption) provable. If Φ isprovable then Φ is true and if ¬Φ is provable then Φ is false.

5 So M decides the truth of Φ. This is a contradiction (with 1above)

Incompleteness Theorem from Undecidability (S, 6.2)

Theorem(Informally) There are true mathematical statements thatcannot be proved

Proof idea.1 The language of all true mathematical statements is

undecidable (by reduction from ATM )

2 The language of all provable statements is Turingrecognizable by a Turing machine M

3 Assume that all true statements are provable4 Given a statement Φ, run M in parallel on Φ and ¬Φ. One

of them is true and thus (by assumption) provable. If Φ isprovable then Φ is true and if ¬Φ is provable then Φ is false.

5 So M decides the truth of Φ. This is a contradiction (with 1above)

Incompleteness Theorem from Undecidability (S, 6.2)

Theorem(Informally) There are true mathematical statements thatcannot be proved

Proof idea.1 The language of all true mathematical statements is

undecidable (by reduction from ATM )2 The language of all provable statements is Turing

recognizable by a Turing machine M

3 Assume that all true statements are provable4 Given a statement Φ, run M in parallel on Φ and ¬Φ. One

of them is true and thus (by assumption) provable. If Φ isprovable then Φ is true and if ¬Φ is provable then Φ is false.

5 So M decides the truth of Φ. This is a contradiction (with 1above)

Incompleteness Theorem from Undecidability (S, 6.2)

Theorem(Informally) There are true mathematical statements thatcannot be proved

Proof idea.1 The language of all true mathematical statements is

undecidable (by reduction from ATM )2 The language of all provable statements is Turing

recognizable by a Turing machine M3 Assume that all true statements are provable

4 Given a statement Φ, run M in parallel on Φ and ¬Φ. Oneof them is true and thus (by assumption) provable. If Φ isprovable then Φ is true and if ¬Φ is provable then Φ is false.

5 So M decides the truth of Φ. This is a contradiction (with 1above)

Incompleteness Theorem from Undecidability (S, 6.2)

Theorem(Informally) There are true mathematical statements thatcannot be proved

Proof idea.1 The language of all true mathematical statements is

undecidable (by reduction from ATM )2 The language of all provable statements is Turing

recognizable by a Turing machine M3 Assume that all true statements are provable4 Given a statement Φ, run M in parallel on Φ and ¬Φ. One

of them is true and thus (by assumption) provable. If Φ isprovable then Φ is true and if ¬Φ is provable then Φ is false.

5 So M decides the truth of Φ. This is a contradiction (with 1above)

Incompleteness Theorem from Undecidability (S, 6.2)

Theorem(Informally) There are true mathematical statements thatcannot be proved

Proof idea.1 The language of all true mathematical statements is

undecidable (by reduction from ATM )2 The language of all provable statements is Turing

recognizable by a Turing machine M3 Assume that all true statements are provable4 Given a statement Φ, run M in parallel on Φ and ¬Φ. One

of them is true and thus (by assumption) provable. If Φ isprovable then Φ is true and if ¬Φ is provable then Φ is false.

5 So M decides the truth of Φ. This is a contradiction (with 1above)

Summary on Computability (what to focus on)

Turing machines and the Church-Turing thesisDiagonalization and the undecidability of the haltingproblemMapping reducibility

top related