CSE 105 theory of computation Proving
Description: CSE 105 theory of computation Proving undecidability by diagonalization Fall 2025 https:cseweb.ucsd.educlassesfa25cse105-a Todays learning goals Sipser Ch 4.1, 4.2 Trace high-level descriptions of algorithms for computational
Related Topics
Download Presentation
"CSE 105 theory of computation Proving" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Presentation Transcript
slide1. CSE 105 theory of computation Proving undecidability by diagonalization
Fall 2025
https://cseweb.ucsd.edu/classes/fa25/cse105-a/<br>
slide2. Today's learning goals Sipser Ch 4.1, 4.2 Trace high-level descriptions of algorithms for computational problems.
Use counting arguments to prove the existence of unrecognizable (undecidable) languages.
Use diagonalization in a proof of undecidability.<br>
slide3. Encoding input for TMs Sipser p. 159 By definition, TM inputs are strings
To define TM M:
"On input w …
..
..
… For inputs that aren't strings,
we have to encode the object
(represent it as a string) first Notation:
<O> is the string that represents (encodes) the object O
<O1, …, On> is the single string that represents the tuple of objects O1, …, On<br>
slide4. Encoding inputs Payoff: problems we care about can be reframed as languages of strings
e.g. "Recognize whether a string is a palindrome."
{ w | w in {0,1}* and w = wR }
e.g. "Check whether a string is accepted by a DFA."
{ <B,w> | B is a DFA over Σ, w in Σ*, and w is in L(B) }
e.g. "Check whether the language of a PDA is infinite."
{ <A> | A is a PDA and L(A) is infinite}<br>
slide5. Encoding inputs Payoff: problems we care about can be reframed as languages of strings
e.g. "Recognize whether a string is a palindrome."
{ w | w in {0,1}* and w = wR }
This set is regular and decidable.
This set is regular and not decidable
This set is nonregular and decidable
This set is nonregular and not decidable.
None of the above<br>
slide6. Computational problems A computational problem is decidable iff the language encoding the problem instances is decidable<br>
slide7. Computational problems Sample computational problems and their encodings:
ADFA "Check whether a string is accepted by a DFA."
{ <B,w> | B is a DFA over Σ, w in Σ*, and w is in L(B) }
EDFA "Check whether the language of a DFA is empty."
{ <A> | A is a DFA over Σ, L(A) is empty }
EQDFA "Check whether the languages of two DFAs are equal."
{ <A, B> | A and B are DFA over Σ, L(A) = L(B)}
FACT: all of these problems are decidable!<br>
slide8. Computational problems Sample computational problems and their encodings:
APDA "Check whether a string is accepted by a PDA."
{ <B,w> | B is a PDA over Σ, w in Σ*, and w is in L(B) }
EPDA "Check whether the language of a PDA is empty."
{ <A> | A is a PDA over Σ, L(A) is empty }
EQPDA "Check whether the languages of two PDAs are equal."
{ <A, B> | A and B are PDA over Σ, L(A) = L(B)}
FACT: some of these problems are decidable, and some are not!<br>
slide9. Computational problems Sample computational problems and their encodings:
ATM "Check whether a string is accepted by a TM."
{ <B,w> | B is a TM over Σ, w in Σ*, and w is in L(B) }
ETM "Check whether the language of a TM is empty."
{ <A> | A is a TM over Σ, L(A) is empty }
EQTM "Check whether the languages of two TMs are equal."
{ <A, B> | A and B are TM over Σ, L(A) = L(B)}
FACT: all of these problems are undecidable!<br>
slide10. Undecidable? There are many ways to prove that a problem is decidable.
How do we find (and prove) that a problem is not decidable?<br>
slide11. Before we proved the Pumping Lemma …
We proved there was a set that was not regular because All sets of strings Counting arguments All Regular
Sets Countable Uncountable<br>
slide12. Why is the set of Turing-recognizable languages countable?
It's equal to the set of all TMs, which we showed is countable.
It's a subset of the set of all TMs, which we showed is countable.
Each Turing-recognizable language is associated with a TM, so there can be no more Turing-recognizable languages than TMs.
More than one of the above.
I don't know. All sets of strings Counting arguments All Turing-recognizable sets Countable Uncountable<br>
slide13. Satisfied? Maybe not …
What's a specific example of a language that is not Turing-recognizable? or not Turing-decidable?
Idea: consider a set that, were it to be Turing-decidable, would have to "talk" about itself, and contradict itself!<br>
slide14. ATM Recall ADFA = {<B,w> | B is a DFA and w is in L(B) }
Decider for this set simulates arbitrary DFA
ATM = {<M,w> | M is a TM and w is in L(M) }
Decider for this set simulates arbitrary TMs ???<br>
slide15. ATM ATM = {<M,w> | M is a TM and w is in L(M) }
Define the TM N = "On input <M,w>:
Simulate M on w.
If M accepts, accept. If M rejects, reject."<br>
slide16. ATM ATM = {<M,w> | M is a TM and w is in L(M) }
Define the TM N = "On input <M,w>:
Simulate M on w.
If M accepts, accept. If M rejects, reject." What is L(N)?<br>
slide17. ATM ATM = {<M,w> | M is a TM and w is in L(M) }
Define the TM N = "On input <M,w>:
Simulate M on w.
If M accepts, accept. If M rejects, reject." Does N decide ATM?<br>
slide18. ATM ATM = {<M,w> | M is a TM and w is in L(M) }
Define the TM N = "On input <M,w>:
Simulate M on w.
If M accepts, accept. If M rejects, reject."
Conclusion: ATM is Turing-recognizable.
Is it decidable?<br>
slide19. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that it is.
Call MATM the decider for ATM:
For every TM M and every string w,
Computation of MATM on <M,w> halts and accepts if w is in L(M).
Computation of MATM on <M,w> halts and rejects if w is not in L(M). MATM ≠ N<br>
slide20. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept."<br>
slide21. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept." Which of the following computations halt?
Computation of D on <X>
Computation of D on <Y> where Y is TM with L(Y) =Σ*
Computation of D on <D>
All of the above.<br>
slide22. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept."
Consider running D on input <D>. Because D is a decider:
either computation halts and accepts …
or computation halts and rejects …<br>
slide23. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept."
If D(<D>) accepts, then MATM(<D>,<D>) rejects, which means D(<D>) should have rejected
If D(<D>) rejects, then MATM(<D>,<D>) accepts, which means D(<D>) should have accepted
Either way, we reached a contradiction<br>
slide24. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept."
Consider running D on input <D>. Because D is a decider:
either computation halts and accepts …
or computation halts and rejects … Diagonalization???
Self-reference
"Is <D> an element of L(D)?"<br>
slide25. Why is this called diagonalization?<br>
slide26. Why is this called diagonalization? Rows of table describe all recognizable languages
Any other row (=language) cannot be recognizable
We will construct such a language<br>
slide27. Why is this called diagonalization? Next idea: specialize only to inputs <Mi>
Suffices to construct row (=language) that differs from any row on some of these inputs<br>
slide28. Why is this called diagonalization? Consider the diagonal: running Mi on <Mi>; then flip it
L = {<M>: M doesn’t accept <M>}
L cannot be recognized by any Mi – they disagree on input <Mi>
Since we consider all TMs, L must be un-recognizable<br>
slide29. Another perspective Define language: L = {<M>: M doesn’t accept <M>}
Assume towards a contradiction some TM M decides L
There are two options:
If <M> in L, then M(<M>) accepts, but then <M> not in L
If <M> not in L, then M(<M>) rejects, but then <M> in L
Conclusion: no TM can decide L<br>
slide30. ATM Recognizable
Not decidable
Fact: A language is decidable iff it and its complement are both recgonizable.
Corollary: The complement of ATM is unrecognizable
ATMC= {<M,w> | M is a TM and w is not in L(M) }<br>
slide31. Decidable vs. undecidable Which of the following languages is undecidable?
INFINITEDFA = { <A> | A is a DFA and L(A) is an infinite language}
STM = { <M> | M is a TM and M has exactly 7 states}
RevDFA = { <B> | B is a DFA and for all strings w, B accepts w iff it accepts wR}
RecTM = { <X> | X is a TM and L(X) is recognizable}
DecTM = { <Y> | Y is a TM and L(Y) is decidable}<br>
slide32. So far<br>
slide33. Do we have to diagonalize? Next time: comparing difficulty of problems.<br>
Fall 2025
https://cseweb.ucsd.edu/classes/fa25/cse105-a/<br>
slide2. Today's learning goals Sipser Ch 4.1, 4.2 Trace high-level descriptions of algorithms for computational problems.
Use counting arguments to prove the existence of unrecognizable (undecidable) languages.
Use diagonalization in a proof of undecidability.<br>
slide3. Encoding input for TMs Sipser p. 159 By definition, TM inputs are strings
To define TM M:
"On input w …
..
..
… For inputs that aren't strings,
we have to encode the object
(represent it as a string) first Notation:
<O> is the string that represents (encodes) the object O
<O1, …, On> is the single string that represents the tuple of objects O1, …, On<br>
slide4. Encoding inputs Payoff: problems we care about can be reframed as languages of strings
e.g. "Recognize whether a string is a palindrome."
{ w | w in {0,1}* and w = wR }
e.g. "Check whether a string is accepted by a DFA."
{ <B,w> | B is a DFA over Σ, w in Σ*, and w is in L(B) }
e.g. "Check whether the language of a PDA is infinite."
{ <A> | A is a PDA and L(A) is infinite}<br>
slide5. Encoding inputs Payoff: problems we care about can be reframed as languages of strings
e.g. "Recognize whether a string is a palindrome."
{ w | w in {0,1}* and w = wR }
This set is regular and decidable.
This set is regular and not decidable
This set is nonregular and decidable
This set is nonregular and not decidable.
None of the above<br>
slide6. Computational problems A computational problem is decidable iff the language encoding the problem instances is decidable<br>
slide7. Computational problems Sample computational problems and their encodings:
ADFA "Check whether a string is accepted by a DFA."
{ <B,w> | B is a DFA over Σ, w in Σ*, and w is in L(B) }
EDFA "Check whether the language of a DFA is empty."
{ <A> | A is a DFA over Σ, L(A) is empty }
EQDFA "Check whether the languages of two DFAs are equal."
{ <A, B> | A and B are DFA over Σ, L(A) = L(B)}
FACT: all of these problems are decidable!<br>
slide8. Computational problems Sample computational problems and their encodings:
APDA "Check whether a string is accepted by a PDA."
{ <B,w> | B is a PDA over Σ, w in Σ*, and w is in L(B) }
EPDA "Check whether the language of a PDA is empty."
{ <A> | A is a PDA over Σ, L(A) is empty }
EQPDA "Check whether the languages of two PDAs are equal."
{ <A, B> | A and B are PDA over Σ, L(A) = L(B)}
FACT: some of these problems are decidable, and some are not!<br>
slide9. Computational problems Sample computational problems and their encodings:
ATM "Check whether a string is accepted by a TM."
{ <B,w> | B is a TM over Σ, w in Σ*, and w is in L(B) }
ETM "Check whether the language of a TM is empty."
{ <A> | A is a TM over Σ, L(A) is empty }
EQTM "Check whether the languages of two TMs are equal."
{ <A, B> | A and B are TM over Σ, L(A) = L(B)}
FACT: all of these problems are undecidable!<br>
slide10. Undecidable? There are many ways to prove that a problem is decidable.
How do we find (and prove) that a problem is not decidable?<br>
slide11. Before we proved the Pumping Lemma …
We proved there was a set that was not regular because All sets of strings Counting arguments All Regular
Sets Countable Uncountable<br>
slide12. Why is the set of Turing-recognizable languages countable?
It's equal to the set of all TMs, which we showed is countable.
It's a subset of the set of all TMs, which we showed is countable.
Each Turing-recognizable language is associated with a TM, so there can be no more Turing-recognizable languages than TMs.
More than one of the above.
I don't know. All sets of strings Counting arguments All Turing-recognizable sets Countable Uncountable<br>
slide13. Satisfied? Maybe not …
What's a specific example of a language that is not Turing-recognizable? or not Turing-decidable?
Idea: consider a set that, were it to be Turing-decidable, would have to "talk" about itself, and contradict itself!<br>
slide14. ATM Recall ADFA = {<B,w> | B is a DFA and w is in L(B) }
Decider for this set simulates arbitrary DFA
ATM = {<M,w> | M is a TM and w is in L(M) }
Decider for this set simulates arbitrary TMs ???<br>
slide15. ATM ATM = {<M,w> | M is a TM and w is in L(M) }
Define the TM N = "On input <M,w>:
Simulate M on w.
If M accepts, accept. If M rejects, reject."<br>
slide16. ATM ATM = {<M,w> | M is a TM and w is in L(M) }
Define the TM N = "On input <M,w>:
Simulate M on w.
If M accepts, accept. If M rejects, reject." What is L(N)?<br>
slide17. ATM ATM = {<M,w> | M is a TM and w is in L(M) }
Define the TM N = "On input <M,w>:
Simulate M on w.
If M accepts, accept. If M rejects, reject." Does N decide ATM?<br>
slide18. ATM ATM = {<M,w> | M is a TM and w is in L(M) }
Define the TM N = "On input <M,w>:
Simulate M on w.
If M accepts, accept. If M rejects, reject."
Conclusion: ATM is Turing-recognizable.
Is it decidable?<br>
slide19. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that it is.
Call MATM the decider for ATM:
For every TM M and every string w,
Computation of MATM on <M,w> halts and accepts if w is in L(M).
Computation of MATM on <M,w> halts and rejects if w is not in L(M). MATM ≠ N<br>
slide20. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept."<br>
slide21. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept." Which of the following computations halt?
Computation of D on <X>
Computation of D on <Y> where Y is TM with L(Y) =Σ*
Computation of D on <D>
All of the above.<br>
slide22. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept."
Consider running D on input <D>. Because D is a decider:
either computation halts and accepts …
or computation halts and rejects …<br>
slide23. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept."
If D(<D>) accepts, then MATM(<D>,<D>) rejects, which means D(<D>) should have rejected
If D(<D>) rejects, then MATM(<D>,<D>) accepts, which means D(<D>) should have accepted
Either way, we reached a contradiction<br>
slide24. Diagonalization proof: ATM not decidable Sipser 4.11 Assume, towards a contradiction, that MATM decides ATM
Define the TM D = "On input <M>:
Run MATM on <M, <M>>.
If MATM accepts, reject; if MATM rejects, accept."
Consider running D on input <D>. Because D is a decider:
either computation halts and accepts …
or computation halts and rejects … Diagonalization???
Self-reference
"Is <D> an element of L(D)?"<br>
slide25. Why is this called diagonalization?<br>
slide26. Why is this called diagonalization? Rows of table describe all recognizable languages
Any other row (=language) cannot be recognizable
We will construct such a language<br>
slide27. Why is this called diagonalization? Next idea: specialize only to inputs <Mi>
Suffices to construct row (=language) that differs from any row on some of these inputs<br>
slide28. Why is this called diagonalization? Consider the diagonal: running Mi on <Mi>; then flip it
L = {<M>: M doesn’t accept <M>}
L cannot be recognized by any Mi – they disagree on input <Mi>
Since we consider all TMs, L must be un-recognizable<br>
slide29. Another perspective Define language: L = {<M>: M doesn’t accept <M>}
Assume towards a contradiction some TM M decides L
There are two options:
If <M> in L, then M(<M>) accepts, but then <M> not in L
If <M> not in L, then M(<M>) rejects, but then <M> in L
Conclusion: no TM can decide L<br>
slide30. ATM Recognizable
Not decidable
Fact: A language is decidable iff it and its complement are both recgonizable.
Corollary: The complement of ATM is unrecognizable
ATMC= {<M,w> | M is a TM and w is not in L(M) }<br>
slide31. Decidable vs. undecidable Which of the following languages is undecidable?
INFINITEDFA = { <A> | A is a DFA and L(A) is an infinite language}
STM = { <M> | M is a TM and M has exactly 7 states}
RevDFA = { <B> | B is a DFA and for all strings w, B accepts w iff it accepts wR}
RecTM = { <X> | X is a TM and L(X) is recognizable}
DecTM = { <Y> | Y is a TM and L(Y) is decidable}<br>
slide32. So far<br>
slide33. Do we have to diagonalize? Next time: comparing difficulty of problems.<br>