Reference · Logic
rainbow.math.logic.clamp-range
In Rainbow 1.4.1, lein verify rainbow.math.logic.clamp-range fails on its own: the module uses lemmas from
math.rational.nnrat.minmax without listing them in its dependencies. It checks once those are installed.
Universal correctness of clamping (the PPO / trust-region clip of AHoF D52), built on the general nnrat min/max bounds: clamp r lo hi = min (max r lo) hi Proved for ALL r, lo, hi (not just worked instances): clamp-at-most-hi : clamp r lo hi <= hi lo-at-most-clamp : lo <= hi -> lo <= clamp r lo hi Together: whenever lo <= hi, the clamped value provably lies in the interval [lo, hi] for every input r -- the guarantee the clip step relies on. Native and axiom-free; chains rainbow.math.rational.nnrat.minmax.
clamp/clamp
clamp/clamp : (x₁ x₂ x₃ : ℚ≥0) → ℚ≥0
ℚ≥0 = nnrat/NonnegativeRational
clamp/clamp-at-most-hi
clamp/clamp-at-most-hi : (r lo hi : ℚ≥0) → clamp/clamp r lo hi ≤ hi
ℚ≥0 = nnrat/NonnegativeRational≤ = nnrat/at-most
clamp/lo-at-most-clamp
clamp/lo-at-most-clamp : (r lo hi : ℚ≥0) (ordered : lo ≤ hi) → lo ≤ clamp/clamp r lo hi
ℚ≥0 = nnrat/NonnegativeRational≤ = nnrat/at-most