TorchLean API

FloatLib.Floats.Formats.Posit.Rounding.SquareRoot.Direct.PrefixProof

Exact semantics of arbitrary-width square-root prefixes #

The direct square-root kernel scales a positive dyadic by an even power of two, computes its integer square root, and jams whether the exact root continues beyond that integer prefix. This module proves the representation-independent integer facts. Posit-specific square-root refinement is kept in Direct.Proof.

Dyadic exponent parity is always zero or one.

Casting the executable parity recovers the Euclidean exponent remainder.

theorem FloatLib.Floats.Formats.Posit.Model.DirectDyadicSquareRoot.sourceExponent_eq (precision : ) (radicand : Numerics.Dyadic) :
radicand.exponent = Int.ofNat (exponentParity radicand + 2 * precision) + (radicand.exponent.ediv 2 - Int.ofNat precision) + (radicand.exponent.ediv 2 - Int.ofNat precision)

The source exponent splits into the generated root scale and its two restored half-scales.

theorem FloatLib.Floats.Formats.Posit.Model.DirectDyadicSquareRoot.toRat_eq_scaledRadicand_mul_scale_sq (precision : ) (radicand : Numerics.Dyadic) (hnegative : radicand.negative = false) :
radicand.toRat = (scaledRadicand precision radicand) * 2 ^ (radicand.exponent.ediv 2 - Int.ofNat precision) * 2 ^ (radicand.exponent.ediv 2 - Int.ofNat precision)

The scaled integer radicand and two copies of the restored root scale denote the source dyadic.

theorem FloatLib.Floats.Formats.Posit.Model.DirectDyadicSquareRoot.scaledRadicand_pos (precision : ) (radicand : Numerics.Dyadic) (hsignificand : radicand.significand 0) :
0 < scaledRadicand precision radicand

Scaling preserves positivity of a nonzero source significand.

theorem FloatLib.Floats.Formats.Posit.Model.DirectDyadicSquareRoot.truncatedRoot_pos (precision : ) (radicand : Numerics.Dyadic) (hsignificand : radicand.significand 0) :
0 < truncatedRoot precision radicand

The truncated root is positive for every nonzero source significand.

theorem FloatLib.Floats.Formats.Posit.Model.DirectDyadicSquareRoot.truncatedRoot_square_le (precision : ) (radicand : Numerics.Dyadic) :
truncatedRoot precision radicand * truncatedRoot precision radicand scaledRadicand precision radicand

The truncated root's square is the lower endpoint of the exact root cell.

theorem FloatLib.Floats.Formats.Posit.Model.DirectDyadicSquareRoot.scaledRadicand_lt_succ_truncatedRoot_square (precision : ) (radicand : Numerics.Dyadic) :
scaledRadicand precision radicand < (truncatedRoot precision radicand + 1) * (truncatedRoot precision radicand + 1)

The scaled radicand lies strictly below the square of the next integer root.

theorem FloatLib.Floats.Formats.Posit.Model.DirectDyadicSquareRoot.squareRemainder_eq_zero_iff (precision : ) (radicand : Numerics.Dyadic) :
squareRemainder precision radicand = 0 scaledRadicand precision radicand = truncatedRoot precision radicand * truncatedRoot precision radicand

The exact square remainder vanishes exactly for an integral scaled root.

theorem FloatLib.Floats.Formats.Posit.Model.DirectDyadicSquareRoot.precision_le_truncatedRoot_log2 (precision : ) (radicand : Numerics.Dyadic) (hsignificand : radicand.significand 0) :
precision (truncatedRoot precision radicand).log2

Generating precision fractional root bits puts the truncated root's leading bit at or above that position.

Exact rational continuation at the scale represented by a generated root prefix.

Instances For
    theorem FloatLib.Floats.Formats.Posit.Model.DirectDyadicSquareRoot.roundCode_eq_fraction (format : Format) (radicand : Numerics.Dyadic) (remainder denominator : ) (hsignificand : radicand.significand 0) (hnegative : radicand.negative = false) (hdenominator : 0 < denominator) (hremainder : remainder < denominator) (hzero : squareRemainder (prefixPrecision format) radicand = 0 remainder = 0) :
    roundCode format radicand = roundPositiveCode format (rootCellPoint format radicand remainder denominator)

    The executable prefix rounds exactly like any proper rational continuation in the same integer root cell.

    Only exactness versus a nonzero continuation is observable after sticky-bit jamming. This theorem lets the square-root refinement proof choose convenient rational lower and upper witnesses around the mathematical root.