Definition of 0 and ::ₘ #
This file defines constructors for multisets:
Zero (Multiset α)instance: the empty multisetMultiset.cons: add one element to a multisetSingleton α (Multiset α)instance: multiset with one element
It also defines the following predicates on multisets:
Multiset.Rel:Rel r s tlifts the relationrbetween two elements to a relation betweensandt, s.t. there is a one-to-one mapping between elements insandtfollowingr.
Notation #
0: The empty multiset.{a}: The multiset containing a single occurrence ofa.a ::ₘ s: The multiset containing one more occurrence ofathansdoes.
Main results #
Multiset.rec: recursion on adding one element to a multiset at a time.
Empty multiset #
0 : Multiset α is the empty set
Instances For
@[implicit_reducible]
@[implicit_reducible]
@[implicit_reducible]
@[implicit_reducible]
cons a s is the multiset which contains s plus one more instance of a.
Instances For
cons a s is the multiset which contains s plus one more instance of a.
Instances For
@[implicit_reducible]
@[simp]
@[simp]
@[simp]
@[simp]
def
Multiset.rec
{α : Type u_1}
{C : Multiset α → Sort u_3}
(C_0 : C 0)
(C_cons : (a : α) → (m : Multiset α) → C m → C (a ::ₘ m))
(C_cons_heq :
∀ (a a' : α) (m : Multiset α) (b : C m), C_cons a (a' ::ₘ m) (C_cons a' m b) ≍ C_cons a' (a ::ₘ m) (C_cons a m b))
(m : Multiset α)
:
C m
Dependent recursor on multisets.
TODO: should be @[recursor 6], but then the definition of Multiset.pi fails with a stack
overflow in whnf.
Instances For
def
Multiset.recOn
{α : Type u_1}
{C : Multiset α → Sort u_3}
(m : Multiset α)
(C_0 : C 0)
(C_cons : (a : α) → (m : Multiset α) → C m → C (a ::ₘ m))
(C_cons_heq :
∀ (a a' : α) (m : Multiset α) (b : C m), C_cons a (a' ::ₘ m) (C_cons a' m b) ≍ C_cons a' (a ::ₘ m) (C_cons a m b))
:
C m
Companion to Multiset.rec with more convenient argument order.
Instances For
@[simp]
theorem
Multiset.recOn_0
{α : Type u_1}
{C : Multiset α → Sort u_3}
{C_0 : C 0}
{C_cons : (a : α) → (m : Multiset α) → C m → C (a ::ₘ m)}
{C_cons_heq :
∀ (a a' : α) (m : Multiset α) (b : C m), C_cons a (a' ::ₘ m) (C_cons a' m b) ≍ C_cons a' (a ::ₘ m) (C_cons a m b)}
:
Multiset.recOn 0 C_0 C_cons C_cons_heq = C_0
@[simp]
@[simp]
theorem
Multiset.eq_zero_of_forall_notMem
{α : Type u_1}
{s : Multiset α}
:
(∀ (x : α), x ∉ s) → s = 0
theorem
Multiset.eq_zero_iff_forall_notMem
{α : Type u_1}
{s : Multiset α}
:
s = 0 ↔ ∀ (a : α), a ∉ s
Singleton #
@[implicit_reducible]
@[simp]
@[simp]
@[simp]
theorem
Multiset.singleton_eq_cons_iff
{α : Type u_1}
{a b : α}
(m : Multiset α)
:
{a} = b ::ₘ m ↔ a = b ∧ m = 0
@[simp]
@[simp]
@[simp]
@[simp]
@[implicit_reducible]
@[simp]
This is a rfl and simp version of bot_eq_zero.
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
Cardinality #
@[simp]
@[simp]
theorem
Multiset.card_eq_two
{α : Type u_1}
{s : Multiset α}
:
s.card = 2 ↔ ∃ (x : α) (y : α), s = {x, y}
theorem
Multiset.card_eq_three
{α : Type u_1}
{s : Multiset α}
:
s.card = 3 ↔ ∃ (x : α) (y : α) (z : α), s = {x, y, z}
theorem
Multiset.card_eq_four
{α : Type u_1}
{s : Multiset α}
:
s.card = 4 ↔ ∃ (x : α) (y : α) (z : α) (w : α), s = {x, y, z, w}
Map for partial functions #
@[simp]
theorem
Multiset.pmap_zero
{α : Type u_1}
{β : Type v}
{p : α → Prop}
(f : (a : α) → p a → β)
(h : ∀ a ∈ 0, p a)
:
pmap f 0 h = 0
Rel r s t -- lift the relation r between two elements to a relation between s and t,
s.t. there is a one-to-one mapping between elements in s and t following r.
- zero {α : Type u_1} {β : Type v} {r : α → β → Prop} : Rel r 0 0
- cons {α : Type u_1} {β : Type v} {r : α → β → Prop} {a : α} {b : β} {as : Multiset α} {bs : Multiset β} : r a b → Rel r as bs → Rel r (a ::ₘ as) (b ::ₘ bs)
Instances For
theorem
Multiset.rel_refl_of_refl_on
{α : Type u_1}
{m : Multiset α}
{r : α → α → Prop}
:
(∀ x ∈ m, r x x) → Rel r m m
theorem
Multiset.rel_eq
{α : Type u_1}
{s t : Multiset α}
:
Rel (fun (x1 x2 : α) => x1 = x2) s t ↔ s = t
theorem
Multiset.rel_flip_eq
{α : Type u_1}
{s t : Multiset α}
:
Rel (fun (a b : α) => b = a) s t ↔ s = t
@[simp]
@[simp]
@[simp]
@[simp]