shift/reset [13] 2 shift / reset shift reset k call/cc reset shift k shift (...) k 1 + shift(fun k -> 2 * (k 3)) k 2 * (1 + 3) 8 reset shift reset (..

Similar documents
さぬきの安全2016-cs5-出力.indd

看護学科案内'16/表紙

平成 19 年度 ( 第 29 回 ) 数学入門公開講座テキスト ( 京都大学数理解析研究所, 平成 19 ~8 年月 72 月日開催 30 日 ) 1 PCF (Programming language for Computable Functions) PCF adequacy adequacy

Int Int 29 print Int fmt tostring 2 2 [19] ML ML [19] ML Emacs Standard ML M M ::= x c λx.m M M let x = M in M end (M) x c λx.

Dive into Algebraic Effects

2016東奥義塾高等学校スクールガイド

01.P28-01


美唄市広報メロディー2014年1月号

Emacs ML let start ::= exp (1) exp ::= (2) fn id exp (3) ::= (4) (5) ::= id (6) const (7) (exp) (8) let val id = exp in

MEISEI HEROES HERO HERO HERO MEISEI HEROES

v6.ai

技術の系統化調査報告「プロセス制御システムの技術系統化調査」

# let rec sigma (f, n) = # if n = 0 then 0 else f n + sigma (f, n-1);; val sigma : (int -> int) * int -> int = <fun> sigma f n ( : * -> * ) sqsum cbsu

MORALITY LEARNING AMBITION 2 KASUMIGAOKA

Parametric Polymorphism

Jacques Garrigue


(CPS)?...

2 984 WWW

2011上宮太子_高校_学校案内

生活設計レジメ

I II III 28 29

44 4 I (1) ( ) (10 15 ) ( 17 ) ( 3 1 ) (2)


3 3.1 algebraic datatype data k = 1 1,1... 1,n1 2 2,1... 2,n2... m m,1... m,nm 1 m m m,1,..., m,nm m 1, 2,..., k 1 data Foo x y = Alice x [y] B

: gettoken(1) module P = Printf exception End_of_system (* *) let _ISTREAM = ref stdin let ch = ref ( ) let read () = (let c =!ch in ch := inp

IPSJ SIG Technical Report Vol.2016-ARC-221 No /8/9 GC 1 1 GC GC GC GC DalvikVM GC 12.4% 5.7% 1. Garbage Collection: GC GC Java GC GC GC GC Dalv

maegaki_4_suzuki_yuusuke.pdf

koba/class/soft-kiso/ 1 λ if λx.λy.y false 0 λ typed λ-calculus λ λ 1.1 λ λ, syntax τ (types) ::= b τ 1 τ 2 τ 1

1 May 2011


main.dvi

IPSJ SIG Technical Report Vol.2011-CE-110 No /7/9 Bebras 1, 6 1, 2 3 4, 6 5, 6 Bebras 2010 Bebras Reporting Trial of Bebras Contest for K12 stud

(a) (b) (c) Canny (d) 1 ( x α, y α ) 3 (x α, y α ) (a) A 2 + B 2 + C 2 + D 2 + E 2 + F 2 = 1 (3) u ξ α u (A, B, C, D, E, F ) (4) ξ α (x 2 α, 2x α y α,

ML λ λ 1 λ 1.1 λ λ λ e (λ ) ::= x ( ) λx.e (λ ) e 1 e 2 ( ) ML λx.e Objective Caml fun x -> e x e let 1


Milner Harper LCF ML HOPE (type inference) news letter Polymorphism [28] [30, 24, 13] 3 Standard ML 1990 ML LCF ML The Definition of Standard ML[31] L

Lebesgue可測性に関するSoloayの定理と実数の集合の正則性=1This slide is available on ` `%%%`#`&12_`__~~~ౡ氀猀e

: Name, Tel name tel (! ) name : Name! Tel tel ( % ) 3. HTML. : Name % Tel name tel 2. 2,., [ ]!, [ ]!, [ ]!,. [! [, ]! ]!,,. ( [ ], ),. : [Name], nam

1 1 CodeDrummer CodeMusician CodeDrummer Fig. 1 Overview of proposal system c

A4_

Autumn

ケインズ『お金の改革論』山形浩生訳 Keynes, A Tract on Monetary Reform, 1923, Japanese translation Hiroo Yamagata 2015

SOZO_経営_PDF用.indd


…J…−†[†E…n…‘†[…hfi¯„^‚ΛžfiüŒå

0911_hyo1.eps

2

untitled

Vol.55 No (Jan. 2014) saccess 6 saccess 7 saccess 2. [3] p.33 * B (A) (B) (C) (D) (E) (F) *1 [3], [4] Web PDF a m

i


Wide Scanner TWAIN Source ユーザーズガイド

3131_2014_02.pdf

C O N T E N T S Annual Report

18年度石見美術館年報最終.indd

schoolʼs history facts about IPMAHS school uniforms

1 (1997) (1997) 1974:Q3 1994:Q3 (i) (ii) ( ) ( ) 1 (iii) ( ( 1999 ) ( ) ( ) 1 ( ) ( 1995,pp ) 1

b-platz press(ビープラッツ プレス)vol120

繝励Μ繝ウ繝

# let st1 = {name = "Taro Yamada"; id = };; val st1 : student = {name="taro Yamada"; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n

% 95% 2002, 2004, Dunkel 1986, p.100 1

TheRecord.indd

第1部 一般的コメント

( )

3.1 Thalmic Lab Myo * Bluetooth PC Myo 8 RMS RMS t RMS(t) i (i = 1, 2,, 8) 8 SVM libsvm *2 ν-svm 1 Myo 2 8 RMS 3.2 Myo (Root

3 2 2 (1) (2) (3) (4) 4 4 AdaBoost 2. [11] Onishi&Yoda [8] Iwashita&Stoica [5] 4 [3] 3. 3 (1) (2) (3)


Modal Phrase MP because but 2 IP Inflection Phrase IP as long as if IP 3 VP Verb Phrase VP while before [ MP MP [ IP IP [ VP VP ]]] [ MP [ IP [ VP ]]]

untitled

表1票4.qx4

福祉行財政と福祉計画[第3版]



第1章 国民年金における無年金

TA3-4 31st Fuzzy System Symposium (Chofu, September 2-4, 2015) Interactive Recommendation System LeonardoKen Orihara, 1 Tomonori Hashiyama, 1


‡Â‡È‡ª‡é

橡ミュラー列伝Ⅰ.PDF

org/ghc/ Windows Linux RPM 3.2 GHCi GHC gcc javac ghc GHCi(ghci) GHCi Prelude> GHCi :load file :l file :also file :a file :reload :r :type expr :t exp


II III I ~ 2 ~

中堅中小企業向け秘密保持マニュアル


PR映画-1

- 2 -


1 (1) (2)

表紙

untitled

untitled

o 2o 3o 3 1. I o 3. 1o 2o 31. I 3o PDF Adobe Reader 4o 2 1o I 2o 3o 4o 5o 6o 7o 2197/ o 1o 1 1o

dsample.dvi


1 Kinect for Windows M = [X Y Z] T M = [X Y Z ] T f (u,v) w 3.2 [11] [7] u = f X +u Z 0 δ u (X,Y,Z ) (5) v = f Y Z +v 0 δ v (X,Y,Z ) (6) w = Z +

A Japanese Word Dependency Corpus ÆüËܸì¤Îñ¸ì·¸¤ê¼õ¤±¥³¡¼¥Ñ¥¹

2) TA Hercules CAA 5 [6], [7] CAA BOSS [8] 2. C II C. ( 1 ) C. ( 2 ). ( 3 ) 100. ( 4 ) () HTML NFS Hercules ( )

6/9-98-資生堂-前半AR-6.5pm

園田学園論文集 50号(よこ)☆/3.浜口

Transcription:

arisa@pllab.is.ocha.ac.jp asai@is.ocha.ac.jp shift / reset CPS shift / reset CPS CPS 1 [3, 5] goto try/catch raise call/cc [17] control/prompt [8], shift/reset [5] control/prompt, shift/reset call/cc (continuationpassing style : CPS) call/cc [9] CPS shift/reset CPS SECD [12] shift/reset Danvy [7] SECD direct style CPS SECD bisimulation Ager [2] CPS CEK shift/reset Danvy [4] Danvy SECD CEK shift/reset Ager [1] [10] backquote unquote λ Ager shift/reset

shift/reset [13] 2 shift / reset shift reset k call/cc reset shift k shift (...) k 1 + shift(fun k -> 2 * (k 3)) k 2 * (1 + 3) 8 reset shift reset (...) shift 1 + reset(4 + shift(fun k -> 2 * (k 3))) 4 k 1 + (2 * (4 + 3)) 15 1 reset shift 3 CPS syntax t ::= x λx. t t 0 t 1 shift(t) reset(t) shift reset [x, t, e] shift [c] v ::= [x, t, e] [c] OCaml 1 (* *) 2 type t = Var of string (* *) 3 Fun of string * t (* *) 4 App of t * t (* *) 5 Shift of t (* shift *) 6 Reset of t (* reset *) 7 (* *) 8 type v = VFun of string * t * e (* *) 9 VCont of c (* *) 10 (* *) 11 and e = ( string * v) list 12 (* *) 13 and c = ( v -> v) x v get(x, e) e x v shift/reset eval1 [6] 1 (* id : v -> v *) 2 let id x = x 3 4 (* eval : t * e * c -> v *) 5 let rec eval (t, e, c) = match t with 6 Var (x) -> c ( get (x, e)) 7 Fun (x, t) -> c ( VFun (x, t, e)) 8 App (t0, t1) -> eval (t1, e, ( fun v1 9 -> eval (t0, e, ( fun v0 10 -> ( match v0 with 11 ( VFun (x, t, e )) -> eval (t, (x, v1) :: e, c) 12 ( VCont (c )) -> c (c v1) ))))) 13 Shift (t) -> eval (t, e, ( fun v 14 -> ( match v with 15 ( VFun (x, t, e )) -> eval (t, (x, VCont (c)) :: e, id) 16 ( VCont (c )) -> c ( VCont (c ))) )) 17 Reset (t) -> c ( eval (t, e, id )) 18 19 (* eval1 : t -> v *) 20 let eval1 t = eval (t, [], id)

CPS shift/reset 13 16 shift 17 reset shift VCont(c) Shift t reset id shift shift/reset shift/reset 4 CPS eval1 shift/reset 12, 17 eval1 CPS eval2 1 type v = (* *) (* *) 2 and e = (* *) (* *) 3 and c = ((v * d) -> v) (* *) 4 and d = ( v -> v) eval2 1 (* cid : v * d -> v *) 2 (* did : v -> v *) 3 let cid (v, d) = d v 4 let did x = x 5 6 (* eval : t * e * c * d -> v *) 7 let rec eval (t, e, c, d) = match t with 8 Var (x) -> c ( get (x, e), d) 9 Fun (x, t) -> c ( VFun (x, t, e), d) 10 App (t0, t1) 11 -> eval (t1, e, ( fun (v1, d1) 12 -> eval (t0, e, ( fun (v0, d0) 13 -> ( match v0 with 14 ( VFun (x, t, e )) -> eval (t, (x, v1) :: e, c, d0) 15 ( VCont (c )) -> c (v1, ( fun v -> c (v, d0 ))))), d1 )), d) 16 Shift ( t) 17 -> eval (t, e, ( fun (v, d ) 18 -> ( match v with 19 ( VFun (x, t, e )) -> eval (t, (x, VCont (c)) :: e, cid, d ) 20 ( VCont (c )) -> c ( VCont (c), d ))), d) 21 Reset (t) -> eval (t, e, cid, ( fun v -> c (v, d ))) 22 23 (* eval2 : t -> v *) 24 let eval2 t = eval (t, [], cid, did ) eval1 CPS c CPS c d CPS 4.1 (CPS [16]). t eval1 eval2 t eval1 CPS t eval2 5 eval2 CPS eval2 [16] eval3 (OCaml fun ) (apply run * )

eval2 Shift OCaml fun 16 20 fun body c c eval2 c Shift fun c fun body 1 type v = (* *) (* *) 2 and e = (* *) (* *) 3 (* *) 4 and c = CApp1 of t * e * c (* A p p fun *) 5 CApp0 of v * c (* A p p fun *) 6 CShift of c (* S h i f t fun *) 7 CReset (* c id *) 8 and d = DRun of c * d (* R e s e t d fun *) 9 DReset (* d id *) eval2 fun 1 (* run_c : c * v * d -> v *) 2 let rec run_c (c, v, d) = match c with 3 CApp1 (t, e, c ) -> eval (t, e, CApp0 (v, c ), d) 4 CApp0 (v, c ) -> ( match v with 5 VFun (x, t, e ) -> eval (t, (x, v ) :: e, c, d) 6 VCont (c ) -> run_c (c, v, DRun (c, d ))) 7 CShift (c ) -> ( match v with 8 VFun (x, t, e ) -> eval (t, (x, VCont (c )) :: e, CReset, d) 9 VCont (c ) -> run_c (c, VCont (c ), d)) 10 CReset -> run_d (d, v) 11 (* run_d : d * v -> v *) 12 and run_d (d, v) = match d with 13 DRun (c, d ) -> run_c (c, v, d ) 14 DReset -> v fun eval2 8 Var c c eval3 Var run c (c, get(x, e), d) d eval3 1 (* cid : c *) 2 (* did : d *) 3 let cid = CReset 4 let did = DReset 5 6 (* eval : t * e * c * d -> v *) 7 let rec eval (t, e, c, d) = match t with 8 Var (x) -> run_c (c, get (x, e), d) 9 Fun (x, t) -> run_c (c, VFun (x, t, e), d) 10 App (t0, t1) -> eval (t1, e, CApp1 (t0, e, c), d) 11 Shift (t) -> eval (t, e, CShift (c), d) 12 Reset (t) -> eval (t, e, cid, DRun (c, d)) 13 14 (* eval3 : t -> v *) 15 let eval3 t = eval (t, [], cid, did ) OCaml fun 5.1 ( [16] ).

t eval2 eval3 t eval2 t eval3 6 eval3 eval3 c eval4 c c c c. eval3 c head c tail c. eval4 1: eval3 eval4 eval3 c CApp1, CApp0, CShift c c c c c tail c CReset d c d 1 (* *) 2 type v = VFun of string * t * e 3 VCont of c list (* c c list *) 4 and e = (* *) (* *) 5 (* *) 6 and c = CApp1 of t * e (* c c *) 7 CApp0 of v (* c CReset *) 8 CShift (* *) 9 and d = DRun of c list (* d d *) eval4 1 (* identity function *) 2 (* cid : c list *) 3 (* did : d list *) 4 let cid = [] 5 let did = [] 6 7 (* eval : t * e * c list * d list -> v *) 8 let rec eval (t, e, c, d) = match t with 9 Var (x) -> run_c (c, get (x, e), d) 10 Fun (x, t) -> run_c (c, VFun (x, t, e), d) 11 App (t0, t1) -> eval (t1, e, CApp1 (t0, e) :: c, d) 12 Shift ( t) -> eval (t, e, CShift :: c, d) 13 Reset ( t) -> eval (t, e, cid, DRun ( c) :: d) 14 15 (* run_c : c list * v * d list -> v *)

16 and run_c (c, v, d) = match c with 17 CApp1 (t, e ) :: c -> eval (t, e, CApp0 (v) :: c, d) 18 CApp0 (v ) :: c -> ( match v with 19 VFun (x, t, e ) -> eval (t, (x, v ) :: e, c, d) 20 VCont (c ) -> run_c (c, v, DRun (c ) :: d)) 21 CShift :: c -> ( match v with 22 VFun (x, t, e ) -> eval (t, (x, VCont (c )) :: e, cid, d) 23 VCont (c ) -> run_c (c, VCont (c ), d)) 24 [] -> run_d (d, v) 25 26 (* run_d : d list * v -> v *) 27 and run_d (d, v) = match d with 28 DRun (c ) :: d -> run_c (c, v, d ) 29 [] -> v 30 31 (* eval4 : t -> v *) 32 let eval4 t = eval (t, [], cid, did ) c c list d d list 11, 12, 17 eval3 eval4 13 CReset (cid) Reset DRun(c) d list reset c d d shift/reset reset shift reset shift eval3 eval4 eval3 eval4 eval3 eval4 6.1 ( ). t eval3 eval4 t eval3 t eval4 7 7.1 eval4 CApp0 v eval5 c list 1 (* *) 2 type v = VFun of string * t * e 3 VCont of (c list ) * s (* c list *) 4 (* *) 5 and s = v list (* *) 6 and e = (* *) (* *) 7 (* *) 8 and c = CApp1 of t * e 9 CApp0 (* *) 10 CShift 11 and d = DRun of (c list ) * s (* c list *)

CApp0(v) v v CApp0 c list (c list) * s VCont DRun s run c run d run c run d eval5 1 (* cid : c list *) 2 (* did : d list *) 3 let cid = [] 4 let did = [] 5 6 (* eval : t * s * e * c * d -> v *) 7 let rec eval (t, s, e, c, d) = match t with 8 Var ( x) -> run_c (c, get (x, e) :: s, d) 9 Fun (x, t) -> run_c (c, VFun (x, t, e) :: s, d) 10 App (t0, t1) -> eval (t1, s, e, CApp1 (t0, e) :: c, d) 11 Shift ( t) -> eval (t, s, e, CShift :: c, d) 12 Reset (t) -> eval (t, [], e, cid, DRun (c, s) :: d) 13 14 (* run_c : c * s * d -> v *) 15 and run_c (c, s, d) = match c with 16 CApp1 (t, e ) :: c -> eval (t, s, e, CApp0 :: c, d) 17 CApp0 :: c -> 18 ( match s with 19 VFun (x, t, e ) :: v :: s -> eval (t, s, (x, v ) :: e, c, d) 20 VCont (c, s ) :: v :: s -> run_c (c, v :: s, DRun (c, s ) :: d)) 21 CShift :: c -> 22 ( match s with 23 VFun (x, t, e ) :: s -> eval (t, [], (x, VCont (c, s )) :: e, cid, d) 24 VCont (c, s ) :: s -> run_c (c, VCont (c, s ) :: s, d)) 25 [] -> run_d (d, s) 26 27 (* run_d : d * s -> v *) 28 and run_d (d, s) = match (d, s) with 29 ( DRun (c, s ) :: d, v :: s ) -> run_c (c, v :: s, d ) 30 ([], v :: s ) -> v 31 32 (* eval5 : t -> v *) 33 let eval5 t = eval (t, [], [], cid, did ) s 8, 9 eval4 20, 24, 29 VCont DRun 29, 30 (s ) 7.2 eval4 eval5 eval4 eval5 bisimulation bisimulation 7.1 (bisimulation [14]). P Q P, Q bisimulation P P P Q Q P Q Q Q Q Q P P P Q P

bisimulation eval4 eval5 eval4 9 eval Var(x) run c (c, get(x, e), d) Var(x), e 4, c 4, d 4 c 4, get(x, e 4 ), d 4 eval, run c, run d run d t, e, c, d, c, v, d, d, v, v eval4 2 t t, [], [], [] Var(x), e, c, d c, get(x, e), d Fun(x, t), e, c, d c, VFun(x, t, e), d App(t0, t1), e, c, d t1, e, CApp1(t0, e) :: c, d Shift(t), e, c, d t, e, CShift :: c, d Reset(t), e, c, d t, e, [], DRun(c) :: d CApp1(t, e) :: c, v, d t, e, CApp0(v) :: c, d CApp0(v) :: c, VFun(x, t, e), d t, (x, v) :: e, c, d CApp0(v) :: c, VCont(c ), d c, v, DRun(c) :: d CShift :: c, VFun(x, t, e), d t, (x, VCont(c)) :: e, [], d CShift :: c, VCont(c ), d c, VCont(c), d [], v, d d, v DRun(c ) :: d, v c, v, d [], v v 2: eval4 eval5 t, s, e, c, d, c, s, d, d, s, v 3 t t, [], [], [], [] Var(x), s, e, c, d c, get(x, e) :: s, d Fun(x, t), s, e, c, d c, VFun(x, t, e) :: s, d App(t0, t1), s, e, c, d t1, s, e, CApp1(t0, e) :: c, d Shift(t), s, e, c, d t, s, e, CShift :: c, d Reset(t), s, e, c, d t, [], e, [], DRun(c, s) :: d CApp1(t, e) :: c, s, d t, s, e, CApp0 :: c, d CApp0 :: c, VFun(x, t, e) :: v :: s, d t, s, (x, v) :: e, c, d CApp0 :: c, VCont(c, s ) :: v :: s, d c, v :: s, DRun(c, s) :: d CShift :: c, VFun(x, t, e) :: s, d t, [], (x, VCont(c, s)) :: e, [], d CShift :: c, VCont(c, s ) :: s, d c, VCont(c, s) :: s, d [], s, d d, s DRun(c, s ) :: d, v :: s c, v :: s, d [], v :: s v 3: eval5 eval4 eval5 bisimulation eval4 eval5 eval4 eval5 eval4 c 4 eval5 s c 5 = s c 4 = s s c 5 c 4 s c 5 = s eval4 eval5

7.2 ( = s ). eval4 S 4 eval5 S 5 t, e 4, c 4, d 4 S 4, c 4, v 4, d 4 S 4, t, s, e 5, c 5, d 5 S 5, c 5, v 5 :: s, d 5 S 5 = s (i) c 4 = [], s = [], c 5 = [] c 4 = s s c 5 (ii) c 4 = s s c 5, e 4 = s e 5 c 4 = CApp1 4 (t, e 4 ) :: c 4, c 5 = CApp1 5 (t, e 5 ) :: c 5 c 4 = s s c 5 (iii) c 4 = s s c 5, v 4 = s v 5 c 4 = CApp0 4 (v 4 ) :: c 4, c 5 = CApp0 5 :: c 5 c 4 = s (v 5 :: s) c 5 (iv) c 4 = s s c 5 c 4 = CShift 4 :: c 4, c 5 = CShift 5 :: c 5 c 4 = s s c 5 c 4 = s s c 5 VCont 4 (c 4 ) = s VCont 5 (s, c 5 ), DRun 4 (c 4 ) = s DRun 5 (c 5, s) = s 7.2 (iii) c 4 CApp0 4 (v 4 ) v 4 c 5 CApp0 5 v 5 s = s eval4 eval5 s bisimulation 7.1 ( bisimulation). c 4 = s s c 5, e 4 = s e 5, d 4 = s d 5, v 4 = s v 5 t, e 4, c 4, d 4 s t, s, e 5, c 5, d 5 c 4 = s s c 5, d 4 = s d 5, v 4 = s v 5 c 4, v 4, d 4 s c 5, v 5 :: s, d 5 d 4 = s d 5, v 4 = s v 5 d 4, v 4 s d 5, v 5 :: s v 4 = s v 5 v 4 s v 5 s bisimulation. P S 4, Q S 5 P s Q P eval4 P Q eval5 Q P s Q Q Q eval5 Q P eval4 P P s Q P [11] eval4 eval5 bisimulation 7.2 ( ). t eval4 eval5 ( t eval4 v 4 eval5 v 5 v 4 = s v 5 ) Biernacka [4] Danvy [7] shift/reset eval5

8 8.1 eval5 c e (10 ) c list eval6 CApp1 1 (* *) 2 type v = VFun of string * t * e 3 VCont of ( c list ) * s 4 VEnv of e (* *) 5 and s = (* *) (* *) 6 and e = (* *) (* *) 7 (* *) 8 and c = CApp1 of t (* *) 9 CApp0 10 CShift 11 and d = (* *) CApp1 e VEnv(e) CApp1 eval6 1 (* cid : c list *) 2 (* did : d list *) 3 let cid = [] 4 let did = [] 5 6 (* eval : t * s * e * c list * d list -> v *) 7 let rec eval (t, s, e, c, d) = match t with 8 Var ( x) -> run_c (c, get (x, e) :: s, d) 9 Fun (x, t) -> run_c (c, VFun (x, t, e) :: s, d) 10 App (t0, t1) -> eval (t1, VEnv (e) :: s, e, CApp1 (t0) :: c, d) 11 Shift ( t) -> eval (t, s, e, CShift :: c, d) 12 Reset (t) -> eval (t, [], e, CReset :: [], DRun (c, s) :: d) 13 14 (* run_c : c list * s * d -> v *) 15 and run_c (c, s, d) = match c with 16 CApp1 (t ) :: c -> 17 ( match s with 18 v :: VEnv (e ) :: s -> eval (t, v :: s, e, CApp0 :: c, d)) 19 CApp0 :: c -> 20 ( match s with 21 VFun (x, t, e ) :: v :: s -> eval (t, s, (x, v ) :: e, c, d) 22 VCont (c, s ) :: v :: s -> run_c (c, v :: s, DRun (c, s ) :: d)) 23 CShift :: c -> 24 ( match s with 25 VFun (x, t, e ) :: s 26 -> eval (t, [], (x, VCont (c, s )) :: e, CReset :: [], d) 27 VCont (c, s ) :: s -> run_c (c, VCont (c, s ) :: s, d)) 28 CReset :: _ -> run_d (d, s) 29 30 (* run_d : d list * s -> v *) 31 and run_d (d, s) = match (d, s) with 32 ( DRun (c, s ) :: d, v :: s ) -> run_c (c, v :: s, d ) 33 ( DReset :: _, v :: s ) -> v 34 35 (* eval6 : t -> v *) 36 let eval6 t = eval (t, [], [], cid, did ) App 10 VEnv t1

t1 CApp1(t0) t1 16 18 (t) 8.2 eval5 eval, run c, run d run d t, s, e, c, d, c, s, d, d, s, v eval5 7.2 eval6 t, s, e, c, d, c, s, d, d, s, v 4 t t, [], [], [], [] Var(x), s, e, c, d c, get(x, e) :: s, d Fun(x, t), s, e, c, d c, VFun(x, t, e) :: s, d App(t0, t1), s, e, c, d t1, VEnv(e) :: s, e, CApp1(t0) :: c, d Shift(t), s, e, c, d t, s, e, CShift :: c, d Reset(t), s, e, c, d t, [], e, [], DRun(c, s) :: d CApp1(t) :: c, v :: VEnv(e) :: s, d t, v :: s, e, CApp0 :: c, d CApp0 :: c, VFun(x, t, e) :: v :: s, d t, s, (x, v) :: e, c, d CApp0 :: c, VCont(c, s ) :: v :: s, d c, v :: s, DRun(c, s) :: d CShift :: c, VFun(x, t, e) :: s, d t, [], (x, VCont(c, s)) :: e, [], d CShift :: c, VCont(c, s ) :: s, d c, VCont(c, s) :: s, d [], s, d d, s DRun(c, s ) :: d, v :: s c, v :: s, d [], v :: s v 4: eval6 bisimulation eval5 eval6 eval5 c eval6 eval5 s 5, c 5, eval6 s 6, c 6 c 5 s 6, c 6 s 5 c 5 = e s 6 c 6 = e eval5 eval6 8.1 ( = e ). eval5 S 5 eval6 S 6 t, s 5, e 5, c 5, d 5 S 5, c 5, v 5 :: s 5, d 5 S 5, t, s 6, e 6, c 6, d 6 S 6, c 6, v 6 :: s 6, d 6 S 6 = e (i) s 5 = [], c 5 = [], s 6 = [], c 6 = [] s 5 c 5 = e s 6 c 6 (ii) s 5 c 5 = e s 6 c 6 e 5 = e e 6 c 5 = CApp1 5 (t, e 5 ) :: c 5, c 6 = CApp1 6 (t) :: c 6 s 5 c 5 = e (VEnv(e 6 ) :: s 6 ) c 6 (iii) s 5 c 5 = e s 6 c 6 c 5 = CApp0 5 :: c 5, c 6 = CApp0 6 :: c 6 (v 5 :: s 5 ) c 5 = e (v 6 :: s 6 ) c 6

(iv) s 5 c 5 = e s 6 c 6 c 5 = CShift 5 :: c 5, c 6 = CShift 6 :: c 6 s 5 c 5 = e s 6 c 6 s 5 c 5 = e s 6 c 6 VCont 5 (c 5, s 5 ) = e VCont 6 (c 6, s 6 ), DRun 5 (c 5, s 5 ) = e DRun 6 (c 6, s 6 ) = e 8.1 (ii) c 5 CApp1 5 (t, e 5 ) c 6 CApp1 6 (t) VEnv(e 6 ) s 6 = e eval5 eval6 bisimulation 8.1 ( bisimulation). s 5 c 5 = e s 6 c 6, e 5 = e e 6, d 5 = e d 6, v 5 = e v 6 t, s 5, e 5, c 5, d 5 e t, s 6, e 6, c 6, d 6 s 5 c 5 = e s 6 c 6, d 5 = e d 6, v 5 = e v 6 c 5, v 5 :: s 5, d 5 e c 6, v 6 :: s 6, d 6 d 5 = e d 6, v 5 = e v 6 d 5, v 5 :: s 5 e d 6, v 6 :: s 6 v 5 = e v 6 v 5 e v 6 e bisimulation. P S 5, Q S 6 P s Q P eval5 P Q eval6 Q P s Q Q Q eval6 Q P eval5 P P s Q P 7.1 [11] eval5 eval6 bisimulation 8.2 ( ). t eval5 eval6 ( t eval5 v 5 eval6 v 6 v 5 = e v 6 ) CPS 3 Danvy shift/reset 9 eval6 4 t, s, e, c, d Landin SECD [12] shift/reset t1 t0

t1 shift/reset s@d ( s d append ) @ shift reset CShift VCont [13] shift shift/reset shift s v v VCont(c, s) VCont index 10 shift/reset CPS CPS t, s, e, c, d shift/reset Landin SECD shift/reset shift/reset shift reset shift/reset shift/reset Ager [1] i i shift/reset shift/reset [1] M. S. Ager, D. Biernacki, O. Danvy, and J. Midtgaard: From Interpreter to Compiler and Virtual Machine: A Functional Derivation, Technical Report RS-03-14, BRICS, Aarhus, Denmark (March 2003).

[2] M. S. Ager, D. Biernacki, O. Danvy, and J. Midtgaard: A Functional Correspondence between Evaluators and Abstract Machines, Technical Report RS-03-13, BRICS, Aarhus, Denmark (March 2003). [3] K. Asai, and Y. Kameyama: Polymorphic Delimited Continuations, Proceedings of the Fifth Asian Symposium on Programming Languages and Systems (APLAS 07), LNCS 4807, pp. 239 254 (November 2007). [4] M. Biernacka, D. Biernacki, and O. Danvy An Operational Foundation for Deliminated Continuations in the CPS Hierarchy, Logical Methods in Computer Science, Vol. 1 (2:5), pp. 1-39 (November 2005). [5] O. Danvy, and A. Filinski: A Functional Abstraction of Typed Contexts, Technical Report 89/12, DIKU, University of Copenhagen (July 1989). [6] O. Danvy, and A. Filinski: Abstracting Control, Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, pp. 151 160 (June 1990). [7] O. Danvy, and K. Millikin: A Rational Deconstruction of Landin s J Operator, Technical Report RS- 06-17, BRICS, Aarhus, Denmark (December 2006). [8] M. Felleisen: The Theory and Practice of First-Class Prompts, Conference Record of the 15th Annual ACM Symposium on Principles of Programming Languages, pp. 180 190 (January 1988). [9] A. Filinski: Representing Monads, Conference Record of the 21st Annual ACM Symposium on Principles of Programming Languages, pp. 446 457 (January 1994). [10] A. Igarashi and M. Iwaki: Deriving Compilers and Virtual Machines for a Multi-Level Languages, Proceedings of the Fifth Asian Symposium on Programming Languages and Systems (APLAS 07), LNCS 4807, pp. 206 221 (November 2007). [11] OCHA-IS 08-3 (February 2009). [12] P. J. Landin: The mechanical evaluation of expressions, The Computer Journal, Vol. 6, No. 4, pp. 308 320, (1964). [13] MinCaml shift/reset 11 (March 2009). [14] R. Milner: Communication and Concurrency Prentice Hall International Series in Computer Science, (1995). [15] G. D. Plotkin: Call-by-name, call-by-value, and the λ-calculus, Theoretical Computer Science, Vol. 1, No. 2, pp. 125 159 (December 1975). [16] J. C. Reynolds: Definitional Interpreters for Higher-Order Programming Languages, Proceedings of the ACM National Conference, Vol. 2, pp. 717 740, (August 1972), reprinted in Higher-Order and Symbolic Computation, Vol. 11, No. 4, pp. 363 397, Kluwer Academic Publishers (December 1998). [17] M. Sperber, R. K. Dybvig, M. Flatt, A. van Straaten: Revised 6 report on the algorithmic language Scheme, http://www.r6rs.org/ (2007).