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
Functors.Early.Subset.From Coq Require Import
Relations.Relation_Definitions
Classes.Morphisms.Import Monoid.Notations.Import Functor.Notations.Import Subset.Notations.#[local] Generalizable VariablesF T A.#[local] Arguments map F%function_scope {Map}
{A B}%type_scope f%function_scope _.(** * Container-Like Functors *)(**********************************************************************)(** ** Operation <<tosubset>> and <<x ∈ ->>*)(**********************************************************************)ClassToSubset (F: Type -> Type) :=
tosubset: F ⇒ subset.#[global] Arguments tosubset {F}%function_scope
{ToSubset} {A}%type_scope.Definitionelement_of `{ToSubset F} {A: Type}:
A -> F A -> Prop := funat => tosubset t a.
F: Type -> Type H: ToSubset F A: Type
foralla : A, element_of a = evalAt a ∘ tosubset
F: Type -> Type H: ToSubset F A: Type
foralla : A, element_of a = evalAt a ∘ tosubset
reflexivity.Qed.#[local] Notation"x ∈ t" :=
(element_of x t) (at level50): tealeaves_scope.(** ** Typeclass *)(**********************************************************************)ClassContainerFunctor
(F: Type -> Type)
`{Map F} `{ToSubset F} :=
{ cont_natural :> Natural (@tosubset F _);
cont_functor :> Functor F;
cont_pointwise: forall (AB: Type) (t: F A) (fg: A -> B),
(foralla, a ∈ t -> f a = g a) -> map F f t = map F g t;
}.(** ** Homomorphisms of Container-Like Functors *)(**********************************************************************)ClassContainerTransformation
{FG: Type -> Type}
`{Map F} `{ToSubset F}
`{Map G} `{ToSubset G}
(η: F ⇒ G) :=
{ cont_trans_natural: Natural η;
cont_trans_commute:
forallA, tosubset (F := F) = tosubset (F := G) ∘ η A;
}.(** * Container Instance for <<subset>> *)(**********************************************************************)SectionContainer_subset.InstanceToSubset_set: ToSubset subset :=
fun (A: Type) (s: subset A) => s.
Natural (@tosubset subset ToSubset_set)
Natural (@tosubset subset ToSubset_set)
forall (AB : Type) (f : A -> B),
map subset f ∘ tosubset = tosubset ∘ map subset f
A, B: Type f: A -> B
map subset f ∘ tosubset = tosubset ∘ map subset f
A, B: Type f: A -> B S: A -> Prop b: B
(map subset f ∘ tosubset) S b =
(tosubset ∘ map subset f) S b
reflexivity.Qed.
forall (AB : Type) (t : A -> Prop) (fg : A -> B),
(foralla : A, a ∈ t -> f a = g a) ->
map subset f t = map subset g t
forall (AB : Type) (t : A -> Prop) (fg : A -> B),
(foralla : A, a ∈ t -> f a = g a) ->
map subset f t = map subset g t
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a
map subset f t = map subset g t
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B
map subset f t b = map subset g t b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B
(existsa : A, t a /\ f a = b) =
(existsa : A, t a /\ g a = b)
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B
(existsa : A, t a /\ f a = b) ->
existsa : A, t a /\ g a = b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B
(existsa : A, t a /\ g a = b) ->
existsa : A, t a /\ f a = b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B H0: existsa : A, t a /\ f a = b
existsa : A, t a /\ g a = b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B
(existsa : A, t a /\ g a = b) ->
existsa : A, t a /\ f a = b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a x: A H0: t x
existsa : A, t a /\ g a = f x
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B
(existsa : A, t a /\ g a = b) ->
existsa : A, t a /\ f a = b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a x: A H0: t x
existsa : A, t a /\ g a = g x
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a x: A H0: t x a: A
x ∈ t
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B
(existsa : A, t a /\ g a = b) ->
existsa : A, t a /\ f a = b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a x: A H0: t x a: A
x ∈ t
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B
(existsa : A, t a /\ g a = b) ->
existsa : A, t a /\ f a = b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B
(existsa : A, t a /\ g a = b) ->
existsa : A, t a /\ f a = b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a b: B H0: existsa : A, t a /\ g a = b
existsa : A, t a /\ f a = b
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a x: A H0: t x
existsa : A, t a /\ f a = g x
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a x: A H0: t x
existsa : A, t a /\ f a = f x
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a x: A H0: t x a: A
x ∈ t
A, B: Type t: A -> Prop f, g: A -> B H: foralla : A, a ∈ t -> f a = g a x: A H0: t x a: A
x ∈ t
auto.Qed.InstanceContainerFunctor_subset: ContainerFunctor subset :=
{| cont_pointwise := subset_pointwise;
|}.EndContainer_subset.(** * Basic Properties of Containers *)(**********************************************************************)Sectionsetlike_functor_theory.Context
(F: Type -> Type)
`{ContainerFunctor F}
{A B: Type}.Implicit Types (t: F A) (b: B) (a: A) (fg: A -> B).(** ** Interaction between (∈) and <<map>> *)(********************************************************************)(** Naturality relates elements before and after a map. *)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type
foralltfb,
b ∈ map F f t <-> (existsa, a ∈ t /\ f a = b)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type
foralltfb,
b ∈ map F f t <-> (existsa, a ∈ t /\ f a = b)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> B b: B
b ∈ map F f t <-> (existsa, a ∈ t /\ f a = b)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> B b: B
(element_of b ∘ map F f) t <->
(existsa, a ∈ t /\ f a = b)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> B b: B
(evalAt b ∘ tosubset ∘ map F f) t <->
(existsa, a ∈ t /\ f a = b)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> B b: B
(evalAt b ∘ (tosubset ∘ map F f)) t <->
(existsa, a ∈ t /\ f a = b)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> B b: B
(evalAt b ∘ (tosubset ∘ map F f)) t <->
(existsa, tosubset t a /\ f a = b)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> B b: B
(evalAt b ∘ (map subset f ∘ tosubset)) t <->
(existsa, tosubset t a /\ f a = b)
reflexivity.Qed.(** This next property says that applying <<f>> (or on the right-hand side, appling <<map f>>) is monotone with respect to the <<∈>> relation. *)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type
foralltfa, a ∈ t -> f a ∈ map F f t
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type
foralltfa, a ∈ t -> f a ∈ map F f t
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> B a: A
a ∈ t -> f a ∈ map F f t
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> B a: A
a ∈ t -> existsa0, a0 ∈ t /\ f a0 = f a
nowexistsa.Qed.(** ** Respectfulness Conditions *)(********************************************************************)(** Renaming to keep consistent name scheme *)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type
foralltfg,
(foralla, a ∈ t -> f a = g a) ->
map F f t = map F g t
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type
foralltfg,
(foralla, a ∈ t -> f a = g a) ->
map F f t = map F g t
apply (cont_pointwise (F := F)).Qed.
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type
forallt (f : A -> A),
(foralla, a ∈ t -> f a = a) -> map F f t = t
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type
forallt (f : A -> A),
(foralla, a ∈ t -> f a = a) -> map F f t = t
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> A H2: foralla, a ∈ t -> f a = a
map F f t = t
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f: A -> A H2: foralla, a ∈ t -> f a = a
map F f t = map F id t
nowapply (cont_pointwise (F := F)).Qed.Endsetlike_functor_theory.(** ** Properness Conditions *)(**********************************************************************)Definitionpointwise_equal_on
(F: Type -> Type) {AB} `{ToSubset F}:
F A -> relation (A -> B) :=
funtfg => (foralla: A, a ∈ t -> f a = g a).Definitionrespectively_equal_at {AB}:
A -> A -> relation (A -> B) :=
fun (a1a2: A) (fg: A -> B) => f a1 = g a2.Definitionequal_at {AB}: A -> relation (A -> B) :=
fun (a: A) (fg: A -> B) => f a = g a.Definitioninjective_relation {AB}
(R: relation A) (R': relation B): relation (A -> B) :=
funfg => foralla1a2: A, R' (f a1) (g a2) -> R a1 a2.Infix"<++" := injective_relation (at level55).Definitionrigid_relation {AB}
(R: relation A) (R': relation B): relation (A -> B) :=
funfg => foralla1a2: A, R' (f a1) (g a2) <-> R a1 a2.Infix"<++>" := rigid_relation (at level55).
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F
forall (AB : Type) (t : F A),
Proper (pointwise_equal_on F t ==> equal_at t) (map F)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F
forall (AB : Type) (t : F A),
Proper (pointwise_equal_on F t ==> equal_at t) (map F)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A
Proper (pointwise_equal_on F t ==> equal_at t) (map F)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A
(pointwise_equal_on F t ==> equal_at t)%signature
(map F) (map F)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f, g: A -> B Hpw: pointwise_equal_on F t f g
equal_at t (map F f) (map F g)
F: Type -> Type H: Map F H0: ToSubset F H1: ContainerFunctor F A, B: Type t: F A f, g: A -> B Hpw: foralla : A, a ∈ t -> f a = g a
map F f t = map F g t
nowapply cont_pointwise.Qed.(** * Quantification over Elements (<<Forall>>, <<Forany>>) *)(* These are not the best combinators to use, it's typically easier to reason when Forall is defined in terms of mapReduce *)(**********************************************************************)Sectionquantification.Context `{ContainerFunctor T}.DefinitionForall_elt `(P: A -> Prop) (t: T A): Prop :=
forall (a: A), a ∈ t -> P a.DefinitionForany_elt `(P: A -> Prop) (t :T A): Prop :=
exists (a: A), a ∈ t /\ P a.Endquantification.(** * Notations *)(**********************************************************************)ModuleNotations.Notation"x ∈ t" :=
(element_of x t) (at level50): tealeaves_scope.EndNotations.