The areas / V01. The language of Mathlib
Mathlib.Logic.Equiv.List
30 declarations. Mathlib docs · Source
theorem Encodable.encodeList.match_1.congr_eq_1 E1 #
∀ {α : Type u_1} (motive : List α → Sort u_2) (x : List α) (h_1 : Unit → motive [])
(h_2 : (a : α) → (l : List α) → motive (a :: l)),
x = [] →
(match x with
| [] => h_1 ()
| a :: l => h_2 a l) ≍
h_1 ()
theorem Encodable.decodeList.match_3.congr_eq_1 E1 #
∀ (motive : ℕ → Sort u_1) (x : ℕ) (h_1 : Unit → motive 0) (h_2 : (v : ℕ) → motive v.succ),
x = 0 →
(match x with
| 0 => h_1 ()
| v.succ => h_2 v) ≍
h_1 ()
theorem Encodable.decodeList.match_1.congr_eq_1 E1 #
∀ (v : ℕ) (motive : (x : ℕ × ℕ) → x.2 ≤ v → Sort u_1) (x : ℕ × ℕ) (x_1 : x.2 ≤ v)
(h_1 : (v₁ v₂ : ℕ) → (h : (v₁, v₂).2 ≤ v) → motive (v₁, v₂) h) (v₁ v₂ : ℕ) (h : (v₁, v₂).2 ≤ v),
x = (v₁, v₂) →
x_1 ≍ h →
(match x, x_1 with
| (v₁, v₂), h => h_1 v₁ v₂ h) ≍
h_1 v₁ v₂ h
theorem Encodable.decodeList.match_3.congr_eq_2 E1 #
∀ (motive : ℕ → Sort u_1) (x : ℕ) (h_1 : Unit → motive 0) (h_2 : (v : ℕ) → motive v.succ) (v : ℕ),
x = v.succ →
(match x with
| 0 => h_1 ()
| v.succ => h_2 v) ≍
h_2 v
theorem Encodable.encodeList.match_1.congr_eq_2 E1 #
∀ {α : Type u_1} (motive : List α → Sort u_2) (x : List α) (h_1 : Unit → motive [])
(h_2 : (a : α) → (l : List α) → motive (a :: l)) (a : α) (l : List α),
x = a :: l →
(match x with
| [] => h_1 ()
| a :: l => h_2 a l) ≍
h_2 a l
def Equiv.listEquivOfEquiv E1 #
{α : Type u_1} → {β : Type u_2} → α ≃ β → List α ≃ List β
An equivalence between α and β generates an equivalence between List α and List β.
def Encodable.encodeList E1 #
{α : Type u_1} → [Encodable α] → List α → ℕ
Explicit encoding function for List α
def Encodable.decodeList E1 #
{α : Type u_1} → [Encodable α] → ℕ → Option (List α)
Explicit decoding function for List α
theorem Encodable.decodeList_encodeList_eq_self E0 #
∀ {α : Type u_1} [inst : Encodable α] (l : List α), Encodable.decodeList (Encodable.encodeList l) = some l
instance List.encodable E0 #
{α : Type u_1} → [Encodable α] → Encodable (List α)
If α is encodable, then so is List α. This uses the pair and unpair functions from
Data.Nat.Pairing.
instance List.countable E0 #
∀ {α : Type u_2} [Countable α], Countable (List α)
theorem Encodable.encode_list_nil E0 #
∀ {α : Type u_1} [inst : Encodable α], Encodable.encode [] = 0
theorem Encodable.encode_list_cons E0 #
∀ {α : Type u_1} [inst : Encodable α] (a : α) (l : List α),
Encodable.encode (a :: l) = (Nat.pair (Encodable.encode a) (Encodable.encode l)).succ
theorem Encodable.decode_list_zero E0 #
∀ {α : Type u_1} [inst : Encodable α], Encodable.decode 0 = some []
theorem Encodable.decode_list_succ E0 #
∀ {α : Type u_1} [inst : Encodable α] (v : ℕ),
Encodable.decode v.succ =
(fun x1 x2 ↦ x1 :: x2) <$> Encodable.decode (Nat.unpair v).1 <*> Encodable.decode (Nat.unpair v).2
theorem Encodable.length_le_encode E1 #
∀ {α : Type u_1} [inst : Encodable α] (l : List α), l.length ≤ Encodable.encode l
instance Multiset.countable E0 #
∀ {α : Type u_1} [Countable α], Countable (Multiset α)
If α is countable, then so is Multiset α.
instance Finset.countable E0 #
∀ {α : Type u_1} [Countable α], Countable (Finset α)
If α is countable, then so is Finset α.
def Encodable.encodableOfList E1 #
{α : Type u_1} → [DecidableEq α] → (l : List α) → (∀ (x : α), x ∈ l) → Encodable α
A listable type with decidable equality is encodable.
def Fintype.truncEncodable E1 #
(α : Type u_2) → [DecidableEq α] → [Fintype α] → Trunc (Encodable α)
A finite type is encodable. Because the encoding is not unique, we wrap it in Trunc to
preserve computability.
def Fintype.toEncodable E1 #
(α : Type u_2) → [Fintype α] → Encodable α
A noncomputable way to arbitrarily choose an ordering on a finite type.
It is not made into a global instance, since it involves an arbitrary choice.
This can be locally made into an instance with attribute [local instance] Fintype.toEncodable.
theorem Denumerable.denumerable_list_aux E0 #
∀ {α : Type u_1} [inst : Denumerable α] (n : ℕ), ∃ a ∈ Encodable.decodeList n, Encodable.encodeList a = n
instance Denumerable.denumerableList E0 #
{α : Type u_1} → [Denumerable α] → Denumerable (List α)
If α is denumerable, then so is List α.
theorem Denumerable.list_ofNat_zero E0 #
∀ {α : Type u_1} [inst : Denumerable α], Denumerable.ofNat (List α) 0 = []
theorem Denumerable.list_ofNat_succ E0 #
∀ {α : Type u_1} [inst : Denumerable α] (v : ℕ),
Denumerable.ofNat (List α) v.succ =
Denumerable.ofNat α (Nat.unpair v).1 :: Denumerable.ofNat (List α) (Nat.unpair v).2
def Equiv.listUniqueEquiv E1 #
(α : Type u_1) → [Unique α] → List α ≃ ℕ
A list on a unique type is equivalent to ℕ by sending each list to its length.
theorem Equiv.listUniqueEquiv_apply E0 #
∀ (α : Type u_1) [inst : Unique α] (a : List α), (Equiv.listUniqueEquiv α) a = a.length
theorem Equiv.listUniqueEquiv_symm_apply E0 #
∀ (α : Type u_1) [inst : Unique α] (n : ℕ), (Equiv.listUniqueEquiv α).symm n = List.replicate n default
def Equiv.listNatEquivNat E1 #
List ℕ ≃ ℕ
List ℕ is equivalent to ℕ.
def Equiv.listEquivSelfOfEquivNat E1 #
{α : Type u_1} → α ≃ ℕ → List α ≃ α
If α is equivalent to ℕ, then List α is equivalent to α.