TorchLean API

FloatLib.Floats.Formats.BinaryInterchange.Configured.Rounding.Proof

Packing correctness for configured binary arithmetic #

The decoding bridge theorems toModel_add through toModel_sqrt and their IEEEOutcome.toModel_add through IEEEOutcome.toModel_sqrt companions state that decoding a configured result recovers the single descriptor-model operation used to compute it, with the same rounding direction and, for the outcomes, the same flags and ternary value. They let proofs transfer results from the model without depending on the configured storage plan. toModel_hAdd, toModel_hSub, toModel_hMul, toModel_hDiv, toModel_neg, and toModel_execFloat_sqrt do the same for the notation +, -, *, /, unary -, and the generic ExecFloat.sqrt, so simp turns a goal about toModel (a + b) into one about Model.add. The projection theorems value_add through value_sqrt mirror the model's: the value of an operation with status := true is the value of the same operation without it.

A nearest-even call without status runs the format's selected capability. A capability certifies its kernels against its own reference operation, so the value theorems take the instance argument ExecFloat.Capability.HasSpec cap Configured.Spec.add (and its siblings): the selected capability's reference is the configured model operation. Instance search proves it for every capability instance in the library, generic, automatic, and first-order binary32 and binary64, since each declares that reference. A custom capability whose reference operation is only propositionally the model operation must declare the instance itself. A capability with another reference operation gets neither the decoding nor the projection theorems, because its default call and its status := true call can then deliver different values.

@[simp]

Repacking and then decoding a model outcome preserves its value, status, and ternary value.

@[simp]

bind delivers the value of its second step.

@[simp]

bind raises every flag that either step raised.

@[simp]

bind keeps the ternary value of its second step.

@[simp]

Decoding a rounded rational gives the model rounding with the same direction.

@[simp]

Decoding a rounded rational with status := true preserves the flags and ternary value.

@[simp]

Rounding a rational with status := true delivers the value of the same rounding.

@[simp]

Decoding configured addition gives model addition with the same rounding mode.

The nearest-even call runs the selected ExecFloat.Add capability, so the theorem asks, as an instance argument, that its reference operation be Configured.Spec.add, the configured model operation. Instance search proves this for every capability the library declares. A custom capability whose reference is only propositionally that operation must declare the instance, and one with another reference operation does not satisfy the theorem.

@[simp]

Decoding configured subtraction gives model subtraction with the same rounding mode.

As for toModel_add, the nearest-even call runs the selected ExecFloat.Sub capability, whose reference operation the instance argument fixes to Configured.Spec.sub.

@[simp]

Decoding configured multiplication gives model multiplication with the same rounding mode.

As for toModel_add, the nearest-even call runs the selected ExecFloat.Mul capability, whose reference operation the instance argument fixes to Configured.Spec.mul.

@[simp]

Decoding configured division gives model division with the same rounding mode.

As for toModel_add, the nearest-even call runs the selected ExecFloat.Div capability, whose reference operation the instance argument fixes to Configured.Spec.div.

@[simp]

Decoding configured FMA gives model FMA with the same rounding mode.

As for toModel_add, the nearest-even call runs the selected ExecFloat.Fma capability, whose reference operation the instance argument fixes to Configured.Spec.fma.

@[simp]

Decoding configured square root gives model square root with the same rounding mode.

As for toModel_add, the nearest-even call runs the selected ExecFloat.Sqrt capability, whose reference operation the instance argument fixes to Configured.Spec.sqrt.

Operator notation #

@[simp]

Decoding a configured sum left + right gives nearest-even model addition.

+ runs the selected ExecFloat.Add capability, so, as for toModel_add, the theorem asks that its reference operation be Configured.Spec.add, which instance search proves for every capability the library declares.

@[simp]

Decoding a configured difference left - right gives nearest-even model subtraction.

- runs the selected ExecFloat.Sub capability, whose reference operation the instance argument fixes to Configured.Spec.sub.

@[simp]

Decoding a configured product left * right gives nearest-even model multiplication.

* runs the selected ExecFloat.Mul capability, whose reference operation the instance argument fixes to Configured.Spec.mul.

@[simp]

Decoding a configured quotient left / right gives nearest-even model division.

/ runs the selected ExecFloat.Div capability, whose reference operation the instance argument fixes to Configured.Spec.div.

@[simp]

Decoding a configured negation -value gives model negation.

Negation goes through the storage codec rather than a selected capability, so the theorem has no instance argument.

@[simp]

Decoding the generic square root ExecFloat.sqrt value gives nearest-even model square root.

value.sqrt on a configured value is ExecFloat.Binary.sqrt, covered by toModel_sqrt. This theorem covers the format-generic call, which runs the selected ExecFloat.Sqrt capability with reference operation Configured.Spec.sqrt.

@[simp]

Decoding configured addition preserves the model result, flags, and ternary value.

@[simp]

Decoding configured subtraction preserves the model result, flags, and ternary value.

@[simp]

Decoding configured multiplication preserves the model result, flags, and ternary value.

@[simp]

Decoding configured division preserves the model result, flags, and ternary value.

@[simp]

Decoding configured FMA preserves the model result, flags, and ternary value.

@[simp]

Configured addition with status := true delivers the value of configured addition.

Like toModel_add, it takes the instance argument HasSpec cap Configured.Spec.add, which instance search proves for every capability the library declares.

@[simp]

Configured subtraction with status := true delivers the value of configured subtraction.

Like toModel_sub, it takes the instance argument HasSpec cap Configured.Spec.sub.

@[simp]

Configured multiplication with status := true delivers the value of configured multiplication.

Like toModel_mul, it takes the instance argument HasSpec cap Configured.Spec.mul.

@[simp]

Configured division with status := true delivers the value of configured division.

Like toModel_div, it takes the instance argument HasSpec cap Configured.Spec.div.

@[simp]

Configured FMA with status := true delivers the value of configured FMA.

Like toModel_fma, it takes the instance argument HasSpec cap Configured.Spec.fma.

@[simp]

Configured square root with status := true delivers the value of configured square root.

Like toModel_sqrt, it takes the instance argument HasSpec cap Configured.Spec.sqrt.