Equivalence between Fin (length l) and elements of a list #
Given a list l,
if
lhas no duplicates, thenList.Nodup.getEquivis the equivalence betweenFin (length l)and{x // x ∈ l}sendingito⟨get l i, _⟩with the inverse sending⟨x, hx⟩to⟨indexOf x l, _⟩;if
lhas no duplicates and contains every element of a typeα, thenList.Nodup.getEquivOfForallMemListdefines an equivalence betweenFin (length l)andα; ifαdoes not have decidable equality, then there is a bijectionList.Nodup.getBijectionOfForallMemList;if
lis sorted w.r.t.(<), thenList.Sorted.getIsois the same bijection reinterpreted as anOrderIso.
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
- List.Nodup.getBijectionOfForallMemList l nd h = ⟨fun (i : Fin l.length) => l.get i, ⋯⟩
Instances For
If l has no duplicates, then List.get defines an equivalence between Fin (length l) and
the set of elements of l.
Equations
- List.Nodup.getEquiv l H = { 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
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
- List.Nodup.getEquivOfForallMemList l nd h = { toFun := fun (i : Fin l.length) => l.get i, invFun := fun (a : α) => ⟨List.indexOf a l, ⋯⟩, left_inv := ⋯, right_inv := ⋯ }
Instances For
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
- List.Sorted.getIso l H = { toEquiv := List.Nodup.getEquiv l ⋯, map_rel_iff' := ⋯ }
Instances For
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'.
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'.
An element x : α of l : List α is a duplicate iff it can be found
at two distinct indices n m : ℕ inside the list l.
An element x : α of l : List α is a duplicate iff it can be found
at two distinct indices n m : ℕ inside the list l.