Documentation

Mathlib.ModelTheory.Infinitary.IndexCoding

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 #

structure FirstOrder.IndexCoding (ι : Type uι) (κ : Type uκ) :
Type (max uι uκ)

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.

  • decode_encode (i : ι) : self.decode (self.encode i) = some i

    Decoding recovers every encoded index.

Instances For
    theorem FirstOrder.IndexCoding.ext {ι : Type uι} {κ : Type uκ} {c₁ c₂ : IndexCoding ι κ} (he : c₁.encode = c₂.encode) (hd : c₁.decode = c₂.decode) :
    c₁ = c₂

    Two codings with the same encode and decode are equal; the coherence proof is irrelevant.

    theorem FirstOrder.IndexCoding.ext_iff {ι : Type uι} {κ : Type uκ} {c₁ c₂ : IndexCoding ι κ} :
    c₁ = c₂ ↔ c₁.encode = c₂.encode ∧ c₁.decode = c₂.decode

    encode is injective: decode_encode already provides a retraction.

    def FirstOrder.IndexCoding.toEmbedding {ι : Type uι} {κ : Type uκ} (c : IndexCoding ι κ) :
    ι ↪ κ

    The underlying embedding of a coding.

    Equations
    Instances For

      The identity coding.

      Equations
      Instances For
        def FirstOrder.IndexCoding.trans {ι : Type uι} {κ : Type uκ} {μ : Type uμ} (c₁ : IndexCoding ι κ) (c₂ : IndexCoding κ μ) :

        Forward composition of codings, in the Equiv.trans argument order: first c₁ : ι → κ, then c₂ : κ → μ.

        Equations
        Instances For
          @[simp]
          theorem FirstOrder.IndexCoding.id_trans {ι : Type uι} {κ : Type uκ} (c : IndexCoding ι κ) :
          @[simp]
          theorem FirstOrder.IndexCoding.trans_id {ι : Type uι} {κ : Type uκ} (c : IndexCoding ι κ) :
          theorem FirstOrder.IndexCoding.trans_assoc {ι : Type uι} {κ : Type uκ} {μ : Type uμ} {ν : Type uν} (c₁ : IndexCoding ι κ) (c₂ : IndexCoding κ μ) (c₃ : IndexCoding μ ν) :
          (c₁.trans c₂).trans c₃ = c₁.trans (c₂.trans c₃)
          def FirstOrder.IndexCoding.sumInl (ι : Type uι) (κ : Type uκ) :
          IndexCoding ι (ι ⊕ κ)

          The canonical coding of the left summand into a sum.

          Equations
          Instances For
            def FirstOrder.IndexCoding.sumInr (ι : Type uι) (κ : Type uκ) :
            IndexCoding κ (ι ⊕ κ)

            The canonical coding of the right summand into a sum.

            Equations
            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
              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
                  def FirstOrder.IndexCoding.ofEquiv {ι : Type uι} {κ : Type uκ} (e : ι ≃ κ) :

                  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
                    theorem FirstOrder.IndexCoding.ofEquiv_trans {ι : Type uι} {κ : Type uκ} {μ : Type uμ} (e₁ : ι ≃ κ) (e₂ : κ ≃ μ) :
                    ofEquiv (e₁.trans e₂) = (ofEquiv e₁).trans (ofEquiv e₂)

                    ofEquiv turns equivalence composition into coding composition.

                    @[simp]

                    The two codings of an equivalence compose to the identity coding.

                    def FirstOrder.IndexCoding.pad {ι : Type uι} {κ : Type uκ} {β : Sort u_1} (c : IndexCoding ι κ) (default : β) (f : ι → β) :
                    κ → β

                    Total extension of a family along a coding: decoded indices select a branch, undecodable ones get the default.

                    Equations
                    Instances For
                      @[simp]
                      theorem FirstOrder.IndexCoding.pad_encode {ι : Type uι} {κ : Type uκ} {β : Sort u_1} (c : IndexCoding ι κ) (default : β) (f : ι → β) (i : ι) :
                      c.pad default f (c.encode i) = f i
                      theorem FirstOrder.IndexCoding.pad_of_decode_none {ι : Type uι} {κ : Type uκ} {β : Sort u_1} (c : IndexCoding ι κ) {default : β} {f : ι → β} {k : κ} (h : c.decode k = none) :
                      c.pad default f k = default
                      theorem FirstOrder.IndexCoding.pad_of_decode_some {ι : Type uι} {κ : Type uκ} {β : Sort u_1} (c : IndexCoding ι κ) {default : β} {f : ι → β} {k : κ} {i : ι} (h : c.decode k = some i) :
                      c.pad default f k = f i
                      @[simp]
                      theorem FirstOrder.IndexCoding.id_pad {ι : Type uι} {β : Sort u_1} (default : β) (f : ι → β) :
                      (IndexCoding.id ι).pad default f = f
                      theorem FirstOrder.IndexCoding.pad_trans {ι : Type uι} {κ : Type uκ} {μ : Type uμ} {β : Sort u_1} (c₁ : IndexCoding ι κ) (c₂ : IndexCoding κ μ) (default : β) (f : ι → β) :
                      (c₁.trans c₂).pad default f = c₂.pad default (c₁.pad default f)

                      Padding along a composite coding is iterated padding: the decode analysis for a chain of codings happens HERE, once, not at every consumer.

                      theorem FirstOrder.IndexCoding.comp_pad {ι : Type uι} {κ : Type uκ} {β : Sort u_1} {γ : Sort u_2} (c : IndexCoding ι κ) (g : β → γ) (default : β) (f : ι → β) :
                      g ∘ c.pad default f = c.pad (g default) (g ∘ f)

                      Mapping commutes with padding: the other half of the transport-coherence engine.