Documentation

Hale.Base.Control.Category

class Control.Category (Cat : Type u → Type u → Type v) :
Type (max (u + 1) v)

A category $\mathcal{C}$ consists of:

  • Objects: types $\alpha, \beta, \gamma, \ldots$
  • Morphisms: $\text{Cat}\;\alpha\;\beta$ (the "arrows" from $\alpha$ to $\beta$)
  • Identity: $\text{id}_\alpha : \text{Cat}\;\alpha\;\alpha$
  • Composition: $(f \ggg g) : \text{Cat}\;\alpha\;\gamma$ for $f : \text{Cat}\;\alpha\;\beta$ and $g : \text{Cat}\;\beta\;\gamma$

Composition is in diagrammatic (left-to-right) order: comp f g means "first $f$, then $g$".

  • id {α : Type u} : Cat α α

    The identity morphism: $\text{id}_\alpha : \text{Cat}\;\alpha\;\alpha$.

    $$\text{id} \ggg f = f = f \ggg \text{id}$$

  • comp {α β γ : Type u} : Cat α βCat β γCat α γ

    Composition in diagrammatic order: $(f \ggg g)(x) = g(f(x))$.

    $$\text{comp}\;f\;g : \text{Cat}\;\alpha\;\gamma$$

Instances
    class Control.LawfulCategory (Cat : Type u → Type u → Type v) [Category Cat] :

    Laws for a lawful category:

    1. Left identity: $\text{id} \ggg f = f$
    2. Right identity: $f \ggg \text{id} = f$
    3. Associativity: $(f \ggg g) \ggg h = f \ggg (g \ggg h)$
    Instances
      structure Control.Fun (α β : Type u) :

      A wrapper for functions as a two-parameter type suitable for Category.

      $$\text{Fun}\;\alpha\;\beta \;\cong\; (\alpha \to \beta)$$

      Needed because Lean's is not a two-parameter type constructor in the required form Type u → Type u → Type v.

      • apply : αβ

        Apply the wrapped function.

      Instances For
        @[implicit_reducible]

        Functions form a category with:

        • $\text{id} = \lambda x.\, x$
        • $(f \ggg g)(x) = g(f(x))$
        Equations

        Functions form a lawful category — all three laws hold definitionally.

        Diagrammatic composition operator: $f \ggg g$ means "first $f$, then $g$".

        $$f \ggg g = \text{Category.comp}\;f\;g$$

        Equations
        Instances For