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 Export
  Functors.Early.Writer
  Functors.Reader
  Misc.Product
  Classes.Monoid.

#[local] Generalizable Variables W T F A M.

From Tealeaves Require Import
  Classes.Categorical.Bimonad
  Classes.Categorical.RightModule.

Import Strength.Notations.
Import Monad.Notations.
Import Monoid.Notations.
Import Product.Notations.

#[local] Arguments ret (T)%function_scope {Return}
  (A)%type_scope _.
#[local] Arguments map F%function_scope {Map}
  {A B}%type_scope f%function_scope _.
#[local] Arguments extract (W)%function_scope {Extract}
  (A)%type_scope _.
#[local] Arguments cojoin W%function_scope {Cojoin}
  {A}%type_scope _.


(** * <<T ∘ (W ×)>> is a monad *)
(* TODO: This can get moved to Categories/DecoratedFunctor.v *)
(**********************************************************************)
Section strength_as_writer_distributive_law.

  Context
    `{Monoid W}.

  
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F

forall A : Type, σ ∘ ret (prod W) (F A) = map F (ret (prod W) A)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F

forall A : Type, σ ∘ ret (prod W) (F A) = map F (ret (prod W) A)
reflexivity. Qed.
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F

forall A : Type, σ ∘ join = map F join ∘ σ ∘ map (prod W) (σ)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F

forall A : Type, σ ∘ join = map F join ∘ σ ∘ map (prod W) (σ)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
A: Type

σ ∘ join = map F join ∘ σ ∘ map (prod W) (σ)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
A: Type
w1, w2: W
t: F A

(σ ∘ join) (w1, (w2, t)) = (map F join ∘ σ ∘ map (prod W) (σ)) (w1, (w2, t))
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
A: Type
w1, w2: W
t: F A

map F (pair (w1 ● w2)) (id t) = map F join (map F (pair (id w1)) (map F (pair w2) t))
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
A: Type
w1, w2: W
t: F A

(map F (pair (w1 ● w2)) ∘ id) t = map F join ((map F (pair (id w1)) ∘ map F (pair w2)) t)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
A: Type
w1, w2: W
t: F A

(map F (pair (w1 ● w2)) ∘ id) t = map F join (map F (pair (id w1) ∘ pair w2) t)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
A: Type
w1, w2: W
t: F A

(map F (pair (w1 ● w2)) ∘ id) t = (map F join ∘ map F (pair (id w1) ∘ pair w2)) t
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
A: Type
w1, w2: W
t: F A

(map F (pair (w1 ● w2)) ∘ id) t = map F (join ∘ (pair (id w1) ∘ pair w2)) t
reflexivity. Qed. Context `{Monad T}. #[export, program] Instance BeckDistributiveLaw_strength: BeckDistributiveLaw (W ×) T := {| bdist_join_r := strength_join T W; bdist_unit_r := strength_ret T W; bdist_join_l := strength_join_l; bdist_unit_l := strength_ret_l; |}. #[export] Instance: Monad (T ∘ (W ×)) := Monad_Beck. End strength_as_writer_distributive_law. (** * Miscellaneous Properties *) (**********************************************************************) Section Writer_miscellaneous. Context `{Monoid W}. Import Categorical.Monad.Notations. (* This rewrite is useful when proving decoration-traversal compatibility in the binder case. *)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W

forall (F : Type -> Type) (Map_F : Map F), Functor F -> forall (w : W) (A : Type), σ ∘ μ ∘ pair w = map F (μ ∘ pair w) ∘ σ
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W

forall (F : Type -> Type) (Map_F : Map F), Functor F -> forall (w : W) (A : Type), σ ∘ μ ∘ pair w = map F (μ ∘ pair w) ∘ σ
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
w: W
A: Type

σ ∘ μ ∘ pair w = map F (μ ∘ pair w) ∘ σ
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
w: W
A: Type
w': W
x: F A

(σ ∘ μ ∘ pair w) (w', x) = (map F (μ ∘ pair w) ∘ σ) (w', x)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
w: W
A: Type
w': W
x: F A

map F (pair (w ● w')) (id x) = map F (μ ○ pair w) (map F (pair w') x)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
F: Type -> Type
Map_F: Map F
H0: Functor F
w: W
A: Type
w': W
x: F A

(map F (pair (w ● w')) ∘ id) x = (map F (μ ○ pair w) ∘ map F (pair w')) x
now rewrite fun_map_map. Qed.
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W

forall (w : W) (A : Type), incr w ∘ pair Ƶ = pair w
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W

forall (w : W) (A : Type), incr w ∘ pair Ƶ = pair w
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
w: W
A: Type

incr w ∘ pair Ƶ = pair w
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
w: W
A: Type
p: A

(incr w ∘ pair Ƶ) p = (w, p)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
w: W
A: Type
p: A

(w ● Ƶ, p) = (w, p)
W: Type
op: Monoid_op W
unit0: Monoid_unit W
H: Monoid W
w: W
A: Type
p: A

(w, p) = (w, p)
reflexivity. Qed. End Writer_miscellaneous.