Documentation

VCVio.ProgramLogic.Unary.DijkstraMonad

Dijkstra monad #

This file aims to formalize the content of the paper Dijkstra monads for all.

class DijkstraMonad (w : Type u → Type v) (d : {α : Type u} → w αType z) [Monad w] :
Type (max (max (u + 1) v) z)
  • dPure {α : Type u} (x : α) : d (pure x)
  • dBind {α β : Type u} {wa : w α} {wb : αw β} : d wa((a : α) → d (wb a))d (wa >>= wb)
Instances
    def DijkstraMonad.dMap {w : Type u_1 → Type u_2} {d : {α : Type u_1} → w αType u_3} [Monad w] [DijkstraMonad w d] {α β : Type u_1} {a : w α} (f : αβ) :
    d ad do let ba pure (f b)
    Equations
    Instances For
      class LawfulDijkstraMonad (w : Type u → Type v) (d : {α : Type u} → w αType z) [Monad w] [LawfulMonad w] [DijkstraMonad w fun {α : Type u} => d] :
      • dPure_dBind {α β : Type u} {f : αw β} (x : α) (g : (a : α) → d (f a)) : (dPure x >>=ᵈ g) = g x
      • dBind_dPure {α : Type u} {a : w α} (x : d a) : (x >>=ᵈ dPure) = x
      • dBind_assoc {α β γ : Type u} {a : w α} {f : αw β} {g : βw γ} (x : d a) (f' : (a : α) → d (f a)) (g' : (b : β) → d (g b)) : (x >>=ᵈ f' >>=ᵈ g') = x >>=ᵈ fun (a : α) => f' a >>=ᵈ g'
      Instances
        class OrderedDijkstraMonad (w : Type u → Type v) (d : {α : Type u} → w αType z) [OrderedMonad w] extends DijkstraMonad w fun {α : Type u} => d :
        Type (max (max (u + 1) v) z)
        Instances
          def DijkstraMonad.dDite {w : Type u_1 → Type u_2} {d : {α : Type u_1} → w αType u_3} [Monad w] [DijkstraMonad w d] {α : Type u_1} (c : Prop) [h : Decidable c] {t : cw α} {e : ¬cw α} :
          ((c' : c) → d (t c'))((c' : ¬c) → d (e c'))d (dite c t e)
          Equations
          Instances For
            def DijkstraMonad.dIte {w : Type u_1 → Type u_2} {d : {α : Type u_1} → w αType u_3} [Monad w] [DijkstraMonad w d] {α : Type u_1} (c : Prop) [Decidable c] {t e : w α} :
            d td ed (if c then t else e)
            Equations
            Instances For
              class DijkstraMonadMorphism (w₁ : Type u → Type v) (w₂ : Type u → Type w) (d₁ : {α : Type u} → w₁ αType z) (d₂ : {α : Type u} → w₂ αType z) [Monad w₁] [Monad w₂] [MonadLiftT w₁ w₂] [DijkstraMonad w₁ fun {α : Type u} => d₁] [DijkstraMonad w₂ fun {α : Type u} => d₂] :
              Type (max (max (u + 1) v) z)
              • dMorphism {α : Type u} {a : w₁ α} : d₁ ad₂ (monadLift a)
              Instances
                class LawfulDijkstraMonadLift (w₁ : Type u → Type v) (w₂ : Type u → Type w) (d₁ : {α : Type u} → w₁ αType z) (d₂ : {α : Type u} → w₂ αType z) [Monad w₁] [Monad w₂] [MonadLiftT w₁ w₂] [DijkstraMonad w₁ fun {α : Type u} => d₁] [DijkstraMonad w₂ fun {α : Type u} => d₂] [inst : DijkstraMonadMorphism w₁ w₂ (fun {α : Type u} => d₁) fun {α : Type u} => d₂] [LawfulMonad w₁] [LawfulMonad w₂] [LawfulMonadLiftT w₁ w₂] :
                Instances

                  Constructing Dijkstra monads from monad relations and vice versa #

                  instance DijkstraMonad.instOfMonadRelation {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [MonadRelation m n] [LawfulMonadRelation m n] :
                  DijkstraMonad n fun {α : Type u_1} (na : n α) => { ma : m α // monadRel ma na }
                  Equations
                  • One or more equations did not get rendered due to their size.
                  instance DijkstraMonad.instOfMonadMorphism {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} [Monad m] [Monad n] [h : MonadLiftT m n] [h' : LawfulMonadLiftT m n] :
                  DijkstraMonad n fun {α : Type u_1} (na : n α) => { ma : m α // monadLift ma = na }
                  Equations
                  instance DijkstraMonad.instMonadSigma {w : Type u_1 → Type u_2} {d : {α : Type u_1} → w αType u_3} [Monad w] [DijkstraMonad w d] :
                  Monad fun (α : Type u_1) => (w : w α) × d w

                  A Dijkstra monad d on a monad w can be seen as a monad on the dependent pair (w, d).

                  Equations
                  instance DijkstraMonad.instLawfulMonadSigma {w : Type u_1 → Type u_2} {d : {α : Type u_1} → w αType u_3} [Monad w] [DijkstraMonad w d] [h : LawfulMonad w] [LawfulDijkstraMonad w fun {α : Type u_1} => d] :
                  LawfulMonad fun (α : Type u_1) => (w : w α) × d w

                  A lawful Dijkstra monad d on a lawful monad w can be seen as a lawful monad on the dependent pair (w, d).

                  instance DijkstraMonad.instMonadLiftTSigma {w : Type u_1 → Type u_2} {d : {α : Type u_1} → w αType u_3} [Monad w] [DijkstraMonad w d] :
                  MonadLiftT (fun (α : Type u_1) => (w : w α) × d w) w
                  Equations
                  instance DijkstraMonad.instMonadRelationSigma {w : Type u_1 → Type u_2} {d : {α : Type u_1} → w αType u_3} [Monad w] [DijkstraMonad w d] :
                  MonadRelation (fun (α : Type u_1) => (w : w α) × d w) w
                  Equations

                  The ordered setting

                  The Free Dijkstra Monad #

                  inductive FreeDijkstra (m : Type u → Type v) [Monad m] {α : Type u} :
                  m αType (max (u + 1) v)
                  Instances For