Representation-independent executable numerical values #
ExecFloat F is the public runtime carrier selected by an EncodedFormat F. Neither this carrier
nor EncodedFormat assumes a floating radix or an IEEE layout. Its runtime representation is
exactly the family-chosen FormatCode F type. Semantic
interpretation is required only by proof-facing definitions, so noncomputable real semantics
cannot disable code generation for the carrier.
The nominal format tag is a proposition attached through Subtype. Lean specifies that a subtype
is represented identically to its carrier in compiled code, so a static format using UInt32
continues to cross generated entry points as a native 32-bit word. See the source documentation on
Subtype in Lean's Init.Prelude:
https://github.com/leanprover/lean4/blob/v4.34.0/src/Init/Prelude.lean#L641-L643.
Static format packages may therefore choose UInt8, UInt32, UInt64, fixed limb records, or
another direct carrier, while dynamic packages may choose descriptor-bearing or runtime-sized
storage without changing the universal API.
The checks under benchmarks/scripts/checks/ validate the carrier specialization used by public
operations. Lean's runtime and specialization behavior are specified by the Lean reference manual:
https://lean-lang.org/doc/reference/latest/.
Erased nominal evidence distinguishing the executable values of different formats.
This proposition has one constructor and contains no data. Its purpose is type separation, not runtime validation.
- intro {F : Type u} : ExecFloatTag F
Instances For
The executable value of format F.
The value is represented exactly as the arbitrary family-selected FormatCode F; the proof-only
tag introduces no runtime descriptor, bit-vector, radix, or exceptional-value assumption.
Instances For
Human-readable formatting supplied by an encoded numerical family.
The formatter receives the family-selected runtime code directly. Keeping this contract below
ExecFloat lets every representation print its mathematical value without requiring a universal
radix, exceptional-value model, or conversion through a host floating-point type.
- format : Numerics.FormatCode F → String
Render one runtime code according to the format's own numerical semantics.
Instances
Lossless conversion between a runtime carrier and its proof model.
plan is an arbitrary static index used only to distinguish carrier choices during typeclass
search. The contract itself is independent of radix, encoding, exceptional values, and arithmetic
semantics. Format families therefore share these inverse laws while keeping their storage plans
and model types separate.
- toModel : Code → Model
Decode one runtime code into the proof model.
- ofModel : Model → Code
Pack one proof-model value into the runtime carrier.
Decoding after packing is exact.
Packing after decoding preserves the runtime code.
Instances
Wrap one family-selected code without conversion.
Instances For
The family-selected code, exposed as a field-like projection for format implementations.
Instances For
Apply a unary operation directly to the family-selected runtime code.
Instances For
Apply a binary operation directly to family-selected runtime codes.
Instances For
Apply a ternary operation directly to family-selected runtime codes.
Instances For
Reading the raw code immediately after wrapping it returns the original code.
Wrapping the raw code of an executable value reconstructs that value.
Two executable values are equal when their family-selected codes are equal.
Decode an executable value through its lossless proof-model codec.
Instances For
Encode a proof-model value through its lossless runtime codec.
Instances For
Lift a unary proof-model operation to the executable carrier.
Instances For
Lift a binary proof-model operation to the executable carrier.
Instances For
Lift a ternary proof-model operation to the executable carrier.
Instances For
Decoding immediately after encoding recovers the proof-model value.
Encoding immediately after decoding recovers the executable value.
Decoding a lifted unary operation exposes the underlying proof-model operation.
Decoding a lifted binary operation exposes the underlying proof-model operation.
Decoding a lifted ternary operation exposes the underlying proof-model operation.
Codec decoding is injective because encoding is its inverse.
Lift a proved unary code operation to ExecFloat.
The executable side remains the direct code operation; the model equation is proof-only.
Lift a proved binary code operation to ExecFloat.
The executable side remains the direct code operation; the model equation is proof-only.
Lift a proved ternary code operation to ExecFloat.
The executable side remains the direct code operation; the model equation is proof-only.
Pointwise-equal unary model operations have equal executable lifts.
Pointwise-equal binary model operations have equal executable lifts.
Pointwise-equal ternary model operations have equal executable lifts.
Complete semantic interpretation inherited from FormatSemantics F.
Instances For
value represents the ordinary finite scalar scalar.
Instances For
One runtime value with an erased proof of its complete denotation.
Instances For
One runtime value with an erased proof of its ordinary finite denotation.
Instances For
#eval uses a format's mathematical display when one is available.
The resulting text is emitted directly rather than represented as a quoted Lean string.
Low-priority structural representation for internal families without a mathematical display.
Public numerical families should provide FormatDisplay.