Optimized field access for binary models #
The public field operations in Model.Carrier use exact-width bit vectors, which expose the
storage layout cleanly to proofs. This module defines extensionally equal Nat implementations
and registers their compiler substitutions. Each field decoder reads the natural-number storage
pattern; packing constructs one natural-number pattern with an erased proof that it fits the
width.
The theorems here are execution certificates: they justify erased bounds or compiler rewrites.
Semantic facts about the public field operations belong in Model.Fields.Proof.
Masked sign, exponent, and fraction fields always fit their declared storage word.
Read the sign directly from the natural-number storage pattern.
Instances For
Decode the exponent after one conversion of the storage word to Nat.
Instances For
Decode the fraction after one conversion of the storage word to Nat.
Instances For
The direct natural-number sign decoder agrees with the public bit-vector definition.
The compiler reads the sign from the natural-number storage pattern.
The direct natural-number exponent decoder agrees with the public bit-vector definition.
The compiler decodes the exponent through one conversion to Nat.
The direct natural-number fraction decoder agrees with the public bit-vector definition.
The compiler decodes the fraction through one conversion to Nat.
Pack fields as one natural-number bit pattern known to fit the exact storage width.
The bound passed to BitVec.ofNatLT is erased from compiled code. Unlike BitVec.ofNat, this
avoids computing a redundant modulus after the masked fields have already established the width.
Instances For
The direct natural-number field packer agrees with the public mask-based definition.
The compiler packs fields as one natural-number bit pattern.
Construct a Model through the direct natural-number field packer.
Instances For
The compiler constructs explicit fields through the direct natural-number packer.