Index codings #
An IndexCoding ι κ consists of an injection into κ and a decoder recovering the encoded
indices. Padding extends an ι-indexed family to κ with a chosen default. In particular,
true padding preserves universal quantification and false padding preserves existence; these
are the neutral extensions used for coded infinitary conjunctions and disjunctions.
The API provides identity and composition, codings from equivalences and explicit or inferred
Encodable data, sum codings, the underlying embedding, and the padding composition laws.
Adapted from Cameron Freer's Mathlib/ModelTheory/Infinitary/IndexCoding.lean in
cameronfreer/mathlib4.
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.
Instances For
Forward composition of codings, in the Equiv.trans argument order: first c₁ : ι → κ,
then c₂ : κ → μ.
Instances For
Composing the identity coding before a coding leaves it unchanged.
Composing a coding with the identity coding leaves it unchanged.
Composition of index codings is associative.
The canonical coding of the left summand into a sum.
Instances For
The canonical coding of the right summand into a sum.
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.
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.
Instances For
The coding induced by an equivalence of carriers. Its decoder always returns the inverse image, so padding along it never selects the default branch.
Instances For
The coding induced by the identity equivalence is the identity coding.
Total extension of a family along a coding: decoded indices select a branch, undecodable ones get the default.
Instances For
Evaluate padding using the decoder, without unfolding the coding or padding.
Padding at an encoded index recovers the original branch.
Padding along the identity coding leaves the family unchanged.
Padding along a composite coding is iterated padding with the same default.
Universal quantification is unchanged by padding with True.
Existential quantification is unchanged by padding with False.
Taking the union of sets assigned to a padded family preserves the original union when the default is assigned the empty set.