Construct a sorted list from a multiset.
def
multiset.sort
{α : Type u_1}
(r : α → α → Prop)
[decidable_rel r]
[is_trans α r]
[is_antisymm α r]
[is_total α r] :
sort s
constructs a sorted list from the multiset s
.
(Uses merge sort algorithm.)
Equations
- multiset.sort r s = quot.lift_on s (list.merge_sort r) _
@[simp]
theorem
multiset.coe_sort
{α : Type u_1}
(r : α → α → Prop)
[decidable_rel r]
[is_trans α r]
[is_antisymm α r]
[is_total α r]
(l : list α) :
multiset.sort r ↑l = list.merge_sort r l
@[simp]
theorem
multiset.sort_sorted
{α : Type u_1}
(r : α → α → Prop)
[decidable_rel r]
[is_trans α r]
[is_antisymm α r]
[is_total α r]
(s : multiset α) :
list.sorted r (multiset.sort r s)
@[simp]
theorem
multiset.sort_eq
{α : Type u_1}
(r : α → α → Prop)
[decidable_rel r]
[is_trans α r]
[is_antisymm α r]
[is_total α r]
(s : multiset α) :
↑(multiset.sort r s) = s
@[simp]
theorem
multiset.mem_sort
{α : Type u_1}
(r : α → α → Prop)
[decidable_rel r]
[is_trans α r]
[is_antisymm α r]
[is_total α r]
{s : multiset α}
{a : α} :
a ∈ multiset.sort r s ↔ a ∈ s
@[simp]
theorem
multiset.length_sort
{α : Type u_1}
(r : α → α → Prop)
[decidable_rel r]
[is_trans α r]
[is_antisymm α r]
[is_total α r]
{s : multiset α} :
(multiset.sort r s).length = s.card
@[instance]
Equations
- multiset.has_repr = {repr := λ (s : multiset α), "{" ++ ", ".intercalate (multiset.sort has_le.le (multiset.map repr s)) ++ "}"}