Categorifying Computations into Components via Arrows as Profunctors
description
Transcript of Categorifying Computations into Components via Arrows as Profunctors
![Page 1: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/1.jpg)
Categorifying Computations into Componentsvia Arrows as Profunctors
Kazuyuki Asada Ichiro Hasuo
RIMS, Kyoto UniversityPRESTO Research Promotion Program, Japan Science and Technology Agency
CSCAT 2010March 18, 2010
![Page 2: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/2.jpg)
Slogan
Computationscategorification
Components
![Page 3: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/3.jpg)
Model of computation
Strong monad J→TK [Moggi 88] Comonad SJ→K [Uustalu, Vene 08] Distributive law SJ→TK
Arrow A(J,K) [Hughes 00]↩
![Page 4: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/4.jpg)
Arrow
An arrow A on C [Hughes 00] is a family of sets A(J, K) (J,K C)∊
three families of functions arr : Set(J, K) → A(J, K) >>> : A(J, K)×A(K, L) → A(J, L) first : A(J, K) → A(J×L, K×L) satisfying certain axioms, e.g.
(a>>>b) >>>c = a >>>(b >>>c)
![Page 5: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/5.jpg)
Arrow, pictorially
An arrow A on C [Hughes 00] is a family of sets A(J, K) ∍
three families of functions (Embedding a pure function f:J →K) (Sequential composition) , (Sideline) satisfying certain axioms, e.g. =
aJ K
arr fJ K
aJ K bK La
J Kb
L
aJ K a
J KLL
>>>
aJ K
bL
cM
bK L
cM
aJ
first
![Page 6: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/6.jpg)
Monad induces Arrow
For a (strong) monad T on C,we have a Kleisli arrow AT on C:
AT(J, K) := CT (J, K) = C(J, TK)
arr: C(J, K) → C(J, TK) (Kleisli embedding) comp: C(J, TK)×C(K, TL) → C(J, TL)
(Kleisli composition) first: C(J, TK) → C(J×L, T(K×L)) f (f×L) ; str
![Page 7: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/7.jpg)
Slogan
Computationscategorification
Components
![Page 8: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/8.jpg)
Components Calculus
(from wikipedia)
![Page 9: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/9.jpg)
Barbosa’s calculus
CJ K
arr fJ K
cJ K dK Lc
J Kd
L
cJ K c
J KLL
F: J→K
: a component
: Pure function
: Sequential composition
: Sideline
cJ KL L c
J K
: Feedback
Arrow!?
![Page 10: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/10.jpg)
=
Arrow
An arrow A on C [Hughes 00] is a family of sets A(J, K) ∍
three families of functions (Embedding a pure function f:J →K) (Sequential composition) , (Sideline) satisfying certain axioms, e.g.
aJ K
arr fJ K
aJ K bK La
J Kb
L
aJ K a
J KLL
>>>
aJ K
bL
cM
bK L
cM
aJ
first
![Page 11: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/11.jpg)
Barbosa’s coalgebraic modeling
T: a monad on Set(e.g. T = Pfin finite powerset)
cJ K =
T(X×K)J
c↑ X
in Set
J: set of inputK: set of outputX: set of state
Coalg( T(-×K)J )
∊
![Page 12: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/12.jpg)
Composition of Components
cJ K
dK L
cJ K
dL>>>
=
,
= =T(X×K)J
a↑ X
T(Y×L)K
b↑ Y
T((X×Y)×L)J
↑X×Y
a>>>b
state spaces: (X×Y) ×Z ≅ X× (Y×Z)
≅cJ K
dL
eM
dK L
eM
cJ
![Page 13: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/13.jpg)
Categorical Arrow
An arrow A on C is a family of sets A(J, K) ∍
three families of functions (Embedding a pure function f:J →K) (Sequential composition) , (Sideline) satisfying certain axioms, e.g.
aJ K
arr fJ K
aJ K bK La
J Kb
L
aJ K a
J KLL
>>>
aJ K
bL
cM
bK L
cM
aJ
first
=
![Page 14: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/14.jpg)
Categorical Arrow
≅
An categorical arrow A on C is a family of sets A(J, K) ∍
three families of functions (Embedding a pure function f:J →K) (Sequential composition) , (Sideline) satisfying certain axioms, e.g.
aJ K
arr fJ K
aJ K bK La
J Kb
L
aJ K a
J KLL
>>>
aJ K
bL
cM
bK L
cM
aJ
first
![Page 15: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/15.jpg)
Categorical Arrow
≅
An categorical arrow A on C is a family of categories A(J, K) ∍
three families of functions (Embedding a pure function f:J →K) (Sequential composition) , (Sideline) satisfying certain axioms, e.g.
aJ K
arr fJ K
aJ K bK La
J Kb
L
aJ K a
J KLL
>>>
aJ K
bL
cM
bK L
cM
aJ
first
Coalg( T(-×K)J )
![Page 16: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/16.jpg)
Categorical Arrow
≅
An categorical arrow A on C is a family of categories A(J, K) ∍
three families of functors (Embedding a pure function f:J →K) (Sequential composition) , (Sideline) satisfying certain axioms, e.g.
aJ K
arr fJ K
aJ K bK La
J Kb
L
aJ K a
J KLL
>>>
aJ K
bL
cM
bK L
cM
aJ
first
Coalg( T(-×K)J )
![Page 17: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/17.jpg)
Categorical Arrow
≅
An categorical arrow A on C is a family of categories A(J, K) ∍
three families of functors (Embedding a pure function f:J →K) (Sequential composition) , (Sideline) satisfying certain axioms, e.g.
aJ K
arr fJ K
aJ K bK La
J Kb
L
aJ K a
J KLL
>>>
aJ K
bL
cM
bK L
cM
aJ
first
![Page 18: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/18.jpg)
Bisimulation
When
A(J, K) (= { c }) := Coalg( T(-×K)J )J K
T(X×K)J
c↑ X
T(Z×K)J
↑finalZ
- - - - - - - ->- - - - - - - ->behavior
![Page 19: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/19.jpg)
Slogan
Computationscategorification
= =
Arrow Categorical Arrow
Components
![Page 20: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/20.jpg)
Slogan
Computationscategorification
= =
Arrow Categorical Arrow
Components
![Page 21: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/21.jpg)
Slogan
Computationscategorification
= =
Arrow Categorical Arrow
Components
![Page 22: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/22.jpg)
2nd Goal
Computationscategorification
= =
Arrow Categorical Arrows
Components
Arrows
concreteconstruction
![Page 23: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/23.jpg)
Construction of categorical arrow
Main technical result: For given arrow A on Set, we construct an arrow-based coalgebraic model:
∊ Coalg( A(J, -×K) ) , we show that these Coalg( A(J, -×K) ) (J,K Set)∊
form a categorical arrow.
A(J, X×K)c↑
X
≅cJ K
dL
eM
dK L
eM
cJ
![Page 24: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/24.jpg)
Two points of the theorem
arrow A categ. arrow Coalg( A(J, -×K) )
monad T categ. arrow Coalg( T(-×K)J ) [Barbosa]+[Hasuo, H., J., S. 09]
a proof technique of calculation in Prof (the bicategory of profunctors), using the fact:Arrow is strong monad in Prof.
( )generalization
![Page 25: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/25.jpg)
What is Prof ?
![Page 26: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/26.jpg)
Profunctors
A profunctor F: C ―|―> D (C, D: categories) is a functor F: Dop×C → Set
Y , X F(Y, X).
![Page 27: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/27.jpg)
Profunctors
A profunctor F: C ――> D (C, D: categories) is a functor F: Dop×C → Set
Y , X F(Y, X).
p =
For g: Y’ → Y in D, f: X → X’ in C,F(g, f) (p) =
pY X
∊Y
pXg f
Y’ X’
![Page 28: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/28.jpg)
Profunctors
Composition G 。 F: C ――> E is
Eop×C → Set Z, X ΣY{( , )}/
~
(sets of “formal composition”)
pY X
pY X
qZ Y
A profunctor F: C ――> D is a functor F: Dop×C → Set
Y , X F(Y, X) = { }
![Page 29: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/29.jpg)
σ
The bicategory Prof
Prof is a bicategory whose
0-cells are small categories,
1-cells are profunctors, and
2-cells are natural transformations.
( C D := Dop×C Set )⇒σ ⇒
![Page 30: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/30.jpg)
Why Prof ?
![Page 31: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/31.jpg)
2-cell vs. morphism
F αX
C α⇓ D vs. FX GX
G
![Page 32: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/32.jpg)
Monad and Arrow w/o first
Monad Arrow(w/o first)• T: C → C• ηX: X→TX• μX: TTX→TX
• TTT ――> TT ↓ ↓ TT ――> T• …
equipped with
satisfying
• A:Cop×C→Set• arr: C(J,K)→A(J,K)• >>>: A(J,K)×A(K,L)
→ A(J,L)
• (a >>> b) >>> c = a >>> (b >>> c)• …
![Page 33: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/33.jpg)
Monad and Arrow w/o first
Monad Arrow(w/o first)
• T: C C
• C C• C C C• C C C C = C C C C•…
equipped with
satisfying
• A:Cop×C→Set• arr: C(J,K)→A(J,K)• >>>: A(J,K)×A(K,L)
→ A(J,L)
• (a >>> b) >>> c = a >>> (b >>> c)• …
η ⇒
μ ⇒
μ ⇒μ ⇒
μ ⇒ μ ⇒
in Cat
![Page 34: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/34.jpg)
Monad and Arrow w/o first
Monad Arrow(w/o first)
• T: C C
• C C• C C C• C C C C = C C C C•…
equipped with
satisfying
• A: C C
• C C• C C C• C C C C = C C C C•…
η ⇒
μ ⇒
μ ⇒μ ⇒
μ ⇒ μ ⇒
arr⇒⇒
⇒⇒⇒ ⇒
>>>
>>>>>> >>>
>>>
[Jacobs, H., H. 09]
in Cat in Prof
![Page 35: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/35.jpg)
Strong monad and Arrow
Monad Arrow
equipped with
satisfying
• first: A(J,K) →A(J×L , K×L )
• …
![Page 36: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/36.jpg)
Strong monad and Arrow
Monad Arrow
• C×C C×C C C
• …
equipped with
Satisfying
• C×C C×C C C
• …
A×C
× ×
A
⇒first
T×C
× ×
T
⇒str
[Asada 10]
in Cat in Prof
![Page 37: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/37.jpg)
Summary
Arrow is equivalent tostrong monad in Prof: i.e.,
C C
satisfying familiar axioms.
A×C
× ×⇒first
A
C×C C×C C C
arr⇒ C C
⇒
>>> CC C
A
A
A
AA
in Prof
![Page 38: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/38.jpg)
Main theorem
Theorem
For an arrow A,
the categories Coalg( A(J, -×K) ) (J,K Set)∊forms a categorical arrow.
![Page 39: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/39.jpg)
Categorical arrow
≅
An categorical arrow A on C is a family of categories A(J, K) ∍
three families of functors (Embedding a pure function f:J →K) (Sequential composition) , (Sideline) satisfying certain axioms, e.g.
aJ K
arr fJ K
aJ K bK La
J Kb
L
aJ K a
J KLL
>>>
aJ K
bL
cM
bK L
cM
aJ
first
Coalg( A(J, -×K) )
![Page 40: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/40.jpg)
Proof of main theorem
Proof. Lemma
For an arrow A,the endofunctors A(J, -×K) (J,K Set)∊forms a lax arrow functor.
Lemma [Hasuo, H., J., S. 09]If (FJ,K )J,K is a lax arrow endofunctor,
Then Coalg(FJ,K ) (J,K Set)∊
forms a categorical arrow.
![Page 41: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/41.jpg)
Key lemma
Proof. Lemma
For an arrow A,the endofunctors A(J, -×K) (J,K Set)∊forms a lax arrow functor.
Lem [Hasuo, J., H., S. 09]If (FJ,K )J,K is a lax arrow endofunctor,
Then Coalg(FJ,K ) (J,K Set)∊
forms a categorical arrow.
![Page 42: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/42.jpg)
Lax arrow functor
(FJ,K: Set→Set)J,K is a lax arrow functorif it is equipped with
Farrf : 1 → FJ,K(1)
F>>>J,K,L : FJ,K(X)×FK,L(Y) → FJ,L(X×Y)
FfirstJ,K,L : FJ,K(X) → FJ×L, K×L(X)
satisfying certain axioms (similar to arrow’s).
cf. F1 : 1 → F1F× : FX×FY → F(X×Y)
![Page 43: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/43.jpg)
Key lemma
LemmaFor an arrow A,there are the following structures:
Farrf : 1 → A(J, 1×K)
F>>>J,K,L : A(J, X×K)× A(K, Y×L) →
A(J, (X×Y)×L) Ffirst
J,K,L : FJ,K(X) → FJ×L, K×L(X)
satisfying certain axioms (similar to arrow’s).
![Page 44: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/44.jpg)
Proof in Prof
E.g.A(J, X×K)× A(K, Y×L) → A(J, (X×Y)×L)
can be described in Prof as
F>>>J,K,L
C3 C2 C2
C2 C C C:=
C3 C2 C2
C2 C C C× A
F>>> ⇒ ⇒ ⇒⇒
>>>
≅ second
C×A
A
A
C× (×)
(×)× C × ×
×
C×A
A
C× (×)
(×)× C ×
![Page 45: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/45.jpg)
Proof in Prof
C3 C2 C2
C2 C C C:=
C3 C2 C2
C2 C C C× A
F>>> ⇒ ⇒ ⇒⇒
>>>
≅ second
C×A
A
A
C× (×)
(×)× C × ×
×
C×A
A
C× (×)
(×)× C ×C4 C3 C3
C3 C3 C2 C2 C2
C2 C C C
⇒≅
C4 C3 C3 C2 C2
C3 C2 C2 C C C
C2 C F>>> ⇒
F>>> ⇒C× F>>> ⇒
F>>> ⇒
C× (×)
C 2× (×)
(×)× C 2
C×AC 2×A C× (×)
(×)× C (×)× C ×
C×A ×A
×
(×)× CA
A
(×)× C 2
(×)× C
×A
A×
C×AC× (×)
C 2×AC 2× (×)
C×AC× (×)
(×)× C
C ×(×)× C
=
![Page 46: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/46.jpg)
Conclusion
Computationscategorification
= =
Arrow Categorical Arrow(s)
Components
Arrows
concreteconstruction
![Page 47: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/47.jpg)
Remark
Key lemma
Microcosm principles
Main theorem
[Hasuo, H., J., S. 09]
![Page 48: Categorifying Computations into Components via Arrows as Profunctors](https://reader035.fdocuments.in/reader035/viewer/2022062501/56816567550346895dd7f2e3/html5/thumbnails/48.jpg)
Remark
Key lemma
Microcosm principles
Outer model(main theorem)
Inner model
compositionality
[Hasuo, H., J., S. 09]