Theorema44_conversions
A44: the conversions to Int at 2.5, -2.5, NaN, the infinities and 1e300, in that order: round rounds a half upward (x + 1/2 exact), and every conversion saturates into [-2^63, 2^63 - 1], NaN giving 0. Float.floor is computed by the C library, so this is proved by native_decide. [native]
Statement
theorem a44_conversions :
let f (x : Float) : ValProof
.sv (.float x)
let xs : List Float := [2.5, -2.5, 0 / 0, 1 / 0, -1 / 0, 1e300]
[BasVal.round, .floor, .ceiling, .truncate].map (fun b => xs.map fun x => (applySet b [f x]).map showElm)
= [[["3"], ["-2"], ["0"], ["9223372036854775807"], ["-9223372036854775808"], ["9223372036854775807"]],
[["2"], ["-3"], ["0"], ["9223372036854775807"], ["-9223372036854775808"], ["9223372036854775807"]],
[["3"], ["-2"], ["0"], ["9223372036854775807"], ["-9223372036854775808"], ["9223372036854775807"]],
[["2"], ["-2"], ["0"], ["9223372036854775807"], ["-9223372036854775808"], ["9223372036854775807"]]] := by
native_decideProved by native_decide: the decision procedure is compiled and run, and its answer is trusted. This is used where values are compared as they print, floats above all, which the kernel cannot compare.
About ruling A44 of the book, where the implementations disagreed or were silent and the definition decides.
In StandardElmMech/Theorems.lean: The command #mod_program_theorems (one theorem per program, in module form, in Lib.Btest; tagged [library] when the program names a core library value), budgetNative, the rulings stated directly, and theorems that D1 makes possible (a43_one_unique, a51_one_choice, log_order_demo).
A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.