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.Finset.Functor

23 declarations. Mathlib docs · Source

Functoriality of Finset

This file defines the functor structure of Finset.

TODO

Currently, all instances are classical because the functor classes want to run over all types. If instead we could state that a functor is lawful/applicative/traversable... between two given types, then we could provide the instances for types with decidable equality.

Functor

Pure

Applicative functor

Monad

Alternative functor

Traversable functor

theorem Multiset.traverse.congr_simp E1 #

∀ {F : Type u → Type u} [inst : Applicative F] [inst_1 : CommApplicative F] {α' β' : Type u} (f f_1 : α' → F β'),
  f = f_1 → ∀ (a a_1 : Multiset α'), a = a_1 → Multiset.traverse f a = Multiset.traverse f_1 a_1

instance Finset.functor E0 #

[(P : Prop) → Decidable P] → Functor Finset

Because Finset.image requires a DecidableEq instance for the target type, we can only construct Functor Finset when working classically.

instance Finset.lawfulFunctor E0 #

∀ [inst : (P : Prop) → Decidable P], LawfulFunctor Finset

theorem Finset.fmap_def E0 #

∀ {α β : Type u} [inst : (P : Prop) → Decidable P] {s : Finset α} (f : α → β), f <$> s = Finset.image f s

instance Finset.pure E0 #

Pure Finset

theorem Finset.pure_def E0 #

∀ {α : Type u_1}, pure = singleton

instance Finset.applicative E0 #

[(P : Prop) → Decidable P] → Applicative Finset

theorem Finset.seq_def E0 #

∀ {α β : Type u} [inst : (P : Prop) → Decidable P] (s : Finset α) (t : Finset (α → β)),
  t <*> s = t.sup fun f ↦ Finset.image f s

theorem Finset.seqLeft_def E0 #

∀ {α β : Type u} [inst : (P : Prop) → Decidable P] (s : Finset α) (t : Finset β), s <* t = if t = ∅ then ∅ else s

theorem Finset.seqRight_def E0 #

∀ {α β : Type u} [inst : (P : Prop) → Decidable P] (s : Finset α) (t : Finset β), s *> t = if s = ∅ then ∅ else t

theorem Finset.image₂_def E0 #

∀ [inst : (P : Prop) → Decidable P] {α β γ : Type u} (f : α → β → γ) (s : Finset α) (t : Finset β),
  Finset.image₂ f s t = f <$> s <*> t

Finset.image₂ in terms of monadic operations. Note that this can't be taken as the definition because of the lack of universe polymorphism.

instance Finset.lawfulApplicative E0 #

∀ [inst : (P : Prop) → Decidable P], LawfulApplicative Finset

instance Finset.commApplicative E0 #

∀ [inst : (P : Prop) → Decidable P], CommApplicative Finset

instance Finset.instMonad E0 #

[(P : Prop) → Decidable P] → Monad Finset

theorem Finset.bind_def E0 #

∀ [inst : (P : Prop) → Decidable P] {α β : Type u_1}, (fun x1 x2 ↦ x1 >>= x2) = Finset.sup

instance Finset.instLawfulMonad E0 #

∀ [inst : (P : Prop) → Decidable P], LawfulMonad Finset

instance Finset.instAlternativeMonad E0 #

[(P : Prop) → Decidable P] → AlternativeMonad Finset

instance Finset.instLawfulAlternative E0 #

∀ [inst : (P : Prop) → Decidable P], LawfulAlternative Finset

def Finset.traverse E1 #

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

Traverse function for Finset.

theorem Finset.id_traverse E0 #

∀ {α : Type u} [inst : DecidableEq α] (s : Finset α), Finset.traverse pure s = pure s

theorem Finset.map_comp_coe E0 #

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

theorem Finset.map_comp_coe_apply E0 #

∀ {α β : Type u} (h : α → β) (s : Multiset α), Finset.image h s.toFinset = (h <$> s).toFinset

theorem Finset.map_traverse E0 #

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