module Order.Diagram.Fixpoint {o β„“} (P : Poset o β„“) where

Least fixpointsπŸ”—

Let be a poset, and be a monotone map. We say that has a least fixpoint if there exists some such that and for every other such that

record is-least-fixpoint (f : Posets.Hom P P) (x : Ob) : Type (o βŠ” β„“) where
  no-eta-equality
  field
    fixed : f .hom x ≑ x
    least : βˆ€ (y : Ob) β†’ f .hom y ≑ y β†’ x ≀ y

record Least-fixpoint (f : Posets.Hom P P) : Type (o βŠ” β„“) where
  no-eta-equality
  field
    fixpoint : Ob
    has-least-fixpoint : is-least-fixpoint f fixpoint
  open is-least-fixpoint has-least-fixpoint public

open is-least-fixpoint

Least fixed points are unique, so the type of least fixpoints of is a proposition.

least-fixpoint-unique
  : βˆ€ {f : Posets.Hom P P} {x y}
  β†’ is-least-fixpoint f x β†’ is-least-fixpoint f y
  β†’ x ≑ y
least-fixpoint-unique x-fix y-fix =
  ≀-antisym (x-fix .least _ (y-fix .fixed)) (y-fix .least _ (x-fix .fixed))

is-least-fixpoint-is-prop
  : βˆ€ {f : Posets.Hom P P} {x}
  β†’ is-prop (is-least-fixpoint f x)
is-least-fixpoint-is-prop {f = f} {x = x} p q i .fixed =
  Ob-is-set (f .hom x) x (p .fixed) (q .fixed) i
is-least-fixpoint-is-prop {f = f} {x = x} p q i .least y y-fix =
  is-prop→pathp
    (Ξ» i β†’ ≀-thin)
    (p .least y y-fix) (q .least y y-fix) i

Least-fixpoint-is-prop
  : βˆ€ {f : Posets.Hom P P}
  β†’ is-prop (Least-fixpoint f)
Least-fixpoint-is-prop {f = f} p q = p≑q where
  module p = Least-fixpoint p
  module q = Least-fixpoint q

  path : p.fixpoint ≑ q.fixpoint
  path = least-fixpoint-unique p.has-least-fixpoint q.has-least-fixpoint

  p≑q : p ≑ q
  p≑q i .Least-fixpoint.fixpoint = path i
  p≑q i .Least-fixpoint.has-least-fixpoint =
    is-prop→pathp (λ i → is-least-fixpoint-is-prop {x = path i})
      p.has-least-fixpoint q.has-least-fixpoint i