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 Import
Classes.Kleisli.Theory.TraversableFunctor
Classes.Categorical.ApplicativeCommutativeIdempotent
Functors.Diagonal.Import List.ListNotations.Import Applicative.Notations.(** * Examples of Commutative-Idempotent-Traversable Homomorphisms *)(**********************************************************************)Sectionci_traversable_hom_examples.Context
`{G: Type -> Type} `{Map G} `{Mult G} `{Pure G}
`{! ApplicativeCommutativeIdempotent G}.(** ** Traverse Commutes with List Reversal *)(********************************************************************)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B l: list A
map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B l: list A
map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
map (List.rev (A:=B)) (traverse f []) =
traverse f (List.rev [])
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
map (List.rev (A:=B)) (traverse f (a :: l)) =
traverse f (List.rev (a :: l))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
map (List.rev (A:=B)) (traverse f []) =
traverse f (List.rev [])
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
map (List.rev (A:=B)) (pure []) = pure []
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
pure (List.rev []) = pure []
reflexivity.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
map (List.rev (A:=B)) (traverse f (a :: l)) =
traverse f (List.rev (a :: l))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
map (List.rev (A:=B))
(pure cons <⋆> f a <⋆> traverse f l) =
traverse f (List.rev (a :: l))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
map (compose (List.rev (A:=B))) (pure cons <⋆> f a) <⋆>
traverse f l = traverse f (List.rev (a :: l))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
map (compose (compose (List.rev (A:=B)))) (pure cons) <⋆>
f a <⋆> traverse f l = traverse f (List.rev (a :: l))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l = traverse f (List.rev (a :: l))
(* rhs *)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l = traverse f (List.rev l ++ [a])
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
pure (app (A:=B)) <⋆> traverse f (List.rev l) <⋆>
traverse f [a]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
pure (app (A:=B)) <⋆>
map (List.rev (A:=B)) (traverse f l) <⋆>
traverse f [a]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
map (precompose (List.rev (A:=B))) (pure (app (A:=B))) <⋆>
traverse f l <⋆> traverse f [a]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
pure (precompose (List.rev (A:=B)) (app (A:=B))) <⋆>
traverse f l <⋆> traverse f [a]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
pure (precompose (List.rev (A:=B)) (app (A:=B))) <⋆>
traverse f l <⋆> traverse f (ret a)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
pure (precompose (List.rev (A:=B)) (app (A:=B))) <⋆>
traverse f l <⋆> map ret (f a)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
map (precompose ret)
(pure (precompose (List.rev (A:=B)) (app (A:=B))) <⋆>
traverse f l) <⋆> f a
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
map (compose (precompose ret))
(pure (precompose (List.rev (A:=B)) (app (A:=B)))) <⋆>
traverse f l <⋆> f a
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
pure
(precompose ret
∘ precompose (List.rev (A:=B)) (app (A:=B))) <⋆>
traverse f l <⋆> f a
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
map flip
(pure
(precompose ret
∘ precompose (List.rev (A:=B)) (app (A:=B)))) <⋆>
f a <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map (List.rev (A:=B)) (traverse f l) =
traverse f (List.rev l)
pure (compose (List.rev (A:=B)) ∘ cons) <⋆> f a <⋆>
traverse f l =
pure
(flip
(precompose ret
∘ precompose (List.rev (A:=B)) (app (A:=B)))) <⋆>
f a <⋆> traverse f l
fequal.Qed.(** ** "Duplicate First Element" *)(********************************************************************)Definitiondupfst {A:Type} (l: list A): list A :=
match l with
| nil => nil
| cons a l' => cons a (cons a l')
end.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G
forallA : Type, A -> list A -> 1 = 1
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G
forallA : Type, A -> list A -> 1 = 1
reflexivity.Qed.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B l: list A
map dupfst (traverse f l) = traverse f (dupfst l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B l: list A
map dupfst (traverse f l) = traverse f (dupfst l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B l: list A
map dupfst (traverse f l) = traverse f (dupfst l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
map dupfst (traverse f []) = traverse f (dupfst [])
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
map dupfst (traverse f (a :: l)) =
traverse f (dupfst (a :: l))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
map dupfst (traverse f []) = traverse f (dupfst [])
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
map dupfst (pure []) = pure []
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
pure (dupfst []) = pure []
reflexivity.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
map dupfst (traverse f (a :: l)) =
traverse f (dupfst (a :: l))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
map dupfst (pure cons <⋆> f a <⋆> traverse f l) =
traverse f (dupfst (a :: l))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
map dupfst (pure cons <⋆> f a <⋆> traverse f l) =
pure cons <⋆> f a <⋆>
(pure cons <⋆> f a <⋆> traverse f l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
map (compose dupfst) (pure cons <⋆> f a) <⋆>
traverse f l =
pure cons <⋆> f a <⋆>
(pure cons <⋆> f a <⋆> traverse f l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
map (compose (compose dupfst)) (pure cons) <⋆> f a <⋆>
traverse f l =
pure cons <⋆> f a <⋆>
(pure cons <⋆> f a <⋆> traverse f l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure cons <⋆> f a <⋆>
(pure cons <⋆> f a <⋆> traverse f l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure compose <⋆> (pure cons <⋆> f a) <⋆>
(pure cons <⋆> f a) <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure compose <⋆> (pure cons <⋆> f a) <⋆>
(map evalAt (f a) <⋆> pure cons) <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure compose <⋆>
(pure compose <⋆> (pure cons <⋆> f a)) <⋆>
map evalAt (f a) <⋆> pure cons <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure compose <⋆> pure compose <⋆> pure compose <⋆>
(pure cons <⋆> f a) <⋆> map evalAt (f a) <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure compose <⋆>
(pure compose <⋆> pure compose <⋆> pure compose) <⋆>
pure cons <⋆> f a <⋆> map evalAt (f a) <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure compose <⋆> pure compose <⋆>
(pure compose <⋆> pure compose) <⋆> pure compose <⋆>
pure cons <⋆> f a <⋆> map evalAt (f a) <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure compose <⋆> (pure compose <⋆> pure compose) <⋆>
pure compose <⋆> pure compose <⋆> pure compose <⋆>
pure cons <⋆> f a <⋆> map evalAt (f a) <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure compose <⋆> pure compose <⋆> pure compose <⋆>
pure compose <⋆> pure compose <⋆> pure compose <⋆>
pure compose <⋆> pure cons <⋆> f a <⋆>
map evalAt (f a) <⋆> pure cons <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure
((compose ∘ compose) compose compose compose compose
cons) <⋆> f a <⋆> map evalAt (f a) <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
map (precompose evalAt)
(pure
((compose ∘ compose) compose compose compose
compose cons) <⋆> f a) <⋆> f a <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
map (compose (precompose evalAt))
(pure
((compose ∘ compose) compose compose compose
compose cons)) <⋆> f a <⋆> f a <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure
(precompose evalAt
∘ (compose ∘ compose) compose compose compose
compose cons) <⋆> f a <⋆> f a <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
map double_input
(pure
(precompose evalAt
∘ (compose ∘ compose) compose compose compose
compose cons)) <⋆> f a <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure
(double_input
(precompose evalAt
∘ (compose ∘ compose) compose compose compose
compose cons)) <⋆> f a <⋆> pure cons <⋆>
traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure (evalAt cons) <⋆>
(pure
(double_input
(precompose evalAt
∘ (compose ∘ compose) compose compose compose
compose cons)) <⋆> f a) <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure compose <⋆> pure (evalAt cons) <⋆>
pure
(double_input
(precompose evalAt
∘ (compose ∘ compose) compose compose compose
compose cons)) <⋆> f a <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure (compose (evalAt cons)) <⋆>
pure
(double_input
(precompose evalAt
∘ (compose ∘ compose) compose compose compose
compose cons)) <⋆> f a <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A IHl: map dupfst (traverse f l) =
traverse f (dupfst l)
pure (compose dupfst ∘ cons) <⋆> f a <⋆> traverse f l =
pure
(evalAt cons
∘ double_input
(precompose evalAt
∘ (compose ∘ compose) compose compose compose
compose cons)) <⋆> f a <⋆> traverse f l
reflexivity.Qed.(** ** "Pair All with First Element" *)(********************************************************************)Definitionpairall {A:Type} (l: list A): list (A * A) :=
match l with
| nil => nil
| cons a l' => cons (a, a) (map (pair a) l')
end.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A: Type a: A l: list A
pairall (a :: l) = map (pair a) (a :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A: Type a: A l: list A
pairall (a :: l) = map (pair a) (a :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A: Type a: A l: list A
(a, a) :: map (pair a) l = (a, a) :: map (pair a) l
reflexivity.Qed.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A: Type
reflexivity.Qed.(* Lemma pairall_commute_cons_simpler {A B: Type} (f: A -> G B) (a: A) (x: A) (l: list A): map (map ∘ pair) (f a) <⋆>traverse f l = traverse (traverse f) (map (pair a) l) -> map (map ∘ pair) (f a) <⋆> traverse f (x :: l) = traverse (traverse f) (map (pair a) (x :: l)). Proof. introv IH. (* RHS *) rewrite map_list_cons. rewrite (traverse_list_cons _ _ _ _ (a, x)). rewrite traverse_Diagonal_rw. rewrite <- IH. clear IH. (* LHS *) rewrite traverse_list_cons. rewrite <- ap4. rewrite <- ap4. rewrite <- ap4. rewrite ap2. rewrite ap2. rewrite ap3. rewrite <- ap4. rewrite ap2. rewrite ap2. rewrite <- map_to_ap. compose near (f a) on left. rewrite (fun_map_map). rewrite <- ap4. rewrite <- ap4. rewrite <- ap4. do 8 rewrite <- ap4. repeat rewrite ap2. rewrite <- map_to_ap. rewrite <- ap_map. rewrite map_ap. compose near (f a) on right. compose near (f a) on right. rewrite (fun_map_map). unfold compose at 7. rewrite (ap_ci2 _ _ (f a)). compose near (f a) on right. compose near (f a) on right. rewrite (fun_map_map). unfold compose at 7. rewrite map_to_ap. rewrite map_to_ap. rewrite ap_cidup. rewrite <- map_to_ap. rewrite app_pure_natural. rewrite <- map_to_ap. fequal. Qed. Lemma pairall_commute_cons {A B: Type} (f: A -> G B) (a: A) (l: list A): l <> nil -> map (F := G) (map (F := list) ∘ pair) (f a) <⋆> (traverse (T := list) f l) = traverse (traverse (T := fun A => A * A) f) (map (pair a) l). Proof. introv Hnotnil. induction l as [| x xs IHxs ]. - contradiction. - destruct xs. + cbn. rewrite map_to_ap. rewrite <- ap4. rewrite <- ap4. rewrite <- ap4. rewrite <- ap4. rewrite ap2. rewrite ap2. rewrite ap2. rewrite ap2. rewrite ap3. rewrite <- ap4. rewrite ap2. rewrite <- ap4. rewrite ap2. rewrite <- ap4. rewrite ap2. rewrite ap2. rewrite ap3. rewrite <- ap4. rewrite ap2. rewrite ap2. rewrite ap3. rewrite <- ap4. rewrite ap2. rewrite ap2. rewrite <- ap4. rewrite ap2. rewrite <- ap4. rewrite ap2. rewrite ap2. fequal. + specialize (IHxs ltac:(easy)). remember (a0 :: xs). apply pairall_commute_cons_simpler. assumption. Qed. *)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f l ->
traverse (traverse f) (map (pair a) (x :: l)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f l ->
traverse (traverse f) (map (pair a) (x :: l)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A IH: traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f l
traverse (traverse f) (map (pair a) (x :: l)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
(* LHS *)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A IH: traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f l
traverse (traverse f) ((a, x) :: map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A IH: traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f l
pure cons <⋆> traverse f (a, x) <⋆>
traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A IH: traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f l
pure cons <⋆> traverse f (a, x) <⋆>
(map (map ∘ pair) (f a) <⋆> traverse f l) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure cons <⋆> traverse f (a, x) <⋆>
(map (map ∘ pair) (f a) <⋆> traverse f l) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure compose <⋆> (pure cons <⋆> traverse f (a, x)) <⋆>
map (map ∘ pair) (f a) <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure compose <⋆> pure compose <⋆> pure cons <⋆>
traverse f (a, x) <⋆> map (map ∘ pair) (f a) <⋆>
traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure (compose compose) <⋆> pure cons <⋆>
traverse f (a, x) <⋆> map (map ∘ pair) (f a) <⋆>
traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure (compose ∘ cons) <⋆> traverse f (a, x) <⋆>
map (map ∘ pair) (f a) <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure (compose ∘ cons) <⋆> (pure pair <⋆> f a <⋆> f x) <⋆>
map (map ∘ pair) (f a) <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure compose <⋆> pure (compose ∘ cons) <⋆>
(pure pair <⋆> f a) <⋆> f x <⋆> map (map ∘ pair) (f a) <⋆>
traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure (compose (compose ∘ cons)) <⋆>
(pure pair <⋆> f a) <⋆> f x <⋆> map (map ∘ pair) (f a) <⋆>
traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure compose <⋆> pure (compose (compose ∘ cons)) <⋆>
pure pair <⋆> f a <⋆> f x <⋆> map (map ∘ pair) (f a) <⋆>
traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure (compose (compose (compose ∘ cons))) <⋆>
pure pair <⋆> f a <⋆> f x <⋆> map (map ∘ pair) (f a) <⋆>
traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure (compose (compose ∘ cons) ∘ pair) <⋆> f a <⋆> f x <⋆>
map (map ∘ pair) (f a) <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
map (precompose (map ∘ pair))
(pure (compose (compose ∘ cons) ∘ pair) <⋆> f a <⋆>
f x) <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
map (compose (precompose (map ∘ pair)))
(pure (compose (compose ∘ cons) ∘ pair) <⋆> f a) <⋆>
f x <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
map (compose (compose (precompose (map ∘ pair))))
(pure (compose (compose ∘ cons) ∘ pair)) <⋆> f a <⋆>
f x <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(compose (precompose (map ∘ pair))
∘ (compose (compose ∘ cons) ∘ pair)) <⋆> f a <⋆>
f x <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(compose (precompose (map ∘ pair))
∘ compose (compose ∘ cons) ∘ pair) <⋆> f a <⋆>
f x <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(compose
(precompose (map ∘ pair) ∘ (compose ∘ cons))
∘ pair) <⋆> f a <⋆> f x <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(compose (precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair) <⋆> f a <⋆> f x <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
map flip
(pure
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair)) <⋆> f x <⋆> f a <⋆> f a <⋆>
traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair)) <⋆> f x <⋆> f a <⋆> f a <⋆>
traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
map double_input
(pure
(flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair)) <⋆> f x) <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
map (compose double_input)
(pure
(flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f x <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair)) <⋆> f x <⋆> f a <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
map flip
(pure
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆> traverse f (x :: l)
(* RHS *)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
map (map ∘ pair) (f a) <⋆>
(pure cons <⋆> f x <⋆> traverse f l)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
pure compose <⋆> map (map ∘ pair) (f a) <⋆>
(pure cons <⋆> f x) <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
map (compose ∘ (map ∘ pair)) (f a) <⋆>
(pure cons <⋆> f x) <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
pure compose <⋆> map (compose ∘ (map ∘ pair)) (f a) <⋆>
pure cons <⋆> f x <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
map (compose ∘ (compose ∘ (map ∘ pair))) (f a) <⋆>
pure cons <⋆> f x <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
pure (evalAt cons) <⋆>
map (compose ∘ (compose ∘ (map ∘ pair))) (f a) <⋆>
f x <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
map
(evalAt cons ∘ (compose ∘ (compose ∘ (map ∘ pair))))
(f a) <⋆> f x <⋆> traverse f l
(* Done ! *)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A l: list A
pure
(flip
(double_input
∘ flip
(compose
(precompose (map ∘ pair) ∘ compose ∘ cons)
∘ pair))) <⋆> f a <⋆> f x <⋆> traverse f l =
pure
(evalAt cons ∘ (compose ∘ (compose ∘ (map ∘ pair)))) <⋆>
f a <⋆> f x <⋆> traverse f l
reflexivity.Qed.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A
l <> [] ->
traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A
l <> [] ->
traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A l: list A Hnotnil: l <> []
traverse (traverse f) (map (pair a) l) =
map (map ∘ pair) (f a) <⋆> traverse f l
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A Hnotnil: [] <> []
traverse (traverse f) (map (pair a) []) =
map (map ∘ pair) (f a) <⋆> traverse f []
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A xs: list A Hnotnil: x :: xs <> [] IHxs: xs <> [] ->
traverse (traverse f) (map (pair a) xs) =
map (map ∘ pair) (f a) <⋆> traverse f xs
traverse (traverse f) (map (pair a) (x :: xs)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: xs)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A Hnotnil: [] <> []
traverse (traverse f) (map (pair a) []) =
map (map ∘ pair) (f a) <⋆> traverse f []
contradiction.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A xs: list A Hnotnil: x :: xs <> [] IHxs: xs <> [] ->
traverse (traverse f) (map (pair a) xs) =
map (map ∘ pair) (f a) <⋆> traverse f xs
traverse (traverse f) (map (pair a) (x :: xs)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: xs)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A xs: list A IHxs: xs <> [] ->
traverse (traverse f) (map (pair a) xs) =
map (map ∘ pair) (f a) <⋆> traverse f xs
traverse (traverse f) (map (pair a) (x :: xs)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: xs)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A IHxs: [] <> [] ->
traverse (traverse f) (map (pair a) []) =
map (map ∘ pair) (f a) <⋆> traverse f []
traverse (traverse f) (map (pair a) [x]) =
map (map ∘ pair) (f a) <⋆> traverse f [x]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x, y: A ys: list A IHxs: y :: ys <> [] ->
traverse (traverse f) (map (pair a) (y :: ys)) =
map (map ∘ pair) (f a) <⋆> traverse f (y :: ys)
traverse (traverse f) (map (pair a) (x :: y :: ys)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: y :: ys)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A IHxs: [] <> [] ->
traverse (traverse f) (map (pair a) []) =
map (map ∘ pair) (f a) <⋆> traverse f []
traverse (traverse f) (map (pair a) [x]) =
map (map ∘ pair) (f a) <⋆> traverse f [x]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
traverse (traverse f) (map (pair a) [x]) =
map (map ∘ pair) (f a) <⋆> traverse f [x]
(* LHS *)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
traverse (traverse f) [(a, x)] =
map (map ∘ pair) (f a) <⋆> traverse f [x]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
traverse (traverse f) (ret (a, x)) =
map (map ∘ pair) (f a) <⋆> traverse f [x]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
map ret (traverse f (a, x)) =
map (map ∘ pair) (f a) <⋆> traverse f [x]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
map ret (pure pair <⋆> f a <⋆> f x) =
map (map ∘ pair) (f a) <⋆> traverse f [x]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
map (compose ret) (pure pair <⋆> f a) <⋆> f x =
map (map ∘ pair) (f a) <⋆> traverse f [x]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
map (compose (compose ret)) (pure pair) <⋆> f a <⋆>
f x = map (map ∘ pair) (f a) <⋆> traverse f [x]
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
map (map ∘ pair) (f a) <⋆> traverse f [x]
(* RHS *)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
map (map ∘ pair) (f a) <⋆> traverse f (ret x)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
map (map ∘ pair) (f a) <⋆> map ret (f x)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure (map ∘ pair) <⋆> f a <⋆> map ret (f x)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure (map ∘ pair) <⋆> f a <⋆> (pure ret <⋆> f x)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure compose <⋆> (pure (map ∘ pair) <⋆> f a) <⋆>
pure ret <⋆> f x
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure compose <⋆> pure compose <⋆> pure (map ∘ pair) <⋆>
f a <⋆> pure ret <⋆> f x
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure (compose compose) <⋆> pure (map ∘ pair) <⋆> f a <⋆>
pure ret <⋆> f x
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure (compose ∘ (map ∘ pair)) <⋆> f a <⋆> pure ret <⋆>
f x
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure (evalAt ret) <⋆>
(pure (compose ∘ (map ∘ pair)) <⋆> f a) <⋆> f x
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure compose <⋆> pure (evalAt ret) <⋆>
pure (compose ∘ (map ∘ pair)) <⋆> f a <⋆> f x
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure (compose (evalAt ret)) <⋆>
pure (compose ∘ (map ∘ pair)) <⋆> f a <⋆> f x
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x: A
pure (compose ret ∘ pair) <⋆> f a <⋆> f x =
pure (evalAt ret ∘ (compose ∘ (map ∘ pair))) <⋆> f a <⋆>
f x
(* Done! *)reflexivity.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x, y: A ys: list A IHxs: y :: ys <> [] ->
traverse (traverse f) (map (pair a) (y :: ys)) =
map (map ∘ pair) (f a) <⋆> traverse f (y :: ys)
traverse (traverse f) (map (pair a) (x :: y :: ys)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: y :: ys)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x, y: A ys: list A IHxs: traverse (traverse f) (map (pair a) (y :: ys)) =
map (map ∘ pair) (f a) <⋆> traverse f (y :: ys)
traverse (traverse f) (map (pair a) (x :: y :: ys)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: y :: ys)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x, y: A ys, rest: list A Heqrest: rest = y :: ys IHxs: traverse (traverse f) (map (pair a) rest) =
map (map ∘ pair) (f a) <⋆> traverse f rest
traverse (traverse f) (map (pair a) (x :: rest)) =
map (map ∘ pair) (f a) <⋆> traverse f (x :: rest)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a, x, y: A ys, rest: list A Heqrest: rest = y :: ys IHxs: traverse (traverse f) (map (pair a) rest) =
map (map ∘ pair) (f a) <⋆> traverse f rest
traverse (traverse f) (map (pair a) rest) =
map (map ∘ pair) (f a) <⋆> traverse f rest
assumption.Qed.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B l: list A
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
map pairall (traverse f (a :: as')) =
traverse (traverse f) (pairall (a :: as'))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
map pairall (pure []) = pure []
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B
pure (pairall []) = pure []
reflexivity.
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
map pairall (traverse f (a :: as')) =
traverse (traverse f) (pairall (a :: as'))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
map pairall (pure cons <⋆> f a <⋆> traverse f as') =
traverse (traverse f) (pairall (a :: as'))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
map (compose pairall) (pure cons <⋆> f a) <⋆>
traverse f as' =
traverse (traverse f) (pairall (a :: as'))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
map (compose (compose pairall)) (pure cons) <⋆> f a <⋆>
traverse f as' =
traverse (traverse f) (pairall (a :: as'))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
traverse (traverse f) (pairall (a :: as'))
(* RHS *)
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
traverse (traverse f) (map (pair a) (a :: as'))
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
map (map ∘ pair) (f a) <⋆> traverse f (a :: as')
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure (map ∘ pair) <⋆> f a <⋆> traverse f (a :: as')
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure (map ∘ pair) <⋆> f a <⋆>
(pure cons <⋆> f a <⋆> traverse f as')
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure compose <⋆> (pure (map ∘ pair) <⋆> f a) <⋆>
(pure cons <⋆> f a) <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure compose <⋆> pure compose <⋆> pure (map ∘ pair) <⋆>
f a <⋆> (pure cons <⋆> f a) <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure (compose compose) <⋆> pure (map ∘ pair) <⋆> f a <⋆>
(pure cons <⋆> f a) <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure (compose ∘ (map ∘ pair)) <⋆> f a <⋆>
(pure cons <⋆> f a) <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure compose <⋆>
(pure (compose ∘ (map ∘ pair)) <⋆> f a) <⋆> pure cons <⋆>
f a <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure compose <⋆> pure compose <⋆>
pure (compose ∘ (map ∘ pair)) <⋆> f a <⋆> pure cons <⋆>
f a <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure (compose compose) <⋆>
pure (compose ∘ (map ∘ pair)) <⋆> f a <⋆> pure cons <⋆>
f a <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure (compose ∘ (compose ∘ (map ∘ pair))) <⋆> f a <⋆>
pure cons <⋆> f a <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure (evalAt cons) <⋆>
(pure (compose ∘ (compose ∘ (map ∘ pair))) <⋆> f a) <⋆>
f a <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure compose <⋆> pure (evalAt cons) <⋆>
pure (compose ∘ (compose ∘ (map ∘ pair))) <⋆> f a <⋆>
f a <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure (compose (evalAt cons)) <⋆>
pure (compose ∘ (compose ∘ (map ∘ pair))) <⋆> f a <⋆>
f a <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure
(evalAt cons ∘ (compose ∘ (compose ∘ (map ∘ pair)))) <⋆>
f a <⋆> f a <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
map double_input
(pure
(evalAt cons
∘ (compose ∘ (compose ∘ (map ∘ pair))))) <⋆>
f a <⋆> traverse f as'
G: Type -> Type H: Map G H0: Mult G H1: Pure G ApplicativeCommutativeIdempotent0: ApplicativeCommutativeIdempotent
G A, B: Type f: A -> G B a: A as': list A
pure (compose pairall ∘ cons) <⋆> f a <⋆>
traverse f as' =
pure
(double_input
(evalAt cons
∘ (compose ∘ (compose ∘ (map ∘ pair))))) <⋆>
f a <⋆> traverse f as'