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

46 declarations. Mathlib docs · Source

theorem Functor.map_id E0 #

∀ {F : Type u → Type v} {α : Type u} [inst : Functor F] [LawfulFunctor F], (fun x ↦ id <$> x) = id

theorem Functor.map_comp_map E0 #

∀ {F : Type u → Type v} {α β γ : Type u} [inst : Functor F] [LawfulFunctor F] (f : α → β) (g : β → γ),
  ((fun x ↦ g <$> x) ∘ fun x ↦ f <$> x) = fun x ↦ (g ∘ f) <$> x

theorem Functor.ext E1 #

∀ {F : Type u_1 → Type u_2} {F1 F2 : Functor F} [LawfulFunctor F] [LawfulFunctor F],
  (∀ (α β : Type u_1) (f : α → β) (x : F α), f <$> x = f <$> x) → F1 = F2

def Functor.Const E1 #

Type u_1 → Type u_2 → Type u_1

Const α is the constant functor, mapping every type to α. When α has a monoid structure, Const α has an Applicative instance. (If α has an additive monoid structure, see Functor.AddConst.)

def Functor.Const.mk E1 #

{α : Type u_1} → {β : Type u_2} → α → Functor.Const α β

Const.mk is the canonical map α → Const α β (the identity), and it can be used as a pattern to extract this value.

def Functor.Const.mk' E1 #

{α : Type u_1} → α → Functor.Const α PUnit.{u_2 + 1}

Const.mk' is Const.mk but specialized to map α to Const α PUnit, where PUnit is the terminal object in Type*.

def Functor.Const.run E1 #

{α : Type u_1} → {β : Type u_2} → Functor.Const α β → α

Extract the element of α from the Const functor.

theorem Functor.Const.ext E1 #

∀ {α : Type u_1} {β : Type u_2} {x y : Functor.Const α β}, x.run = y.run → x = y

def Functor.Const.map E1 #

{γ : Type u_1} → {α : Type u_2} → {β : Type u_3} → (α → β) → Functor.Const γ β → Functor.Const γ α

The map operation of the Const γ functor.

instance Functor.Const.functor E0 #

{γ : Type u_1} → Functor (Functor.Const γ)

instance Functor.Const.lawfulFunctor E0 #

∀ {γ : Type u_1}, LawfulFunctor (Functor.Const γ)

instance Functor.Const.instInhabited E0 #

{α : Type u_1} → {β : Type u_2} → [Inhabited α] → Inhabited (Functor.Const α β)

def Functor.AddConst E1 #

Type u_1 → Type u_2 → Type u_1

AddConst α is a synonym for constant functor Const α, mapping every type to α. When α has an additive monoid structure, AddConst α has an Applicative instance. (If α has a multiplicative monoid structure, see Functor.Const.)

def Functor.AddConst.mk E1 #

{α : Type u_1} → {β : Type u_2} → α → Functor.AddConst α β

AddConst.mk is the canonical map α → AddConst α β, which is the identity, where AddConst α β = Const α β. It can be used as a pattern to extract this value.

def Functor.AddConst.run E1 #

{α : Type u_1} → {β : Type u_2} → Functor.AddConst α β → α

Extract the element of α from the constant functor.

instance Functor.AddConst.functor E0 #

{γ : Type u_1} → Functor (Functor.AddConst γ)

instance Functor.AddConst.lawfulFunctor E0 #

∀ {γ : Type u_1}, LawfulFunctor (Functor.AddConst γ)

instance Functor.instInhabitedAddConst E0 #

{α : Type u_1} → {β : Type u_2} → [Inhabited α] → Inhabited (Functor.AddConst α β)

def Functor.Comp E1 #

(Type u → Type w) → (Type v → Type u) → Type v → Type w

Functor.Comp is a wrapper around Function.Comp for types. It prevents Lean's type class resolution mechanism from trying a Functor (Comp F id) when Functor F would do.

def Functor.Comp.mk E1 #

{F : Type u → Type w} → {G : Type v → Type u} → {α : Type v} → F (G α) → Functor.Comp F G α

Construct a term of Comp F G α from a term of F (G α), which is the same type. Can be used as a pattern to extract a term of F (G α).

def Functor.Comp.run E1 #

{F : Type u → Type w} → {G : Type v → Type u} → {α : Type v} → Functor.Comp F G α → F (G α)

Extract a term of F (G α) from a term of Comp F G α, which is the same type.

theorem Functor.Comp.run_mk E0 #

∀ {F : Type u → Type w} {G : Type v → Type u} {α : Type v} (x : F (G α)), (Functor.Comp.mk x).run = x

theorem Functor.Comp.mk_run E0 #

∀ {F : Type u → Type w} {G : Type v → Type u} {α : Type v} (x : Functor.Comp F G α), Functor.Comp.mk x.run = x

theorem Functor.Comp.ext E1 #

∀ {F : Type u → Type w} {G : Type v → Type u} {α : Type v} {x y : Functor.Comp F G α}, x.run = y.run → x = y

instance Functor.Comp.instInhabited E0 #

{F : Type u → Type w} → {G : Type v → Type u} → {α : Type v} → [Inhabited (F (G α))] → Inhabited (Functor.Comp F G α)

def Functor.Comp.map E1 #

{F : Type u → Type w} →
  {G : Type v → Type u} → [Functor F] → [Functor G] → {α β : Type v} → (α → β) → Functor.Comp F G α → Functor.Comp F G β

The map operation for the composition Comp F G of functors F and G.

instance Functor.Comp.functor E0 #

{F : Type u → Type w} → {G : Type v → Type u} → [Functor F] → [Functor G] → Functor (Functor.Comp F G)

theorem Functor.Comp.map_mk E0 #

∀ {F : Type u → Type w} {G : Type v → Type u} [inst : Functor F] [inst_1 : Functor G] {α β : Type v} (h : α → β)
  (x : F (G α)), h <$> Functor.Comp.mk x = Functor.Comp.mk ((fun x ↦ h <$> x) <$> x)

theorem Functor.Comp.run_map E0 #

∀ {F : Type u → Type w} {G : Type v → Type u} [inst : Functor F] [inst_1 : Functor G] {α β : Type v} (h : α → β)
  (x : Functor.Comp F G α), (h <$> x).run = (fun x ↦ h <$> x) <$> x.run

theorem Functor.Comp.id_map E1 #

∀ {F : Type u → Type w} {G : Type v → Type u} [inst : Functor F] [inst_1 : Functor G] [LawfulFunctor F]
  [LawfulFunctor G] {α : Type v} (x : Functor.Comp F G α), Functor.Comp.map id x = x

theorem Functor.Comp.comp_map E1 #

∀ {F : Type u → Type w} {G : Type v → Type u} [inst : Functor F] [inst_1 : Functor G] [LawfulFunctor F]
  [LawfulFunctor G] {α β γ : Type v} (g' : α → β) (h : β → γ) (x : Functor.Comp F G α),
  Functor.Comp.map (h ∘ g') x = Functor.Comp.map h (Functor.Comp.map g' x)

instance Functor.Comp.lawfulFunctor E0 #

∀ {F : Type u → Type w} {G : Type v → Type u} [inst : Functor F] [inst_1 : Functor G] [LawfulFunctor F]
  [LawfulFunctor G], LawfulFunctor (Functor.Comp F G)

theorem Functor.Comp.functor_comp_id E1 #

∀ {F : Type u_1 → Type u_2} [AF : Functor F] [LawfulFunctor F], Functor.Comp.functor = AF

theorem Functor.Comp.functor_id_comp E1 #

∀ {F : Type u_1 → Type u_2} [AF : Functor F] [LawfulFunctor F], Functor.Comp.functor = AF

def Functor.Comp.seq E1 #

{F : Type u → Type w} →
  {G : Type v → Type u} →
    [Applicative F] →
      [Applicative G] → {α β : Type v} → Functor.Comp F G (α → β) → (Unit → Functor.Comp F G α) → Functor.Comp F G β

The <*> operation for the composition of applicative functors.

instance Functor.Comp.instPure E0 #

{F : Type u → Type w} → {G : Type v → Type u} → [Applicative F] → [Applicative G] → Pure (Functor.Comp F G)

instance Functor.Comp.instSeq E0 #

{F : Type u → Type w} → {G : Type v → Type u} → [Applicative F] → [Applicative G] → Seq (Functor.Comp F G)

theorem Functor.Comp.run_pure E0 #

∀ {F : Type u → Type w} {G : Type v → Type u} [inst : Applicative F] [inst_1 : Applicative G] {α : Type v} (x : α),
  (pure x).run = pure (pure x)

theorem Functor.Comp.run_seq E0 #

∀ {F : Type u → Type w} {G : Type v → Type u} [inst : Applicative F] [inst_1 : Applicative G] {α β : Type v}
  (f : Functor.Comp F G (α → β)) (x : Functor.Comp F G α), (f <*> x).run = (fun x1 x2 ↦ x1 <*> x2) <$> f.run <*> x.run

instance Functor.Comp.instApplicativeComp E0 #

{F : Type u → Type w} → {G : Type v → Type u} → [Applicative F] → [Applicative G] → Applicative (Functor.Comp F G)

def Functor.Liftp E1 #

{F : Type u → Type v} → [Functor F] → {α : Type u} → (α → Prop) → F α → Prop

If we consider x : F α to, in some sense, contain values of type α, predicate Liftp p x holds iff every value contained by x satisfies p.

def Functor.Liftr E1 #

{F : Type u → Type v} → [Functor F] → {α : Type u} → (α → α → Prop) → F α → F α → Prop

If we consider x : F α to, in some sense, contain values of type α, then Liftr r x y relates x and y iff (1) x and y have the same shape and (2) we can pair values a from x and b from y so that r a b holds.

def Functor.supp E1 #

{F : Type u → Type v} → [Functor F] → {α : Type u} → F α → Set α

If we consider x : F α to, in some sense, contain values of type α, then supp x is the set of values of type α that x contains.

theorem Functor.of_mem_supp E1 #

∀ {F : Type u → Type v} [inst : Functor F] {α : Type u} {x : F α} {p : α → Prop},
  Functor.Liftp p x → ∀ y ∈ Functor.supp x, p y

abbrev Functor.mapConstRev E1 #

{f : Type u → Type v} → [Functor f] → {α β : Type u} → f β → α → f α

If f is a functor, if fb : f β and a : α, then mapConstRev fb a is the result of applying f.map to the constant function β → α sending everything to a, and then evaluating at fb. In other words it's const a <$> fb.

def Functor.«term_$>_» E1 #

Lean.TrailingParserDescr

If f is a functor, if fb : f β and a : α, then mapConstRev fb a is the result of applying f.map to the constant function β → α sending everything to a, and then evaluating at fb. In other words it's const a <$> fb.