Encodings #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file contains the definition of a (finite) encoding, a map from a type to strings in an alphabet, used in defining computability by Turing machines. It also contains several examples:
Examples #
fin_encoding_nat_bool
: a binary encoding of ℕ in a simple alphabet.fin_encoding_nat_Γ'
: a binary encoding of ℕ in the alphabet used for TM's.unary_fin_encoding_nat
: a unary encoding of ℕfin_encoding_bool_bool
: an encoding of bool.
- Γ : Type ?
- encode : α → list self.Γ
- decode : list self.Γ → option α
- decode_encode : ∀ (x : α), self.decode (self.encode x) = option.some x
An encoding of a type in a certain alphabet, together with a decoding.
Instances for computability.encoding
- computability.encoding.has_sizeof_inst
- computability.inhabited_encoding
- to_encoding : computability.encoding α
- Γ_fin : fintype self.to_encoding.Γ
An encoding plus a guarantee of finiteness of the alphabet.
Instances for computability.fin_encoding
- computability.fin_encoding.has_sizeof_inst
- computability.inhabited_fin_encoding
Equations
- blank : computability.Γ'
- bit : bool → computability.Γ'
- bra : computability.Γ'
- ket : computability.Γ'
- comma : computability.Γ'
A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma.
Instances for computability.Γ'
- computability.Γ'.has_sizeof_inst
- computability.Γ'.fintype
- computability.inhabited_Γ'
Equations
The natural inclusion of bool in Γ'.
An arbitrary section of the natural inclusion of bool in Γ'.
Equations
- computability.section_Γ'_bool computability.Γ'.comma = arbitrary bool
- computability.section_Γ'_bool computability.Γ'.ket = arbitrary bool
- computability.section_Γ'_bool computability.Γ'.bra = arbitrary bool
- computability.section_Γ'_bool (computability.Γ'.bit b) = b
- computability.section_Γ'_bool computability.Γ'.blank = arbitrary bool
An encoding function of the positive binary numbers in bool.
An encoding function of the binary numbers in bool.
An encoding function of ℕ in bool.
Equations
A decoding function from list bool
to ℕ.
Equations
- computability.decode_nat = λ (l : list bool), ↑(computability.decode_num l)
A binary encoding of ℕ in bool.
Equations
- computability.encoding_nat_bool = {Γ := bool, encode := computability.encode_nat, decode := λ (n : list bool), option.some (computability.decode_nat n), decode_encode := computability.encoding_nat_bool._proof_1}
A binary fin_encoding of ℕ in bool.
A binary encoding of ℕ in Γ'.
Equations
- computability.encoding_nat_Γ' = {Γ := computability.Γ', encode := λ (x : ℕ), list.map computability.inclusion_bool_Γ' (computability.encode_nat x), decode := λ (x : list computability.Γ'), option.some (computability.decode_nat (list.map computability.section_Γ'_bool x)), decode_encode := computability.encoding_nat_Γ'._proof_1}
A binary fin_encoding of ℕ in Γ'.
A unary encoding function of ℕ in bool.
Equations
A unary fin_encoding of ℕ.
Equations
- computability.unary_fin_encoding_nat = {to_encoding := {Γ := bool, encode := computability.unary_encode_nat, decode := λ (n : list bool), option.some (computability.unary_decode_nat n), decode_encode := computability.unary_fin_encoding_nat._proof_1}, Γ_fin := bool.fintype}
An encoding function of bool in bool.
Equations
A fin_encoding of bool in bool.
Equations
- computability.fin_encoding_bool_bool = {to_encoding := {Γ := bool, encode := computability.encode_bool, decode := λ (x : list bool), option.some (computability.decode_bool x), decode_encode := computability.fin_encoding_bool_bool._proof_1}, Γ_fin := bool.fintype}