TorchLean API

FloatLib.Floats.Formats.BinaryInterchange.DirectedSemantics.Rational.Quotient

Directed integer rounding of nonnegative rational quotients #

The quotient operations used by directed rational rounding satisfy format-independent order bounds. Floor rounding lies below the exact real quotient, ceiling rounding lies above it, and integer lower and upper thresholds are preserved in the expected directions.

Natural quotient bounds #

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.div_le_quotCeil (numerator denominator : ) :
numerator / denominator quotCeil numerator denominator

The floor quotient is no larger than the ceiling quotient.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.quotCeil_le_div_add_one (numerator denominator : ) :
quotCeil numerator denominator numerator / denominator + 1

The ceiling quotient is at most one larger than the floor quotient.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.div_mul_le_numerator (numerator denominator : ) :
numerator / denominator * denominator numerator

Multiplying the floor quotient back by its denominator does not exceed the numerator.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.numerator_le_quotCeil_mul (numerator denominator : ) (hdenominator : denominator 0) :
numerator quotCeil numerator denominator * denominator

Multiplying the ceiling quotient back by a nonzero denominator covers the numerator.

Exact real enclosure #

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.ceil_real_nat_div_eq_quotCeil (numerator denominator : ) (hdenominator : denominator 0) :
numerator / denominator = Int.ofNat (quotCeil numerator denominator)

The executable natural ceiling is the exact integer ceiling of the represented real quotient.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.natCast_div_le_div (numerator denominator : ) (hdenominator : denominator 0) :
↑(numerator / denominator) numerator / denominator

The natural floor quotient lies below the exact real quotient.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.div_le_natCast_quotCeil (numerator denominator : ) (hdenominator : denominator 0) :
numerator / denominator (quotCeil numerator denominator)

The exact real quotient lies below its natural ceiling quotient.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.natCast_roundQuotDirected_false_le (numerator denominator : ) (hdenominator : denominator 0) :
(roundQuotDirected false numerator denominator) numerator / denominator

Downward quotient rounding is a lower bound on the exact real quotient.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.le_natCast_roundQuotDirected_true (numerator denominator : ) (hdenominator : denominator 0) :
numerator / denominator (roundQuotDirected true numerator denominator)

Upward quotient rounding is an upper bound on the exact real quotient.

Exact rational invariance #

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.roundQuotDirected_eq_of_rat_eq (roundUp : Bool) (numerator denominator numerator' denominator' : ) (hdenominator : denominator 0) (hdenominator' : denominator' 0) (hvalue : numerator / denominator = numerator' / denominator') :
roundQuotDirected roundUp numerator denominator = roundQuotDirected roundUp numerator' denominator'

Directed quotient rounding depends only on the represented nonnegative rational.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.roundQuotDirected_scaleByPowerOfTwo_add (roundUp : Bool) (numerator denominator : ) (firstExponent secondExponent : ) (hdenominator : denominator 0) :
have first := Numerics.RationalBinary.scaleByPowerOfTwo numerator denominator firstExponent; have second := Numerics.RationalBinary.scaleByPowerOfTwo first.1 first.2 secondExponent; have combined := Numerics.RationalBinary.scaleByPowerOfTwo numerator denominator (firstExponent + secondExponent); roundQuotDirected roundUp second.1 second.2 = roundQuotDirected roundUp combined.1 combined.2

Successive exact binary scalings may be combined before directed quotient rounding.

Preservation of integer thresholds #

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.le_roundQuotDirected_of_mul_le (roundUp : Bool) (numerator denominator lower : ) (hdenominator : denominator 0) (hlower : lower * denominator numerator) :
lower roundQuotDirected roundUp numerator denominator

An integer lower bound on a quotient survives either directed integer rounding.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.roundQuotDirected_le_of_lt_mul (roundUp : Bool) (numerator denominator upper : ) (hdenominator : denominator 0) (hupper : numerator < upper * denominator) :
roundQuotDirected roundUp numerator denominator upper

A strict integer upper bound on a quotient bounds either directed integer rounding.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.pow2_le_roundQuotDirected_of_le_div (roundUp : Bool) (numerator denominator exponent : ) (hdenominator : denominator 0) (hlower : (pow2 exponent) numerator / denominator) :
pow2 exponent roundQuotDirected roundUp numerator denominator

A real power-of-two lower bound survives either directed integer rounding.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.roundQuotDirected_le_pow2_of_div_lt (roundUp : Bool) (numerator denominator exponent : ) (hdenominator : denominator 0) (hupper : numerator / denominator < (pow2 exponent)) :
roundQuotDirected roundUp numerator denominator pow2 exponent

A strict real power-of-two upper bound weakly bounds either directed integer rounding.