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, and its runtime representation is
the family-chosen FormatCode F type. Only proof-side definitions need a semantic interpretation,
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
still crosses 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.35.0/src/Init/Prelude.lean#L697-L699.
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 no data. It separates types and validates nothing at runtime.
- intro {F : Type u} : ExecFloatTag F
Instances For
The executable value of format F.
The value is represented as the family-selected FormatCode F, and the proof-only tag adds 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. Because this contract sits below
ExecFloat, every representation can print its mathematical value without a universal radix, an
exceptional-value model or a 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. Nothing in the contract depends on radix, encoding, exceptional values or 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 returns the model value.
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 to the family-selected runtime code, without decoding.
Instances For
Apply a binary operation to family-selected runtime codes, without decoding.
Instances For
Apply a ternary operation to family-selected runtime codes, without decoding.
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.
A unary code operation that commutes with toModel is the lift of its model operation.
The executable side stays the code operation, and the model equation is used only in proofs.
A binary code operation that commutes with toModel is the lift of its model operation.
A ternary code operation that commutes with toModel is the lift of its model operation.
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 text is emitted unquoted, and is parenthesized when it is negative and appears as an
argument, as in some (-1.5).
Low-priority structural representation for internal families without a mathematical display.
Public numerical families should provide FormatDisplay.