Documentation

CslibFrontier.Computability.WordRAM.Realization.Structure

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:

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 #

@[reducible, inline]

The single-word encoding of a natural number, definitionally equal to WordEncoding.encode (α := ℕ).

@[simp]

Coordinate zero of blockWords is the block's base address.

@[simp]

Coordinate one of blockWords is the block's length.

theorem Cslib.WordRAM.Realization.blockWords_fits {w : ℕ} {b : Block} (hbase : Fits w b.base) (hlen : Fits w b.length) (i : Fin 2) :

Both words of blockWords b fit in w bits when b.base and b.length do.

@[simp]
theorem Cslib.WordRAM.Realization.appendWords_castAdd {δ α : Type} {k l : ℕ} (input : δ ↪ Fin k → ℕ) (output : α ↪ Fin l → ℕ) (p : δ × α) (i : Fin k) :
(appendWords input output) p (Fin.castAdd l i) = input p.1 i

The left slice of appendWords reads the first component's encoding.

@[simp]
theorem Cslib.WordRAM.Realization.appendWords_natAdd {δ α : Type} {k l : ℕ} (input : δ ↪ Fin k → ℕ) (output : α ↪ Fin l → ℕ) (p : δ × α) (j : Fin l) :
(appendWords input output) p (Fin.natAdd k j) = output p.2 j

The right slice of appendWords reads the second component's encoding.

@[simp]
theorem Cslib.WordRAM.Realization.appendWords_addNat {δ α : Type} {k : ℕ} (input : δ ↪ Fin k → ℕ) (output : α ↪ Fin k → ℕ) (p : δ × α) (j : Fin k) :
(appendWords input output) p (j.addNat k) = output p.2 j

Equal-width addNat normal-form companion of appendWords_natAdd.

def Cslib.WordRAM.Realization.sigmaWords {α : Type} {β : α → Type} {k l : ℕ} (fst : α ↪ Fin k → ℕ) (snd : (a : α) → β a ↪ Fin l → ℕ) :
(a : α) × β a ↪ Fin (k + l) → ℕ

Faithfully encode a dependent pair whose second component has a fixed register width l independent of the first component.

@[simp]
theorem Cslib.WordRAM.Realization.sigmaWords_castAdd {α : Type} {β : α → Type} {k l : ℕ} (fst : α ↪ Fin k → ℕ) (snd : (a : α) → β a ↪ Fin l → ℕ) (p : (a : α) × β a) (i : Fin k) :
(sigmaWords fst snd) p (Fin.castAdd l i) = fst p.fst i

The left slice of sigmaWords reads the first component's encoding.

@[simp]
theorem Cslib.WordRAM.Realization.sigmaWords_natAdd {α : Type} {β : α → Type} {k l : ℕ} (fst : α ↪ Fin k → ℕ) (snd : (a : α) → β a ↪ Fin l → ℕ) (p : (a : α) × β a) (j : Fin l) :
(sigmaWords fst snd) p (Fin.natAdd k j) = (snd p.fst) p.snd j

The right slice of sigmaWords reads the second component's encoding.

@[simp]
theorem Cslib.WordRAM.Realization.sigmaWords_addNat {α : Type} {β : α → Type} {k : ℕ} (fst : α ↪ Fin k → ℕ) (snd : (a : α) → β a ↪ Fin k → ℕ) (p : (a : α) × β a) (j : Fin k) :
(sigmaWords fst snd) p (j.addNat k) = (snd p.fst) p.snd j

Equal-width addNat normal-form companion of sigmaWords_natAdd.

theorem Cslib.WordRAM.Realization.fits_sigmaWords {α : Type} {β : α → Type} {k l w : ℕ} (fst : α ↪ Fin k → ℕ) (snd : (a : α) → β a ↪ Fin l → ℕ) {p : (a : α) × β a} (h₁ : ∀ (i : Fin k), Fits w (fst p.fst i)) (h₂ : ∀ (j : Fin l), Fits w ((snd p.fst) p.snd j)) (i : Fin (k + l)) :
Fits w ((sigmaWords fst snd) p i)

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.