TorchLean API

NN.Floats.NeuralFloat.Rounding.Order

Order Theory for Generic Rounding #

Monotonicity is subtle because two inputs may be scaled with different canonical exponents. The proof separates equal-grid inputs from inputs in different magnitude bins and uses the bounds from GenericRound in the latter case.

theorem TorchLean.Floats.neuralRound_le_of_cexp_eq {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) [NeuralValidRnd rnd] {x y : } (hxy : x y) (he : neuralCexp β fexp x = neuralCexp β fexp y) :

Rounding is monotone when both inputs use the same canonical exponent.

theorem TorchLean.Floats.neuralRound_mono_pos {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) [NeuralValidRnd rnd] {x y : } (hx : 0 < x) (hxy : x y) :

Positive generic rounding is monotone.

theorem TorchLean.Floats.neuralRound_nonneg {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) [NeuralValidRnd rnd] {x : } (hx : 0 x) :

Rounding a nonnegative value with a valid mode produces a nonnegative value.

theorem TorchLean.Floats.neuralRound_nonpos {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) [NeuralValidRnd rnd] {x : } (hx : x 0) :

Rounding a nonpositive value with a valid mode produces a nonpositive value.

theorem TorchLean.Floats.neuralRound_mono {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) [NeuralValidRnd rnd] {x y : } (hxy : x y) :

Generic rounding is monotone on all real inputs.

theorem TorchLean.Floats.neural_generic_le_round {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) [NeuralValidRnd rnd] {x y : } (hx : neuralGenericFormat β fexp x) (hxy : x y) :

A representable lower value remains below rounding of any larger input.

theorem TorchLean.Floats.neural_round_le_generic {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) [NeuralValidRnd rnd] {x y : } (hy : neuralGenericFormat β fexp y) (hxy : x y) :

Rounding of a smaller input remains below a representable upper value.

Directed-down generic rounding selects the greatest representable value below its input.

Directed-up generic rounding selects the least representable value above its input.

Generic truncation satisfies the toward-zero rounding specification.

Nearest-even generic rounding is no farther from the input than any other integer rounding.

Nearest-even rounding selects a globally nearest representable value.