Index codings #
An IndexCoding ι κ is an injection encode : ι → κ together with a decoder that is a left
inverse on encoded values (mirroring Encodable, the codomain-ℕ special case). Codings are
how an ι-indexed infinitary connective is expressed at a larger carrier κ, and how
infinitary formulas are transported between carriers (Infinitary/Reindex.lean).
Main definitions #
IndexCoding.id,IndexCoding.trans: identity and forward composition, withid_trans,trans_id,trans_assoc.IndexCoding.sumInl,IndexCoding.sumInr: the canonical codings into a sum.IndexCoding.ofEncodable/ofEncodableWith: the coding of an encodable type intoℕ, by instance search or from an explicitly givenEncodablevalue; no choice is involved.IndexCoding.ofEquiv: the coding induced by an equivalence; itsdecodeis total.IndexCoding.pad: total extension of anι-indexed family to aκ-indexed one, sending undecodable indices to a default. The lawspad_transandcomp_padcentralize all decoder analysis; consumers chain and commute pads through them.IndexCoding.toEmbedding: the underlying embedding (decode_encodeforces injectivity).
A coding of the index type ι into κ: an injection encode together with a decoder
that is a left inverse on encoded values. Values outside the range of encode may decode to
none or to duplicate source branches; the padding semantics only ever relies on
decode_encode.
- encode : ι → κ
The injection.
- decode : κ → Option ι
The decoder, a left inverse on encoded values.
Decoding recovers every encoded index.
Instances For
encode is injective: decode_encode already provides a retraction.
The identity coding.
Equations
- FirstOrder.IndexCoding.id ι = { encode := fun (i : ι) => i, decode := some, decode_encode := ⋯ }
Instances For
Forward composition of codings, in the Equiv.trans argument order: first c₁ : ι → κ,
then c₂ : κ → μ.
Equations
Instances For
The canonical coding of the left summand into a sum.
Equations
- FirstOrder.IndexCoding.sumInl ι κ = { encode := Sum.inl, decode := Sum.getLeft?, decode_encode := ⋯ }
Instances For
The canonical coding of the right summand into a sum.
Equations
- FirstOrder.IndexCoding.sumInr ι κ = { encode := Sum.inr, decode := Sum.getRight?, decode_encode := ⋯ }
Instances For
Explicit-data variant of ofEncodable: build the coding from a given encoding value
rather than by instance search. Code that stores a particular Encodable as data (e.g. a
coded-family presentation that must not consult ambient instances) uses this, so the compiler
enforces that the resulting syntax depends on the stored encoding.
Equations
- FirstOrder.IndexCoding.ofEncodableWith e = { encode := Encodable.encode, decode := Encodable.decode, decode_encode := ⋯ }
Instances For
Total extension of a family along a coding: decoded indices select a branch, undecodable ones get the default.