List Permutations #
This file introduces the List.Perm relation, which is true if two lists are permutations of one
another.
Notation #
The notation ~ is used for permutation equivalence.
theorem List.Subperm.filter {α : Type u_1} (p : α → Bool) ⦃l l' : List α⦄ (h : l.Subperm l') :
(List.filter p l).Subperm (List.filter p l')
@[instance_reducible]
instance List.decidableSubperm {α : Type u_1} [BEq α] [LawfulBEq α] :
DecidableRel fun (x1 x2 : List α) => x1.Subperm x2
Equations
- x✝¹.decidableSubperm x✝ = decidable_of_iff (x✝¹.isSubperm x✝ = true) ⋯
theorem List.Perm.insertP {α : Type u_1} {l₁ l₂ : List α} (p : α → Bool) (a : α) (h : l₁.Perm l₂) :
(List.insertP p a l₁).Perm (List.insertP p a l₂)
theorem List.cons_uncurry_swapAt_perm_cons {α : Type u_1} (xs : List α) (i : Nat) (v : α) :
(Function.uncurry cons (xs.swapAt i v)).Perm (v :: xs)
idxInj #
def List.Subperm.idxInj {α : Type u_1} [BEq α] [ReflBEq α] {xs ys : List α} (h : xs.Subperm ys) (i : Fin xs.length) :
Subperm.idxInj is an injective map from Fin xs.length to Fin ys.length
which exists when we have xs <+~ ys: conceptually it represents an embedding of
one list into the other. For example:
(by decide : [1, 0, 1] <+~ [5, 0, 1, 3, 1]).idxInj 1 = 1
Equations
- h.idxInj i = ⟨List.idxOfNth xs[↑i] ys (List.countBefore xs[i] xs ↑i), ⋯⟩
Instances For
idxBij #
Perm.idxBij is a bijective map from Fin xs.length to Fin ys.length
which exists when we have xs.Perm ys: conceptually it represents a permuting of
one list into the other. For example:
(by decide : [0, 1, 1, 3, 5] ~ [5, 0, 1, 3, 1]).idxBij 2 = 4