I feel like we covered this topic too quickly, and moreover we jumped into overly complex examples of halt without first understanding the simpler ones. The examples in the course notes show functions with 1 or more parameters when we really should have started with functions that don't take any inputs at all. Here is a snippet of code I posted on Piazza that I believe should have been the original proof for the non-existence of halt.
def halt(func): """Return True iff func() eventually halts.
Assume this exists. """ def unhaltable(): """Loop infinitely if calling halt(unhaltable) returns True, i.e. unhaltable() halts. Return False otherwise.""" if halt(unhaltable): while True: pass else: return False
The above code provides a much simpler proof than the confused( ) function proof from the course notes. There are no extraneous parameters that complicate our understanding of the underlying concept. With this proof in hand we can then branch out to other functions that actually do take in arguments and then gradually develop more complex proofs from there.
These extra parameters and functions that take in two functions as arguments caused me to focus too much on the python syntax side of things rather than the concept of halting. I spent several days deciphering the code and trying to program functions that take in two functions as inputs, as well as seeing what happens when a function calls itself but with another function as its own input argument. I wanted to know whether the function passed in as an argument is ever reached or whether we just create a never ending recursive function. I even used a python visualizer to try and see what was going on.
Another area of confusion is that the conceptual halt function doesn't necessarily have to run the code of the function it receives. It could instead just scan the code and analyze it to see if it halts. Passing in a function along with another object input distorted this concept because I kept thinking that the function was just going to recurse forever. The challenges noted above are what prompted me to rewrite the confused() function from the course notes into something simpler like what is shown above.
To sum up the semester I'm going to include a link to this student's Week 12 slog post. Truth be told, that comic he posted is probably what half the students in all of comp. sci. are thinking when they go through this course. I was sure to let him know in the comments section.
http://andrewgoupilcsc165.blogspot.ca/
To sum up the semester I'm going to include a link to this student's Week 12 slog post. Truth be told, that comic he posted is probably what half the students in all of comp. sci. are thinking when they go through this course. I was sure to let him know in the comments section.
http://andrewgoupilcsc165.blogspot.ca/