CS 3780: Theory of Computation * Lecture Notes - Student Version † Kyle Burke July 9, 2019 This work is licensed under a Creative Commons “Attribution 4.0 Inter- national” license. Abstract Lecture notes for an undergraduate Theory of Computation course. These notes assume some background in discrete math or set theory. The notes deviate from the normal topic order by covering all the machines first, then properties of the language classes, and finally non-inclusion into those classes. Many sections of the notes have yet to be completed. Contents -1.0 Resources ........................................ 3 -1.1 Organization ...................................... 3 -1.2 Exercises ........................................ 3 -1.3 In Progress ....................................... 4 -1.4 Acknowledgements ................................... 4 -1.5 LaTeX Commands and Packages ........................... 5 0 Motivation and Preview of CS Theory 5 0.0 Limits of Computation ................................. 6 0.1 The Halting Problem is Undecideable ........................ 7 0.2 Computing Models ................................... 12 0.3 Languages ........................................ 13 0.4 Math Background ................................... 14 1 Automata and Machines 17 1.0 Deterministic Finite-state Automata (DFAs) .................... 17 1.1 Nondeterminism (NFAs) ................................ 32 1.2 Pushdown Automata .................................. 44 1.3 Turing Machines .................................... 52 * Kyle would always like to hear about how useful his notes are. If you have any comments about these, please email him at [email protected]or leave a comment at https://paithanq.blogspot.com/2018/08/ theory-of-computation-lecture-notes.html. † Created with lectureNotes.sty, which is available at: http://turing.plymouth.edu/ ~ kgb1013/ lectureNotesLatexStyle.php (or, GitHub: https://github.com/paithan/LaTeX-LectureNotes). 1
151
Embed
CS 3780: Theory of Computation - Plymouth State …kgb1013/DB/3780/lecture...CS 3780: Theory of Computation∗ Lecture Notes - Student Version† Kyle Burke July 9, 2019 This work
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CS 3780: Theory of Computation∗
Lecture Notes - Student Version†
Kyle Burke
July 9, 2019
This work is licensed under a Creative Commons “Attribution 4.0 Inter-national” license.
Abstract
Lecture notes for an undergraduate Theory of Computation course. These notes assumesome background in discrete math or set theory. The notes deviate from the normal topicorder by covering all the machines first, then properties of the language classes, and finallynon-inclusion into those classes. Many sections of the notes have yet to be completed.
∗Kyle would always like to hear about how useful his notes are. If you have any comments aboutthese, please email him at [email protected] or leave a comment at https://paithanq.blogspot.com/2018/08/
theory-of-computation-lecture-notes.html.†Created with lectureNotes.sty, which is available at: http://turing.plymouth.edu/~kgb1013/
These notes were created while teaching from Introduction to the Theory ofComputation, Third Edition, by Mike Sipser2[2]. (The chapters and sectionshere do not correspond with the text chapters.) These notes deviate fromthe order of topics covered there, but this does not diminish just how usefulSipser’s book is! Topics are covered in far more depth than these sparsenotes.
When I reach this course, all assignments are to be done in LATEX. Youcan use CoCalc3 to edit and compile everything so you don’t need to in-stall LATEX locally. Also, Stack Overflow has a good list of LATEXresourceshere: http://stackoverflow.com/documentation/latex/topics4 You’llwant to learn to use the automata library from the tikz package to creatediagrams; there’s lots of good information about this online.
-1.1 Organization
In my first time teaching this course, I noticed that students really enjoyedlearning about all the automata and machines, but didn’t like all the theoryserved up too soon. For example, they weren’t interested in learning toomuch about why some languages were not regular until they’d already seenin practice that Pushdown Automata are more powerful than DFAs andNFAs.
In order to better harness this motivation, I’ve reorganized the materialso that all of the automata come first (Section 1), followed by more dis-cussion about the different types of languages (Section 2). It is not untilSection 3 that we use pumping lemmas to show that some languages are notin some classes. In Section 4, we look at intractibility and how to handle it.
I tested this new ordering for the first time in Fall of 2017 and it wentreally well. I will do it again for Fall 2018.
-1.2 Exercises
I have included exercises in many of the subsections. For each type ofproblem, I have tried to include at least three problems:
• At least one problem with the answer given in the end of the book sothe student can see things worked through once.
• At least one problem with no answer given, which I assign for zeropoints. I can answer most questions from students without ”givingpoints away” on the assignment.
• At least one problem assigned for credit which I expect students to docompletely on their own.
Some advanced problems do not have this trio of parts.
-1.3 In Progress
These notes are very much a work in progress. I do not expect that ev-erything will be completed by the end of 2018, at which point I won’t beteaching this subject again for a while.
Here’s my TODO list:
• Include a table of the best approximation algorithms/hardness-of-approximationresults for some classical NP-hard problems.
• I need to add some diagrams. For example, the growing hierarchy oflanguage classes that we build.
• There are entire sections where I haven’t yet written up notes.
-1.4 Acknowledgements
Thanks to the Fall 2016 students of CS 3780 (Plymouth State) for puttingup with me learning to teach this course while it was running. I changedthe order of some things mid-lecture, and they rolled along with all of themodifications. Thanks also to students in following semesters for puttingup with all the unfinished sections and mid-lecture changes.
Thanks to the developers of the LATEX automata library in the tikz pack-age5.
Thank you to Christin Wixson, who manages the Plymouth State’srepository of Open Educational Resources. She helped me ensure that thesenotes fit the requirements for an OER and met the Creative Commons li-cense standards.
Thanks to Lisa Walton, who first taught me this material in the fall of2001. Sadly, Lisa passed away a few years ago, a loss for computer scienceeducation.
There are also many small fixes that people have noticed, including:
• Dale Skrien found many issues with the reduction problems near theend of the book.
5I don’t know the homepage of the library, but here’s a Stack Exchange answer with an example: http://tex.
-1.5 LaTeX Commands and Packages 0 MOTIVATION AND PREVIEW OF CS THEORY
• Madeleine Gibson6 found an error on the answer for an exercise, as wellas many typos.
• Charlie Hemenway7 found an error in the link to an answer for anexercise.
• Chrissy Shatney8 found multiple errors in pumping lemma exercises.
• Robert Kram9 found a spacing error in an exercise.
• Peter Simari10 found an error on a homework problem.
• Dominic Bruzzese, Justin Campbell, Madeleine Gibson, Sergei Homkow-icz, Rob Kram, Lucien Pease, Chrissy Shatney, and Peter Simari founda typo in an exercise.
0.0 Limits of Computation 0 MOTIVATION AND PREVIEW OF CS THEORY
0.0 Limits of Computation
Q: What if I limit the scope to computational problems? First, what is acomputational problem?
A:
Here are some example problems, phrased as questions: Examples:
• “Is this list of numbers, X, sorted in increasing order?”
• “What is the result of this list of numbers, X, if I sort it in increasingorder?”
Q:I have lots more to say about this, but first, let’s return to the questionof uncomputable. What could that mean if I have an uncomputableproblem?
A:
There are things that we just can’t write a program to do. Any program.In Python, Java, C/C++, etc. No programming language that we knowcan solve undecideable problems.
0.1 The Halting Problem is Undecideable 0 MOTIVATION AND PREVIEW OF CS THEORY
Q: What kind of proof techniques are you familiar with?
A:
We’re going to use a proof by contradiction. I find that the proof is bestexplained by a Seussian poem, “Scooping the Loop Snooper” by Geoffrey K.Pullum at U. Edinburgh11. Here’s the text (with my comments interspersed)
No general procedure for bug checks will do.Now, I won’t just assert that, I’ll prove it to you.I will prove that although you might work till you drop,you cannot tell if computation will stop.
For imagine we have a procedure called Pthat for specified input permits you to seewhether specified source code, with all of its faults,defines a routine that eventually halts.
Q: What kind of proof techinque am I using, assuming that program Pdoes exist? Hint: in Latin, it’s known as reductio ad absurdum.
A:
Q: What does that mean I’m going to show? What kind of situation am Igoing to arrive at?
A:
You feed in your program, with suitable data,and P gets to work, and a little while later
0.1 The Halting Problem is Undecideable 0 MOTIVATION AND PREVIEW OF CS THEORY
(in finite compute time) correctly inferswhether infinite looping behavior occurs.
If there will be no looping, then P prints out ‘Good.’That means work on this input will halt, as it should.But if it detects an unstoppable loop,then P reports ‘Bad!’ — which means you’re in the soup.
Okay, let’s summarize that on the board:
P (X, Y )→
{Good, if X(Y ) halts
Bad, if X(Y ) loops infinitely
Q: Does P solve the halting problem?
A:
Well, the truth is that P cannot possibly be,because if you wrote it and gave it to me,I could use it to set up a logical bindthat would shatter your reason and scramble your mind.
Here’s the trick that I’ll use — and it’s simple to do.I’ll define a procedure, which I will call Q,that will use P’s predictions of halting successto stir up a terrible logical mess.
For a specified program, say A, one supplies,the first step of this program called Q I deviseis to find out from P what’s the right thing to sayof the looping behavior of A run on A.
If P’s answer is ‘Bad!’, Q will suddenly stop.But otherwise, Q will go back to the top,and start off again, looping endlessly back,till the universe dies and turns frozen and black.
0.1 The Halting Problem is Undecideable 0 MOTIVATION AND PREVIEW OF CS THEORY
Q:Okay, let’s write down the steps of Q. I wrote it in 3 steps. Step 0 is:Run P (A,A)→ R.What are the other steps?
A:
And this program called Q wouldn’t stay on the shelf;I would ask it to forecast its run on itself.When it reads its own source code, just what will it do?What’s the looping behavior of Q run on Q?
If P warns of infinite loops, Q will quit;yet P is supposed to speak truly of it!And if Q’s going to quit, then P should say ‘Good.’Which makes Q start to loop! (P denied that it would.)
No matter how P might perform, Q will scoop it:Q uses P’s output to make P look stupid.Whatever P says, it cannot predict Q:P is right when it’s wrong, and is false when it’s true!
I’ve created a paradox, neat as can be —and simply by using your putative P.When you posited P you stepped into a snare;Your assumption has led you right into my lair.
So where can this argument possibly go?I don’t have to tell you; I’m sure you must know.A reductio: There cannot possibly bea procedure that acts like the mythical P.
You can never find general mechanical meansfor predicting the acts of computing machines;it’s something that cannot be done. So we usersmust find our own bugs. Our computers are losers!
0.1 The Halting Problem is Undecideable 0 MOTIVATION AND PREVIEW OF CS THEORY
Q: What’s the paradox?
A:
Q: Does this mean there’s no way for us to solve the halting problem?
A:
For another version of the proof, you can watch a fun video: https:
//www.youtube.com/watch?v=92WHN-pAFCs.
Q: Why do I care about this? I’m going to be a web developer, not atheorist!
A:
Also, you don’t want to fall for a hilarious joke like the one posted togetacoder.com in November, 2008. As covered by Will Benton’s blog12,user ”AlanT” proposed the following project for programmers to bid on:
”The purpose of this project is to create a debugger program. This pro-gram will take as input the source code another program, and will analyzethat other program and determine if it will run to completion, or have anerror, or go into an infinite loop.
”To state that another way, given a function f and input x, determine iff(x) will halt.”
The post and the responses are cached at http://turing.plymouth.
12Post originally at http://blog.willbenton.com/2008/11/rent-a-coder-hilarity/, but it seems to be brokennow. There’s an old YCombinator article (https://news.ycombinator.com/item?id=5660860) about it with lots ofgood comments.
0.2 Computing Models 0 MOTIVATION AND PREVIEW OF CS THEORY
edu/~kgb1013/3780/images/getacoderHalting.pdf13. Here are some high-
lights:
• User kagtech from Chennai, India is the last response, promising asolution in 18 days for $1,800, saying: ”We have gone through yourproject specifications; give us the opportunity to arise up your needs tobe done. We can do this task as sprint; let us do this work for you asper your timeline and schedule. We have a top-notch team. We ensurethat your feedback and comments are timely reflected in the technicalspecification on all stages of the projects Development. We are readyto start the work. Thanks & Warm Regards, Team - KAG Tech.”
There are lots like this one.
• User eliterammer claims to be able to solve the halting problem in 10days for $300!
• User germanquality can apparently do it for the same price, but in only1 day! Also, there’s some extreme biasing at work: ”As the superiorGerman programmer I am I’ve already solved the problem in my headas per your specification. I’m able to deliver a solution in source codein any language that can print a line of text. If necessary, I can alsoprovide flowcharts and a solution on solid German-made paper”.
• Some users got the joke. For example, GeorgeCantor says ”Herr T,Despite the fact that I died in 1918 you may find the following adviceimportant. I would be happy to work on your project but you willquickly find that it is impossible, nay undecidable. It is a simple conse-quence of my diagonalization argument for uncountable numbers thatwere such a program to exist it would be possible to create a programon which it could not work and hence you would obtain a contradictionand your original program would ’disappear in a puff of logic’. GrußGott, Georg”
0.2 Computing Models
Humans seem to be able to solve the halting problem. There may be someother “computing” device that someone invents that does solve the haltingproblem. It just means we can’t do it in our current computing model.
13This is my copy of Will Benton’s PDF of the article that was at http://blog.willbenton.com/wp-content/
uploads//2008/11/bug-finder.pdf. Thanks to Will Benton for saving this!
0.3 Languages 0 MOTIVATION AND PREVIEW OF CS THEORY
Q: What’s our computing model based on?
A:
Q: What does it mean when we say a programming language is complete?
A:
Are we going to learn about turing machines now? No, we’ll get there,though. We’re going to learn about simpler models of computation first.Plan:
• Finite Automata, then
• Pushdown Automata, then
• Turing Machines
0.3 Languages
Q: Recall the two sorting-based problems I mentioned at the beginning.What were those?
A:
We’re going to focus on boolean problems, meaning the answer is eitherYes or No. (True or False. Monkey or Gibbon.)
Actually, we’re going say Accept and Reject. Each of the automata (ma-chines) we create is going to return one of these two things on any input.The exact set of inputs that a machine answers Accept on is called a lan-guage. If automata M recognizes language A, then we say L(M) = A.
0.4 Math Background 0 MOTIVATION AND PREVIEW OF CS THEORY
Exercise 4
Let S = {a, b} and T = {a, c, c}. Replace the question marks in the followingexpressions with the set expression. (I.e., do not use S and T in your answers.)
a) S ∪ T =?
b) S ∩ T =?
c) T \ S =?
d) S × T =?
e) P(S) =?
Exercise 5
Let S = {a, d} and T = {a, b, c}. Replace the question marks in the followingexpressions with the set expression. (I.e., do not use S and T in your answers.)
a) S ∪ T =?
b) S ∩ T =?
c) T \ S =?
d) S × T =?
e) P(S) =?
Exercise 6
Write out the set description of this graph (the formal version, meaning G =(V,E) = . . .):
a
b c
(Answer 0.4.6 in Appendix)
Exercise 7
Write out the set description of this graph (the formal version, meaning G =(V,E) = . . .):
1.0 Deterministic Finite-state Automata (DFAs) 1 AUTOMATA AND MACHINES
Q: Which state is the accepting one?
A: Also q0
Q: And the rejecting state?
A:
Q: Can we have multiple accepting and rejecting states?
A: Yup! The accepting ones will always have the doublecircle around them
DFAs start at the start state and read the input string one character ata time, changing state at each step based on the current character. We candenote this process in the following way:
M(0010) : q00010
→ 0q0010
→ 00q010
→ 001q10
→ 0010q1
→ reject
We reject at the end because q1 is not an accepting state.⟨ Give the align example code for this in LATEX. ⟩
Describe the DFA that recognizes the following language, L ⊂ {0, 1}∗:{w | w contains a 1 and a 0 somewhere before that 1}Use either a figure or set notation to describe the automata.(Answer 1.0.12 in Appendix)
Exercise 13
Describe the DFA that recognizes the following language L ⊂ {a, b}∗:{w | w contains the substring aaa}Use either a figure or set notation to describe the automata.(Answer 1.0.13 in Appendix)
Exercise 14
Describe the DFA that recognizes the following language, L ⊂ {a, b}∗:L = {w | w does not contain the substring bab}Use either a figure or set notation to describe the automata.
Exercise 15
Describe the DFA that recognizes the following language, L ⊂ {a, b}∗:L = {w | w starts with an a and ends with a b}Use either a figure or set notation to describe the automata.
Exercise 16
Describe the DFA that recognizes the following language, L ⊂ {a, b}∗:L = {w | the second character of w is a}Use either a figure or set notation to describe the automata.
Exercise 17
Describe the DFA that recognizes the following language, L ⊂ {a, b}∗:L = {ba, aba, abab}Use either a figure or set notation to describe the automata.
Exercise 18
Describe the DFA that recognizes the following language, L ⊂ {a, b}∗:L = {w | every third character of w is a} E.g. bbaabab ∈ LUse either a figure or set notation to describe the automata.
1.1 Nondeterminism (NFAs)
This material is covered in Sipser in section 1.2. [2]
b) Describe the language using only explicit sets and the language opera-tions (∗, ∪, and ◦).
Exercise 11
Determine the language of the following NFA, M , over alphabet Σ = {a, b, c}.
q0start
q1
q2
q3
q4
q5
q6
a, b, c
ε
ε
ε
a
b
c
a) Describe the language using set-builder description using an Englishdescription.
b) Describe the language using only explicit sets and the language opera-tions (∗, ∪, and ◦).
Exercise 12
Use the NFA-building theorems from this section to build an NFA, M , so thatL(M) = {c}+.
(Answer 1.1.12 in Appendix)
Exercise 13
Use the NFA-building theorems from this section to build an NFA, M , so thatL(M) = ({b} ∪ {ab})∗. Your answer should have four steps of automata. ({b}, {ab},{b} ∪ {ab}, and ({b} ∪ {ab})∗)
Exercise 14
Use the NFA-building theorems from this section to build an NFA, M , so thatL(M) = {a}∗ ∪ ({c}∗ ◦ {b}).
Exercise 15
Use the NFA-building theorems from this section to build an NFA, M , so thatL(M) = {w | w is either abc repeated any number of times, or an even-length string with no a’s ending in bc}.(Hint: first come up with the sublanguages, then put them together using the theo-rems.)
Q: Is this PDA deterministic or non-deterministic?
A: Non-deterministic. Some transitions aren’t listed ANDit uses ε.
Q: What about M(0011)?
A:
Q: What about M(00011)?
A:
Q: What’s the language recognized by M , L(M)?
A:
Q:What if we wanted a PDA that recognizes the language L = {0n1n |n ∈N}? It’s similar to the machine above, but we have to make a littlechange. What do we need to know before we accept?
Q:What are some things that are going to be different about Turing Ma-chines that will make this a possibility? (I don’t expect them to get allof these.)
A:
• Can go back and forth on the input string.
• Can read and write the input. (So we call it a ”tape”instead.)
• No stack, so we’ll just use the tape. Thus, it mustbe unboundedly long on one side.
• Need another way to indicate when we’re done, sothe accept and reject states will be terminal (themachine stops when it reaches them).
⟨ Draw the following Turing Machine, M1, explaining how the notationworks. ⟩
Q:Remember the definition of recognizes : (the specifics matter a bunchmore now)M recognizes L ⊂ Σ∗ means w ∈ L ⇔ M(w) → accept. What couldhappen on w /∈ L?
A: M(w) could either reject or loop
Q: Sometimes we want to talk about machines that never loop. What arethese machines called?
A: We call these machines deciders. If M is a decider and itrecognizes L, we say that ”M decides L”.
Q: Which of M1 and M2 is a decider?
A:
Before we continue, it’s common to not draw all the edges to qreject, oreven draw it at all. Instead, it’s understood that all missing transitions leadto the reject state.
A turing machine that reaches the accept state on a language is said torecognize that language. A language is turing-recognizable if there’s a TMthat recognizes it.
Draw the diagram for a Turing Machine that decides the following language overalphabet Σ = {a, b, c}:{w | The sum of the number of a’s and b’s in w is 8}(Answer 1.3.0 in Appendix)
Exercise 1
Draw the diagram for a Turing Machine that decides the following language, A,over alphabet Σ = {a, b, c}:A = {w | w is in alphabetical order.}Hint: To clean up your figure, it’s okay to leave edges out, then specify: ”All
missing transitions go to qreject.”
Exercise 2
Draw the diagram for a Turing Machine that decides the following language overalphabet {a, b, c}:{w | The sum of the number of a’s and b’s in w is even.}
Exercise 3
No PDA exists to recognize
L0 = {w | w contains an equal number of a’s, b’s, and c’s}
. A Turing Machine does exist that decides L0, but it is too complicated to includeas a homework problem.
Instead, draw the diagram for a Turing Machine that decides
L1 = {w | w contains an equal number of a’s and b’s}
over the input alphabet {a, b}. There is a PDA that recognizes this, but it’s still aworthwhile exercise.
(Answer 1.3.3 in Appendix)
Exercise 4
Draw the diagram for a turing machine that decides the following language overalphabet {a, b}:{anb2n | ∀n ≥ 0}
Exercise 5
Draw the diagram for a turing machine that decides the following language overalphabet {a, b}:{anbabn | ∀n ≥ 0}
2 Language Classes
2.0 Regular Languages
This material is covered in Sipser in section 1.3. [2]A language is a regular language if there’s a DFA that recognizes it.A regular language is often described using a regular expression. Regular
Expressions are used widely in computer science. Each corresponds to aregular language. Blahblahblah.
TODO: explain regular expressions here. Explain that they are genera-tors for a language. Give a list of some of the special operations used byreal-world regular expressions (e.g. Java).
Q:What do you think each of these mean? What is the language A ◦ B?Example: C = {(01)∗}, D = {(10)∗}, what is C ◦ D? TODO: makesure this is back in section 0.4, then remove it here.
A:
Q: What’s the meaning of A ◦B, then?
A:
Q: What do you think is true of every A ◦ B, when A and B are recog-nizeable by an NFA?
A:
Q: How can we prove it?
A:
⟨ Draw the machine-blobs MA and MB. Put a start state and someaccepting states in each. ⟩
The following language is regular over the alphabet {a, b}:
L = {w | w does not contain both a’s and b’s.}
Prove that L is regular by finding a regular expression equivalent to L.(Answer 2.0.1 in Appendix)
Exercise 2
The following language is regular over the alphabet {a, b}:
L = {w | w is not empty and if it contains any a’s, it has no b’s.}
Prove that L is regular by finding a regular expression equivalent to L.
Exercise 3
The following language is regular over the alphabet {a, b}:
L = {w | w contains an odd number of a’s and exactly one b.}
Prove that L is regular by finding a regular expression equivalent to L.
2.1 Context-Free Languages
This material is covered in Sipser in section 2.1. [2]
Q: Which kind of automata have the power to recognize context-free lan-guages?
A: Pushdown Automata
Regular Languages are important because Regular Expressions are usedin pattern recognition. Context-Free Languages are important in definingprogramming languages.
Just as we can use regular expressions to generate all strings in a reg-ular language, context-free grammars can generate strings in context-freelanguages. Here’s an example:
Context-Free Grammar for Python boolean expressions (where the onlyvariables are X, Y, and Z).
We can use this to generate Parse Trees. What’s the Parse Tree for this?⟨ Draw the Parse Tree (Image TODO) ⟩Each Context-Free language has a CF grammar that generates all the
strings in it. Let’s look at one of the first CF-languages we considered:L = {aibi|i ∈ N}.
Q:So, there will be one state where all the transitions leave based on thetop element of the stack. What happens after we finish pushing thosesymbols backwards onto the stack?
A:
Q: How do we get to that main state from the start?
A:
Q: How do we finish?
A:
⟨ Do out the example above. ⟩
Exercises for 2.1
Exercise 0
Consider the following CFG G:
A→ zAz | yByB → aaa | zCbC → a | A | bz
(a) What are the variables of G?
(b) What is the start variable of G?
(c) What are the terminals of G?
(d) Give the derivation that shows zyaaayz ∈ L(G).
(e) Give the derivation that shows zyaaayz ∈ L(G).
Create a PDA for the following grammar on Σ = {a, b, c}. (Hint: Book Theorem2.20 has the steps to follow on page 118.)
X → Xa | Y aY → Y b | ZZ → Zc | c
(Answer 2.1.9 in Appendix)
Exercise 10
Create a PDA for the following grammar on Σ = {a, b, c}. (Hint: Book Theorem2.20 has the steps to follow on page 118.)
A→ Aab | cBB → Bba | ε
Exercise 11
Create a PDA for the following grammar on Σ = {a, b, c}. (Hint: Book Theorem2.20 has the steps to follow on page 118.)
E → aaEb | SSS → Sa | c
2.2 Decideable Languages
This material is covered in Sipser in section 4.1. [2]TODO: draw superset figure: (((Unambiguous CFLs (Regular Languages)
) CFLs) Decideable Languages)A languages is decideable if there is a Turing Machine that decides it.
Q:What if we consider languages that are sets of machines? Consider thefollowing language: L = {M | M is a DFA}. How would we representa single machine, M , as a string?
Recall that each Regular Language can be generatedby a Regular Expression. What if instead of spec-ifying the machine, I specify the expression? Is{(E,w) | E is a regular expression and w is a matching string}decideable?
A:
Q: Let’s call this machine D. How does it work?
A:
Q:Let’s try some questions where we don’t include any input and just askabout a machine. What’s the most basic question we could ask abouta DFA?
A:
Q: Is this language decideable? {M | M is a DFA and it recognizes ∅}
TODO: add questions here about whether two machines recognize thesame language.
Okay, we’ve shown that answering questions about Regular-Language-Machines is decideable. We know from the beginning of the semester (Sec-tion 0.1) that we can’t answer all questions about Turing Machines. Next,let’s take a closer look at analyzing Pushdown Automata using Turing Ma-chines...
Q: What do you think? Are basic questions about PDAs going to bedecideable?
⟨ Talk about the complement of a language, L = LC . If L is decideable,what about L? TODO: write this out. ⟩
TODO: add more here?
Exercises for 2.2
Exercise 0
Let Σ = {a, b, c}. Let Σ-star be this language: {A | A is a DFA and L(A) = Σ∗}.Show that Σ-star is decideable.
(Answer 2.2.0 in Appendix)
Exercise 1
Let Σ = {a, b} and OnlyA = {A | A is a DFA and L(A) = {a}∗}. Show thatOnlyA is decideable.
2.3 Turing-Recognizeable Languages 3 NON-INCLUSION
Exercise 2
Let Rejected = {(A,w) | A is an NFA and w /∈ L(A)}. Show that Rejectedis decideable.
Exercise 3
Let Intersect = {(A,B,w) | A and B are DFAs and w ∈ L(A) ∩ L(B)}. Showthat Intersect is decideable.
Exercise 4
Let NFA-Accept = {(A,w) | A is an NFA and w ∈ L(A)}. Show that NFA-Accept is decideable. (This is totally an example in the text book. TODO: add thecitation here.)
(Answer 2.2.4 in Appendix)
2.3 Turing-Recognizeable Languages
This material is covered in Sipser in section 4.2. [2]There are some languages that are recognized by Turing Machines, even if
those machines aren’t decided. A language is Turing-recognizeable if thereis a Turing Machine that recognizes it, meaning a machine that alwaysaccepts when given a string in that language, and does not accept whengiven a string not in that language.
3 Non-Inclusion
When is a language not regular? When is it not context-free? When is itundecideable? There are some tools we can use to help sort languages out.If we can’t find an automata, but we think one might exist, these parts canhelp us be more certain.
3.0 Non-Regular Languages
This material is covered in Sipser in section 1.4. [2]Pumping LemmaThere is a nice lemma15 to help determine whether a language is regular:
The Pumping Lemma:If L is a regular language, then there exists an integer, p ≥ 1 such that
∀w ∈ L : if |w| ≥ p, then ∃x, y, z : w = xyz where:
Q: Since all three cases break, what does that mean?
A:There’s no way to satisfy the pumping lemma, so there’sour contradiction! The initial assumption must be wrong:L must not be regular.Hooray, our proof of non-inclusion is done!
Q: So what’s the basic idea in these proofs?
A:
1. Proof-by-contradiction: assume it is regular.
2. Then, by Pumping Lemma, there must be a p thatsatisfies the lemma.
3. Choose an element w ∈ L where |w| ≥ p to show thecontradiction. This will usually use p somewhere init.
4. Show that you can’t subdivide w to satisfy all threeconditions. (You may need multiple cases here.)
5. If you can’t subdivide in any of the cases, that’s yourcontradiction! Boom!
Exercises for 3.0
Exercise 0
What is the pumping length of L = {a, aa, ab, bb}?(Answer 3.0.0 in Appendix)
Exercise 1
What is the pumping length of L = {aibjck | i, j, k ≤ 5}?
Exercise 2
Consider the following regular language:
L = {a}∗ ◦ {b}∗
(a) Choose a working p to satisfy the pumping lemma.
This material is covered in Sipser in section 2.3. [2]
Q: Okay, so what do we do if we want to show that a language is too hardfor a PDA to recognize?
A:
Pumping LemmaPumping Lemma for CFLs : If L is a context-free language, then ∃p >
0 : ∀w ∈ L, if |w| ≥ p, then ∃ uvxyz = w where:
• |vy| 6= ε
• |vxy| ≤ p, and
• ∀i ≥ 0 : uvixyiz ∈ LAs with Regular Languages, the smallest p is known as L’s pumping length.
Satisfying the Pumping Lemma for CFLsLet’s apply the Pumping Lemma to L = {akbk | k ∈ N}.
Q: How should we divvy up any string aibi into u, v, x, y, and z?
A:
TODO: ... more about this example. E.g. what is the pumping length?(2)
TODO: next example: L = {akbbbck | k ∈ N}TODO: next example: L = {ambncm | m,n ∈ N}TODO: next example: L = {ambncndm | m,n ∈ N}TODO: next example: L = {akbmcn | k = m or k = n}Showing Non-Context FreeThis material is covered in Sipser in section TODO. [2]
Since vy 6= ε, the only option for uv2xy2z is a2p+1. TODO: continue from
here...Use: Order of the elements doesn’t matter, so...Consider the case where: s = a8, uxz = a4, v = aa, and y = aa.Notice, when i = 0, |s| = 4, which is okay.When i = 1, |s| = 8, also okay.But, when i = 2, |s| = 12, which doesn’t work.Let’s generalize this to show that it never works. Proof by contradiction:Assume L is context-free. Then the pumping lemma holds. Let p be the
pumping length of L. Then let s be a string in L where |s| > 2p.Let m = |uxz| and n = |vy|. Then m + i × n is always a power of 2,
∀i ∈ N.Consider the first 4: m = 2b, m + n = 2b2c = 2b+c, m + 2n = 2b+c2d =
2b+c+d, m+ 3n = 2b+c+d2f = 2b+c+d+f , where b, c, d, f > 0.Note: c ≥ 1 → m + n = 2b+c ≥ 2b+1 = 2 · 2b = 2m. Thus, m + n ≥ 2m
and n ≥ m.At the same time, d ≥ 1 → m + 2n = 2b+c+d ≥ 2b+c+1 = 2 · 2b+c =
2(m+ n). Thus, m+ 2n ≥ 2m+ 2n, meaning m ≥ 2m, and 0 ≥ m. Thus,m = 0.
But, |vxy| ≤ p, so m = |uxz| ≥ |uz| = |s|−|vxy| > 2p−|vxy| ≥ 2p−p =p > 0. Thus, m > 0.
Next example: L = {aibici | i ∈ N} Show that this is not context-free.
Exercises for 3.1
Exercise 0
Consider the following context-free language:
L = {akbck | k ∈ N}
(a) Choose a working p to satisfy the pumping lemma. (It does not needto be the shortest.)
(b) For any string, w, longer than your chosen p, show how to divide it intou, v, x, y, and z. (You might need multiple cases.)
(c) Show that the three conditions of the pumping lemma decompositionhold for your divisions.
(a) Choose a working p to satisfy the pumping lemma. (It does not needto be the shortest.)
(b) For any string, w, longer than your chosen p, show how to divide it intou, v, x, y, and z. (You might need multiple cases.)
(c) Show that the three conditions of the pumping lemma decompositionhold for your divisions.
Exercise 2
Consider the following context-free language:
L = {akbmcmdk | k,m ∈ N}
(a) Choose a working p to satisfy the pumping lemma. (It does not needto be the shortest.)
(b) For any string, w, longer than your chosen p, show how to divide it intou, v, x, y, and z. (You might need multiple cases.)
(c) Show that the three conditions of the pumping lemma decompositionhold for your divisions.
Exercise 3
(Should I even include this one? I do it in class. I guess I’m keeping this right nowbecause the answer in the back is more detailed than in the notes.) Use the PumpingLemma for Context-Free Languages to show that this language is not context free:
L = {a2n | n ∈ N}
(Answer 3.1.3 in Appendix)
Exercise 4
Use the Pumping Lemma for Context-Free Languages to show that L is not contextfree, where
L = {anbmcndm| n,m ∈ N}
(Answer 3.1.4 in Appendix)
Exercise 5
Use the Pumping Lemma for Context-Free Languages to show that this languageis not context free:
For simplicity, we’ll just use a python program for M instead of a Tur-ing Machine. I’m going to be a bit more restrictive and assume that thefollowing language is undecideable as a result of the halting problem:
PythonHalt = {(p, x) | p is a Python program that, on input x, halts.}
From there, we’ll build a new program, H, that decides PythonHalt.
Q: What’s our first step?
A:
Okay, create a new TM, H(k, y) (k is the input python program, y is theinput to k):
1. Create a new Python program, n, which is just k but with the followingline added to the end:print(5) #Apparently we’re using Python 3.
Q: There’s still a problem here. What’s that problem?
A:
Q: How do we solve this problem?
A:
That function we added to transform the problem instances is called areduction. If we can reduce from language A to language B, that meansthat there’s a function, f , where:
• f : Σ∗(A)→ Σ∗(B), and
• w ∈ A⇔ f(w) ∈ BThe reduction is exactly the function f . We say, ”f is a reduction from
Assume that both languages are over the same alphabet: Σ = {a, b, c, d}.(Answer 3.2.0 in Appendix)
Exercise 1
Consider these two languages:
A = {w | w is an even number represented in binary}, and
B = {w | w is in alphabetical order}The alphabets for these are Σ(A) = {0, 1} and Σ(B) = {a, b, c}. Find a reduction,
f , from A to B.
Exercise 2
Consider these two languages over the same alphabet {a, b, c}:
A = ({ab} ∪ {cb})∗
, and
B = {ac}∗ ◦ {bbbb}Find a reduction, f , from A to B.
Exercise 3
Consider the following language:YesBeluga = {M |M is a Java program that prints the string Beluga to the console}Show that YesBeluga is undecideable.(Answer 3.2.3 in Appendix)
Exercise 4
You can run code in many languages that reformats (meaning, deletes) a harddrive. For example, in Java, run this code to reformat a Windows drive:19 (I haven’tactually tried this out, but I think it formats the C drive. For the purposes of this,let’s assume that’s the case.)
Process p = Runtime.getRuntime().exec("CMD /C format f:
/FS:NTFS /Q /X /Y");
19Source: http://stackoverflow.com/questions/20491849/formatting-fat32-usb-drive-on-windows Don’t ac-tually run this code unless you really want to delete all of your files!
Consider the following language:ReformatsYou = {(X,w) | X is a Java program that, on input w,
reformats the C drive.}.Show that ReformatsYou is undecideable.Hint: for my solution, I assumed that I could create a Virtual Machine and execute
Java code inside of that.
Exercise 5
Show that the following language, VisitsState, is undecideable.
VisitsState = {(M, q, w) | TM M run on input w visits state q}
(Answer 3.2.5 in Appendix)
Exercise 6
Show that the following language, VisitsThreeStates, is undecideable.
VisitsThreeStates = {(M,w, qa, qb, qc) | TM M run on input w visits all states qa, qb, and qc}
If you can’t complete a formal proof, write a ”proof sketch” or try writing it outthoroughly in words. If you can explain how this proof will differ from the previousone, that will get you most of the way there.
Exercise 7
Show that the following language, VisitsAllStates, is undecideable.
VisitsAllStates = {(M,w) | TM M run on input w visits all states aside from qreject}
If you can’t complete a formal proof, write a ”proof sketch” or try writing it outthoroughly in words.
Exercise 8
Consider the following language: NothingUseless = {M |M is a TM with no unreachable states}.Show that NothingUseless is undecideable. (An unreachable state is one that isnever visited on any input string.)
3.3 Turing Unrecognizeability
This material is covered in Sipser in section 4.2. [2]Different Infinities
So they’re both countably infinite! Even though one is a strict subset ofthe other, they have the same ”size”. That word is a little weird... whenwe’re talking about infinities, we use the term cardinality instead of size.
Let’s consider some other sets:
• Z• H
• E
• R• Q• Q
Q: What’s the cardinality of Z? Hint: find a function
Q: Think about a language L over alphabet Σ = {0, 1}. What are thepossible cardinalities of L?
A:
Q: What about Σ = {a, b}?
A:
Q: What if we add elements to Σ? E.g. {a, b, c}
A:
Q: So, over any finite alphabet, what is the cardinality of L?
A: Finite or countably infinite
Q:Now let’s try to figure out the cardinality of the set of Turing Machinesover some finite Σ. What is true about the size of the number of statesin a Turing Machine?
Q: So what is the size of the set of all Turing Machines? (Let’s call thisset M)
A:
Q: What about S, the set of all languages over some Σ = {a, b}?
A: There is no onto f : N→ S
Q: How is this possible?
A:Consider the following diagonalization argument. As-sume onto f . Now consider the following languageL = {ak | f(k) does not contain a string of length k}
Q: What’s the result of all of this?
A: There are more languages than TMs! That means thereare languages that aren’t Turing-Recognizeable!
Let’s try to find one of these languages that is not Turing-Recognizeable!First we have to take a look back at language complements, i.e. LC . For
Note: we can verify solutions in polynomial time.I.e., they can be solved in polynomial time on a Non-deterministic Turing
Machine.Then, out of the chaos, 3SAT emerged and NP was defined.Cook-Levin Theorem:⟨ Talk more about this stuff. You know what you’re doing. ⟩
4.1 Approximation Algorithms
This material is covered in Sipser in section 10.1. [2]
Q: Your boss comes up to you and wants you to write a perfect schedulingalgorithm for meetings. Should your response be that this is impossible?
A:Maybe. Maybe not. What if you couldn’t get it per-fectly right, but you could get pretty close. What if youcouldn’t schedule everything, but you could schedule 98%of the meetings?
Q:
For a maximization problem, if the optimal (max) value is OPT , then ak-approximation algorithm is one that always returns a value betweenk×OPT and OPT . In the example above, your algorithm would be a.98-approximation algorithm.How are approximations for minimization problems described?
Example: MAX-CUT, which is NP-hard. There is an α-approximationalgorithm (where α ≈ .868) by Goemanns and Williamson21[1]
This algorithm is really cool! ... add in the details...
Q:
Consider all of the following problems. Are they minimization or max-imization problems? What property is being approximated? If neces-sary, give them a new name that makes sense.
• Hamiltonian Cycle
• Independent Set
• Vertex Cover
• Subset Sum
A:
Q:There is a weird 2-approximation algorithm for Vertex Cover. See ifyou can figure it out. Hint: order doesn’t matter. Double hint: justtake both.
A:
21A good summary of the details is here: http://www.sfu.ca/~mdevos/notes/semidef/GW.pdf
(This is the machine from Exercise 1.0.3.)Answer:L(D) = {0}+
Answer of exercise 1.0.10
Answer Not Provided
Answer of exercise 1.0.11
Answer Not Provided
Answer of exercise 1.0.12
Question:Describe the DFA that recognizes the following language, L ⊂ {0, 1}∗:{w | w contains a 1 and a 0 somewhere before that 1}Use either a figure or set notation to describe the automata.Answer:Figure solution:
• F = {q2}Naturally, there are lots of other possible machines that accept thislanguage.
Answer of exercise 1.0.13
Question:Describe the DFA that recognizes the following language L ⊂ {a, b}∗:{w | w contains the substring aaa}Use either a figure or set notation to describe the automata.Answer:Figure solution:
Question:The following language is regular over the alphabet {a}:
L = {w | The number of a’s in w is congruent to 2 mod 5.}
Prove that L is regular by finding a regular expression equivalent to L.Answer:
L = {w | The number of a’s in w is congruent to 2 mod 5}= {w | w is aa followed by a multiple of aaaaa }= {aaw | The number of a’s in w is a multiple of 5.}= {aa} ◦ {w | The number of a’s in w is a multiple of 5.}= {aa} ◦ {aaaaa}∗
Thus, L = {aa} ◦ {aaaaa}∗
Answer of exercise 2.0.1
Question:The following language is regular over the alphabet {a, b}:
L = {w | w does not contain both a’s and b’s.}
Prove that L is regular by finding a regular expression equivalent to L.Answer:
L = {w | w does not contain both a’s and b’s.}= {w | w contains only a’s or only b’s}= {w | w contains only a’s }∪ {w | w contains only b’s}
1. aaaba ∈ L(G). To prove this, we show a derivation C ⇒∗ aaaba.
C ⇒ aC
⇒ aaC
⇒ aaaDa
⇒ aaaba
2. abba /∈ L(G). To prove this, we show that no possible derivationswork. When there’s no chance for a path to match abba any longer, weindicate this with the � symbol.
Start with C:
• C ⇒ aC ⇒ aaC ; abba �• ⇒ aaDa ; abba �• ⇒ ab 6= abba �• ⇒ aC ; abba �• ⇒ aDa⇒ aba 6= abba �• ⇒ aa 6= abba �• ⇒ aCaaaa ; abba �• ⇒ aDa ; abba �• ⇒ b 6= abba �• C ; abba
All of the paths fail, so abba cannot be in L(G).
Answer of exercise 2.1.4
Answer Not Provided
Answer of exercise 2.1.5
Answer Not Provided
Answer of exercise 2.1.6
Question:Give a context-free grammar, G, that generates L = {w | w starts and ends with 0}
In this grammar, the following symbols are used for terminal characters: Σ ={a, b, c}. Create a cycle to and from the base state that uses these (this is part 2b):
q0start q1
qbase
qaccept
ε, ε→ $
ε, ε→ X
ε, $→ ε
a, a → εb, b → εc, c → ε
Now add a leaving path for the first grammar variable (this is part 2a):
q0start q1
qbase
qaccept
qX
ε, ε→ $
ε, ε→ X
ε, $→ ε
a, a → εb, b → εc, c → ε
ε,X → ε
Then include transitions for each option from that variable-rule, putting the sym-bols on the stack in reverse order, then returning to the base state. Here’s the loopfor the rule X → Xa:
3. If any non-accepting state is marked, reject. Otherwise, accept.
This decides Σ-star because it should accept all inputs. All marked states arereachable by some input string, so A accepts all inputs exactly when all markedstates are accepting states.
Answer of exercise 2.2.1
Question:Let Σ = {a, b} and OnlyA = {A | A is a DFA and L(A) = {a}∗}. Show that
OnlyA is decideable.Answer:We show that OnlyA is decideable by describing a program that decides OnlyA:On input (A), where A is a DFA:
1. Mark the start state of A with one symbol (say, x).
2. Repeat until no new states get marked with x: Mark any state x thathas a transition on a to it from any already-marked x state.
3. For each state in A marked with an x, follow the b-transition and markthe resulting state with symbol y.
4. Repeat until no new states get marked with y: Mark any state y thathas a transition to it from any already-y-marked state.
5. Check that all x-marked states are accepting states, and all y-markedand non-marked states are not accepting states. If this is the case,accept, otherwise reject.
This decides OnlyA because all a-transitions lead back to accepting states, but allb-transitions should lead to non-accepting states. Any states marked x are reachableby only a strings, while y-marked states are reachable by any string that contains atleast one b. (States marked with both should not are reachable by both, and such amachine will be rejected.)
Answer of exercise 2.2.2
Answer Not Provided
Answer of exercise 2.2.3
Answer Not Provided
Answer of exercise 2.2.4
Question:Let NFA-Accept = {(A,w) | A is an NFA and w ∈ L(A)}. Show that NFA-
Accept is decideable. (This is totally an example in the text book. TODO: add thecitation here.)
• |y| = |a| ≥ 1 X• |xy| = |a| ≤ 1 = p X• ∀i : xyiz = aiajbk = ai+jbk ∈ L X
In Case B:
• |y| = |b| ≥ 1 X• |xy| = |b| ≤ 1 = p X• ∀i : xyiz = bib = bi+j ∈ L X
Answer of exercise 3.0.3
Answer Not Provided
Answer of exercise 3.0.4
Answer Not Provided
Answer of exercise 3.0.5
Question:Use the pumping lemma to show that the following language, L, is not regular.
L = {a2k | ∀k ∈ N}
Answer:Proof-by-contradiction. Assume L is regular. Then the pumping lemma applies.Let w be a string of 2k a’s, with a working decomposition w = xyz. Note that
|y| ≥ 1 (otherwise, the first decomposition condition is broken) so y includes at leastone a.
Now, by the third condition, xy2z = xyyz is also in the language, and, since|y| ≤ |xyz|, |xyyz| ≤ 2 |xyz|.
However, |xyyz| ≥ 2 |xyz|, otherwise, |xyyz| is not a power of 2.Thus, |xyyz| = 2 |xyz|, meaning x = z = ε. Then xyz = y. Also, by the third
condition, y3 = yyy ∈ L.However, y and y3 cannot both have lengths that are powers of 2. Thus, y and
yyy cannot both be in L. →←By contradiction, our assumpion that L is regular must be false.Thus, L is not regular.
Question:(Should I even include this one? I do it in class. I guess I’m keeping this right now
because the answer in the back is more detailed than in the notes.) Use the PumpingLemma for Context-Free Languages to show that this language is not context free:
L = {a2n | n ∈ N}
Answer:Proof-by-contradiction: Assume L is context-free.Then the pumping lemma for context-free languages must hold. Thus, there exists
a p such that for any string, w ∈ L, if |w| ≥ p, there must be a working decompositionw = uvxyz such that:
• |vxy| ≤ p
• |vy| ≥ 1
• ∀i : uvixyiz ∈ LConsider the first power of 2 strictly greater than p, 2k > p. a2k ∈ L. Let uvxyz
be the decomposition for w = a2k .Since |vy| ≥ 1, a ∈ vy. Thus, |uvvxyyz| > 2k
Thus, 2k < |uvvxyyz| < 2k+1, so uv2xy2z /∈ L. Thus L cannot be context-free! →←By contradiction, the assumption must be false. Thus, L must not be context-free.
Answer of exercise 3.1.4
Question:Use the Pumping Lemma for Context-Free Languages to show that L is not context
Answer:Proof-by-contradiction. Assume that L is context free. Then there must be a p
that satisfies the pumping lemma (fCFL). Thus, for any string w ∈ L with at least pcharacters, there’s a decomposition that satisfies the three conditions.
Consider w = ap+1bp+1cp+1dp+1. Let’s find a working decomposition to satisfy thepumping lemma (for Context-Free Languages).
In order for the third condition to be met (∀i : uvixyiz ∈ L), v cannot consist of amix of different characters and the same is true for y. Since the number of a’s and c’shas to be the same (and the same is true for b’s and d’s) there are only two possiblecases. Either v = ak and y = ck or v = bk and y = dk.
Case A: v = ak and y = ck where k ≤ p+ 1Then x contains all of the b’s, so |vxy| ≥ p+ 1 > p, breaking that condition.Case B: v = bk and y = dk where k ≤ p+ 1Then x contains all of the c’s, so |vxy| ≥ p+ 1 > p, also breaking that condition.Neither of the cases satisfy the pumping lemma! →← Thus, L must not be context
free.
Answer of exercise 3.1.5
Answer Not Provided
Answer of exercise 3.1.6
Answer Not Provided
Answer of exercise 3.2.0
Question:Find a reduction, f from A to B, where:
A = {anbn | n ∈ N}, and
B = {anbmcmdn | n,m ∈ N}Assume that both languages are over the same alphabet: Σ = {a, b, c, d}.Answer:f needs to be a function from Σ∗ to itself, so: f : Σ∗ → Σ∗.Let w = x0x1x2 · · ·xk where each xi is a single character of w. Let g be this
• We still have to show that f(w) ∈ B ⇔ w ∈ A. Two cases: w ∈ A ⇒f(w) ∈ B and f(w) ∈ B ⇒ w ∈ A. 18
Case A: w ∈ AThen ∃k such that w = akbk. Then,
f(w) = f(akbk)
= g(a)kg(b)k
= akdk
∈ B X
Case B: f(w) ∈ Bf(w) can’t contain any b’s (since b is not in the range of g) so f(w) =akdk for some k. Since the only way to get those characters with g isfrom a’s and b’s, respectively, w must equal akbk. X
So, f is a reduction from A to B.
Answer of exercise 3.2.1
Answer Not Provided
Answer of exercise 3.2.2
Answer Not Provided
Answer of exercise 3.2.3
Question:Consider the following language:YesBeluga = {M |M is a Java program that prints the string Beluga to the console}
18Alternatively, for the second case, we could just show w /∈ A⇒ f(w) /∈ B. I chose to stick with the direct routebecause there were lots of little cases I didn’t want to list, but it can certainly be done!
Now the input for VisitsState is: (M ′, qaccept, w).Claim: (M ′, qaccept, w) ∈ VisitsState exactly when (M,w) ∈ Halting.Proof of claim:M ′ is exactly the same as M , except that we moved the accept and reject states
(qaccept and qreject) and replaced them with non-halting states (qold−acc and qold−rej,respectively). Then we added transitions between these two states and qaccept so thatthe machine will always advance there.
Now, if M(w) halts, then M ′(w) will reach either qold−acc or qold−rej and then moveon to qaccept, which is the vertex we chose as our second input for VisitsState. Thus,whenever M(w) halts, M ′(w) will visit qaccept. X
We still have to show that if M(w) doesn’t halt, M ′(w) will not reach qaccept. Notethat only way to reach qaccept in M ′ is by going through qold−acc or qold−rej. Thosetwo states are only reached on M ′(w) when M(w) halts by reaching qaccept or qreject.Thus, if M(w) doesn’t halt, M ′(w) cannot reach qaccept. XThis completes the proofof the claim.
The reduction is complete, thus VisitsState is undecideable.
Answer of exercise 3.2.6
Answer Not Provided
Answer of exercise 3.2.7
Answer Not Provided
Answer of exercise 3.2.8
Answer Not Provided
B Bibliography
References
[1] Michel X. Goemans and David P. Williamson. A general approximationtechnique for constrained forest problems. SIAM J. Comput., 24(2):296–317, 1995.
[2] Michael Sipser. Introduction to the theory of computation. PWS Pub-lishing Company, 1997.