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.Categorical.Applicative
Classes.Kleisli.TraversableFunctor
Classes.Categorical.TraversableFunctor.(*From Tealeaves Require Import Adapters.CategoricalToKleisli.TraversableFunctor.*)#[local] Generalizable Variablesϕ T G A M F.Import Applicative.Notations.(*(** * Vectors *)(******************************************************************************)Inductive Vector (A : Type) : forall (n : nat), Type :=| Vnil : Vector A 0| Vcons : A -> forall (n : nat), Vector A n -> Vector A (S n). *)#[global] Notation"'VEC' n" := (funA => Vector.t A n) (at level3).
A: Type
Vector.t A 1 -> A
A: Type
Vector.t A 1 -> A
A: Type v: Vector.t A 1
A
A: Type n: nat Heqn: n = 1 v: Vector.t A n
A
A: Type Heqn: 0 = 1
A
A: Type n: nat Heqn: S n = 1 h: A v: Vector.t A n IHv: n = 1 -> A
A
A: Type Heqn: 0 = 1
A
inversion Heqn.
A: Type n: nat Heqn: S n = 1 h: A v: Vector.t A n IHv: n = 1 -> A
A
assumption.Defined.(** ** Properties of vectors *)(******************************************************************************)
B: Type
forallb : Vector.t B 0, b = Vector.nil B
B: Type
forallb : Vector.t B 0, b = Vector.nil B
B: Type b: Vector.t B 0
b = Vector.nil B
B: Type b: Vector.t B 0
Vector.nil B = Vector.nil B
reflexivity.Qed.(** ** Functor instance *)(******************************************************************************)Fixpointmap_Vector (n : nat) {AB : Type} (f : A -> B) (v : VEC n A) : VEC n B :=
match v in Vector.t _ n return Vector.t B n with
| Vector.nil _(*=A*) => Vector.nil B
| Vector.cons _(*=A*) a(*:A*) m(*n = S m*) rest =>
Vector.cons B (f a) m (map_Vector m f rest)
end.#[export] InstanceMap_Vector (n : nat) : Map (VEC n) := @map_Vector n.
forall (n : nat) (A : Type), map id = id
forall (n : nat) (A : Type), map id = id
n: nat A: Type
map id = id
n: nat A: Type v: Vector.t A n
map id v = id v
A: Type
map id (Vector.nil A) = id (Vector.nil A)
A: Type h: A n: nat v: Vector.t A n IHv: map id v = id v
map id (Vector.cons A h n v) =
id (Vector.cons A h n v)
A: Type
map id (Vector.nil A) = id (Vector.nil A)
reflexivity.
A: Type h: A n: nat v: Vector.t A n IHv: map id v = id v
map id (Vector.cons A h n v) =
id (Vector.cons A h n v)
A: Type h: A n: nat v: Vector.t A n IHv: map id v = id v
Vector.cons A (id h) n (map_Vector n id v) =
id (Vector.cons A h n v)
A: Type h: A n: nat v: Vector.t A n IHv: map id v = id v
Vector.cons A h n (map_Vector n (funx : A => x) v) =
Vector.cons A h n v
A: Type h: A n: nat v: Vector.t A n IHv: map id v = id v
map_Vector n (funx : A => x) v = v
apply IHv.Qed.
forall (n : nat) (ABC : Type) (f : A -> B)
(g : B -> C), map g ∘ map f = map (g ∘ f)
forall (n : nat) (ABC : Type) (f : A -> B)
(g : B -> C), map g ∘ map f = map (g ∘ f)
n: nat A, B, C: Type f: A -> B g: B -> C
map g ∘ map f = map (g ∘ f)
n: nat A, B, C: Type f: A -> B g: B -> C v: Vector.t A n
(map g ∘ map f) v = map (g ∘ f) v
A, B, C: Type f: A -> B g: B -> C
(map g ∘ map f) (Vector.nil A) =
map (g ∘ f) (Vector.nil A)
A, B, C: Type f: A -> B g: B -> C h: A n: nat v: Vector.t A n IHv: (map g ∘ map f) v = map (g ∘ f) v
(map g ∘ map f) (Vector.cons A h n v) =
map (g ∘ f) (Vector.cons A h n v)
A, B, C: Type f: A -> B g: B -> C
(map g ∘ map f) (Vector.nil A) =
map (g ∘ f) (Vector.nil A)
reflexivity.
A, B, C: Type f: A -> B g: B -> C h: A n: nat v: Vector.t A n IHv: (map g ∘ map f) v = map (g ∘ f) v
(map g ∘ map f) (Vector.cons A h n v) =
map (g ∘ f) (Vector.cons A h n v)
A, B, C: Type f: A -> B g: B -> C h: A n: nat v: Vector.t A n IHv: (map g ∘ map f) v = map (g ∘ f) v
Vector.cons C (g (f h)) n
(map_Vector n g (map_Vector n f v)) =
Vector.cons C ((g ∘ f) h) n (map_Vector n (g ∘ f) v)
A, B, C: Type f: A -> B g: B -> C h: A n: nat v: Vector.t A n IHv: (map g ∘ map f) v = map (g ∘ f) v
Vector.cons C (g (f h)) n
(map_Vector n g (map_Vector n f v)) =
Vector.cons C ((g ∘ f) h) n (map_Vector n (g ∘ f) v)
A, B, C: Type f: A -> B g: B -> C h: A n: nat v: Vector.t A n IHv: (map g ∘ map f) v = map (g ∘ f) v
map_Vector n g (map_Vector n f v) =
map_Vector n (g ∘ f) v
apply IHv.Qed.#[export] InstanceFunctor_Vector (n : nat) : Functor (VEC n) :=
{| fun_map_id := fun_map_id_Vector n;
fun_map_map := fun_map_map_Vector n;
|}.(** ** Traversable instance *)(******************************************************************************)Fixpointdist_Vector (n : nat) (G : Type -> Type) `{Map G} `{Pure G} `{Mult G}
{A : Type} (v : VEC n (G A)) : G (VEC n A) :=
match v in Vector.t _ n return G (Vector.t A n) with
| Vector.nil _(*=A*) => pure (F := G) (Vector.nil A)
| Vector.cons _(*=A*) a(*:FA*) m(*n = S m*) rest =>
pure (F := G) (Basics.flip (funa => Vector.cons A a m))
<⋆> dist_Vector m G rest
<⋆> a
(* pure (F := G) (fun a => Vector.cons A a m) <⋆> a <⋆> dist_Vector m G rest *)end.#[export] InstanceDist_Vector (n : nat):
ApplicativeDist (VEC n) := @dist_Vector n.Tactic Notation"cleanup_Vector" :=
repeat (change (map_Vector ?n (A := ?x) (B := ?y))
with (map (F := VEC n) (A := x) (B := y)) +
change (dist_Vector ?n?G (A := ?x))
with (dist (VEC n) G (A := x))).Tactic Notation"cleanup_Vector_*" :=
repeat ((change (map_Vector ?n (A := ?x) (B := ?y))
with (map (F := VEC n) (A := x) (B := y)) in *) ||
change (dist_Vector ?n?G (A := ?x))
with (dist (VEC n) G (A := x)) in *).
n: nat
forall (G : Type -> Type) (H1 : Map G) (H2 : Pure G)
(H3 : Mult G),
Applicative G -> Natural (@dist_Vector n G H1 H2 H3)
n: nat
forall (G : Type -> Type) (H1 : Map G) (H2 : Pure G)
(H3 : Mult G),
Applicative G -> Natural (@dist_Vector n G H1 H2 H3)
n: nat G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G
Natural (@dist_Vector n G H1 H2 H3)
n: nat G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G
forall (AB : Type) (f : A -> B),
map f ∘ dist_Vector n G = dist_Vector n G ∘ map f
n: nat G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B
map f ∘ dist_Vector n G = dist_Vector n G ∘ map f
n: nat G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B
map (map f) ∘ dist_Vector n G =
dist_Vector n G ∘ map (map f)
n: nat G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B
map (map f) ○ dist_Vector n G =
dist_Vector n G ○ map (map f)
n: nat G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B v: (VEC n ∘ G) A
map (map f) (dist_Vector n G v) =
dist_Vector n G (map (map f) v)
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B
map (map f) (dist_Vector 0 G (Vector.nil (G A))) =
dist_Vector 0 G (map (map f) (Vector.nil (G A)))
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist_Vector n G v) = dist_Vector n G (map (map f) v)
map (map f)
(dist_Vector (S n) G (Vector.cons (G A) h n v)) =
dist_Vector (S n) G
(map (map f) (Vector.cons (G A) h n v))
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B
map (map f) (dist_Vector 0 G (Vector.nil (G A))) =
dist_Vector 0 G (map (map f) (Vector.nil (G A)))
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B
map (map f) (pure (Vector.nil A)) =
pure (Vector.nil B)
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B
(map (map f) ∘ pure) (Vector.nil A) =
pure (Vector.nil B)
apply (app_pure_natural (G := G)).
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist_Vector n G v) = dist_Vector n G (map (map f) v)
map (map f)
(dist_Vector (S n) G (Vector.cons (G A) h n v)) =
dist_Vector (S n) G
(map (map f) (Vector.cons (G A) h n v))
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist_Vector n G v) = dist_Vector n G (map (map f) v)
map (map f)
(pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist_Vector n G v <⋆> h) =
pure (Basics.flip (funa : B => Vector.cons B a n)) <⋆>
dist_Vector n G (map_Vector n (map f) v) <⋆> map f h
(* LHS *)
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist_Vector n G v) = dist_Vector n G (map (map f) v)
map (compose (map f))
(pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist_Vector n G v) <⋆> h =
pure (Basics.flip (funa : B => Vector.cons B a n)) <⋆>
dist_Vector n G (map_Vector n (map f) v) <⋆> map f h
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist_Vector n G v) = dist_Vector n G (map (map f) v)
map (compose (compose (map f)))
(pure (Basics.flip (funa : A => Vector.cons A a n))) <⋆>
dist_Vector n G v <⋆> h =
pure (Basics.flip (funa : B => Vector.cons B a n)) <⋆>
dist_Vector n G (map_Vector n (map f) v) <⋆> map f h
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist_Vector n G v) = dist_Vector n G (map (map f) v)
pure
(compose (map f)
∘ Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist_Vector n G v <⋆> h =
pure (Basics.flip (funa : B => Vector.cons B a n)) <⋆>
dist_Vector n G (map_Vector n (map f) v) <⋆> map f h
(* RHS *)
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist VEC n G v) = dist VEC n G (map (map f) v)
pure
(compose (map f)
∘ Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G v <⋆> h =
pure (Basics.flip (funa : B => Vector.cons B a n)) <⋆>
dist VEC n G (map (map f) v) <⋆> map f h
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist VEC n G v) = dist VEC n G (map (map f) v)
pure
(compose (map f)
∘ Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G v <⋆> h =
pure (Basics.flip (funa : B => Vector.cons B a n)) <⋆>
map (map f) (dist VEC n G v) <⋆> map f h
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist VEC n G v) = dist VEC n G (map (map f) v)
pure
(compose (map f)
∘ Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G v <⋆> h =
map (precompose f)
(pure (Basics.flip (funa : B => Vector.cons B a n)) <⋆>
map (map f) (dist VEC n G v)) <⋆> h
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist VEC n G v) = dist VEC n G (map (map f) v)
pure
(compose (map f)
∘ Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G v <⋆> h =
map (precompose f)
(map (precompose (map f))
(pure
(Basics.flip (funa : B => Vector.cons B a n))) <⋆>
dist VEC n G v) <⋆> h
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist VEC n G v) = dist VEC n G (map (map f) v)
pure
(compose (map f)
∘ Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G v <⋆> h =
map (compose (precompose f))
(map (precompose (map f))
(pure
(Basics.flip (funa : B => Vector.cons B a n)))) <⋆>
dist VEC n G v <⋆> h
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist VEC n G v) = dist VEC n G (map (map f) v)
pure
(compose (map f)
∘ Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G v <⋆> h =
(map (compose (precompose f))
∘ map (precompose (map f)))
(pure
(Basics.flip (funa0 : B => Vector.cons B a0 n))) <⋆>
dist VEC n G v <⋆> h
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist VEC n G v) = dist VEC n G (map (map f) v)
pure
(compose (map f)
∘ Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G v <⋆> h =
map (compose (precompose f) ∘ precompose (map f))
(pure
(Basics.flip (funa0 : B => Vector.cons B a0 n))) <⋆>
dist VEC n G v <⋆> h
G: Type -> Type H1: Map G H2: Pure G H3: Mult G H: Applicative G A, B: Type f: A -> B h: G A n: nat v: Vector.t (G A) n IHv: map (map f) (dist VEC n G v) = dist VEC n G (map (map f) v)
pure
(compose (map f)
∘ Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G v <⋆> h =
pure
((compose (precompose f) ∘ precompose (map f))
(Basics.flip (funa0 : B => Vector.cons B a0 n))) <⋆>
dist VEC n G v <⋆> h
reflexivity.Qed.
n: nat
forall (G1G2 : Type -> Type) (H1 : Map G1)
(H3 : Mult G1) (H2 : Pure G1) (H4 : Map G2)
(H6 : Mult G2) (H5 : Pure G2)
(ϕ : forallA : Type, G1 A -> G2 A),
ApplicativeMorphism G1 G2 ϕ ->
forallA : Type,
dist VEC n G2 ∘ map (ϕ A) =
ϕ (VEC n A) ∘ dist VEC n G1
n: nat
forall (G1G2 : Type -> Type) (H1 : Map G1)
(H3 : Mult G1) (H2 : Pure G1) (H4 : Map G2)
(H6 : Mult G2) (H5 : Pure G2)
(ϕ : forallA : Type, G1 A -> G2 A),
ApplicativeMorphism G1 G2 ϕ ->
forallA : Type,
dist VEC n G2 ∘ map (ϕ A) =
ϕ (VEC n A) ∘ dist VEC n G1
n: nat G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type
dist VEC n G2 ∘ map (ϕ A) =
ϕ (VEC n A) ∘ dist VEC n G1
n: nat G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type
dist VEC n G2 ○ map (ϕ A) =
ϕ (Vector.t A n) ○ dist VEC n G1
n: nat G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type v: Vector.t (G1 A) n
dist VEC n G2 (map (ϕ A) v) =
ϕ (Vector.t A n) (dist VEC n G1 v)
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type h: G1 A n: nat v: Vector.t (G1 A) n IHv: dist VEC n G2 (map (ϕ A) v) = ϕ (Vector.t A n) (dist VEC n G1 v)
dist VEC (S n) G2
(map (ϕ A) (Vector.cons (G1 A) h n v)) =
ϕ (Vector.t A (S n))
(dist VEC (S n) G1 (Vector.cons (G1 A) h n v))
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type
pure (Vector.nil A) =
ϕ (Vector.t A 0) (pure (Vector.nil A))
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type
pure (Vector.nil A) = pure (Vector.nil A)
reflexivity.
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type h: G1 A n: nat v: Vector.t (G1 A) n IHv: dist VEC n G2 (map (ϕ A) v) = ϕ (Vector.t A n) (dist VEC n G1 v)
dist VEC (S n) G2
(map (ϕ A) (Vector.cons (G1 A) h n v)) =
ϕ (Vector.t A (S n))
(dist VEC (S n) G1 (Vector.cons (G1 A) h n v))
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type h: G1 A n: nat v: Vector.t (G1 A) n IHv: dist VEC n G2 (map (ϕ A) v) = ϕ (Vector.t A n) (dist VEC n G1 v)
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist_Vector n G2 (map_Vector n (ϕ A) v) <⋆> ϕ A h =
ϕ (Vector.t A (S n))
(pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist_Vector n G1 v <⋆> h)
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type h: G1 A n: nat v: Vector.t (G1 A) n IHv: dist VEC n G2 (map (ϕ A) v) = ϕ (Vector.t A n) (dist VEC n G1 v)
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G2 (map (ϕ A) v) <⋆> ϕ A h =
ϕ (Vector.t A (S n))
(pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G1 v <⋆> h)
(* LHS *)
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type h: G1 A n: nat v: Vector.t (G1 A) n IHv: dist VEC n G2 (map (ϕ A) v) = ϕ (Vector.t A n) (dist VEC n G1 v)
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
ϕ (Vector.t A n) (dist VEC n G1 v) <⋆> ϕ A h =
ϕ (Vector.t A (S n))
(pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G1 v <⋆> h)
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type h: G1 A n: nat v: Vector.t (G1 A) n IHv: dist VEC n G2 (map (ϕ A) v) = ϕ (Vector.t A n) (dist VEC n G1 v) appmor_app_F: Applicative G1 appmor_app_G: Applicative G2 appmor_natural: forall (AB : Type) (f : A -> B)
(x : G1 A),
ϕ B (map f x) = map f (ϕ A x) appmor_pure: forall (A : Type) (a : A),
ϕ A (pure a) = pure a appmor_mult: forall (AB : Type) (x : G1 A)
(y : G1 B),
ϕ (A * B) (x ⊗ y) = ϕ A x ⊗ ϕ B y
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
ϕ (Vector.t A n) (dist VEC n G1 v) <⋆> ϕ A h =
ϕ (Vector.t A (S n))
(pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G1 v <⋆> h)
(* RHS *)
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type h: G1 A n: nat v: Vector.t (G1 A) n IHv: dist VEC n G2 (map (ϕ A) v) =
ϕ (Vector.t A n) (dist VEC n G1 v) appmor_app_F: Applicative G1 appmor_app_G: Applicative G2 appmor_natural: forall (AB : Type) (f : A -> B)
(x : G1 A),
ϕ B (map f x) = map f (ϕ A x) appmor_pure: forall (A : Type) (a : A),
ϕ A (pure a) = pure a appmor_mult: forall (AB : Type) (x : G1 A)
(y : G1 B),
ϕ (A * B) (x ⊗ y) = ϕ A x ⊗ ϕ B y
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
ϕ (Vector.t A n) (dist VEC n G1 v) <⋆>
ϕ A h =
ϕ (A -> Vector.t A (S n))
(pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n G1 v) <⋆>
ϕ A h
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type h: G1 A n: nat v: Vector.t (G1 A) n IHv: dist VEC n G2 (map (ϕ A) v) =
ϕ (Vector.t A n) (dist VEC n G1 v) appmor_app_F: Applicative G1 appmor_app_G: Applicative G2 appmor_natural: forall (AB : Type) (f : A -> B)
(x : G1 A),
ϕ B (map f x) = map f (ϕ A x) appmor_pure: forall (A : Type) (a : A),
ϕ A (pure a) = pure a appmor_mult: forall (AB : Type) (x : G1 A)
(y : G1 B),
ϕ (A * B) (x ⊗ y) = ϕ A x ⊗ ϕ B y
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
ϕ (Vector.t A n) (dist VEC n G1 v) <⋆>
ϕ A h =
ϕ (Vector.t A n -> A -> Vector.t A (S n))
(pure (Basics.flip (funa : A => Vector.cons A a n))) <⋆>
ϕ (Vector.t A n) (dist VEC n G1 v) <⋆>
ϕ A h
G1, G2: Type -> Type H1: Map G1 H3: Mult G1 H2: Pure G1 H4: Map G2 H6: Mult G2 H5: Pure G2 ϕ: forallA : Type, G1 A -> G2 A H: ApplicativeMorphism G1 G2 ϕ A: Type h: G1 A n: nat v: Vector.t (G1 A) n IHv: dist VEC n G2 (map (ϕ A) v) =
ϕ (Vector.t A n) (dist VEC n G1 v) appmor_app_F: Applicative G1 appmor_app_G: Applicative G2 appmor_natural: forall (AB : Type) (f : A -> B)
(x : G1 A),
ϕ B (map f x) = map f (ϕ A x) appmor_pure: forall (A : Type) (a : A),
ϕ A (pure a) = pure a appmor_mult: forall (AB : Type) (x : G1 A)
(y : G1 B),
ϕ (A * B) (x ⊗ y) = ϕ A x ⊗ ϕ B y
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
ϕ (Vector.t A n) (dist VEC n G1 v) <⋆>
ϕ A h =
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
ϕ (Vector.t A n) (dist VEC n G1 v) <⋆>
ϕ A h
reflexivity.Qed.
n: nat
forallA : Type, dist VEC n (funA0 : Type => A0) = id
n: nat
forallA : Type, dist VEC n (funA0 : Type => A0) = id
n: nat A: Type
dist VEC n (funA : Type => A) = id
n: nat A: Type v: Vector.t A n
dist VEC n (funA : Type => A) v = id v
A: Type
dist VEC 0 (funA : Type => A) (Vector.nil A) =
id (Vector.nil A)
A: Type h: A n: nat v: Vector.t A n IHv: dist VEC n (funA : Type => A) v = id v
dist VEC (S n) (funA : Type => A)
(Vector.cons A h n v) = id (Vector.cons A h n v)
A: Type
dist VEC 0 (funA : Type => A) (Vector.nil A) =
id (Vector.nil A)
A: Type
pure (Vector.nil A) = id (Vector.nil A)
reflexivity.
A: Type h: A n: nat v: Vector.t A n IHv: dist VEC n (funA : Type => A) v = id v
dist VEC (S n) (funA : Type => A)
(Vector.cons A h n v) = id (Vector.cons A h n v)
A: Type h: A n: nat v: Vector.t A n IHv: dist VEC n (funA : Type => A) v = id v
pure (Basics.flip (funa : A => Vector.cons A a n))
(dist_Vector n (funA : Type => A) v) h =
id (Vector.cons A h n v)
A: Type h: A n: nat v: Vector.t A n IHv: dist VEC n (funA : Type => A) v = id v
pure (Basics.flip (funa : A => Vector.cons A a n))
(dist VEC n (funA : Type => A) v) h =
id (Vector.cons A h n v)
(* LHS *)
A: Type h: A n: nat v: Vector.t A n IHv: dist VEC n (funA : Type => A) v = id v
pure (Basics.flip (funa : A => Vector.cons A a n))
(id v) h = id (Vector.cons A h n v)
reflexivity.Qed.
n: nat
forall (G1 : Type -> Type) (H1 : Map G1)
(H2 : Pure G1) (H3 : Mult G1),
Applicative G1 ->
forall (G2 : Type -> Type) (H5 : Map G2)
(H6 : Pure G2) (H7 : Mult G2),
Applicative G2 ->
forallA : Type,
dist VEC n (G1 ∘ G2) =
map (dist VEC n G2) ∘ dist VEC n G1
n: nat
forall (G1 : Type -> Type) (H1 : Map G1)
(H2 : Pure G1) (H3 : Mult G1),
Applicative G1 ->
forall (G2 : Type -> Type) (H5 : Map G2)
(H6 : Pure G2) (H7 : Mult G2),
Applicative G2 ->
forallA : Type,
dist VEC n (G1 ∘ G2) =
map (dist VEC n G2) ∘ dist VEC n G1
n: nat G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type
dist VEC n (G1 ∘ G2) =
map (dist VEC n G2) ∘ dist VEC n G1
n: nat G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type
dist VEC n (G1 ∘ G2) =
map (dist VEC n G2) ○ dist VEC n G1
n: nat G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type v: Vector.t ((G1 ∘ G2) A) n
dist VEC n (G1 ∘ G2) v =
map (dist VEC n G2) (dist VEC n G1 v)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
dist VEC (S n) (G1 ∘ G2)
(Vector.cons ((G1 ∘ G2) A) h n v) =
map (dist VEC (S n) G2)
(dist VEC (S n) G1 (Vector.cons ((G1 ∘ G2) A) h n v))
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type
pure (pure (Vector.nil A)) =
pure (dist VEC 0 G2 (Vector.nil (G2 A)))
reflexivity.
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
dist VEC (S n) (G1 ∘ G2)
(Vector.cons ((G1 ∘ G2) A) h n v) =
map (dist VEC (S n) G2)
(dist VEC (S n) G1 (Vector.cons ((G1 ∘ G2) A) h n v))
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist_Vector n (G1 ∘ G2) v <⋆> h =
map (dist VEC (S n) G2)
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist_Vector n G1 v <⋆> h)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
dist VEC n (G1 ∘ G2) v <⋆> h =
map (dist VEC (S n) G2)
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v <⋆> h)
(* LHS *)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
pure (Basics.flip (funa : A => Vector.cons A a n)) <⋆>
map (dist VEC n G2) (dist VEC n G1 v) <⋆> h =
map (dist VEC (S n) G2)
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v <⋆> h)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
pure
(pure (Basics.flip (funa : A => Vector.cons A a n))) <⋆>
map (dist VEC n G2) (dist VEC n G1 v) <⋆> h =
map (dist VEC (S n) G2)
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v <⋆> h)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
map (ap G2)
(pure
(pure
(Basics.flip (funa : A => Vector.cons A a n))) <⋆>
map (dist VEC n G2) (dist VEC n G1 v)) <⋆> h =
map (dist VEC (S n) G2)
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v <⋆> h)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
map (ap G2)
(map (ap G2)
(pure
(pure
(Basics.flip
(funa : A => Vector.cons A a n)))) <⋆>
map (dist VEC n G2) (dist VEC n G1 v)) <⋆> h =
map (dist VEC (S n) G2)
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v <⋆> h)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
map (ap G2)
(map (precompose (dist VEC n G2))
(map (ap G2)
(pure
(pure
(Basics.flip
(funa : A => Vector.cons A a n))))) <⋆>
dist VEC n G1 v) <⋆> h =
map (dist VEC (S n) G2)
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v <⋆> h)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
map (compose (ap G2))
(map (precompose (dist VEC n G2))
(map (ap G2)
(pure
(pure
(Basics.flip
(funa : A => Vector.cons A a n)))))) <⋆>
dist VEC n G1 v <⋆> h =
map (dist VEC (S n) G2)
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v <⋆> h)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
map (compose (ap G2))
(map (precompose (dist VEC n G2))
(map (ap G2)
(pure
(pure
(Basics.flip
(funa : A => Vector.cons A a n)))))) <⋆>
dist VEC n G1 v <⋆> h =
map (compose (dist VEC (S n) G2))
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v) <⋆> h
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
map (compose (ap G2))
((map (precompose (dist VEC n G2)) ∘ map (ap G2))
(pure
(pure
(Basics.flip
(funa0 : A => Vector.cons A a0 n))))) <⋆>
dist VEC n G1 v <⋆> h =
map (compose (dist VEC (S n) G2))
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v) <⋆> h
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
map (compose (ap G2))
(map (precompose (dist VEC n G2) ∘ ap G2)
(pure
(pure
(Basics.flip
(funa0 : A => Vector.cons A a0 n))))) <⋆>
dist VEC n G1 v <⋆> h =
map (compose (dist VEC (S n) G2))
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v) <⋆> h
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
(map (compose (ap G2))
∘ map (precompose (dist VEC n G2) ∘ ap G2))
(pure
(pure
(Basics.flip
(funa0 : A => Vector.cons A a0 n)))) <⋆>
dist VEC n G1 v <⋆> h =
map (compose (dist VEC (S n) G2))
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v) <⋆> h
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
map
(compose (ap G2)
∘ (precompose (dist VEC n G2) ∘ ap G2))
(pure
(pure
(Basics.flip
(funa0 : A => Vector.cons A a0 n)))) <⋆>
dist VEC n G1 v <⋆> h =
map (compose (dist VEC (S n) G2))
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v) <⋆> h
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
pure
((compose (ap G2)
∘ (precompose (dist VEC n G2) ∘ ap G2))
(pure
(Basics.flip
(funa0 : A => Vector.cons A a0 n)))) <⋆>
dist VEC n G1 v <⋆> h =
map (compose (dist VEC (S n) G2))
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v) <⋆> h
(* RHS *)
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
pure
((compose (ap G2)
∘ (precompose (dist VEC n G2) ∘ ap G2))
(pure
(Basics.flip
(funa0 : A => Vector.cons A a0 n)))) <⋆>
dist VEC n G1 v <⋆> h =
map (compose (compose (dist VEC (S n) G2)))
(pure
(Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n))) <⋆>
dist VEC n G1 v <⋆> h
G1: Type -> Type H1: Map G1 H2: Pure G1 H3: Mult G1 H: Applicative G1 G2: Type -> Type H5: Map G2 H6: Pure G2 H7: Mult G2 H0: Applicative G2 A: Type h: (G1 ∘ G2) A n: nat v: Vector.t ((G1 ∘ G2) A) n IHv: dist VEC n (G1 ∘ G2) v = map (dist VEC n G2) (dist VEC n G1 v)
pure
((compose (ap G2)
∘ (precompose (dist VEC n G2) ∘ ap G2))
(pure
(Basics.flip
(funa0 : A => Vector.cons A a0 n)))) <⋆>
dist VEC n G1 v <⋆> h =
pure
(compose (dist VEC (S n) G2)
∘ Basics.flip
(funa : G2 A => Vector.cons (G2 A) a n)) <⋆>
dist VEC n G1 v <⋆> h