For your homework, I want these ranges of variables, as seen.
But if you want true challenges, here are some more.
For instance, you can go and also record the types of variables,
say, the type of x is the same as the type of 2.
Or you could go and check for set patterns.
For instance, you could report that the variable x
is in the list of values 2, 4, and 16.
The relationships between variables--
In the square root function, the y variable always has the same value as the return value.
That's not very surprising, because we actually return y, but that's an interesting property.
Likewise, the return value of a square root function
is always less or equal to the value that we want to compute the square root for.
You can obtain such relationships between variables
by coming up with a pattern, say like equal or less than,
and instantiating that pattern with all variables,
and then seeing which patterns actually hold over multiple runs.
With that, enjoy building your own dynamic invariant checker,
and make it easier for future generations to write assertions. Thank you.
Come compito a casa, voglio questi intervalli come abbiam visto.
Ma se vuoi una vera sfida, eccoti dell'altro.
Per esempio, puoi anche prender nota dei tipi di variabili,
per esempio, il tipo di x e' uguale al tipo 2.
Oppure potresti vedere se ci sono pattern di strutture set,
per esempio, potresti segnalare che la variabile x
e' compresa nell'elenco di valori 2, 4 e 16.
Le relazioni tra variabili:
nella funzione square-root, la variabile y ha sempre lo stesso valore del valore di rientro.
Non c'e' niente di eccezionale, perche' effettivamente ritorna y, ma e' una proprieta' interessante.
Allo stesso modo, il valore di rientro della funzione square-root
e' sempre minore o uguale al valore di cui vogliamo calcolarne la radice.
Potrai ottenere queste relazioni tra variabili
creando un pattern, tipo == o <=
e istanziando questo pattern per tutte le variabili
e poi vedere quale schema regge veramente dopo esecuzioni multiple.
Detto questo, divertiti a creare il tuo controllore dinamico di invarianti
e facilitare la scrittura di asserzioni per le future generazioni. Grazie.
宿題をするためには確認した変数の値域が必要です
本気ならもう少し詳しい情報を集めましょう
変数のタイプを記録しましょう
例えばxは2と同じタイプだとかです
あるいは決まったパターンを見つけましょう
例えば変数xは値2、4、16の配列にあると
リポートすることができますね
そして変数間の関係です
square_root関数では
y変数は常に戻り値と同じ値になります
返されるのはyなので驚くことではありませんが
面白い特徴です
同様にsquare_root関数の戻り値は
平方根で算出する値より少ないか
等しいかのどちらかです
変数間の相関関係を知るためには次のようにします
まずはパターンを見つけて
そのパターンを全変数でインスタンス化します
そして複数の実行で
そのパターンが有効であることを確認しましょう
それを基に独自の動的不変条件チェッカを
作成してください
そうすれば次の世代が
アサーションを書きやすくなるでしょう
在你的作业中,我要求有这些变量的范围,如示。
但如果你想真正地挑战下,那就再加点难度吧。
比如,你可以记录这些类型的变量,
比如,x
或者,你可以检查集合里的模式。
比如,你记录下变量x
是2,4,16中的一个值。
那变量之间的关系--
在这个平方根函数里,y变量的值和返回值 自然永远一样。
不惊讶,因为返回的就是y,但这仍是个有趣的性质。
同样的,平方根函数的返回值
总是比要去求平方根的值小,(0-1之间的小数除外)。
你可以得到变量之间的这种关系,
只要提出一个模式,比如说 <= ,
用所有的变量来作例子,
看看在多次运行中,这个模式是否一直成立 。
这样,你就很享受构建你自己的动态不变量检查器的过程,
未来写断言也会更加轻松。本单元结束,谢谢。