TorchLean API

NN.Floats.NeuralFloat.Rounding.Generic

Rounding Into A Generic Format #

This file develops the converse of neural_round_preserves_generic: rounding an arbitrary real produces a value in the selected generic format. The proof follows the small/large magnitude split used by Flocq rather than assuming the conclusion as part of the rounding definition.

theorem TorchLean.Floats.neuralValidExp_small {fexp : } [NeuralValidExp fexp] {e : } (h : e fexp e) :
fexp (fexp e + 1) fexp e

The Valid_exp consequence used when the input magnitude is below the selected exponent.

theorem TorchLean.Floats.neuralValidExp_large {fexp : } [NeuralValidExp fexp] {e : } (h : fexp e < e) :
fexp (e + 1) e

The Valid_exp consequence used when the selected exponent is below the input magnitude.

theorem TorchLean.Floats.neural_round_pos_small_cases {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) [NeuralValidRnd rnd] (x : ) (hx : 0 < x) (hsmall : neuralMagnitude β x fexp (neuralMagnitude β x)) :
neuralRound rnd x = 0 neuralRound rnd x = neuralBpow β (fexp (neuralMagnitude β x))

Positive inputs in the small-magnitude regime round either to zero or to one radix power.

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

Rounding in the small-magnitude regime produces a generic-format value.

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

In the large-magnitude regime, rounding stays inside the input magnitude bin and produces a generic-format value.

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

Rounding in the large-magnitude regime produces a generic-format value.

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

Every positive real rounds into the selected generic format.

Conjugate a rounding rule by negation.

Instances For
    theorem TorchLean.Floats.neuralRound_neg {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) [NeuralValidRnd rnd] (x : ) :

    Rounding a negated input is negated rounding with the conjugate integer rule.

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

    Rounding any real produces a value in the selected generic format.