Extra for Experts

Note that this program is capable of processing itself. The C language is sufficiently expressive, or capable of expressing computational ideas, that it can answer meaningful questions about other arbitrary C programs themselves. This is a very useful property; for instance, we can write a C program that answers the following questions about another C program: However, this property paradoxically means that there are some questions we can never get a C program to answer about arbitrary C programs, like: and many other undecideable questions. Kurt Gödel, a famous mathematician, proved that any system capable of answering questions about itself must be incomplete, that is, contain true statements that are unprovable (i.e., questions that are unanswerable). C and most other programming languages fit this description. Alan Turing, another famous mathematician and computer scientist, showed that the question above, "Will this program ever finish...," can't be answered by another program. There is another class of questions that can be answered, but the best known algorithms that answer them take an exponential amount of time, i.e., a very long time. One such question about C programs is this:
Given a logical expression (like something in an if statement), is there any possible assignment to the variables involved that will cause it to be true?
It seems like a simple question, but the best answer people have come up with so far is not much better than "try all possible combinations of true and false," of which there are an exponential number. Problems like this are called NP-complete, and you will run into them if you take later computer science or electrial engineering classes. What does this mean for you? Many problems other than questions about C programs are undecideable or NP-complete, and there are mathematical tools for proving that they are. If your boss ever asks you to write some fast code to solve a certain problem and you think it can't be done, you may be right. You can try to prove that the problem is unsolvable by a computer in a reasonable amount of time. For more information on this and other cool computer science stuff, see the comp.theory Frequently Asked Questions List. (This Extra for Experts section brought to you as a blatant plug for the CS class Analysis of Algorithms and my section in the theory FAQ :-)