Tealeaves.Classes.Kleisli.DecoratedContainerFunctor
From Tealeaves Require Export
Classes.Kleisli.DecoratedFunctor
Classes.Categorical.ContainerFunctor
Classes.Categorical.Comonad (Extract, extract)
Functors.Early.Subset
Functors.Early.Ctxset.
Import ContainerFunctor.Notations.
Import Monoid.Notations.
Import Functor.Notations.
Import Subset.Notations.
Import List.ListNotations.
#[local] Generalizable Variables E T.
Classes.Kleisli.DecoratedFunctor
Classes.Categorical.ContainerFunctor
Classes.Categorical.Comonad (Extract, extract)
Functors.Early.Subset
Functors.Early.Ctxset.
Import ContainerFunctor.Notations.
Import Monoid.Notations.
Import Functor.Notations.
Import Subset.Notations.
Import List.ListNotations.
#[local] Generalizable Variables E T.
Class ToCtxset (E: Type) (F: Type → Type) :=
toctxset: ∀ A: Type, F A → ctxset E A.
#[global] Arguments toctxset {E}%type_scope {F}%function_scope
{ToCtxset} {A}%type_scope _.
toctxset: ∀ A: Type, F A → ctxset E A.
#[global] Arguments toctxset {E}%type_scope {F}%function_scope
{ToCtxset} {A}%type_scope _.
Definition ToSubset_ToCtxset
`{ToCtxset_ET: ToCtxset E T}: ToSubset T :=
fun A ⇒ map (F := subset) extract ∘ toctxset.
Class Compat_ToSubset_ToCtxset (E: Type) (T: Type → Type)
`{ToCtxset_ET: ToCtxset E T}
`{ToSubset_T: ToSubset T}: Prop :=
compat_tosubset_toctxset:
ToSubset_T =
(ToSubset_ToCtxset (ToCtxset_ET := ToCtxset_ET)).
Lemma tosubset_to_toctxset
`{ToCtxset_ET: ToCtxset E T}
`{ToSubset_T: ToSubset T}
`{! Compat_ToSubset_ToCtxset E T}:
∀ (A: Type), tosubset (F := T) (A := A) =
map (F := subset) extract ∘ toctxset.
Proof.
intros.
rewrite compat_tosubset_toctxset.
reflexivity.
Qed.
`{ToCtxset_ET: ToCtxset E T}: ToSubset T :=
fun A ⇒ map (F := subset) extract ∘ toctxset.
Class Compat_ToSubset_ToCtxset (E: Type) (T: Type → Type)
`{ToCtxset_ET: ToCtxset E T}
`{ToSubset_T: ToSubset T}: Prop :=
compat_tosubset_toctxset:
ToSubset_T =
(ToSubset_ToCtxset (ToCtxset_ET := ToCtxset_ET)).
Lemma tosubset_to_toctxset
`{ToCtxset_ET: ToCtxset E T}
`{ToSubset_T: ToSubset T}
`{! Compat_ToSubset_ToCtxset E T}:
∀ (A: Type), tosubset (F := T) (A := A) =
map (F := subset) extract ∘ toctxset.
Proof.
intros.
rewrite compat_tosubset_toctxset.
reflexivity.
Qed.
Definition element_ctx_of `{ToCtxset E T} {A: Type}:
E × A → T A → Prop := fun p t ⇒ toctxset t p.
#[local] Notation "x ∈d t" :=
(element_ctx_of x t) (at level 50): tealeaves_scope.
Lemma element_ctx_of_toctxset `{ToCtxset E T} {A: Type}:
∀ (p:E×A), element_ctx_of p = evalAt p ∘ toctxset.
Proof.
reflexivity.
Qed.
E × A → T A → Prop := fun p t ⇒ toctxset t p.
#[local] Notation "x ∈d t" :=
(element_ctx_of x t) (at level 50): tealeaves_scope.
Lemma element_ctx_of_toctxset `{ToCtxset E T} {A: Type}:
∀ (p:E×A), element_ctx_of p = evalAt p ∘ toctxset.
Proof.
reflexivity.
Qed.
Class DecoratedContainerFunctor
(E: Type) (F: Type → Type)
`{Mapd E F} `{ToCtxset E F} :=
{ dcont_functor :> DecoratedFunctor E F;
dcont_natural :> DecoratedHom E F (ctxset E) (@toctxset E _ _);
dcont_pointwise:
∀ (A B: Type) (t: F A) (f g: E × A → B),
(∀ e a, (e, a) ∈d t → f (e, a) = g (e, a)) →
mapd f t = mapd g t;
}.
(E: Type) (F: Type → Type)
`{Mapd E F} `{ToCtxset E F} :=
{ dcont_functor :> DecoratedFunctor E F;
dcont_natural :> DecoratedHom E F (ctxset E) (@toctxset E _ _);
dcont_pointwise:
∀ (A B: Type) (t: F A) (f g: E × A → B),
(∀ e a, (e, a) ∈d t → f (e, a) = g (e, a)) →
mapd f t = mapd g t;
}.
Class DecoratedContainerTransformation
{E: Type} {F G: Type → Type}
`{Map F} `{Mapd E F} `{ToCtxset E F}
`{Map G} `{Mapd E G} `{ToCtxset E G}
(η: F ⇒ G) :=
{ dcont_trans_natural: Natural η;
dcont_trans_commute:
∀ A, toctxset (F := F) = toctxset (F := G) ∘ η A;
}.
{E: Type} {F G: Type → Type}
`{Map F} `{Mapd E F} `{ToCtxset E F}
`{Map G} `{Mapd E G} `{ToCtxset E G}
(η: F ⇒ G) :=
{ dcont_trans_natural: Natural η;
dcont_trans_commute:
∀ A, toctxset (F := F) = toctxset (F := G) ∘ η A;
}.
Module Notations.
Notation "x ∈d t" :=
(element_ctx_of x t) (at level 50): tealeaves_scope.
End Notations.
Notation "x ∈d t" :=
(element_ctx_of x t) (at level 50): tealeaves_scope.
End Notations.