# Equivalence between Fin (length l) and elements of a list #

Given a list l,

• if l has no duplicates, then List.Nodup.getEquiv is the equivalence between Fin (length l) and {x // x ∈ l} sending i to ⟨get l i, _⟩ with the inverse sending ⟨x, hx⟩ to ⟨indexOf x l, _⟩;

• if l has no duplicates and contains every element of a type α, then List.Nodup.getEquivOfForallMemList defines an equivalence between Fin (length l) and α; if α does not have decidable equality, then there is a bijection List.Nodup.getBijectionOfForallMemList;

• if l is sorted w.r.t. (<), then List.Sorted.getIso is the same bijection reinterpreted as an OrderIso.

@[simp]
theorem List.Nodup.getBijectionOfForallMemList_coe {α : Type u_1} (l : List α) (nd : l.Nodup) (h : ∀ (x : α), x l) (i : Fin l.length) :
i = l.get i
def List.Nodup.getBijectionOfForallMemList {α : Type u_1} (l : List α) (nd : l.Nodup) (h : ∀ (x : α), x l) :
{ f : Fin l.lengthα // }

If l lists all the elements of α without duplicates, then List.get defines a bijection Fin l.length → α. See List.Nodup.getEquivOfForallMemList for a version giving an equivalence when there is decidable equality.

Equations
• = fun (i : Fin l.length) => l.get i,
Instances For
@[simp]
theorem List.Nodup.getEquiv_symm_apply_val {α : Type u_1} [] (l : List α) (H : l.Nodup) (x : { x : α // x l }) :
(().symm x) = List.indexOf (x) l
@[simp]
theorem List.Nodup.getEquiv_apply_coe {α : Type u_1} [] (l : List α) (H : l.Nodup) (i : Fin l.length) :
(() i) = l.get i
def List.Nodup.getEquiv {α : Type u_1} [] (l : List α) (H : l.Nodup) :
Fin l.length { x : α // x l }

If l has no duplicates, then List.get defines an equivalence between Fin (length l) and the set of elements of l.

Equations
• = { toFun := fun (i : Fin l.length) => l.get i, , invFun := fun (x : { x : α // x l }) => List.indexOf (x) l, , left_inv := , right_inv := }
Instances For
@[simp]
theorem List.Nodup.getEquivOfForallMemList_symm_apply_val {α : Type u_1} [] (l : List α) (nd : l.Nodup) (h : ∀ (x : α), x l) (a : α) :
(().symm a) =
@[simp]
theorem List.Nodup.getEquivOfForallMemList_apply {α : Type u_1} [] (l : List α) (nd : l.Nodup) (h : ∀ (x : α), x l) (i : Fin l.length) :
() i = l.get i
def List.Nodup.getEquivOfForallMemList {α : Type u_1} [] (l : List α) (nd : l.Nodup) (h : ∀ (x : α), x l) :
Fin l.length α

If l lists all the elements of α without duplicates, then List.get defines an equivalence between Fin l.length and α.

See List.Nodup.getBijectionOfForallMemList for a version without decidable equality.

Equations
• = { toFun := fun (i : Fin l.length) => l.get i, invFun := fun (a : α) => ⟨, , left_inv := , right_inv := }
Instances For
theorem List.Sorted.get_mono {α : Type u_1} [] {l : List α} (h : List.Sorted (fun (x x_1 : α) => x x_1) l) :
Monotone l.get
theorem List.Sorted.get_strictMono {α : Type u_1} [] {l : List α} (h : List.Sorted (fun (x x_1 : α) => x < x_1) l) :
def List.Sorted.getIso {α : Type u_1} [] [] (l : List α) (H : List.Sorted (fun (x x_1 : α) => x < x_1) l) :
Fin l.length ≃o { x : α // x l }

If l is a list sorted w.r.t. (<), then List.get defines an order isomorphism between Fin (length l) and the set of elements of l.

Equations
• = { toEquiv := , map_rel_iff' := }
Instances For
@[simp]
theorem List.Sorted.coe_getIso_apply {α : Type u_1} [] {l : List α} [] (H : List.Sorted (fun (x x_1 : α) => x < x_1) l) {i : Fin l.length} :
(() i) = l.get i
@[simp]
theorem List.Sorted.coe_getIso_symm_apply {α : Type u_1} [] {l : List α} [] (H : List.Sorted (fun (x x_1 : α) => x < x_1) l) {x : { x : α // x l }} :
(().symm x) = List.indexOf (x) l
theorem List.sublist_of_orderEmbedding_get?_eq {α : Type u_1} {l : List α} {l' : List α} (f : ) (hf : ∀ (ix : ), l.get? ix = l'.get? (f ix)) :
l.Sublist l'

If there is f, an order-preserving embedding of ℕ into ℕ such that any element of l found at index ix can be found at index f ix in l', then Sublist l l'.

theorem List.sublist_iff_exists_orderEmbedding_get?_eq {α : Type u_1} {l : List α} {l' : List α} :
l.Sublist l' ∃ (f : ), ∀ (ix : ), l.get? ix = l'.get? (f ix)

A l : List α is Sublist l l' for l' : List α iff there is f, an order-preserving embedding of ℕ into ℕ such that any element of l found at index ix can be found at index f ix in l'.

theorem List.sublist_iff_exists_fin_orderEmbedding_get_eq {α : Type u_1} {l : List α} {l' : List α} :
l.Sublist l' ∃ (f : Fin l.length ↪o Fin l'.length), ∀ (ix : Fin l.length), l.get ix = l'.get (f ix)

A l : List α is Sublist l l' for l' : List α iff there is f, an order-preserving embedding of Fin l.length into Fin l'.length such that any element of l found at index ix can be found at index f ix in l'.

theorem List.duplicate_iff_exists_distinct_get {α : Type u_1} {l : List α} {x : α} :
∃ (n : Fin l.length) (m : Fin l.length) (_ : n < m), x = l.get n x = l.get m

An element x : α of l : List α is a duplicate iff it can be found at two distinct indices n m : ℕ inside the list l.

@[deprecated List.duplicate_iff_exists_distinct_get]
theorem List.duplicate_iff_exists_distinct_nthLe {α : Type u_1} {l : List α} {x : α} :
∃ (n : ) (hn : n < l.length) (m : ) (hm : m < l.length) (_ : n < m), x = l.nthLe n hn x = l.nthLe m hm

An element x : α of l : List α is a duplicate iff it can be found at two distinct indices n m : ℕ inside the list l.