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✝¹)
      Instances For
        @[instance_reducible]
        @[instance_reducible]

        The natural inclusion of Bool in Γ'.

        Instances For

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

          Instances For

            An encoding function of the positive binary numbers in Bool.

            Instances For

              An encoding function of the binary numbers in Bool.

              Instances For

                An encoding function of ℕ in Bool.

                Instances For

                  A decoding function from List Bool to the positive binary numbers.

                  Instances For

                    A decoding function from List Bool to the binary numbers.

                    Instances For

                      A decoding function from List Bool to ℕ.

                      Instances For

                        A binary Encoding of ℕ in Bool.

                        Instances For

                          A binary Encoding of ℕ in Γ'.

                          Instances For

                            A unary encoding function of ℕ in Bool.

                            Instances For

                              A unary decoding function from List Bool to ℕ.

                              Instances For

                                An encoding function of Bool in Bool.

                                Instances For

                                  A decoding function from List Bool to Bool.

                                  Instances For

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

                                    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.

                                      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.

                                        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.

                                          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.

                                            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.

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

                                                Deprecated alias for encodingNatBool.

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

                                                  Deprecated alias for encodingNatΓ'.

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

                                                    Deprecated alias for unaryEncodingNat.

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

                                                      Deprecated alias for encodingBoolBool.

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

                                                        Deprecated alias for encodingList.

                                                        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.

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

                                                            Deprecated alias for Encoding.card_le_aleph0.