Dijkstra monad #
This file aims to formalize the content of the paper Dijkstra monads for all.
Equations
- «term_>>=ᵈ_» = Lean.ParserDescr.trailingNode `«term_>>=ᵈ_» 55 55 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " >>=ᵈ ") (Lean.ParserDescr.cat `term 56))
Instances For
Equations
- «term_<$>ᵈ_» = Lean.ParserDescr.trailingNode `«term_<$>ᵈ_» 100 101 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " <$>ᵈ ") (Lean.ParserDescr.cat `term 100))
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]
:
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 : c → w α}
{e : ¬c → w α}
:
Equations
- DijkstraMonad.dDite c dt de = Decidable.casesOn h (fun (h : ¬c) => de h) fun (h : c) => dt h
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 α}
:
Equations
- DijkstraMonad.dIte c dt de = DijkstraMonad.dDite c (fun (x : c) => dt) fun (x : ¬c) => de
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)
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]
:
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]
:
instance
DijkstraMonad.instMonadSigma
{w : Type u_1 → Type u_2}
{d : {α : Type u_1} → w α → Type u_3}
[Monad w]
[DijkstraMonad w d]
:
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
- DijkstraMonad.instMonadLiftTSigma = { monadLift := fun {α : Type ?u.42} (x : (w : w α) × d w) => x.fst }
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
The ordered setting
The Free Dijkstra Monad #
- pure {m : Type u → Type v} [Monad m] {α : Type u} (x : α) : FreeDijkstra m (pure x)
- roll {m : Type u → Type v} [Monad m] {α β : Type u} (x : m α) {f : α → m β} (r : α → FreeDijkstra m (x >>= f)) : FreeDijkstra m (x >>= f)