Elm Exactly

Theorema49_apply_float

StandardElmMech/Theorems.lean:289, The rulings, stated directly (kernel-checked) · native_decide (trusts the compiled evaluator)

A49: at floats APPLY(clamp, lo, hi, x) is min (max x lo) hi with the IEEE 754-2019 minimum and maximum: hi when lo > hi, NaN when any argument is NaN, +0 for clamp 0 1 -0. Floats are compared as printed, so this is proved by native_decide. [native]

Statement

theorem a49_apply_float :
    let f (x : Float) : Val

Proof

.sv (.float x)
    let nan : Float := 0 / 0
    let nz : Float := -0
    ([applySet .clamp [f 10, f 0, f 5], applySet .clamp [f nan, f 1, f 0.5],
      applySet .clamp [f 0, f nan, f 0.5], applySet .clamp [f 0, f 1, f nan],
      applySet .clamp [f 0, f 1, f nz], applySet .clamp [f (-1), f nz, f 0],
      applySet .clamp [f 0, f 1, f 0.5]].map (·.map showElmSigned))
      = [["+0"], ["NaN"], ["NaN"], ["NaN"], ["+0"], ["-0"], ["0.5"]] := by
  native_decide

Proved 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 A49 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.