אחד הבאגים הנפוצים בתכניות מחשב הוא לולאות אינסופיות. דהיינו- אומרים למחשב לבצע פקודה מסוימת מספר פעמים, אבל שוכחים, במקרים מסוימים, להגיד לו לעצור, והתוצאה היא שהמחשב נתקע עם הפקודה הזו ומבצע אותה שוב ושוב בלי לעצור, וצריך להפסיק את פעולתו באופן חיצוני. לכן, באופן טבעי, התעוררה שאלה: האם ניתן לכתוב תכנית, שתקרא תכניות אחרות ותזהיר מפני לולאות אין סופיות שנמצאות בתוכה? כלומר, במילים אחרות, האם ניתן להכריע בשאלה האם תכנית תעצור או לא, רק מתוך התבוננות בקוד שלה (דהיינו, בלי להריץ אותה, לא בפועל ולא בראש)? אם זה היה אפשרי זה היה חוסך למתכנתים הרבה כאב ראש של חיפוש באגים. לצערנו, התשובה היא שלא. אין שום דרך לעשות את זה. כלומר בעיית העצירה היא אי כריעה (לא ניתנת להכרעה). ההוכחה היא אלגנטית מאד, ומישהו בשם ג'פרי פולום כתב אותה בחרוזים. להלן תרגום של ההוכחה. שְלִילַת מְגַלֶּה הַלּוּלָאוֹת הַמּהֻלָּל / ג'פרי ק. פולום אֵין תָּכְנִית שֶתֵּדַע מָה אֲחֶרֶת עוֹשָׂה. זוֹ עֻבְדָּה מוּצָקָה, וְלֹא סְתָם מְצוּצָה: תּוּכָל עַד מָחָר אֶת הַמֹּח לִשְבֹּר- לֹא תּוּכַל לְנַבֵּא אִם תָּכְנִית תַּעֲצֹר. נַנִּיחַ שֶP הִיא שִיטָה שֶכָּזֹאת שֶלְּתוֹך כָּל תָּכְנִית מְצִיצָה, לְגַּלּוֹת שֶאֵין שוּם לוּלָאָה אֵינְסוֹפִית מִסְתַּחְרֶרֶת; וְאִם אֵין שָם כְּלוּם- אָז 'טוֹב!' הִיא אוֹמֶרֶת. מְזִינִים אֶת הַקּוֹד וְאֶת כָּל הַנְּתוּנִים, וְP אָז תַּחֲקֹר בַּפְּרָטִים הַקְּטַנִּים וּתְחַשְבֵּן אִם הַכֹּל מִסְתַּדֵּר כָּרָאוּי (בְּנִגּוּד לְמַצָּב לוּלָאִי לֹא רָצוּי). הָאֱמֶת הִיא שֶP כָּזוֹ לֹא תִּתָּכֵן, כִּי אִם תִּכָּתֵב P, וְלִי תִּנָּתֵן, אֶשְתַּמֵּש בָּהּ לִצֹּר כֶּשֶל לוֹגִי מֻצְלָח שֶיִּשְבֹּר הֶגְיוֹנְךָ וְחוּשֶיךָ יִמְעַךְ. הַתַּכְסִיס הוּא פָּשוּט וְיוֹצֵא מִן הַכְּלָל. אַגְדִּיר עוֹד תָּכְנִית, בְּשֵם Q, לְמָשָל, שֶתִּקַּח כָּל תָּכְנִית, וּלְP אָז תִּקְרָא, שֶתִּקְבַּע אִם יֵש בָּהּ לוּלָאָה מַמְאִירָה; אִם יֵש, אָז Q תַּדְפִּיס 'אוּף!' וְתִפְרֹש; אַךְ אִם אֵין, אָז Q תַּחֲזֹר לָהּ לָרֹאש, וְתַתְחִיל מֵחָדָש, תִּסְתּוֹבֵב בְּלִי לַחֲדֹל, עַד יִגְוַע הַיְּקוּם וְיִקְפָּא וְיִבֹּל. הַתָּכְנִית הַזּוֹ, Q, לֹא תֻּשְאַר יְתוֹמָה; מַמְזֵר שֶכְּמוֹתִי- אַפְעִילָהּ עַל עַצְמָהּ! אֵיךְ Q תִּתְנַהֵג בְּמַצָּב שֶכָּזֶה? כְּשֶתִּקְרָא אֶת עַצְמָהּ- מָה בְּדִיּוּק תַּעֲשֶׂה? אִם P תְּגַלֶּה לוּלָאָה- Q תֵּצֵא; אַךְ P אֲמוּרָה לְדַוֵּחַ עַל זֶה. כָּךְ שֶאִם Q תֵּצֵא- אָז P תֹּאמַר 'טוֹב!' וְQ תֵּאָלֵץ לְהַתְחִיל שוּב לָסֹב! מָה שֶP לֹא תַּגִּיד, Q יָשָר מְעַקֶּמֶת; Q גוֹרֶמֶת לְP לָצֵאת דֵּי מְטֻמְטֶמֶת. כִּי אִם P צוֹדֶקֶת- יוֹצֵא שֶשִּקְּרָה; וְאִם מְשַקֶּרֶת- אֱמֶת הִיא דִּבְּרָה! כָּזֶה פָּרָדוֹקְס אֱלֶגָנְטִי יָצָא, פָּשוּט בִּגְלַל P, הַהֲלִיך הַמֻּמְצָא. אִם תַּנִּיחַ שֶP אֲמִתִּי- הִסְתַּבַּכְתָּ; בְּפַח הַיּוֹקְשִים שֶטָּמַנְתִּי- נִלְכַּדְתָּ! אָז אֵיך נֵחָלֵץ מִצָּרָה כֹּה סְבוּכָה? לֹא צָרִיךְ שֶאַגִּיד; תְּנַחֵש לְבַדְּךָ. מַסְקָנָה הֶכְרֵחִית, שֶבְּזֶה הָעוֹלָם, יְצוּר אֲגָדִי כְּמוֹ P- לֹא קַיָּם. לֹא תַּצְלִיחַ לִבְנוֹת מִין מִתְקָן שֶכָּזֶה שֶיּוּכַל לְנַבֵּא מָה מַחְשֵב יַעֲשֶׂה. זֶה בִּלְתִּי אֶפְשָרִי. וְלָכֵן אֲנָשִים מוֹצְאִים בָּאגִים לְבַד; מַחְשֵבִים הֵם טִפְּשִים!!

Scooping the Loop Snooper No program can say what another will do. Now, I won't just assert that, I'll prove it to you: I will prove that although you might work til you drop, you can't predict whether a program will stop. Imagine we have a procedure called P that will snoop in the source code of programs to see there aren't infinite loops that go round and around; and P prints the word "Fine!" if no looping is found. You feed in your code, and the input it needs, and then P takes them both and it studies and reads and computes whether things will all end as the should (as opposed to going loopy the way that they could). 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 bind that would shatter your reason and scramble your mind. Here's the trick I would use - and it's simple to do. I'd define a procedure - we'll name the thing Q - that would take and program and call P (of course!) to tell if it looped, by reading the source; And if so, Q would simply print "Loop!" and then stop; but if no, Q would go right back to the top, and start off again, looping endlessly back, til the universe dies and is frozen and black. And this program called Q wouldn't stay on the shelf; I would run it, and (fiendishly) feed it itself. What behaviour results when I do this with Q? When it reads its own source, just what will it do? If P warns of loops, Q will print "Loop!" and quit; yet P is supposed to speak truly of it. So if Q's going to quit, then P should say, "Fine!" - which will make Q go back to its very first line! No matter what P would have done, Q will scoop it: Q uses P's output to make P look stupid. If P gets things right then it lies in its tooth; and if it speaks falsely, it's telling the truth! I've created a paradox, neat as can be - and simply by using your putative P. When you assumed P you stepped into a snare; Your assumptions have led you right into my lair. So, how to escape from this logical mess? I don't have to tell you; I'm sure you can guess. By reductio, there cannot possibly be a procedure that acts like the mythical P. You can never discover mechanical means for predicting the acts of computing machines. It's something that cannot be done. So we users must find our own bugs; our computers are losers!