Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf ·...

42
1 Resumption-Based Categorical Geometry of Interaction for Effects 室屋晃子 (蓮尾研究室) 2014212

Transcript of Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf ·...

Page 1: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

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

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

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

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

5

ステートマシンへの変換例

非決定的な選択

Page 6: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

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

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

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

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

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

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

12

パイプへの変換例

λx. xλf. f 0

適用→パイプの相互接続

評価→トークンの動き

   パイプ間のやりとり

Page 13: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

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

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

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

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

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

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

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

20

パイプへの変換例

Page 21: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

21

パイプへの変換例

Page 22: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

22

パイプへの変換例

Page 23: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

23

パイプへの変換例

⊕ λf. (f 1)+1λf. f 0 λx. x

Page 24: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

24

パイプへの変換例

⊕ λf. (f 1)+1λf. f 0 λx. x

Page 25: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

25

パイプへの変換例

⊕ λf. (f 1)+1λf. f 0 λx. x

Page 26: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

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

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

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

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

30

「記憶」の実現

プログラム +「記憶」

パイプ +「記憶」

Page 31: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

31

「記憶」の実現

プログラム +「記憶」→ 継続渡し形式

パイプ +「記憶」→ ステートマシン

[Hasuo & Hoshino, LICS'11]

[Abramsky, Haghverdi & Scott, MSCS'02] で説明

Page 32: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

32

「記憶」の実現

プログラム +「記憶」→ 継続渡し形式

パイプ +「記憶」→ ステートマシン

[Hasuo & Hoshino, LICS'11]

[Abramsky, Haghverdi & Scott, MSCS'02] で説明

今回の成果:

ステートマシンの具体的構成を与える

→ 計算効果つき高階プログラムの変換の

  一般的フレームワーク

今回の成果:

ステートマシンの具体的構成を与える

→ 計算効果つき高階プログラムの変換の

  一般的フレームワーク

Page 33: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

33

: 確率的

: 非決定的

: 計算効果なし

「記憶」の埋め込み

ステートマシン = パイプ + 内部状態

cx

A

B

モナド

Page 34: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

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

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

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

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

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

39

今回の成果

プログラムをステートマシンに変換する

一般的フレームワーク

● 高階関数型プログラミング● 計算効果つき

Page 40: Resumption-Based Categorical Geometry of Interaction for ...kmuroya/talks/bsc.pdf · 高階関数型プログラミング 計算効果つき 非決定的、確率的、量子 categorical

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

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

42

今後の展望

具体的な計算効果に対する応用● 非決定的計算、確率的計算● 量子計算

関連手法との比較● Geometry of Synthesis [Ghica, ICFP'11 など]

高階関数型のプログラムを論理回路に変換する

[Hasuo & Hoshino, LICS'11]の簡略化?

「記憶」の埋め込み?