mathlib documentation

data.equiv.list

Equivalences involving list-like types #

This file defines some additional constructive equivalences using encodable and the pairing function on .

def encodable.encode_list {α : Type u_1} [encodable α] :
list α

Explicit encoding function for list α

Equations
def encodable.decode_list {α : Type u_1} [encodable α] :
option (list α)

Explicit decoding function for list α

Equations
@[instance]
def encodable.list {α : Type u_1} [encodable α] :

If α is encodable, then so is list α. This uses the mkpair and unpair functions from data.nat.pairing.

Equations
@[simp]
theorem encodable.encode_list_nil {α : Type u_1} [encodable α] :
@[simp]
theorem encodable.encode_list_cons {α : Type u_1} [encodable α] (a : α) (l : list α) :
@[simp]
theorem encodable.decode_list_zero {α : Type u_1} [encodable α] :
@[simp]
theorem encodable.decode_list_succ {α : Type u_1} [encodable α] (v : ) :
encodable.decode (list α) v.succ = (λ (_x : α) (_y : list α), _x :: _y) <$> encodable.decode α v.unpair.fst <*> encodable.decode (list α) v.unpair.snd
theorem encodable.length_le_encode {α : Type u_1} [encodable α] (l : list α) :
def encodable.encode_multiset {α : Type u_1} [encodable α] (s : multiset α) :

Explicit encoding function for multiset α

Equations
def encodable.decode_multiset {α : Type u_1} [encodable α] (n : ) :

Explicit decoding function for multiset α

Equations
@[instance]
def encodable.multiset {α : Type u_1} [encodable α] :

If α is encodable, then so is multiset α.

Equations
def encodable.encodable_of_list {α : Type u_1} [decidable_eq α] (l : list α) (H : ∀ (x : α), x l) :

A listable type with decidable equality is encodable.

Equations
def encodable.fintype.encodable (α : Type u_1) [fintype α] :

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 local attribute [instance] fintype.encodable.

Equations
@[instance]
def encodable.vector {α : Type u_1} [encodable α] {n : } :

If α is encodable, then so is vector α n.

Equations
@[instance]
def encodable.fin_arrow {α : Type u_1} [encodable α] {n : } :
encodable (fin n → α)

If α is encodable, then so is fin n → α.

Equations
@[instance]
def encodable.fin_pi (n : ) (π : fin nType u_1) [Π (i : fin n), encodable («π» i)] :
encodable (Π (i : fin n), «π» i)
Equations
@[instance]
def encodable.array {α : Type u_1} [encodable α] {n : } :

If α is encodable, then so is array n α.

Equations
@[instance]
def encodable.finset {α : Type u_1} [encodable α] :

If α is encodable, then so is finset α.

Equations
def encodable.fintype_arrow (α : Type u_1) (β : Type u_2) [decidable_eq α] [fintype α] [encodable β] :
trunc (encodable (α → β))
Equations
def encodable.fintype_pi (α : Type u_1) (π : α → Type u_2) [decidable_eq α] [fintype α] [Π (a : α), encodable («π» a)] :
trunc (encodable (Π (a : α), «π» a))
Equations
def encodable.sorted_univ (α : Type u_1) [fintype α] [encodable α] :
list α

The elements of a fintype as a sorted list.

Equations
theorem encodable.mem_sorted_univ {α : Type u_1} [fintype α] [encodable α] (x : α) :
def encodable.fintype_equiv_fin {α : Type u_1} [fintype α] [encodable α] :

An encodable fintype is equivalent to the same size fin.

Equations
@[instance]
def encodable.fintype_arrow_of_encodable {α : Type u_1} {β : Type u_2} [encodable α] [fintype α] [encodable β] :
encodable (α → β)

If α and β are encodable and α is a fintype, then α → β is encodable as well.

Equations
theorem denumerable.denumerable_list_aux {α : Type u_1} [denumerable α] (n : ) :
@[instance]
def denumerable.denumerable_list {α : Type u_1} [denumerable α] :

If α is denumerable, then so is list α.

Equations
@[simp]
def denumerable.lower  :
list list

Outputs the list of differences of the input list, that is lower [a₁, a₂, ...] n = [a₁ - n, a₂ - a₁, ...]

Equations
def denumerable.raise  :
list list

Outputs the list of partial sums of the input list, that is raise [a₁, a₂, ...] n = [n + a₁, n + a₁ + a₂, ...]

Equations

raise l n is an non-decreasing sequence.

@[instance]
def denumerable.multiset {α : Type u_1} [denumerable α] :

If α is denumerable, then so is multiset α. Warning: this is not the same encoding as used in encodable.multiset.

Equations

Outputs the list of differences minus one of the input list, that is lower' [a₁, a₂, a₃, ...] n = [a₁ - n, a₂ - a₁ - 1, a₃ - a₂ - 1, ...].

Equations

Outputs the list of partial sums plus one of the input list, that is raise [a₁, a₂, a₃, ...] n = [n + a₁, n + a₁ + a₂ + 1, n + a₁ + a₂ + a₃ + 2, ...]. Adding one each time ensures the elements are distinct.

Equations
theorem denumerable.raise_lower' {l : list } {n : } :
(∀ (m : ), m ln m)list.sorted has_lt.lt ldenumerable.raise' (denumerable.lower' l n) n = l

raise' l n is a strictly increasing sequence.

Makes raise' l n into a finset. Elements are distinct thanks to raise'_sorted.

Equations
@[instance]
def denumerable.finset {α : Type u_1} [denumerable α] :

If α is denumerable, then so is finset α. Warning: this is not the same encoding as used in encodable.finset.

Equations

The type lists on unit is canonically equivalent to the natural numbers.

Equations
def equiv.list_equiv_self_of_equiv_nat {α : Type} (e : α ) :
list α α

If α is equivalent to , then list α is equivalent to α.

Equations