• 検索結果がありません。

Token-passing semantics with and without rewriting

N/A
N/A
Protected

Academic year: 2022

シェア "Token-passing semantics with and without rewriting"

Copied!
41
0
0

読み込み中.... (全文を見る)

全文

(1)

Token-passing semantics with and without rewriting

Koko Muroya

(RIMS, Kyoto University

& University of Birmingham)

Steven W. T. Cheung Dan R. Ghica

(University of Birmingham)

(2)

Token-passing semantics

without rewriting

(3)

Token-passing semantics without rewriting

execution models, provided by Girard’s GoI, of functional programming

● call-by-name λ-calculus [Danos&Regnier ‘99] [Mackie ‘95]

● call-by-value λ-calculus [Fernandez&Mackie ‘02]

● and more: PCF, effects, concurrency...

(4)

Token-passing semantics without rewriting

execution models, provided by Girard’s GoI, of functional programming

● call-by-name λ-calculus [Danos&Regnier ‘99] [Mackie ‘95]

● call-by-value λ-calculus [Fernandez&Mackie ‘02]

● and more: PCF, effects, concurrency...

program diagram

evaluation token passing

(MELL) proof net, λ-graph, ...

(5)

Token-passing semantics without rewriting

live demo:

Jamping Abstract Machine for call-by-name λ-calculus [DR99]

https://koko-m.github.io/GoI-Visualiser/

program diagram

evaluation token passing result token data/position

(6)

Token-passing semantics without rewriting

live demo:

Jamping Abstract Machine for call-by-name λ-calculus [DR99]

https://koko-m.github.io/GoI-Visualiser/

program λ-graph + !-boxes

evaluation token passing + jumping result token data/position

(7)

Token-passing semantics without rewriting

execution models of functional programming

● compiler [Mackie ‘95]

● higher-order synthesis [Ghica ‘07]

program diagram

evaluation token passing result token data/position

(8)

Token-passing semantics

with rewriting

(9)

Token-passing semantics with rewriting

execution models of functional programming

● call-by-name & call-by-value λ-calculus [Sinot ‘05]

● call-by-need & fully lazy λ-calculus [Sinot ‘06]

● call-by-need & call-by-value λ-calculus [−&Ghica ‘17]

conventional small-step semantics, diagramatically (+ more)

(10)

Token-passing semantics with rewriting

execution models of functional programming

● call-by-name & call-by-value λ-calculus [Sinot ‘05]

● call-by-need & fully lazy λ-calculus [Sinot ‘06]

● call-by-need & call-by-value λ-calculus [−&Ghica ‘17]

program diagram

evaluation

redex search token passing

reduction diagram rewriting

inspired by virtual reduction [Danos&Regnier ‘93]

(11)

Token-passing semantics with rewriting

live demo:

Dynamic GoI Machine for call-by-value λ-calculus [KG17]

https://koko-m.github.io/GoI-Visualiser/

program diagram

evaluation

redex search token passing

reduction diagram rewriting

result diagram

(12)

Token-passing semantics with rewriting

live demo:

Dynamic GoI Machine for call-by-value λ-calculus [KG17]

https://koko-m.github.io/GoI-Visualiser/

program λ-graph +

!-boxes

evaluation

redex search token passing

reduction diagram rewriting

result λ-graph +

!-boxes

(13)

Token-passing semantics with rewriting

execution models of functional programming

● with robustness [S05] [S06]

● with time/space efficiency [MG17]

program diagram

evaluation

redex search token passing

reduction diagram rewriting

result diagram

(14)

Token-passing semantics with rewriting

execution models of functional programming

● with robustness [S05] [S06]

● with time/space efficiency [MG17]

program diagram

evaluation

redex search token passing

reduction diagram rewriting

result diagram

whenever possible

(15)

Token-passing semantics with rewriting

execution models of functional programming

● with robustness [S05] [S06]

● with time/space efficiency [MG17]

program diagram

evaluation

redex search token passing

reduction diagram rewriting

result diagram

selective?

(16)

Token-passing semantics

with and without rewriting

(17)

token-passing semantics without rewriting

… space efficiency

token-passing semantics with rewriting

… time efficiency

non-trivial space/time balancing?

selective rewriting

(18)

token-passing semantics without rewriting

… space efficiency

token-passing semantics with rewriting

… time efficiency

non-trivial space/time balancing?

another perspective

selective rewriting

(19)

token-passing semantics without rewriting

… result given by the token

token-passing semantics with rewriting

… result given by a diagram

programming with dual result

… given by the token and a diagram?

selective rewriting

(20)

token-passing semantics without rewriting

… result given by the token

token-passing semantics with rewriting

… result given by a diagram

programming with “computation graphs”

… result being value with computation graph

selective rewriting

(21)

Programming with “computation graphs”

result value

with computation graph

● construction

● manipulation

(22)

TensorFlow, Google’s machine-learning library

Programming with “computation graphs”

W = tf.Variable(...) b = tf.Variable(...) y = W * x_data + b x_data = ...

y_data = ...

sess = tf.Session() sess.run(init)

sess.run(train) x_data = ...

sess = tf.Session() sess.run(init)

y_initial_values = sess.run(y)

construction

machine-learning model with parameters

manipulation

model training

(imperative parameter update) value extraction

output prediction

(23)

TensorFlow, Google’s machine-learning library

Programming with “computation graphs”

W = tf.Variable(...) b = tf.Variable(...) y = W * x_data + b x_data = ...

y_data = ...

sess = tf.Session() sess.run(init)

sess.run(train) x_data = ...

sess = tf.Session() sess.run(init)

y_initial_values = sess.run(y)

construction

x

*

W b

+

y

“variables”

(24)

TensorFlow, Google’s machine-learning library

Programming with “computation graphs”

W = tf.Variable(...) b = tf.Variable(...) y = W * x_data + b x_data = ...

y_data = ...

sess = tf.Session() sess.run(init)

sess.run(train) x_data = ...

sess = tf.Session() sess.run(init)

y_initial_values = sess.run(y)

construction

x

*

W b

+

y

“variables”

“parameters”

(25)

TensorFlow, Google’s machine-learning library

Programming with “computation graphs”

W = tf.Variable(...) b = tf.Variable(...) y = W * x_data + b x_data = ...

y_data = ...

sess = tf.Session() sess.run(init)

sess.run(train) x_data = ...

sess = tf.Session() sess.run(init)

y_initial_values = sess.run(y)

manipulation

x

*

W’ b’

+

y

in-place (imperative) parameter update

(26)

TensorFlow, Google’s machine-learning library

Programming with “computation graphs”

W = tf.Variable(...) b = tf.Variable(...) y = W * x_data + b x_data = ...

y_data = ...

sess = tf.Session() sess.run(init)

sess.run(train) x_data = ...

sess = tf.Session() sess.run(init)

y_initial_values = sess.run(y)

manipulation

x

*

W’ b’

+

y x_data

output prediction

(27)

Self-Adjusting Computation [Acar ‘05]

(Incremental, an OCaml library)

Programming with “computation graphs”

construction

acyclic dependency graph with “modifiables/cells”

manipulation

change propagation value extraction

“spreadsheet”

let x = Inc.Var.create 1 in let y = Inc.map2

(Inc.Var.watch x)

(Inc.Var.watch x) ~f:( + ) in let z = Inc.Var.create 2 in let w = Inc.map2

(Inc.Var.watch y)

(Inc.Var.watch z) ~f:( + ) in let w_obs = Inc.observe w in Inc.Var.set x 3;

Inc.stabilize ();

print_int

(Inc.Observer.value_exn w_obs)

(28)

Self-Adjusting Computation [Acar ‘05]

(Incremental, an OCaml library)

Programming with “computation graphs”

construction

“spreadsheet”

let x = Inc.Var.create 1 in let y = Inc.map2

(Inc.Var.watch x)

(Inc.Var.watch x) ~f:( + ) in let z = Inc.Var.create 2 in let w = Inc.map2

(Inc.Var.watch y)

(Inc.Var.watch z) ~f:( + ) in let w_obs = Inc.observe w in Inc.Var.set x 3;

Inc.stabilize ();

print_int

(Inc.Observer.value_exn w_obs)

1

+

2

+

“modifiables”

“cells”

x z

y

(29)

Self-Adjusting Computation [Acar ‘05]

(Incremental, an OCaml library)

Programming with “computation graphs”

construction

“spreadsheet”

let x = Inc.Var.create 1 in let y = Inc.map2

(Inc.Var.watch x)

(Inc.Var.watch x) ~f:( + ) in let z = Inc.Var.create 2 in let w = Inc.map2

(Inc.Var.watch y)

(Inc.Var.watch z) ~f:( + ) in let w_obs = Inc.observe w in Inc.Var.set x 3;

Inc.stabilize ();

print_int

(Inc.Observer.value_exn w_obs)

3

+

2

+

change set

x z

y

(30)

Self-Adjusting Computation [Acar ‘05]

(Incremental, an OCaml library)

Programming with “computation graphs”

manipulation

“spreadsheet”

let x = Inc.Var.create 1 in let y = Inc.map2

(Inc.Var.watch x)

(Inc.Var.watch x) ~f:( + ) in let z = Inc.Var.create 2 in let w = Inc.map2

(Inc.Var.watch y)

(Inc.Var.watch z) ~f:( + ) in let w_obs = Inc.observe w in Inc.Var.set x 3;

Inc.stabilize ();

print_int

(Inc.Observer.value_exn w_obs)

3

+

2

+

change propagation

x z

y

(31)

Self-Adjusting Computation [Acar ‘05]

(Incremental, an OCaml library)

Programming with “computation graphs”

value extraction

“spreadsheet”

let x = Inc.Var.create 1 in let y = Inc.map2

(Inc.Var.watch x)

(Inc.Var.watch x) ~f:( + ) in let z = Inc.Var.create 2 in let w = Inc.map2

(Inc.Var.watch y)

(Inc.Var.watch z) ~f:( + ) in let w_obs = Inc.observe w in Inc.Var.set x 3;

Inc.stabilize ();

print_int

(Inc.Observer.value_exn w_obs)

3

+

2

+

observation

x z

y

(32)

Probabilistic Programming

Programming with “computation graphs”

construction

stochastic model + observations

manipulation

stochastic inference value extraction

posterior distribution

[program]

[run-time system]

(33)

TensorFlow

imperative parameter update on machine-learning model Self-Adjusting Computation

change propagation on acyclic dependency graph Probabilistic Programming

inference on stochastic model

Programming with “computation graphs”

result value

with computation graph

● construction

● manipulation

(34)

token-passing semantics without rewriting

… result given by the token

token-passing semantics with rewriting

… result given by a diagram

programming with “computation graphs”

… result being value with computation graph

selective rewriting

(35)

Token-passing semantics with & without rewriting

program diagram

evaluation

redex search token passing reduction diagram rewriting

computation graphs

construction selective

diagram rewriting manipulation diagram rewriting value extraction token data

(36)

Idealised TensorFlow [−,Cheung&Ghica ‘18]

functional parameter update on machine-learning model Synchronous Self-Adjusting Computation

change propagation on cyclic dependency graph

Programming with “computation graphs”

result value

with computation graph

● construction

● manipulation

(37)

live demo: https://cwtsteven.github.io/GoI-SAC-Visualiser/

Synchronous Self-Adjusting Computation

construction

cyclic dependency graph with “modifiables/cells”

manipulation

cell-wise change propagation

x = {1}

y = x + x z = {2}

w = y + z link x to 3;

_ = step () _ = step () w;

multiple

independent tokens

(38)

live demo: https://cwtsteven.github.io/GoI-SAC-Visualiser/

Synchronous Self-Adjusting Computation

construction

cyclic dependency graph with “modifiables/cells”

manipulation

cell-wise change propagation

(* alternating signal *) x = {true}

link x to ~x;

_ = step () _ = step ()

multiple

independent tokens

(39)

token-passing semantics without rewriting

… result given by the token

token-passing semantics with rewriting

… result given by a diagram

programming with “computation graphs”

… result being value with computation graph

selective rewriting

(40)

Token-passing semantics with & without rewriting

program diagram

evaluation

redex search token passing reduction diagram rewriting

computation graphs

construction selective

diagram rewriting manipulation diagram rewriting value extraction token data

(41)

Directions

● sit back and lay the foundation?

○ “cells”, special constants

■ shared but never duplicated

■ blocking rewrite

● more applications?

○ differentiating (higher-order) computation graphs

○ digesting meta-level stochastic inference

参照

関連したドキュメント

The exception is when the token points downwards at the left output of a primitive operation node (#), and the top three elements of the computation stack have to be checked. Let

• local & step-wise reasoning to prove observational equivalence, with the concept of robustness..

The mGoI framework provides token machine semantics of effectful computations, namely computations with algebraic effects, in which effectful λ-terms are translated to transducers..

In this note, we show how the notion of relational flow dia- gram (essentially a matrix whose entries are relations on the set of states of the program), introduced by Schmidt, can

This work is devoted to an interpretation and computation of the first homology groups of the small category given by a rewriting system.. It is shown that the elements of the

There is a unique Desargues configuration D such that q 0 is the von Staudt conic of D and the pencil of quartics is cut out on q 0 by the pencil of conics passing through the points

modular proof of soundness using U-simulations.. & RIMS, Kyoto U.). Equivalence

Case 1: Without loss of generality, say all the lines are black; then the black con- figuration together with the members of the special class which also have all black lines