Word encodings of structures as the tuple of their fields #
word_enc_structure eS : S where f₁ : e₁, …, fₙ : eₙ declares a faithful finite-register word
encoding eS : S ↪ (Fin k → ℕ) of a one-constructor structure S from explicit per-field
word encodings eᵢ : Fᵢ ↪ (Fin kᵢ → ℕ) (or explicit WordEncoding Fᵢ values), mirroring
Turing.MultiTapeTM.enc_structure without hidden default-encoding typeclass search:
eSFields, the left-associatedappendWordsencoding of the field tuple, andeS, the combinedS ↪ (Fin k → ℕ)embedding proved injective structurally withoutfin_cases;eS_apply, unfoldingeS atoeSFieldsapplied to the tuple of field values;- when every field width reduces to a numeral (
k = k₁ + ⋯ + kₙ),@[simp]coordinate equationseS_coord_0, …,eS_coord_{k-1}whose right-hand sides are normalized through nestedwordWords,blockWordsandword_enc_structureprojections; - per-field slice equations
eS_<field>(marked@[simp]when widths are symbolic) and the word-fit composition lemmaeS_fits.
Applied structure types with implicit variable parameters (word_enc_structure eL : Layout n),
explicit command parameters (p : T) before :, flattened parent structures, and dependent fields
f : w using hw (encoding f as the scalar word w f for an injective w reading earlier
fields by name) follow the same conventions as enc_structure. Supporting @[simp] coordinate
and slice equations (blockWords_zero, blockWords_one, appendWords_castAdd,
appendWords_natAdd, appendWords_addNat, sigmaWords_castAdd, sigmaWords_natAdd,
sigmaWords_addNat) and word-fit helpers (blockWords_fits, fits_sigmaWords) normalize encoded
slices and compose Fits bounds across Block, appendWords and sigmaWords.
Main definitions #
wordWords: the one-word scalar encodingℕ ↪ (Fin 1 → ℕ).sigmaWords: fixed-fiber-width dependent-pair word encoding(Σ a, β a) ↪ (Fin (k + l) → ℕ).
Coordinate zero of blockWords is the block's base address.
Coordinate one of blockWords is the block's length.
Every word of sigmaWords fst snd p fits when both components' words fit.
Normalize the right-hand side of a generated @[simp] coordinate equation in the current
simp context so that nested wordWords, blockWords and word_enc_structure projections
reduce to direct field accesses and satisfy simpNF.
word_enc_structure eS : S where f₁ : e₁, f₂ : e₂ declares the finite-register word encoding
eS : S ↪ (Fin k → ℕ) of a structure S as the concatenated words of its fields in declaration
order, together with eSFields, eS_apply, coordinate @[simp] equations eS_coord_j (when all
field widths reduce to numerals), field-slice equations eS_<field>, and eS_fits.
List every field of S once in declaration order, giving an explicit Fᵢ ↪ (Fin kᵢ → ℕ) (or
explicit WordEncoding Fᵢ value) for each field; no typeclass search chooses a default encoding.
A parent structure may be listed as toParent or flattened into its fields. A field whose type
depends on earlier fields may be written f : w using hw, encoding f as the single word w f
via hw : Function.Injective w. Explicit (p : T) parameters before : become explicit arguments
of every generated declaration; the optional public or private prefix defaults to public.
Elaborate word_enc_structure: tuple abbreviation, structure embedding, _apply, @[simp]
coordinate equations, per-field slice equations and _fits.