The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V03. Sets, finite structures and big operators

Mathlib.Data.Multiset.Functor

14 declarations. Mathlib docs · Source

instance Multiset.functor E0 #

Functor Multiset

theorem Multiset.fmap_def E0 #

∀ {α' β' : Type u_1} {s : Multiset α'} (f : α' → β'), f <$> s = Multiset.map f s

instance Multiset.instLawfulFunctor E0 #

LawfulFunctor Multiset

def Multiset.traverse E1 #

{F : Type u → Type u} →
  [inst : Applicative F] → [CommApplicative F] → {α' β' : Type u} → (α' → F β') → Multiset α' → F (Multiset β')

Map each element of a Multiset to an action, evaluate these actions in order, and collect the results.

instance Multiset.instMonad E0 #

Monad Multiset

theorem Multiset.pure_def E0 #

∀ {α : Type u_1}, pure = singleton

theorem Multiset.bind_def E0 #

∀ {α β : Type u_1}, (fun x1 x2 ↦ x1 >>= x2) = Multiset.bind

instance Multiset.instLawfulMonad E0 #

LawfulMonad Multiset

theorem Multiset.map_comp_coe E0 #

∀ {α β : Type u_1} (h : α → β), Functor.map h ∘ Multiset.ofList = Multiset.ofList ∘ Functor.map h

theorem Multiset.id_traverse E1 #

∀ {α : Type u_1} (x : Multiset α), Multiset.traverse pure x = pure x

theorem Multiset.comp_traverse E1 #

∀ {G H : Type u_1 → Type u_1} [inst : Applicative G] [inst_1 : Applicative H] [inst_2 : CommApplicative G]
  [inst_3 : CommApplicative H] {α β γ : Type u_1} (g : α → G β) (h : β → H γ) (x : Multiset α),
  Multiset.traverse (Functor.Comp.mk ∘ Functor.map h ∘ g) x =
    Functor.Comp.mk (Multiset.traverse h <$> Multiset.traverse g x)

theorem Multiset.map_traverse E0 #

∀ {G : Type u_1 → Type u_1} [inst : Applicative G] [inst_1 : CommApplicative G] {α β γ : Type u_1} (g : α → G β)
  (h : β → γ) (x : Multiset α), Functor.map h <$> Multiset.traverse g x = Multiset.traverse (Functor.map h ∘ g) x

theorem Multiset.traverse_map E1 #

∀ {G : Type u_1 → Type u_1} [inst : Applicative G] [inst_1 : CommApplicative G] {α β γ : Type u_1} (g : α → β)
  (h : β → G γ) (x : Multiset α), Multiset.traverse h (Multiset.map g x) = Multiset.traverse (h ∘ g) x

theorem Multiset.naturality E1 #

∀ {G H : Type u_1 → Type u_1} [inst : Applicative G] [inst_1 : Applicative H] [inst_2 : CommApplicative G]
  [inst_3 : CommApplicative H] (eta : ApplicativeTransformation G H) {α β : Type u_1} (f : α → G β) (x : Multiset α),
  (fun {α} ↦ eta.app α) (Multiset.traverse f x) = Multiset.traverse ((fun {α} ↦ eta.app α) ∘ f) x