Example: a loop whose length comes from the data, and a hundred buffers
Library · Source module
Example: a loop whose length comes from the data, and a hundred buffers
Halving. NLAlib.Ops.Examples.halve halves a word while it is not zero, with a fuel given as a size. The number of rounds is not a size: it is the bit length of the number the word decodes to.
Main results
* NLAlib.Ops.Examples.halve_wp: total correctness by wp_whileFuel, with an invariant on the decoded state (dec a = v / 2 ^ i after i rounds) and the bound Nat.size v from the mathematics; the fuel only has to be at least that. * NLAlib.Ops.Examples.runs_halve: the same with counts that depend on the data, Nat.size v calls of half and Nat.size v + 1 tests, by RunsFromW.whileFuel. The loop leaves before the fuel is used up, and the fuel does not appear in the bound. * NLAlib.Ops.Examples.wpL_halveStrict: partial correctness with no bound at all. * NLAlib.Ops.Examples.exists_isHalving: the contracts can be met.
A hundred buffers. NLAlib.Ops.Examples.read_of_hundred: reads through writes to other buffers of an injective family of a hundred handles, with one disjointness hypothesis.
Declarations
- NLAlib.Ops.Examples.HOp
- NLAlib.Ops.Examples.HOp.ofNat
- NLAlib.Ops.Examples.HOp.ofNat_ctorIdx
- NLAlib.Ops.Examples.HTst
- NLAlib.Ops.Examples.HTst.ofNat
- NLAlib.Ops.Examples.HTst.ofNat_ctorIdx
- NLAlib.Ops.Examples.HalveInv
- NLAlib.Ops.Examples.IsHalving
- NLAlib.Ops.Examples.exists_isHalving
- NLAlib.Ops.Examples.halve
- NLAlib.Ops.Examples.halveInv_cap
- NLAlib.Ops.Examples.halveInv_step
- NLAlib.Ops.Examples.halveInv_test
- NLAlib.Ops.Examples.halveStrict
- NLAlib.Ops.Examples.halve_wp
- NLAlib.Ops.Examples.read_of_hundred
- NLAlib.Ops.Examples.runs_halve
- NLAlib.Ops.Examples.wpL_halveStrict