sublists #
List.Sublists gives a list of all (not necessarily contiguous) sublists of a list.
This file contains basic results on this function.
sublists #
sublistsLen #
Auxiliary function to construct the list of all sublists of a given length. Given an
integer n, a list l, a function f and an auxiliary list L, it returns the list made of
f applied to all sublists of l of length n, concatenated with L.
Equations
- List.sublistsLenAux 0 x✝² x✝¹ x✝ = x✝¹ [] :: x✝
- List.sublistsLenAux n.succ [] x✝¹ x✝ = x✝
- List.sublistsLenAux n.succ (a :: l) x✝¹ x✝ = List.sublistsLenAux (n + 1) l x✝¹ (List.sublistsLenAux n l (x✝¹ ∘ List.cons a) x✝)
Instances For
The list of all sublists of a list l that are of length n. For instance, for
l = [0, 1, 2, 3] and n = 2, one gets
[[2, 3], [1, 3], [1, 2], [0, 3], [0, 2], [0, 1]].
Equations
- List.sublistsLen n l = List.sublistsLenAux n l id []
Instances For
@[simp]
@[simp]
theorem List.sublistsLen_sublist_sublists' {α : Type u} (n : ℕ) (l : List α) :
(sublistsLen n l).Sublist l.sublists'
theorem List.sublistsLen_sublist_of_sublist {α : Type u} (n : ℕ) {l₁ l₂ : List α} (h : l₁.Sublist l₂) :
(sublistsLen n l₁).Sublist (sublistsLen n l₂)
theorem List.length_of_sublistsLen {α : Type u} {n : ℕ} {l l' : List α} :
l' ∈ sublistsLen n l → l'.length = n
@[simp]
theorem List.Pairwise.sublists' {α : Type u} {R : α → α → Prop} {l : List α} :
Pairwise R l → Pairwise (Lex (Function.swap R)) l.sublists'
Alias of the reverse direction of List.nodup_sublists.
Alias of the forward direction of List.nodup_sublists.
Alias of the forward direction of List.nodup_sublists'.
theorem List.nodup_sublistsLen {α : Type u} (n : ℕ) {l : List α} (h : l.Nodup) :
(sublistsLen n l).Nodup