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 / V33. Data structures and computation

Mathlib.Control.Bifunctor

38 declarations. Mathlib docs · Source

Functors with two arguments

This file defines bifunctors.

A bifunctor is a function F : Type* → Type* → Type* along with a bimap which turns F α β into F α' β' given two functions α → α' and β → β'. It further

  • respects the identity: bimap id id = id
  • composes in the obvious way: (bimap f' g') ∘ (bimap f g) = bimap (f' ∘ f) (g' ∘ g)

Main declarations

  • Bifunctor: A typeclass for the bare bimap of a bifunctor.
  • LawfulBifunctor: A typeclass asserting this bimap respects the bifunctor laws.

def Bifunctor.ctorIdx E1 #

{F : Type u₀ → Type u₁ → Type u₂} → Bifunctor F → ℕ

class Bifunctor E3 #

(Type u₀ → Type u₁ → Type u₂) → Type (max (max (u₀ + 1) (u₁ + 1)) u₂)

Lawless bifunctor. This typeclass only holds the data for the bimap.

ctor Bifunctor.mk E0 #

{F : Type u₀ → Type u₁ → Type u₂} →
  ({α α' : Type u₀} → {β β' : Type u₁} → (α → α') → (β → β') → F α β → F α' β') → Bifunctor F

abbrev Bifunctor.bimap E1 #

{F : Type u₀ → Type u₁ → Type u₂} →
  [self : Bifunctor F] → {α α' : Type u₀} → {β β' : Type u₁} → (α → α') → (β → β') → F α β → F α' β'

class LawfulBifunctor E3 #

(F : Type u₀ → Type u₁ → Type u₂) → [Bifunctor F] → Prop

Bifunctor. This typeclass asserts that a lawless Bifunctor is lawful.

ctor LawfulBifunctor.mk E0 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F],
  (∀ {α : Type u₀} {β : Type u₁} (x : F α β), bimap id id x = x) →
    (∀ {α₀ α₁ α₂ : Type u₀} {β₀ β₁ β₂ : Type u₁} (f : α₀ → α₁) (f' : α₁ → α₂) (g : β₀ → β₁) (g' : β₁ → β₂)
        (x : F α₀ β₀), bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x) →
      LawfulBifunctor F

theorem LawfulBifunctor.id_bimap E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} {inst : Bifunctor F} [self : LawfulBifunctor F] {α : Type u₀} {β : Type u₁}
  (x : F α β), bimap id id x = x

theorem LawfulBifunctor.bimap_bimap E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} {inst : Bifunctor F} [self : LawfulBifunctor F] {α₀ α₁ α₂ : Type u₀}
  {β₀ β₁ β₂ : Type u₁} (f : α₀ → α₁) (f' : α₁ → α₂) (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α₀ β₀),
  bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x

theorem LawfulBifunctor.bimap_id_id E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} {inst : Bifunctor F} [self : LawfulBifunctor F] {α : Type u₀} {β : Type u₁},
  bimap id id = id

theorem LawfulBifunctor.bimap_comp_bimap E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} {inst : Bifunctor F} [self : LawfulBifunctor F] {α₀ α₁ α₂ : Type u₀}
  {β₀ β₁ β₂ : Type u₁} (f : α₀ → α₁) (f' : α₁ → α₂) (g : β₀ → β₁) (g' : β₁ → β₂),
  bimap f' g' ∘ bimap f g = bimap (f' ∘ f) (g' ∘ g)

abbrev Bifunctor.fst E1 #

{F : Type u₀ → Type u₁ → Type u₂} → [Bifunctor F] → {α α' : Type u₀} → {β : Type u₁} → (α → α') → F α β → F α' β

Left map of a bifunctor.

abbrev Bifunctor.snd E1 #

{F : Type u₀ → Type u₁ → Type u₂} → [Bifunctor F] → {α : Type u₀} → {β β' : Type u₁} → (β → β') → F α β → F α β'

Right map of a bifunctor.

theorem Bifunctor.fst_id E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α : Type u₀} {β : Type u₁},
  Bifunctor.fst id = id

theorem Bifunctor.id_fst E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α : Type u₀} {β : Type u₁} (x : F α β),
  Bifunctor.fst id x = x

theorem Bifunctor.id_snd E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α : Type u₀} {β : Type u₁} (x : F α β),
  Bifunctor.snd id x = x

theorem Bifunctor.snd_id E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α : Type u₀} {β : Type u₁},
  Bifunctor.snd id = id

theorem Bifunctor.fst_comp_fst E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α₀ α₁ α₂ : Type u₀} {β : Type u₁}
  (f : α₀ → α₁) (f' : α₁ → α₂), Bifunctor.fst f' ∘ Bifunctor.fst f = Bifunctor.fst (f' ∘ f)

theorem Bifunctor.comp_fst E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α₀ α₁ α₂ : Type u₀} {β : Type u₁}
  (f : α₀ → α₁) (f' : α₁ → α₂) (x : F α₀ β), Bifunctor.fst f' (Bifunctor.fst f x) = Bifunctor.fst (f' ∘ f) x

theorem Bifunctor.fst_comp_snd E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α₀ α₁ : Type u₀} {β₀ β₁ : Type u₁}
  (f : α₀ → α₁) (f' : β₀ → β₁), Bifunctor.fst f ∘ Bifunctor.snd f' = bimap f f'

theorem Bifunctor.fst_snd E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α₀ α₁ : Type u₀} {β₀ β₁ : Type u₁}
  (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀), Bifunctor.fst f (Bifunctor.snd f' x) = bimap f f' x

theorem Bifunctor.snd_fst E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α₀ α₁ : Type u₀} {β₀ β₁ : Type u₁}
  (f : α₀ → α₁) (f' : β₀ → β₁) (x : F α₀ β₀), Bifunctor.snd f' (Bifunctor.fst f x) = bimap f f' x

theorem Bifunctor.snd_comp_fst E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α₀ α₁ : Type u₀} {β₀ β₁ : Type u₁}
  (f : α₀ → α₁) (f' : β₀ → β₁), Bifunctor.snd f' ∘ Bifunctor.fst f = bimap f f'

theorem Bifunctor.comp_snd E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α : Type u₀} {β₀ β₁ β₂ : Type u₁}
  (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α β₀), Bifunctor.snd g' (Bifunctor.snd g x) = Bifunctor.snd (g' ∘ g) x

theorem Bifunctor.snd_comp_snd E1 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α : Type u₀} {β₀ β₁ β₂ : Type u₁}
  (g : β₀ → β₁) (g' : β₁ → β₂), Bifunctor.snd g' ∘ Bifunctor.snd g = Bifunctor.snd (g' ∘ g)

instance Prod.bifunctor E0 #

Bifunctor Prod

instance Prod.lawfulBifunctor E0 #

LawfulBifunctor Prod

instance Bifunctor.const E0 #

Bifunctor Functor.Const

instance LawfulBifunctor.const E0 #

LawfulBifunctor Functor.Const

instance Bifunctor.flip E0 #

{F : Type u₀ → Type u₁ → Type u₂} → [Bifunctor F] → Bifunctor (flip F)

instance LawfulBifunctor.flip E0 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F], LawfulBifunctor (flip F)

instance Sum.bifunctor E0 #

Bifunctor Sum

instance Sum.lawfulBifunctor E0 #

LawfulBifunctor Sum

instance Bifunctor.functor E0 #

{F : Type u₀ → Type u₁ → Type u₂} → [Bifunctor F] → {α : Type u₀} → Functor (F α)

instance Bifunctor.lawfulFunctor E0 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] [LawfulBifunctor F] {α : Type u₀}, LawfulFunctor (F α)

instance Function.bicompl.bifunctor E0 #

{F : Type u₀ → Type u₁ → Type u₂} →
  [Bifunctor F] →
    (G : Type u_1 → Type u₀) → (H : Type u_2 → Type u₁) → [Functor G] → [Functor H] → Bifunctor (Function.bicompl F G H)

instance Function.bicompl.lawfulBifunctor E0 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] (G : Type u_1 → Type u₀) (H : Type u_2 → Type u₁)
  [inst_1 : Functor G] [inst_2 : Functor H] [LawfulFunctor G] [LawfulFunctor H] [LawfulBifunctor F],
  LawfulBifunctor (Function.bicompl F G H)

instance Function.bicompr.bifunctor E0 #

{F : Type u₀ → Type u₁ → Type u₂} →
  [Bifunctor F] → (G : Type u₂ → Type u_1) → [Functor G] → Bifunctor (Function.bicompr G F)

instance Function.bicompr.lawfulBifunctor E0 #

∀ {F : Type u₀ → Type u₁ → Type u₂} [inst : Bifunctor F] (G : Type u₂ → Type u_1) [inst_1 : Functor G] [LawfulFunctor G]
  [LawfulBifunctor F], LawfulBifunctor (Function.bicompr G F)