Dynamic GoI machine
Call-by-need and call-by-value graph rewriter
S-REPLS 4 (London), 27 September 2016
Koko Muroya & Dan Ghica (Univ. Birmingham)
Dynamic GoI machine Call-by-need and call-by-value graph rewriter - - PowerPoint PPT Presentation
Dynamic GoI machine Call-by-need and call-by-value graph rewriter Koko Muroya & Dan Ghica (Univ. Birmingham) S-REPLS 4 (London), 27 September 2016 GoI machine [Danos & Regnier 99] [Mackie 95] abstract machine to interpret
S-REPLS 4 (London), 27 September 2016
Koko Muroya & Dan Ghica (Univ. Birmingham)
Muroya (U. Birmingham)
2
compositionally
Muroya (U. Birmingham)
q q 1 1
Muroya (U. Birmingham)
q q 1 1
Muroya (U. Birmingham)
call-by-name
4
Muroya (U. Birmingham)
call-by-name call-by-value
5
CPS transformation (Schöpp, Hoshino+) memory assigned to nodes (Hoshino+, Dal Lago+) parallelism: multiple tokens (Dal Lago+) dynamic jumps (Fernández+)
Muroya (U. Birmingham)
call-by-name call-by-value
6
avoid repeated evaluation force evaluation of function arguments
Muroya (U. Birmingham)
7
q q 3 q 3 6
Muroya (U. Birmingham)
7
q q 3 q 3 6
Muroya (U. Birmingham) 8
Muroya (U. Birmingham) 8
Muroya (U. Birmingham) 8
Muroya (U. Birmingham)
9
Muroya (U. Birmingham)
9
Muroya (U. Birmingham)
9
Muroya (U. Birmingham)
10
Muroya (U. Birmingham)
10
Muroya (U. Birmingham)
11
Muroya (U. Birmingham)
11
Muroya (U. Birmingham)
11
Muroya (U. Birmingham)
12
Muroya (U. Birmingham)
12
Muroya (U. Birmingham)
13
Muroya (U. Birmingham)
13
Muroya (U. Birmingham)
14
Muroya (U. Birmingham)
14
Muroya (U. Birmingham)
14
Muroya (U. Birmingham)
15
Muroya (U. Birmingham)
15
Muroya (U. Birmingham)
16
Muroya (U. Birmingham)
16
Muroya (U. Birmingham)
16
Muroya (U. Birmingham)
17
Muroya (U. Birmingham)
17
Muroya (U. Birmingham)
call-by-name call-by-need
18
avoid repeated evaluation force evaluation of function arguments
Muroya (U. Birmingham)
19
q q 3 6
Muroya (U. Birmingham)
19
q q 3 6
Muroya (U. Birmingham)
20
Muroya (U. Birmingham)
20
Muroya (U. Birmingham)
20
Muroya (U. Birmingham)
21
Muroya (U. Birmingham)
21
Muroya (U. Birmingham)
21
Muroya (U. Birmingham)
22
Muroya (U. Birmingham)
22
Muroya (U. Birmingham)
23
Muroya (U. Birmingham)
23
Muroya (U. Birmingham)
23
Muroya (U. Birmingham)
24
Muroya (U. Birmingham)
24
Muroya (U. Birmingham)
25
Muroya (U. Birmingham)
25
Muroya (U. Birmingham)
26
“move” transition
_ ((G, `e, `b), p, d, m) 99K ((G, `e, `b), p0, d0, m0)
(α : p, m) 99K (β : Ax : α : p, m) (α : p, m) 99K (β : Cut : α : p, m) Ax α ↑ β Ax α β ↓ Cut α ↓ β Cut α β ↑ (αl : p, m) 99K (β : ($, αr) : αl : p, l : m) (β : p, l : m) 99K (αl : ($, αr) : β : p, m) $ αl ↓ αr β $ αl αr β ↓ $ αl αr β ↑ $ αl ↑ αr β (αr : p, m) 99K (β : ($, αl) : αr : p, r : m) (β : p, r : m) 99K (αr : ($, αl) : β : p, m) $ αl αr ↓ β $ αl αr β ↓ $ αl αr β ↑ $ αl αr ↑ β (α : p, m) 99K (β : ! : α : p, m) (β : p, m) 99K (α : ! : β : p, m) ! α ↓ β ! α β ↓ ! α β ↑ ! α ↑ β (α : p, m) 99K (β : D : α : p, m) D α ↓ β D α β ↓ (αi : p, m) 99K (β : C+ : αi : p, m) (α : p, m) 99K (β : C : α : p, m) Ck+1 αi ↓ α1 αk+1 · · · · · · β Ck+1 αi α1 αk+1 · · · · · · β ↓ C1 α ↓ β C1 α β ↓ (β : p, m) 99K (α1 : Sum1 : β : p, m) (α1 : p, m) 99K (α2 : Sum2 : α1 : p, m) Sum α1 α2 β ↑ Sum α1 ↑ α2 β Sum α1 ↓ α2 β Sum α1 α2 ↑ β (α2 : p, m) 99K (β : Sum : α2 : p, m) (α : p, m) 99K (α : (Val, n) : α : p, m) Sum α1 α2 ↓ β Sum α1 α2 β ↓ n α ↑ n α ↓
(β : p, m) 99K (β0 : (⇧, α0, α) : β : p, m) α0 α β0 β " α0 α β0 # β
Muroya (U. Birmingham)
27
“rewrite” transition
_ ((G, `e, `b), p, d, m) ((G0, `0
e, `0 b), p0, d0, m)
α : ($, α0) : β : Cut : γ : ($⇤, δ0) : δ : p α : Cut : δ : p $ $⇤ Cut α ↑ α0 δ δ0 β γ Cut Cut α ↑ δ α0 δ0 $ $⇤ Cut α0 α ↑ δ0 δ β γ Cut Cut α ↑ δ α0 δ0 α : Cut : β : Ax : γ : p γ : p Cut Ax α ↑ β γ γ ↑ α : ! : β : Cut : γ : Ax : δ : p α : ! : δ : p ! Cut Ax α ↑ β γ δ ! α ↑ δ α : ! : β : Cut : γ : ? : δ : p α : ! : Cut : δ : p ! ? Cut α ↑ β γ δ ! Cut α ↑ β δ α : ! : β : Cut : γ : D : δ : p α : Cut : δ : p ? ? ! D Cut α1 β1 αm βm α ↑ β γ δ G · · · · · · β1 βm Cut α ↑ δ G · · ·
α : Sum : β2 : ! : γ2 : (Val, m) : γ2 : ! : β2 : Sum2 : β1 : ! : γ1 : (Val, n) : γ1 : ! : β1 : Sum1 : α : p γ1 : ! : α : p Sum ! ! n m γ1 γ2 β1 β2 α ↓ n + m ! γ1 ↑ α α : ! : β : Cut : γ : C : δ : p α : ! : β : Cut : δ : p ? ? ! C1 Cut α1 β1 αm βm α ↑ β γ0 δ G · · · · · · ? ? ! Cut α1 β1 αm βm α ↑ β δ G · · · · · ·
↵ : ! : : Cut : : C+ : i : p ↵ : ! : : Cut : i : p ? ? ! Ck+1 Cut ~ C · · · ↵1 1 ↵m m ↵ ↑
k+1 i · · · · · · G · · · · · · ? ? ! Cut ↵1 ↵m ↵ ↑
G · · · · · · ? ? ! Ck Cut ~ C · · · µ1 µm µ ⌫
· · · k+1 ˜ G · · · · · · 1 m ⌫1 ⌫m α : ! : β : Cut : γ0 : (⇧, δ0, δ) : γ : p γ : p ? ? ! Cut α1 β1 αm βm α " β γ0 δ0 γ δ G · · · · · · ? ? ! Cut α1 β1 αm βm α β γ0 γ " G · · · · · ·
Muroya (U. Birmingham)
28
_
def.
⇐ ⇒ ( if a rewrite is possible 99K if no rewrite but a move is possible
hV, Eit !val hE, V ic hM N, Eit !val hM, E[[ ] N]it hM + N, Eit !val hM, E[[ ] + N]it hx, E1[let x = V in E2]it !val hE1[let x = V in E2], V ic
h i ! h i h[ ], A[V ]ic !val hA[V ]ia hE[[ ] N], A[x. M]ic !val hN, E[A[let x0 := [ ] in M[x0/x]]]it hE[[ ] + N], A[n]ic !val hN, E[A[n + [ ]]]it hE[n + [ ]], A[m]ic !val hE, A[n + m]ic hE[let x = V 0 in [ ]], A[V ]ic !val hE, let x = V 0 in A[V ]ic hE[let x := [ ] in M], A[V ]ic !val hM, E[A[let x = V in [ ]]]it
_ _ Theorem A.2. There exists a binary relation ‡ that satisfies c
k
→val c0 ∧ c ‡ (G, p, d, m) = ⇒ (G, p, d, m)
O(k)
_ · · · _ (G0, p0, d0, m0) ∧ c0 ‡ (G0, p0, d0, m0) .
Muroya (U. Birmingham)
29
x† :=
_ _ Theorem A.2. There exists a binary relation ‡ that satisfies c
k
→val c0 ∧ c ‡ (G, p, d, m) = ⇒ (G, p, d, m)
O(k)
_ · · · _ (G0, p0, d0, m0) ∧ c0 ‡ (G0, p0, d0, m0) .
(λx. M)† := (M N)† :=
Muroya (U. Birmingham)
call-by-name call-by-need & call-by-value
30
avoid repeated evaluation force evaluation of function arguments