Equivalence between Fin (length l)
and elements of a list #
Given a list l
,
if
l
has no duplicates, thenList.Nodup.getEquiv
is the equivalence betweenFin (length l)
and{x // x ∈ l}
sendingi
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α
, thenList.Nodup.getEquivOfForallMemList
defines an equivalence betweenFin (length l)
andα
; ifα
does not have decidable equality, then there is a bijectionList.Nodup.getBijectionOfForallMemList
;if
l
is sorted w.r.t.(<)
, thenList.Sorted.getIso
is 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
.