Documentation

ToMathlib.Control.OrderedMonad

Ordered monads #

This file collects all definitions and basic theorems about adding ordering to monads.

Main definitions #

def pointwiseRelation {α β : Type u} (r : ββProp) (f g : αβ) :
ααProp

pointwiseRelation r f g is the pullback of a relation r on β to a relation on α via f and g.

Equations
    Instances For
      def Proper (A : Type u) (R : AAProp) (m : A) :

      Proper R m states that a value m respects the relation R by being related to itself. This is useful for expressing that certain operations preserve relationships.

      NOTE: this is a direct translation from Coq, the Lean version is essentially IsRefl

      Equations
        Instances For
          class OrderedMonad (m : Type u → Type v) extends Monad m :
          Type (max (u + 1) v)

          An ordered monad m is a monad equipped with a preorder on each type m α, such that the bind operation preserves the order.

          • map {α β : Type u} : (αβ)m αm β
          • mapConst {α β : Type u} : αm βm α
          • pure {α : Type u} : αm α
          • seq {α β : Type u} : m (αβ)(Unitm α)m β
          • seqLeft {α β : Type u} : m α(Unitm β)m α
          • seqRight {α β : Type u} : m α(Unitm β)m β
          • bind {α β : Type u} : m α(αm β)m β
          • monadOrder {α : Type u} : Preorder (m α)
          • bind_mono {α β : Type u} {ma ma' : m α} {f f' : αm β} (ha : ma ma') (hf : ∀ (a : α), f a f' a) : ma >>= f ma' >>= f'
          Instances
            instance instPreorderOfOrderedMonad {m : Type u → Type u_1} [OrderedMonad m] {α : Type u} :
            Preorder (m α)
            Equations
              class Monad.IsOrdered (m : Type u → Type v) [Monad m] :
              Type (max (u + 1) v)

              Unbundled version of OrderedMonad.

              • monadOrder {α : Type u} : Preorder (m α)
              • bind_mono {α β : Type u} {ma ma' : m α} {f f' : αm β} (ha : ma ma') (hf : ∀ (a : α), f a f' a) : ma >>= f ma' >>= f'
              Instances
                Equations
                  @[reducible]
                  def OrderedMonad.monadLE {m : Type u → Type u_1} [OrderedMonad m] {α : Type u} :
                  m αm αProp

                  The less-than-or-equal relation on an ordered monad m.

                  Equations
                    Instances For
                      @[reducible]
                      def OrderedMonad.monadLT {m : Type u → Type u_1} [OrderedMonad m] {α : Type u} :
                      m αm αProp

                      The less-than relation on an ordered monad m.

                      Equations
                        Instances For

                          The less-than-or-equal relation on an ordered monad m.

                          Equations
                            Instances For

                              The less-than relation on an ordered monad m.

                              Equations
                                Instances For

                                  Any monad can be given the discrete preorder, where a ≤ b if and only if a = b.

                                  This is put into the Discrete scope in order to avoid conflicts with other instances. This instance should only be used as a last resort.

                                  Equations
                                    Instances For
                                      class OrderedMonadAlgebra (m : Type u → Type v) [OrderedMonad m] [MonadAlgebra m] :
                                      Type (u + 1)
                                      Instances
                                        class MonadLift.LE (m : Type u → Type v) (n : Type u → Type w) [Monad m] [OrderedMonad n] [φ : MonadLift m n] [ψ : MonadLift m n] :

                                        A class that express an ordering for monad lifts.

                                        Instances
                                          instance instPreorderMonadLiftOfMonadOfOrderedMonad {m : Type u → Type u_1} {n : Type u → Type u_2} [Monad m] [OrderedMonad n] :

                                          If the target monad n is ordered, then we have a preorder on the monad lifts from m to n.

                                          Equations
                                            class OrderedMonadLift (m : semiOutParam (Type u → Type v)) (n : Type u → Type w) [OrderedMonad m] [OrderedMonad n] extends MonadLift m n :
                                            Type (max (max (u + 1) v) w)
                                            Instances
                                              class OrderedMonadLiftT (m : Type u → Type v) (n : Type u → Type w) [OrderedMonad m] [OrderedMonad n] extends MonadLiftT m n :
                                              Type (max (max (u + 1) v) w)
                                              Instances
                                                @[simp]
                                                theorem monadLift_mono' {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [OrderedMonad m] [OrderedMonad n] [OrderedMonadLiftT m n] {α : Type u_1} {a b : m α} (h : monadLE a b) :
                                                instance instOrderedMonadLiftT {m : Type u_1 → Type u_2} [OrderedMonad m] :
                                                Equations
                                                  def instDiscreteMonadLift {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [h : OrderedMonad n] [MonadLift m n] :

                                                  Given the (default) discrete preorder on the beginning monad m, we can have a preorder on the monad lifts from m to n.

                                                  This is stated as a definition and not an instance, since oftentimes we want to have another instance on the monad lift.

                                                  Equations
                                                    Instances For
                                                      class MonadRelation.IsUpperClosed (m : Type u → Type v) (n : Type u → Type w) [Monad m] [OrderedMonad n] [MonadRelation m n] :
                                                      Instances
                                                        instance MonadRelation.instOfMonadOfOrderedMonadOfMonadLiftT {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [OrderedMonad n] [MonadLiftT m n] :
                                                        Equations
                                                          class OrderedMonadTransformer (t : (Type u → Type v)Type u → Type w) extends MonadTransformer t :
                                                          Type (max (max (u + 1) (v + 1)) w)
                                                          Instances
                                                            class AssertAssume (α : Type u) [Preorder α] :
                                                            Instances
                                                              class Monad.AssertAssume (m : Type u → Type v) [(α : Type u) → Preorder (m α)] :
                                                              Type (max (u + 1) v)
                                                              Instances
                                                                def leftKanExtension {w : Type u → Type v} [Monad w] [OrderedMonad w] {α β : Type u} (f : w β) (p : w α) :
                                                                Type (max 0 u v)
                                                                Equations
                                                                  Instances For
                                                                    def rightKanExtension {w : Type u → Type v} [Monad w] [OrderedMonad w] {α β : Type u} (f : w β) (p : w α) :
                                                                    Type (max 0 u v)
                                                                    Equations
                                                                      Instances For