module Cat.Instances.Shape.Interval where

Interval category🔗

The interval category, or walking arrow, is the category with two points, called (as a form of endearment) and and a single arrow between them. Correspondingly, in shorthand this category is referred to as Since it has a single (non-trivial) arrow, it is a partial order; In fact, it is the partial order generated by the type of booleans and the natural ordering on them, with

open Precategory

Bool-poset : Poset lzero lzero
Bool-poset .Poset.Ob        = Bool
Bool-poset .Poset._≤_       = _≤_
Bool-poset .Poset.≤-thin    = hlevel 1
Bool-poset .Poset.≤-refl    = ≤-refl
Bool-poset .Poset.≤-trans   = ≤-trans
Bool-poset .Poset.≤-antisym = ≤-antisym

The interval category is the category underlying the poset of booleans:

0≤1 : Precategory lzero lzero
0≤1 = poset→category Bool-poset

Meets🔗

Note that the category is finitely complete (i.e. it is bounded, and has binary meets for every pair of elements): The top element is (go figure), and meets are given by the boolean “and” function.

0≤1-top : Terminal 0≤1
0≤1-top .top = true

0≤1-top .has⊤ false .centre = _
0≤1-top .has⊤ false .paths _ = refl

0≤1-top .has⊤ true  .centre = _
0≤1-top .has⊤ true  .paths _ = refl

0≤1-products :  A B  Product 0≤1 A B
0≤1-products A B .apex = and A B
0≤1-products A B .π₁   = and-≤l A B
0≤1-products A B .π₂   = and-≤r A B
0≤1-products A B .has-is-product .⟨_,_⟩ = and-univ _ A B
0≤1-products A B .has-is-product .π₁∘⟨⟩ = prop!
0≤1-products A B .has-is-product .π₂∘⟨⟩ = prop!
0≤1-products A B .has-is-product .unique _ _ = prop!

The space of arrows🔗

The total space of the family of a precategory is referred to as its “space of arrows”. A point in this space is a “free-standing arrow”: it comes equipped with its own domain and codomain. We note that, since a precategory has no upper bound on the h-level of its space of objects, its space of arrows also need not be particularly truncated. However, for a univalent category it is a groupoid, and for a poset it is a set.

An equivalent description of the space of arrows is as the collection of functors a functor out of corresponds rather directly to picking out an arrow in Its domain is the object that maps to, and is codomain is the object that maps to.

Arrow : Precategory o   Type (o  )
Arrow C = Σ[ A  C ] Σ[ B  C ] (C.Hom A B)
  where module C = Precategory C

We now fix a category and prove the correspondence between the space of arrows as defined above, and the space of functors

module _ {C : Precategory o } where
  import Cat.Reasoning C as C

  arrow→functor : Arrow C  Functor 0≤1 C
  arrow→functor (A , B , f) = fun where
    fun : Functor _ _
    fun .F₀ false = A
    fun .F₀ true = B
    fun .F₁ {false} {false} _ = C.id
    fun .F₁ {false} {true}  _ = f
    fun .F₁ {true}  {true}  _ = C.id

The other direction, turning a functor into an object of Arr, is mostly immediate: we can extract the non-trivial arrow by seeing what the non-trivial arrow maps to, and type inference can fill in the domain/codomain.

  functor→arrow : Functor 0≤1 C  Arrow C
  functor→arrow F = _ , _ , F .F₁ {false} {true} _

That this function is an equivalence is also straightforward: The only non-trivial step is appealing to functoriality of specifically that it must preserve identity arrows. The converse direction (going functor → arrow → functor) is definitionally the identity.

  arrow≃functor : is-equiv arrow→functor
  arrow≃functor = is-iso→is-equiv (iso functor→arrow rinv linv) where
    rinv : is-right-inverse functor→arrow arrow→functor
    rinv F =
      Functor-path
         { true  refl ; false  refl })
         { {false} {false} _  sym (F-id F)
           ; {false} {true}  _  refl
           ; {true}  {true}  _  sym (F-id F) })

    linv : is-left-inverse functor→arrow arrow→functor
    linv x = refl

Correspondingly, we could define the arrow category as the functor category but we prefer a definition in components for usability reasons.

  record Homᵃ (f : C.Hom a b) (g : C.Hom x y) : Type  where
    no-eta-equality

    field
      top : C.Hom a x
      bot : C.Hom b y
      com : g C.∘ top  bot C.∘ f
Arr : Precategory o   Precategory (o  ) 
Arr C .Ob                          = Arrow C
Arr C .Hom (_ , _ , f) (_ , _ , g) = Homᵃ C f g
Arr C .Hom-set _ _ = hlevel 2
Arr C .id  = record
  { top = C .id
  ; bot = C .id
  ; com = C .idr _  sym (C .idl _)
  }
Arr C ._∘_ sa sb = record where
  module C = Cat C

  top = sa .top C.∘ sb .top
  bot = sa .bot C.∘ sb .bot
  com = C.extendl (sa .com)  C.pushr (sb .com)
Arr C .idr   f     = ext (C .idr _       ,ₚ C .idr _)
Arr C .idl   f     = ext (C .idl _       ,ₚ C .idl _)
Arr C .assoc f g h = ext (C .assoc _ _ _ ,ₚ C .assoc _ _ _)