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 underlying embedding of a coding.
Equations
- c.toEmbedding = { toFun := c.encode, inj' := ⋯ }
Instances For
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
The canonical coding of an encodable type into ℕ. No choice is involved; a Countable
carrier can be upgraded noncomputably via Encodable.ofCountable at the call site.
Equations
Instances For
The coding induced by an equivalence of carriers. Its decode is total, so reindexing
along it introduces no padding: this is the case of genuine syntactic transport (in
particular the ULift universe adjustment), as opposed to an arbitrary coding, which
preserves semantics but pads.
Equations
Instances For
Total extension of a family along a coding: decoded indices select a branch, undecodable ones get the default.
Instances For
Padding along a composite coding is iterated padding: the decode analysis for a chain of codings happens HERE, once, not at every consumer.