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
Classes.Functor.#[local] Set Implicit Arguments.#[local] Generalizable VariablesX Y A B F i o.(** * The [Store] functor *)(**********************************************************************)Sectionfix_parameters.Context
{AB: Type}.InductiveStoreC: Type :=
| MkStore: (B -> C) -> A -> Store C.(** ** Functor Instance *)(********************************************************************)Definitionmap_Store `{f: X -> Y} (c: Store X): Store Y :=
match c with
| MkStore mk a => MkStore (f ∘ mk) a
end.#[export] InstanceMap_Batch: Map Store := @map_Store.#[export, program] InstanceFunctor_Batch: Functor Store.Solve All Obligations with (intros; now ext [?]).Endfix_parameters.(** ** <<Store>> as a Parameterized Comonad *)(**********************************************************************)Sectionparameterized.#[local] Unset Implicit Arguments.Definitionextract_Store {AB: Type} (s: @Store A A B): B :=
match s with
| MkStore mk b => mk b
end.Definitioncojoin_Store {ACX: Type} (B: Type)
(s: @Store A C X): @Store A B (@Store B C X) :=
match s with
| MkStore mk a => MkStore (funb => MkStore mk b) a
end.Context
(ABCX: Type).
now ext [i1 mk].Qed.Endparameterized.(** ** A Representation Lemma *)(**********************************************************************)DefinitionrunStore `{Map F} `(f: A -> F B):
forallX, Store X -> F X :=
funA '(MkStore mk a) => map mk (f a).DefinitionrunStore_inv `{Map F}
`(run: forallX, @Store A B X -> F X): A -> F B :=
fun (a: A) => run B (MkStore id a).Sectionrepresentation.Context
`{Functor F}.
F: Type -> Type Map_F: Map F H: Functor F
forall (io : Type) (f : i -> F o),
runStore_inv (runStore f) = f
F: Type -> Type Map_F: Map F H: Functor F
forall (io : Type) (f : i -> F o),
runStore_inv (runStore f) = f
F: Type -> Type Map_F: Map F H: Functor F i, o: Type f: i -> F o
runStore_inv (runStore f) = f
F: Type -> Type Map_F: Map F H: Functor F i, o: Type f: i -> F o i1: i
runStore_inv (runStore f) i1 = f i1
F: Type -> Type Map_F: Map F H: Functor F i, o: Type f: i -> F o i1: i
map id (f i1) = f i1
nowrewrite (fun_map_id).Qed.
F: Type -> Type Map_F: Map F H: Functor F
forall (AB : Type)
(ϕ : forallX : Type, Store X -> F X),
Natural ϕ -> runStore (runStore_inv ϕ) = ϕ
F: Type -> Type Map_F: Map F H: Functor F
forall (AB : Type)
(ϕ : forallX : Type, Store X -> F X),
Natural ϕ -> runStore (runStore_inv ϕ) = ϕ
F: Type -> Type Map_F: Map F H: Functor F A, B: Type ϕ: forallX : Type, Store X -> F X H0: Natural ϕ
runStore (runStore_inv ϕ) = ϕ
F: Type -> Type Map_F: Map F H: Functor F A, B: Type ϕ: forallX : Type, Store X -> F X H0: Natural ϕ
(fun (A0 : Type) '(MkStore mk a) =>
map mk (ϕ B (MkStore id a))) = ϕ
F: Type -> Type Map_F: Map F H: Functor F A, B: Type ϕ: forallX : Type, Store X -> F X H0: Natural ϕ X: Type mk: B -> X a: A
map mk (ϕ B (MkStore id a)) = ϕ X (MkStore mk a)
F: Type -> Type Map_F: Map F H: Functor F A, B: Type ϕ: forallX : Type, Store X -> F X H0: Natural ϕ X: Type mk: B -> X a: A
(map mk ∘ ϕ B) (MkStore id a) = ϕ X (MkStore mk a)