TorchLean API

FloatLib.Floats.Formats.Posit.Quire.Configured.Proof

Correctness of the configured posit quire interface #

The public raw-word operations are lossless, posit-to-quire conversion preserves exact rational meaning, and the distinguished zero and NaR values are preserved across both conversion directions. The fold theorems at the end transport the standard capacity guarantees to accumulation loops written against the configured carrier.

References #

@[simp]

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

@[simp]

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

@[simp]

Converting posit NaR to its associated quire produces the reserved quire NaR.

@[simp]

Converting posit zero to its associated quire produces the all-zero quire.

@[simp]

Configured posit-to-quire conversion preserves the complete optional exact rational meaning.

The theorem is unconditional: ordinary values are proved to fit the standard quire exactly, and posit NaR maps to quire NaR.

@[simp]

Rounding the reserved quire NaR to a posit produces posit NaR.

@[simp]

Rounding the all-zero quire to a posit produces the unique posit zero.

Accumulation loops #

Configured exact values are the model's exact values of the decoded posits.

Configured exact products are the model's exact products of the decoded posit pairs.

theorem FloatLib.Floats.ExecFloat.Posit.Quire.toRat?_foldl_qMulAdd_zero {format : Formats.Posit.Format} {plan : Formats.Posit.Configured.StoragePlan format} {code : Type} [ModelCodec plan (Formats.Posit.Model format) code] (pairs : List (ExecFloat (Formats.Posit.Configured.Family format code plan) × ExecFloat (Formats.Posit.Configured.Family format code plan))) (products : List ) (hproducts : exactProducts? pairs = some products) (hlength : pairs.length < Formats.Posit.Quire.Model.productSumTermLimit) :
toRat? (List.foldl (fun (quire : Formats.Posit.Quire.Model format) (pair : ExecFloat (Formats.Posit.Configured.Family format code plan) × ExecFloat (Formats.Posit.Configured.Family format code plan)) => qMulAdd quire pair.1 pair.2) zero pairs) = some products.sum

Folding qMulAdd over fewer than 2^31 pairs of ordinary configured posits, starting from the zero quire, is exact: the result is not NaR and denotes the exact rational sum of the products.

exactProducts? pairs = some products records that no input is NaR and identifies the exact products. Callers need no additional bounds on the quire coefficients.

theorem FloatLib.Floats.ExecFloat.Posit.Quire.toRat?_foldl_qAddP_zero {format : Formats.Posit.Format} {plan : Formats.Posit.Configured.StoragePlan format} {code : Type} [ModelCodec plan (Formats.Posit.Model format) code] (addends : List (ExecFloat (Formats.Posit.Configured.Family format code plan))) (values : List ) (hvalues : exactValues? addends = some values) (hlength : addends.length < Formats.Posit.Quire.Model.positSumTermLimit format) :
toRat? (List.foldl qAddP zero addends) = some values.sum

Folding qAddP over fewer than 2^(23 + 4n) ordinary configured posits, starting from the zero quire, is exact.