mathlib documentation

data.finset.sort

Construct a sorted list from a finset. #

sort #

def finset.sort {α : Type u_1} (r : α → α → Prop) [decidable_rel r] [is_trans α r] [is_antisymm α r] [is_total α r] (s : finset α) :
list α

sort s constructs a sorted list from the unordered set s. (Uses merge sort algorithm.)

Equations
@[simp]
theorem finset.sort_sorted {α : Type u_1} (r : α → α → Prop) [decidable_rel r] [is_trans α r] [is_antisymm α r] [is_total α r] (s : finset α) :
@[simp]
theorem finset.sort_eq {α : Type u_1} (r : α → α → Prop) [decidable_rel r] [is_trans α r] [is_antisymm α r] [is_total α r] (s : finset α) :
@[simp]
theorem finset.sort_nodup {α : Type u_1} (r : α → α → Prop) [decidable_rel r] [is_trans α r] [is_antisymm α r] [is_total α r] (s : finset α) :
@[simp]
theorem finset.sort_to_finset {α : Type u_1} (r : α → α → Prop) [decidable_rel r] [is_trans α r] [is_antisymm α r] [is_total α r] [decidable_eq α] (s : finset α) :
@[simp]
theorem finset.mem_sort {α : Type u_1} (r : α → α → Prop) [decidable_rel r] [is_trans α r] [is_antisymm α r] [is_total α r] {s : finset α} {a : α} :
@[simp]
theorem finset.length_sort {α : Type u_1} (r : α → α → Prop) [decidable_rel r] [is_trans α r] [is_antisymm α r] [is_total α r] {s : finset α} :
theorem finset.sort_perm_to_list {α : Type u_1} (r : α → α → Prop) [decidable_rel r] [is_trans α r] [is_antisymm α r] [is_total α r] (s : finset α) :
theorem finset.sorted_zero_eq_min'_aux {α : Type u_1} [linear_order α] (s : finset α) (h : 0 < (finset.sort has_le.le s).length) (H : s.nonempty) :
theorem finset.sorted_zero_eq_min' {α : Type u_1} [linear_order α] {s : finset α} {h : 0 < (finset.sort has_le.le s).length} :
theorem finset.min'_eq_sorted_zero {α : Type u_1} [linear_order α] {s : finset α} {h : s.nonempty} :
theorem finset.max'_eq_sorted_last {α : Type u_1} [linear_order α] {s : finset α} {h : s.nonempty} :
def finset.order_iso_of_fin {α : Type u_1} [linear_order α] (s : finset α) {k : } (h : s.card = k) :

Given a finset s of cardinality k in a linear order α, the map order_iso_of_fin s h is the increasing bijection between fin k and s as an order_iso. Here, h is a proof that the cardinality of s is k. We use this instead of an iso fin s.card ≃o s to avoid casting issues in further uses of this function.

Equations
def finset.order_emb_of_fin {α : Type u_1} [linear_order α] (s : finset α) {k : } (h : s.card = k) :
fin k ↪o α

Given a finset s of cardinality k in a linear order α, the map order_emb_of_fin s h is the increasing bijection between fin k and s as an order embedding into α. Here, h is a proof that the cardinality of s is k. We use this instead of an embedding fin s.card ↪o α to avoid casting issues in further uses of this function.

Equations
@[simp]
theorem finset.coe_order_iso_of_fin_apply {α : Type u_1} [linear_order α] (s : finset α) {k : } (h : s.card = k) (i : fin k) :
theorem finset.order_iso_of_fin_symm_apply {α : Type u_1} [linear_order α] (s : finset α) {k : } (h : s.card = k) (x : s) :
theorem finset.order_emb_of_fin_apply {α : Type u_1} [linear_order α] (s : finset α) {k : } (h : s.card = k) (i : fin k) :
@[simp]
theorem finset.order_emb_of_fin_mem {α : Type u_1} [linear_order α] (s : finset α) {k : } (h : s.card = k) (i : fin k) :
@[simp]
theorem finset.range_order_emb_of_fin {α : Type u_1} [linear_order α] (s : finset α) {k : } (h : s.card = k) :
theorem finset.order_emb_of_fin_zero {α : Type u_1} [linear_order α] {s : finset α} {k : } (h : s.card = k) (hz : 0 < k) :
(s.order_emb_of_fin h) 0, hz⟩ = s.min' _

The bijection order_emb_of_fin s h sends 0 to the minimum of s.

theorem finset.order_emb_of_fin_last {α : Type u_1} [linear_order α] {s : finset α} {k : } (h : s.card = k) (hz : 0 < k) :
(s.order_emb_of_fin h) k - 1, _⟩ = s.max' _

The bijection order_emb_of_fin s h sends k-1 to the maximum of s.

@[simp]
theorem finset.order_emb_of_fin_singleton {α : Type u_1} [linear_order α] (a : α) (i : fin 1) :

order_emb_of_fin {a} h sends any argument to a.

theorem finset.order_emb_of_fin_unique {α : Type u_1} [linear_order α] {s : finset α} {k : } (h : s.card = k) {f : fin k → α} (hfs : ∀ (x : fin k), f x s) (hmono : strict_mono f) :

Any increasing map f from fin k to a finset of cardinality k has to coincide with the increasing bijection order_emb_of_fin s h.

theorem finset.order_emb_of_fin_unique' {α : Type u_1} [linear_order α] {s : finset α} {k : } (h : s.card = k) {f : fin k ↪o α} (hfs : ∀ (x : fin k), f x s) :

An order embedding f from fin k to a finset of cardinality k has to coincide with the increasing bijection order_emb_of_fin s h.

@[simp]
theorem finset.order_emb_of_fin_eq_order_emb_of_fin_iff {α : Type u_1} [linear_order α] {k l : } {s : finset α} {i : fin k} {j : fin l} {h : s.card = k} {h' : s.card = l} :

Two parametrizations order_emb_of_fin of the same set take the same value on i and j if and only if i = j. Since they can be defined on a priori not defeq types fin k and fin l (although necessarily k = l), the conclusion is rather written (i : ℕ) = (j : ℕ).

theorem finset.card_le_of_interleaved {α : Type u_1} [linear_order α] {s t : finset α} (h : ∀ (x y : α), x sy sx < y(∃ (z : α) (H : z t), x < z z < y)) :
s.card t.card + 1
@[protected, instance]
def finset.has_repr {α : Type u_1} [has_repr α] :
Equations