Documentation

Mathlib.Computability.Encoding

Encodings #

This file contains the definition of an encoding, a map from a type to strings in an alphabet, used in defining computability by Turing machines. It also contains several examples:

Examples #

structure Computability.Encoding (α : Type u) (Γ : Type v) :
Type (max u v)

An encoding of a type in a certain alphabet, together with a decoding.

  • encode : αList Γ

    The encoding function

  • decode : List ΓOption α

    The decoding function

  • decode_encode (x : α) : self.decode (self.encode x) = some x

    Decoding and encoding are inverses of each other.

Instances For

    A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma.

    Instances For
      def Computability.instDecidableEqΓ'.decEq (x✝ x✝¹ : Γ') :
      Decidable (x✝ = x✝¹)
      Equations
      Instances For

        An arbitrary section of the natural inclusion of Bool in Γ'.

        Equations
        Instances For

          An encoding function of the binary numbers in Bool.

          Equations
          Instances For

            An encoding function of in Bool.

            Equations
            Instances For

              A decoding function from List Bool to the binary numbers.

              Equations
              Instances For

                A decoding function from List Bool to .

                Equations
                Instances For

                  A binary Encoding of in Γ'.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    A unary decoding function from List Bool to .

                    Equations
                    Instances For

                      A unary Encoding of in Bool.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        An encoding function of Bool in Bool.

                        Equations
                        Instances For

                          A decoding function from List Bool to Bool.

                          Equations
                          Instances For

                            An Encoding of Bool in Bool.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              An Encoding of a List α in alphabet α, encoded directly.

                              Equations
                              Instances For
                                def Computability.encodingProd {α : Type u_1} {β : Type u_2} {Γ₁ : Type u_3} {Γ₂ : Type u_4} (ea : Encoding α Γ₁) (eb : Encoding β Γ₂) :
                                Encoding (α × β) (Γ₁ Γ₂)

                                Given an Encoding of α and β, constructs an Encoding of α × β by concatenating the encodings, mapping the symbols from the first encoding with Sum.inl and those from the second with Sum.inr.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Deprecated aliases for FinEncoding and unbundled Γ #

                                  @[reducible, deprecated "Use `Encoding α Γ` along with `[Fintype Γ]` instead" (since := "2026-05-07")]
                                  def Computability.FinEncoding (α : Type u) {Γ : Type v} [Fintype Γ] :
                                  Type (max u v)

                                  Deprecated: Use Encoding α Γ along with [Fintype Γ] instead.

                                  Equations
                                  Instances For
                                    @[reducible, deprecated "Γ is now an explicit parameter of `Encoding`" (since := "2026-05-07")]
                                    def Computability.Encoding.Γ {α : Type u} {Γ : Type v} :
                                    Encoding α ΓType v

                                    Deprecated: Γ is now an explicit parameter of Encoding.

                                    Equations
                                    Instances For
                                      @[reducible, deprecated "Use `inferInstanceAs (Fintype Γ)` instead" (since := "2026-05-07")]
                                      def Computability.FinEncoding.ΓFin {α : Type u} {Γ : Type v} [h : Fintype Γ] :
                                      Encoding α ΓFintype Γ

                                      Deprecated: Use inferInstanceAs (Fintype Γ) instead.

                                      Equations
                                      Instances For
                                        @[reducible, deprecated "Use the encoding directly" (since := "2026-05-07")]
                                        def Computability.FinEncoding.toEncoding {α : Type u} {Γ : Type v} [Fintype Γ] (e : Encoding α Γ) :
                                        Encoding α Γ

                                        Deprecated: Use the encoding directly.

                                        Equations
                                        Instances For
                                          @[reducible, inline, deprecated Computability.encodingNatBool (since := "2026-05-07")]

                                          Deprecated alias for encodingNatBool.

                                          Equations
                                          Instances For
                                            @[reducible, inline, deprecated Computability.encodingNatΓ' (since := "2026-05-07")]

                                            Deprecated alias for encodingNatΓ'.

                                            Equations
                                            Instances For
                                              @[reducible, inline, deprecated Computability.unaryEncodingNat (since := "2026-05-07")]

                                              Deprecated alias for unaryEncodingNat.

                                              Equations
                                              Instances For
                                                @[reducible, inline, deprecated Computability.encodingBoolBool (since := "2026-05-07")]

                                                Deprecated alias for encodingBoolBool.

                                                Equations
                                                Instances For
                                                  @[reducible, deprecated Computability.encodingList (since := "2026-05-07")]

                                                  Deprecated alias for encodingList.

                                                  Equations
                                                  Instances For
                                                    @[reducible, deprecated Computability.encodingProd (since := "2026-05-07")]
                                                    def Computability.finEncodingPair {α : Type u_1} {β : Type u_2} {Γ₁ : Type u_3} {Γ₂ : Type u_4} [Fintype Γ₁] [Fintype Γ₂] (ea : Encoding α Γ₁) (eb : Encoding β Γ₂) :
                                                    Encoding (α × β) (Γ₁ Γ₂)

                                                    Deprecated alias for encodingProd.

                                                    Equations
                                                    Instances For
                                                      @[deprecated Computability.Encoding.card_le_aleph0 (since := "2026-05-07")]

                                                      Deprecated alias for Encoding.card_le_aleph0.