TorchLean API

FloatLib.Floats.Formats.Posit.Quire.Model.Proof

Correctness of the standard posit quire model #

The standard quire model has raw-word round-trip laws, an exact characterization of the reserved NaR word, ordinary coefficient bounds, and rational semantics for integer dyadic conversion.

References #

The quire width is positive for every valid posit descriptor.

@[simp]
theorem FloatLib.Floats.Formats.Posit.Quire.Model.ofNatBits_toNatBits {format : Format} (value : Model format) :
ofNatBits format value.toNatBits = value

Re-encoding a quire's complete bit pattern preserves it.

@[simp]
theorem FloatLib.Floats.Formats.Posit.Quire.Model.toNatBits_ofNatBits_of_lt (format : Format) (bits : ) (bits_lt : bits < 2 ^ width format) :
(ofNatBits format bits).toNatBits = bits

An in-range unsigned word is unchanged by standard-quire encoding.

@[simp]

The canonical zero quire has integer coefficient zero.

@[simp]

The canonical NaR quire uses the reserved sign-bit coefficient.

Zero and quire NaR are distinct at every valid posit width.

@[simp]

The quire NaR predicate recognizes the canonical NaR value.

@[simp]

The canonical zero quire is not NaR.

@[simp]
theorem FloatLib.Floats.Formats.Posit.Quire.Model.isNaR_eq_true_iff {format : Format} (value : Model format) :
value.isNaR = true value = nar format

The executable NaR test recognizes exactly the reserved word.

A quire word equals NaR exactly when its signed coefficient is the reserved minimum.

Every stored quire coefficient lies in the inclusive signed range of its physical word.

A coefficient is ordinary exactly when the quire word is not the reserved NaR code.

Negation preserves the set of ordinary quire coefficients.

theorem FloatLib.Floats.Formats.Posit.Quire.Model.ordinaryCoefficient_of_natAbs_lt {format : Format} {value : } (hvalue : value.natAbs < 2 ^ (width format - 1)) :
OrdinaryCoefficient format value

Any integer whose absolute magnitude is below the positive half-range is an ordinary quire coefficient.

The strict bound excludes both signed overflow and the reserved most-negative NaR word.

Encoding an ordinary coefficient preserves it exactly.

A coefficient outside the ordinary range, including the reserved minimum, becomes NaR.

Dyadic-to-quire scaling preserves exact value when the stored exponent is high enough.