Static-byte runtime representation #
Nominal binary formats of at most eight bits share a compact byte carrier, family interface,
model adapters, raw table execution, and exact operation specifications. The persistent code is
a UInt8 together with an erased range proof. No FloatFormat, BitVec, or
arbitrary-precision integer is stored in a value.
Each standards package supplies a nominal type and a Family instance. The instance fixes the
binary-interchange proof model, proves that its codes fit in one byte, and names the monomorphic
kernels used at runtime. Table construction is isolated in Core.Construction; conversion and
lifting theorems are isolated in Core.Proof.
Nominal Family and Plans.TablePlan instances use always_inline so the compiler can eliminate
their closed format metadata and policy branches at a public call. The named table definitions
remain shared and lazy.
OCP, IEEE, ONNX, and custom format packages can share these carrier and refinement interfaces. Each descriptor still determines its own exceptional-value policy.
Lean represents subtypes identically to their data carrier, so Code F has the runtime
representation of UInt8; its bound is proof-only. See Lean Init.Prelude,
https://github.com/leanprover/lean4/blob/v4.34.0/src/Init/Prelude.lean#L641-L643.
benchmarks/scripts/checks/static-lowbit-codegen.sh checks the intended allocation and
specialization properties.
Bit-exact binary-interchange model value used to specify and prove a static byte format.
Instances For
Direct byte code for one at-most-eight-bit binary-interchange model.
The proof excludes patterns above the declared format width and is erased by Lean's compiler.
Instances For
Interpret a direct byte code in its exact-width binary proof model.
Instances For
Six byte kernels and their refinement equations for one binary-interchange model.
The executable fields consume and return direct byte codes. Their equations interpret those codes in the independent binary model and compare them with its specifications. A family may therefore select exhaustive native-index tables, direct byte arithmetic, or a model adapter independently for each operation without changing the universal carrier.
Executable addition on direct byte codes.
Executable subtraction on direct byte codes.
Executable multiplication on direct byte codes.
Executable division on direct byte codes.
Executable square root on a direct byte code.
Executable fused multiply-add on direct byte codes.
- add_eq_spec (left right : ByteCode format) : byteCodeToModel (self.add left right) = Model.Spec.add (byteCodeToModel left) (byteCodeToModel right)
Addition refines the independent model specification.
- sub_eq_spec (left right : ByteCode format) : byteCodeToModel (self.sub left right) = Model.Spec.sub (byteCodeToModel left) (byteCodeToModel right)
Subtraction refines the independent model specification.
- mul_eq_spec (left right : ByteCode format) : byteCodeToModel (self.mul left right) = Model.Spec.mul (byteCodeToModel left) (byteCodeToModel right)
Multiplication refines the independent model specification.
- div_eq_spec (left right : ByteCode format) : byteCodeToModel (self.div left right) = Model.Spec.div (byteCodeToModel left) (byteCodeToModel right)
Division refines the independent model specification.
- sqrt_eq_spec (value : ByteCode format) : byteCodeToModel (self.sqrt value) = Model.Spec.sqrt (byteCodeToModel value)
Square root refines the independent model specification.
- fma_eq_spec (left right addend : ByteCode format) : byteCodeToModel (self.fma left right addend) = Model.Spec.fma (byteCodeToModel left) (byteCodeToModel right) (byteCodeToModel addend)
Fused multiply-add refines the independent model specification.
Instances For
Descriptor and certified kernels for a nominal static-byte format.
The class contains no global registry. It is resolved from the nominal format type, and concrete packages provide monomorphic kernel fields rather than selecting a backend at runtime.
- format : FloatFormat
Binary-interchange format used as the proof model.
Every valid code fits in one byte.
Statically selected proved kernels.
Instances
Direct byte carrier selected by a static-byte family.
Instances For
Convert a valid byte code to the exact-width binary proof model.
Instances For
Convert one model value to its direct valid byte code.
Instances For
View an at-most-eight-bit binary-interchange model through the shared finite-encoding backend.
The encoding is a proved bijection between exact model values and their stored words. It is the
only binary-specific input required by the format-independent TinyTable implementation.
Instances For
Execute a shared certified binary table on the static-byte carrier.
Instances For
Execute a shared certified unary table on the static-byte carrier.
Instances For
Execute a shared certified ternary table on the static-byte carrier.
Instances For
Adapt a model-level ternary operation to the direct byte carrier.
Instances For
Convert one family model value to its direct valid byte code.
Instances For
Interpret a universal static-byte value in the binary proof model.
Instances For
Repack a binary proof-model value into the direct static-byte carrier.