resumption-based categorical geometry of interaction for ...kmuroya/talks/bsc.pdf ·...
TRANSCRIPT
![Page 1: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/1.jpg)
1
Resumption-Based Categorical
Geometry of Interaction for Effects
室屋晃子 (蓮尾研究室)
2014年2月12日
![Page 2: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/2.jpg)
2
Resumption-Based Categorical
Geometry of Interaction for Effects
室屋晃子 (蓮尾研究室)
2014年2月12日
Naohiko Hoshino, Koko Muroya, Ichiro Hasuo,
Memoryful Geometry of Interaction:From Coalgebraic Components fo Algebraic Effects,
submitted to LICS '14
![Page 3: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/3.jpg)
3
目的
プログラムを
ステートマシンに
変換する
● 高階関数型プログラミング● 計算効果つき
非決定的、確率的、量子
L I Rq/0 q/0 q/1 q/1
● sequential machine● stream transducer● Mealy machine
![Page 4: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/4.jpg)
4
目的
プログラムを
ステートマシンに
変換する
←for effects
←resumption-based
←categorical Geometry
of Interaction
● 高階関数型プログラミング● 計算効果つき
非決定的、確率的、量子
L I Rq/0 q/0 q/1 q/1
![Page 5: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/5.jpg)
5
ステートマシンへの変換例
非決定的な選択
![Page 6: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/6.jpg)
6
ステートマシンへの変換例
⊕
I
λf. (f 1)+1
*
λf. f 0
*
λx. x
*
L I Rq/n0 q/n0 q/n1
q/n1
![Page 7: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/7.jpg)
7
先行研究 [Hasuo & Hoshino, LICS'11]
プログラムを
パイプに
変換する
● 高階関数型プログラミング● 計算効果つき
非決定的、確率的、量子
categorical Geometry of Interaction[Abramsky, Haghverdi & Scott, MSCS'02]
realizability[Longley, PhD thesis]
![Page 8: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/8.jpg)
8
: 確率的
: 非決定的
: 計算効果なし
先行研究 [Hasuo & Hoshino, LICS'11]
パイプ = 関数 + 計算効果
f
A
B
モナド
a0 a1 a2 ...
b0 b1 b2 ...
![Page 9: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/9.jpg)
9
: 確率的
: 非決定的
: 計算効果なし
先行研究 [Hasuo & Hoshino, LICS'11]
パイプ = 関数 + 計算効果
モナド
a0 a1 a2 ...
b0 b1 b2 ...
f
A
B
![Page 10: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/10.jpg)
10
: 確率的
: 非決定的
: 計算効果なし
先行研究 [Hasuo & Hoshino, LICS'11]
パイプ = 関数 + 計算効果
モナド
a0 a1 a2 ...
b0 b1 b2 ...
f
A
B
![Page 11: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/11.jpg)
11
: 確率的
: 非決定的
: 計算効果なし
先行研究 [Hasuo & Hoshino, LICS'11]
パイプ = 関数 + 計算効果
モナド
a0 a1 a2 ...
b0 b1 b2 ...
0.1 0.20.5
f
A
B
![Page 12: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/12.jpg)
12
パイプへの変換例
λx. xλf. f 0
適用→パイプの相互接続
評価→トークンの動き
パイプ間のやりとり
![Page 13: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/13.jpg)
13
パイプへの変換例
λx. xλf. f 0
適用→パイプの相互接続
評価→トークンの動き
パイプ間のやりとり
λf. f 0 λx. x
ask: f
ask: x
ans: x = 0
ans: f 0 = 0
ans: 0
![Page 14: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/14.jpg)
14
パイプへの変換例
λx. xλf. f 0
適用→パイプの相互接続
評価→トークンの動き
パイプ間のやりとり
λf. f 0 λx. x
ask: f
ask: x
ans: x = 0
ans: f 0 = 0
ans: 0
![Page 15: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/15.jpg)
15
パイプへの変換例
λx. xλf. f 0
適用→パイプの相互接続
評価→トークンの動き
パイプ間のやりとり
λf. f 0 λx. x
ask: f
ask: x
ans: x = 0
ans: f 0 = 0
ans: 0
![Page 16: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/16.jpg)
16
パイプへの変換例
λx. xλf. f 0
適用→パイプの相互接続
評価→トークンの動き
パイプ間のやりとり
λf. f 0 λx. x
ask: f
ask: x
ans: x = 0
ans: f 0 = 0
ans: 0
![Page 17: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/17.jpg)
17
パイプへの変換例
λx. xλf. f 0
適用→パイプの相互接続
評価→トークンの動き
パイプ間のやりとり
λf. f 0 λx. x
ask: f
ask: x
ans: x = 0
ans: f 0 = 0
ans: 0
![Page 18: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/18.jpg)
18
パイプへの変換例
λx. xλf. f 0
適用→パイプの相互接続
評価→トークンの動き
パイプ間のやりとり
λf. f 0 λx. x
ask: f
ask: x
ans: x = 0
ans: f 0 = 0
ans: 0
![Page 19: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/19.jpg)
19
パイプへの変換例
λx. xλf. f 0
適用→パイプの相互接続
評価→トークンの動き
パイプ間のやりとり
λf. f 0 λx. x
ask: f
ask: x
ans: x = 0
ans: f 0 = 0
ans: 0cf. ゲーム意味論
[Abramsky, Jagadeesan & Malacaria, '00][Hyland & Ong, '00]
![Page 20: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/20.jpg)
20
パイプへの変換例
![Page 21: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/21.jpg)
21
パイプへの変換例
![Page 22: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/22.jpg)
22
パイプへの変換例
![Page 23: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/23.jpg)
23
パイプへの変換例
⊕ λf. (f 1)+1λf. f 0 λx. x
![Page 24: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/24.jpg)
24
パイプへの変換例
⊕ λf. (f 1)+1λf. f 0 λx. x
![Page 25: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/25.jpg)
25
パイプへの変換例
⊕ λf. (f 1)+1λf. f 0 λx. x
![Page 26: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/26.jpg)
26
パイプへの変換例
⊕ λf. (f 1)+1λf. f 0 λx. x
ans: f 0 = 0
![Page 27: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/27.jpg)
27
パイプへの変換例
⊕ λf. (f 1)+1λf. f 0 λx. x
ans: f 0 = 0
![Page 28: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/28.jpg)
28
パイプへの変換例
⊕ λf. (f 1)+1λf. f 0 λx. x
ans: 1
![Page 29: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/29.jpg)
29
パイプへの変換例
⊕ λf. (f 1)+1λf. f 0 λx. x
ans: 1
「記憶」が必要 「記憶」が必要
![Page 30: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/30.jpg)
30
「記憶」の実現
プログラム +「記憶」
パイプ +「記憶」
![Page 31: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/31.jpg)
31
「記憶」の実現
プログラム +「記憶」→ 継続渡し形式
パイプ +「記憶」→ ステートマシン
[Hasuo & Hoshino, LICS'11]
[Abramsky, Haghverdi & Scott, MSCS'02] で説明
![Page 32: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/32.jpg)
32
「記憶」の実現
プログラム +「記憶」→ 継続渡し形式
パイプ +「記憶」→ ステートマシン
[Hasuo & Hoshino, LICS'11]
[Abramsky, Haghverdi & Scott, MSCS'02] で説明
今回の成果:
ステートマシンの具体的構成を与える
→ 計算効果つき高階プログラムの変換の
一般的フレームワーク
今回の成果:
ステートマシンの具体的構成を与える
→ 計算効果つき高階プログラムの変換の
一般的フレームワーク
![Page 33: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/33.jpg)
33
: 確率的
: 非決定的
: 計算効果なし
「記憶」の埋め込み
ステートマシン = パイプ + 内部状態
cx
A
B
モナド
![Page 34: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/34.jpg)
34
ステートマシンへの変換例
⊕
I
λf. (f 1)+1
*
λf. f 0
*
λx. x
*
L I R
![Page 35: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/35.jpg)
35
ステートマシンへの変換例
⊕
I
λf. (f 1)+1
*
λf. f 0
*
λx. x
*
L I R
2項演算子 ↓
ステートマシン上の2項演算
![Page 36: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/36.jpg)
36
ステートマシンへの変換例
⊕
L
λf. (f 1)+1
*
λf. f 0
*
λx. x
*
L I R
2項演算子 ↓
ステートマシン上の2項演算
![Page 37: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/37.jpg)
37
ステートマシンへの変換例
⊕
R
λf. (f 1)+1
*
λf. f 0
*
λx. x
*
L I R
2項演算子 ↓
ステートマシン上の2項演算
![Page 38: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/38.jpg)
38
ステートマシンへの変換例
⊕
I
λf. (f 1)+1
*
λf. f 0
*
λx. x
*
L I R
![Page 39: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/39.jpg)
39
今回の成果
プログラムをステートマシンに変換する
一般的フレームワーク
● 高階関数型プログラミング● 計算効果つき
![Page 40: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/40.jpg)
40
今回の成果
プログラムをステートマシンに変換する
一般的フレームワーク
1.計算効果をモデルする
an algebraic operation α on a monad
2.ステートマシンを modular に構成する
3.ステートマシンによる表示的意味論を与える
a category on resumptions
● 高階関数型プログラミング● 計算効果つき
![Page 41: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/41.jpg)
41
今回の成果
プログラムをステートマシンに変換する
一般的フレームワーク
1.計算効果をモデルする
an algebraic operation α on a monad
2.ステートマシンを modular に構成する
3.ステートマシンによる表示的意味論を与える
a category on resumptions
● 高階関数型プログラミング● 計算効果つき
投稿版
卒論
![Page 42: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical](https://reader036.vdocuments.fr/reader036/viewer/2022071215/6044e23421dbcf2a41121210/html5/thumbnails/42.jpg)
42
今後の展望
具体的な計算効果に対する応用● 非決定的計算、確率的計算● 量子計算
関連手法との比較● Geometry of Synthesis [Ghica, ICFP'11 など]
高階関数型のプログラムを論理回路に変換する
[Hasuo & Hoshino, LICS'11]の簡略化?
「記憶」の埋め込み?