Going through it together, vladimir immediately returns 1,
so it halts in pretty much 1 step.
So yes, this does not loop forever.
To figure out the value of nabokov, we call nabokov,
which causes us to call nabokov, which causes us to call nabokov.
This is one of those infinite loops.
Not my most symmetric infinity symbol ever.
We never actually get a value out of this.
We call ourselves over and over again.
This procedure does not halt.
You might be thinking, "Oh, eventually we will run out of stack space,"
or more prosaic concerns like that, but remember here
I want you to think in the abstract.
We're assuming this mythical halts procedure.
How about pale? X is 0, while True, x is x + 1.
We actually looked at this before.
This loop does not halt, does not terminate.
How about fire?
We start out with x is 0 and y is 1000,
and as long as x is less than y, we add 2 to x and we add y to 1.
After a little bit, this will be 2 and 1001, then this will be 4 and 1002,
this will be 6 and 1003.
And although it doesn't look like it now, eventually x will catch up to y
because x is growing twice as fast.
For example, after 1000 steps, x will be 2000 and y will also be 2000,
at which point we'll break out of this loop.
So fire does in fact halt.
Pale Fire was a 1962 novel by Nabokov.
He's perhaps more famous for Lolita.
He was a Russian author who did a lot of writing in English.
All right. We didn't see anything bad. That all looked fine.
We could figure out just by staring at things whether they halted or not.
Why am I predicting doom and gloom? We didn't have any problems.
一緒に見ていきましょう
vladmirはすぐに1を返します
1ステップで停止します
従ってこれは無限ループしません
nabokovの返り値を知るためにnabokovを呼び
それがnabokovを呼び さらにnabokovを呼んで
無限ループします
無限の記号がうまく書けませんでしたね
返り値を得ることはありません
自分自身を何度も何度も呼び出すので
この関数は停止しません
“最終的にはスタック領域が
足りなくなる”と考えたり
もっと平易な停止をする理由を
考えたかもしれませんが
抽象的に考えてください
この神秘的なhalts関数について考えているのです
paleはどうでしょう
xは0でTrueの間はxにx+1を代入します
前にも見ましたね
このループは停止しません
fireはどうでしょう
xが0でyが1000から始まります
xがyより小さい限り
xに2を足しyに1を足し続けます
すぐにこれは2と1001、4と1002となり
そして6、1003となります
今のところ差は大きいですが
xは2倍大きくなるので
最終的にxはyに追いつくでしょう
1000ステップのあと xは2000でyも2000になります
その時点でループから抜けます
つまりfireはきちんと停止します
「青白い炎」は1962年に
ナボコフによって書かれた小説です
彼の作品では
おそらく「ロリータ」の方が有名でしょう
ロシア人の作家で英語で多くの作品を残しています
悪いところは何もなく すべて順調そうです
ただ眺めるだけでプログラムが停止するかどうか
見分けることができました
今のところ何も問題はないのに
なぜ私は散々な未来を想像していたのでしょうか?
Resolvendo isso juntos -- vladimir retorna imediatamente,
portanto pára em apenas 1 passo.
Então, sim, isso não entra em loop infinito.
Para saber o valor de nabokov, nós chamamos nabokov,
o que resulta em chamar nabokov, que chama nabokov, que chama nabokov.
Este então entra em loop infinito.
Este não é dos meus símbolos de infinito mais simétricos.
Nunca realmente obtemos um valor daqui --
chamamos a nós mesmos de novo e de novo.
Esta função nunca pára.
Você pode estar pensando: "Oh, eventualmente vamos exceder o espaço da pilha",
ou alguma coisa assim, mas lembre-se: aqui eu
quero que você pense de modo abstrato.
Estamos assumindo esta mítica função halts.
E esta, pale? x = 0, while True x = x + 1.
Já vimos isto antes.
Este loop não pára, não termina.
E fire?
Começamos com x = 0 e y = 1000,
e, enquanto x < y, somamos 2 a x e somamos 1 a y.
Depois de algum tempo, isso será 2 e 1001, e depois será 4 e 1002,
depois 6 e 1003.
E embora possa não parecer ainda, eventualmente x irá passar y,
Porque x cresce duas vezes mais rápido.
Por exemplo, depois de 1000 passos, x será 2000 e y será também 2000,
ponto no qual esse loop termina.
Portanto, fire de fato pára.
Pale Fire foi uma novela de Nabokov, de 1962.
Ele é talvez mais famoso por Lolita.
Ele foi um autor russo que escreveu vários livros em inglês.
Ok. Não vimos nada ruim aqui -- isso nos parece ok.
Pudemos determinar isso apenas verificando se cada comando pára ou não.
Porque eu estou prevendo um desastre? Não tivemos nenhum problema aqui.