Documentation

Mathlib.Data.Finset.Functor

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 #

instance Finset.functor [(P : Prop) → Decidable P] :

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

Equations
    @[simp]
    theorem Finset.fmap_def {α β : Type u} [(P : Prop) → Decidable P] {s : Finset α} (f : αβ) :
    f <$> s = image f s

    Pure #

    Equations
      @[simp]
      theorem Finset.pure_def {α : Type u_1} :

      Applicative functor #

      Equations
        @[simp]
        theorem Finset.seq_def {α β : Type u} [(P : Prop) → Decidable P] (s : Finset α) (t : Finset (αβ)) :
        t <*> s = t.sup fun (f : αβ) => image f s
        @[simp]
        theorem Finset.seqLeft_def {α β : Type u} [(P : Prop) → Decidable P] (s : Finset α) (t : Finset β) :
        s <* t = if t = then else s
        @[simp]
        theorem Finset.seqRight_def {α β : Type u} [(P : Prop) → Decidable P] (s : Finset α) (t : Finset β) :
        s *> t = if s = then else t
        theorem Finset.image₂_def [(P : Prop) → Decidable P] {α β γ : Type u} (f : αβγ) (s : Finset α) (t : 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.

        Monad #

        instance Finset.instMonad [(P : Prop) → Decidable P] :
        Equations
          @[simp]
          theorem Finset.bind_def [(P : Prop) → Decidable P] {α β : Type u_1} :
          (fun (x1 : Finset β) (x2 : βFinset α) => x1 >>= x2) = sup

          Alternative functor #

          Traversable functor #

          def Finset.traverse {α β : Type u} {F : Type u → Type u} [Applicative F] [CommApplicative F] [DecidableEq β] (f : αF β) (s : Finset α) :
          F (Finset β)

          Traverse function for Finset.

          Equations
            Instances For
              @[simp]
              theorem Finset.id_traverse {α : Type u} [DecidableEq α] (s : Finset α) :
              @[simp]
              theorem Finset.map_comp_coe_apply {α β : Type u} (h : αβ) (s : Multiset α) :
              theorem Finset.map_traverse {α β γ : Type u} {G : Type u → Type u} [Applicative G] [CommApplicative G] (g : αG β) (h : βγ) (s : Finset α) :