Built with Alectryon, running Coq+SerAPI v8.16.0+0.16.3. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus. On Mac, use instead of Ctrl.
From Tealeaves Require Import
  Classes.Categorical.Monad
  Classes.Kleisli.Monad.

Import Kleisli.Monad.Notations.

(** * Kleisli Monads to Categorical Monads *)
(**********************************************************************)

(** ** Derived <<join>> Operation *)
(**********************************************************************)
Module DerivedOperations.
  #[export] Instance Join_Bind
    (T : Type -> Type)
    `{Return_T: Return T}
    `{Bind_TT: Bind T T}: Join T :=
  fun A => bind (@id (T A)).
End DerivedOperations.

(** ** Derived Categorical Laws *)
(**********************************************************************)
Module ToCategorical.

  Section proofs.

    Context
      (T : Type -> Type)
      `{Classes.Kleisli.Monad.Monad T}.

    (* Alectyron doesn't like this
       Import KleisliToCategorical.Monad.DerivedOperations.
     *)
    Import DerivedOperations.
    Existing Instance Kleisli.Monad.DerivedOperations.Map_Bind.
    Existing Instance Kleisli.Monad.DerivedInstances.Functor_Monad.

    
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Natural (@ret T Return_T)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Natural (@ret T Return_T)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Functor (fun A : Type => A)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
Functor T
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
forall (A B : Type) (f : A -> B), map f ∘ ret = ret ∘ map f
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Functor (fun A : Type => A)
typeclasses eauto.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Functor T
typeclasses eauto.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

forall (A B : Type) (f : A -> B), map f ∘ ret = ret ∘ map f
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

map f ∘ ret = ret ∘ map f
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (ret ∘ f) ∘ ret = ret ∘ map f
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (ret ∘ f) ∘ ret = ret ∘ f
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

ret ∘ f = ret ∘ f
reflexivity. Qed.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Natural (@join T (Join_Bind T))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Natural (@join T (Join_Bind T))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Functor (T ∘ T)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
Functor T
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
forall (A B : Type) (f : A -> B), map f ∘ join = join ∘ map f
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Functor (T ∘ T)
typeclasses eauto.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Functor T
typeclasses eauto.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

forall (A B : Type) (f : A -> B), map f ∘ join = join ∘ map f
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

map f ∘ join = join ∘ map f
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

map f ∘ join = join ∘ map (map f)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (ret ∘ f) ∘ join = join ∘ bind (ret ∘ bind (ret ∘ f))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (ret ∘ f) ∘ bind id = bind id ∘ bind (ret ∘ bind (ret ∘ f))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (ret ∘ f) ∘ bind id = bind id ∘ bind (ret ∘ bind (ret ∘ f))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (ret ∘ f ⋆ id) = bind id ∘ bind (ret ∘ bind (ret ∘ f))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (bind (ret ∘ f) ∘ id) = bind id ∘ bind (ret ∘ bind (ret ∘ f))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (bind (ret ∘ f)) = bind id ∘ bind (ret ∘ bind (ret ∘ f))
(* RHS *)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (bind (ret ∘ f)) = bind (id ⋆ ret ∘ bind (ret ∘ f))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (bind (ret ∘ f)) = bind (bind id ∘ (ret ∘ bind (ret ∘ f)))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (bind (ret ∘ f)) = bind (bind id ∘ ret ∘ bind (ret ∘ f))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (bind (ret ∘ f)) = bind (id ∘ bind (ret ∘ f))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A, B: Type
f: A -> B

bind (bind (ret ∘ f)) = bind (bind (ret ∘ f))
reflexivity. Qed.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Categorical.Monad.Monad T
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Categorical.Monad.Monad T
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Functor T
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
Natural (@ret T Return_T)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
Natural (@join T (Join_Bind T))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
forall A : Type, join ∘ ret = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
forall A : Type, join ∘ map ret = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
forall A : Type, join ∘ join = join ∘ map join
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Functor T
typeclasses eauto.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Natural (@ret T Return_T)
typeclasses eauto.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

Natural (@join T (Join_Bind T))
typeclasses eauto.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

forall A : Type, join ∘ ret = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

join ∘ ret = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind id ∘ ret = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind id ∘ ret = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

id = id
reflexivity.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

forall A : Type, join ∘ map ret = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

join ∘ map ret = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind id ∘ bind (ret ∘ ret) = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind id ∘ bind (ret ∘ ret) = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind (id ⋆ ret ∘ ret) = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind (bind id ∘ (ret ∘ ret)) = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind (bind id ∘ ret ∘ ret) = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind (id ∘ ret) = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind ret = id
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

id = id
reflexivity.
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T

forall A : Type, join ∘ join = join ∘ map join
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

join ∘ join = join ∘ map join
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind id ∘ bind id = bind id ∘ bind (ret ∘ bind id)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind id ∘ bind id = bind id ∘ bind (ret ∘ bind id)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind (id ⋆ id) = bind id ∘ bind (ret ∘ bind id)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind (id ⋆ id) = bind (id ⋆ ret ∘ bind id)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind (bind id ∘ id) = bind (bind id ∘ (ret ∘ bind id))
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind (bind id ∘ id) = bind (bind id ∘ ret ∘ bind id)
T: Type -> Type
Return_T: Return T
Bind_TT: Bind T T
H: Monad T
A: Type

bind (bind id ∘ id) = bind (id ∘ bind id)
reflexivity. Qed. End proofs. End ToCategorical.