Lusteral Uniform and Modular Composition of Data-flow & - - PowerPoint PPT Presentation

lusteral
SMART_READER_LITE
LIVE PREVIEW

Lusteral Uniform and Modular Composition of Data-flow & - - PowerPoint PPT Presentation

Lusteral Uniform and Modular Composition of Data-flow & Control-flow in the Lazy -Calculus joint work with Marc Pouzet M. Mendler, University of Bamberg Synchron 2008 CPL Aussois Synchron 2008 CPL Aussois 1 Constructive Data


slide-1
SLIDE 1

Synchron 2008 – CPL Aussois

Lusteral

Uniform and Modular Composition of Data-flow & Control-flow in the Lazy λ-Calculus

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 1

joint work with Marc Pouzet

slide-2
SLIDE 2

Synchron 2008 – CPL Aussois

Constructive Data Flow

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-2

Introduction

slide-3
SLIDE 3

Synchron 2008 – CPL Aussois

Data Flow Programming

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 3

Signal, Lustre, SCADE V4, LabView, Simulink, ...

slide-4
SLIDE 4

Synchron 2008 – CPL Aussois

Control Flow Programming

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 4

wA

A/arm

wB

B/arm

WaitAandB

done

/ AB

dA dB

ABSync Reset signal arm

idle cnt 1

arm Detection Inhib

Timer

2 T / disarm

eot

disarm

2

signal disarm

Esterel, SyncCharts, Argos, Stateflow, Statemate, ...

slide-5
SLIDE 5

Synchron 2008 – CPL Aussois

Starting the 3rd Millennium ...

ReLuC, Lucide Synchrone, SCADE 6, 7, 8, Synoptic, ...

... we are looking at hybrid engines with tight integration

  • f data flow and control flow:
slide-6
SLIDE 6

Synchron 2008 – CPL Aussois

Starting the 3rd Millennium ...

... we need to understand the semantical mechanics of such a hybrid (4 education, certification, verification,...)

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-6

Recent work (2005): J.-L. Colaço, B. Pagano, M. Pouzet give semantics of Scade V6 by

  • syntactic compilation of
  • SF DF using states-as-activation-clocks with explicit

absence values Open Question: Can SF and DF be unified into a

  • compositional semantic model
  • on equal footing, without „absence“ values ?
slide-7
SLIDE 7

equational reasoning higher-order polymorphic declarative extensible

Lusterel Language Design Workbench

strong typing smooth morphing between data and control-flow

Synchron 2008 – CPL Aussois

The Lusteral Experiment

  • Lustre-style DF + Esterel-style SF under the same (co-

recursive, functional) reactive process model

  • shallow embedding in Haskell, aka lazy λ-calculus
  • separation control ≠ data (no absence values)
  • simple set of well-understood functional combinators
  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 7

We aim to integrate

Lustre DF Esterel SF

slide-8
SLIDE 8

Synchron 2008 – CPL Aussois

Kahn Principle

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 8

  • At any time, a computing station is either computing or

waiting for information on one of its input lines

  • Each computation station follows a sequential program

Working Hypothesis:

  • Stream processing functions of Haskell are Kahn

processes: Lazy rewriting is deterministic and sequential !

  • Kahn processes can be coded in Haskell. Kahn processes

exhibit parallelism of expression not of execution!

slide-9
SLIDE 9

Synchron 2008 – CPL Aussois

Constructive Data Flow

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-9

The Role of Laziness

slide-10
SLIDE 10

Synchron 2008 – CPL Aussois

Orthogonality in Time and Space

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 10

slide-11
SLIDE 11

Synchron 2008 – CPL Aussois

Data Flow

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 11

data flow

slide-12
SLIDE 12

Synchron 2008 – CPL Aussois

Data Flow

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 12

data flow Q: How do we treat the cyclic DF dependencies ? A: Fixpoints on prefix-ordering, lazy recursion on streams!

slide-13
SLIDE 13

Synchron 2008 – CPL Aussois

State Flow

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 13

state flow

slide-14
SLIDE 14

Synchron 2008 – CPL Aussois

State Flow

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 14

state flow Q: How do we treat the cyclic SF dependencies ? A: Scott information-ordering, lazy recursion on state

slide-15
SLIDE 15

Synchron 2008 – CPL Aussois

Fixed-point on Partial States

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 16

xs = ys = zs = xs = f (3 fby (fst zs), snd zs) zs f h g

fby

3 ys xs ys = h (snd xs) zs = g (ys, fst xs) 3 5 6 2

slide-16
SLIDE 16

Synchron 2008 – CPL Aussois

Fixed-point on Partial States

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 17

xs = ys = zs = xs = f (3 fby (fst zs), snd zs) zs f h g

fby

3 ys xs ys = h (snd xs) zs = g (ys, fst xs) 3 9 5 6 1 2 9 4

slide-17
SLIDE 17

Synchron 2008 – CPL Aussois

Fixed-point on Partial States

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 18

4 1 9 3 5 2 5 2 1 xs = ys = zs = xs = f (3 fby (fst zs), snd zs) zs f h g

fby

3 ys xs ys = h (snd xs) zs = g (ys, fst xs) 7 7 9 5 1 3 5 6 2

slide-18
SLIDE 18

Synchron 2008 – CPL Aussois

Where Eagerness is not Productive ...

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 19

xs = f (3 fby (fst zs), snd zs) ys = h (snd xs) zs = g (ys, fst xs) fst (f(3:fst zs), snd(g(h(snd(f(3 fby (fst zs), snd zs))),fst xs) … loop ! fst xs fst (f(3 fby (fst zs), snd zs)) fst (f(3:(fst zs), snd zs)) fst (f(3:(fst zs), snd(g(ys,fst xs)))) fst (f(3:(fst zs), snd(g(h(snd xs),fst xs)) zs f h g

fby

3 ys xs Eager Evaluation

slide-19
SLIDE 19

lazy on streams lazy on state (data)

Synchron 2008 – CPL Aussois

... Lazy Function Evaluation may be.

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 20

xs = f (3 fby (fst zs), snd zs) ys = h (snd xs) zs = g (ys, fst xs) fst xs fst(f(3 fby (fst zs), snd zs)) fst((f1 × f2)(3 fby (fst zs), snd zs)) fst((λw.(f1(fst w), f2(snd w))(3 fby (fst zs), snd zs)) fst(f1(fst(3 fby (fst zs), snd zs)), f2(snd(3 fby (fst zs), snd zs))) f1(3:(fst zs)) f1(3) : f1(fst zs) f1(fst(3 fby (fst zs), snd zs)) f h g

fby

3 ys xs zs f1(3 fby (fst zs)) ... f1(3) : H(f1(3)) : H(H(f1(3))) : H(H(H(f1(3)))) : ... where H[v] = f1(g1(h(f2(g2(v)))) Lazy Evaluation

slide-20
SLIDE 20

Synchron 2008 – CPL Aussois

Constructive Data Flow

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-21

SF ≠ Clocked DF

slide-21
SLIDE 21

Synchron 2008 – CPL Aussois

Clock Schedules are Implicit

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 28

when

xs cs zs xs = x0 x1 ⊥ x2 ⊥ x3 x4 ⊥ x5 x6 ... cs = T F ⊥ F ⊥ T F ⊥ T T ... zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... cs?c xs?x zs!x tick c=F c=T tick absence ⊥ is not communicated !

loop read c from cs; if c then read x from xs; write x to zs; else pause; pause; end loop loop read c from cs; if c then read x from xs; write x to zs; else pause; pause; end loop

slide-22
SLIDE 22

Synchron 2008 – CPL Aussois

Absence = Identity Reaction on ‘State Bus‘

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 29

when

xs cs1 zs xs = x0 x1 ⊥ x2 ⊥ x3 x4 ⊥ x5 x6 ... cs1= T F ⊥ F ⊥ T F ⊥ T T ... zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... ys = y0 y1 ⊥ y2 ⊥ y3 y4 ⊥ y5 y6 ... cs2= F T ⊥ T ⊥ F T ⊥ F F ... zs = ⊥ y1 ⊥ y2 ⊥ ⊥ y4 ⊥ ⊥ ⊥ ...

when

ys cs2 zs

slide-23
SLIDE 23

zs = x0 y1 ⊥ y2 ⊥ x3 y4 ⊥ x5 x6 ...

Synchron 2008 – CPL Aussois

Absence = Identity Reaction on ‘State Bus‘

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 30

when

xs cs1 zs zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... zs = ⊥ y1 ⊥ y2 ⊥ ⊥ y4 ⊥ ⊥ ⊥ ... ``state bus´´ zs

when

ys cs2 zs state bus values = response functions: parallel emits = function composition: The last value dominates the bus

slide-24
SLIDE 24

zs = x0 y1 ⊥ y2 ⊥ x3 y4 ⊥ x5 x6 ...

Synchron 2008 – CPL Aussois

Absence = Identity Reaction on ‘State Bus‘

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 31

when

xs cs1 zs zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... zs = ⊥ y1 ⊥ y2 ⊥ ⊥ y4 ⊥ ⊥ ⊥ ... ``state bus´´ zs

when

ys cs2 zs

non-termination Ω ≠ identity ⊥ ≠ absence ∗ x ◦ y same as x default y (Signal) but deeply coded !

SF DF DF

slide-25
SLIDE 25

zs = x0 y1 ⊥ y2 ⊥ x3 y4 ⊥ x5 x6 ...

Synchron 2008 – CPL Aussois

Absence = Identity Reaction on ‘State Bus‘

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 32

zs = x0 ⊥ ⊥ ⊥ ⊥ x3 ⊥ ⊥ x5 x6 ... zs = ⊥ y1 ⊥ y2 ⊥ ⊥ y4 ⊥ ⊥ ⊥ ...

  • M. Fourman [1989]:

Response functions (cpo) to model bi-directional instantaneous communication. non-termination Ω ≠ identity ⊥ ≠ absence ∗ x ◦ y same as x default y (Signal) but deeply coded !

SF DF DF

slide-26
SLIDE 26

Synchron 2008 – CPL Aussois

Constructive Data Flow

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-33

Synchronous Processes

slide-27
SLIDE 27

Synchron 2008 – CPL Aussois

SF/DF Reaction Relations

  • M. Mendler, University of Bamberg

Synchron 2008 – CPL Aussois 37

R::b

DF::SDF (a,b) c

E::a v::c

Data Flow

R::b

SF::SSM a b

E::a

State Flow

slide-28
SLIDE 28

Synchron 2008 – CPL Aussois

Constructive Data Flow

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-39

SF/DF Process Language

slide-29
SLIDE 29

Synchron 2008 – CPL Aussois

State Flow

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-40

state flow variable signal emission weak preemption parallel binding DF to signal local signal iteration wait branching signal input

slide-30
SLIDE 30

Synchron 2008 – CPL Aussois

Data Flow

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-41

close-off state flow static lifting of value operators up-sampling down-sampling delay initialisation initialised delay data flow variable feed-back, recursive data flow

slide-31
SLIDE 31

Synchron 2008 – CPL Aussois

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-46

Mode Automaton Example

slide-32
SLIDE 32

SEC TDIV

STOP

Synchron 2008 – CPL Aussois

Macro States & Mode Automaton

START s := 0 last_s Leftb/

H

Leftb/ Rightb/ CONTROL last_s := pre s MEM CHRONO s := if False cnt < pre cnt then (last_s + 1) ´mod´ 60 else last_s cnt := 0 (pre cnt + 1) mod 100

slide-33
SLIDE 33

Synchron 2008 – CPL Aussois

MEM

s

STOP

last_s s

START

s

SEC

cnt

TDIV

time

Data Flow

CONTROL

last_s

CHRONO

s

user action

system

slide-34
SLIDE 34

Synchron 2008 – CPL Aussois

MEM

s last_s

Reaction interface „E;R“ MEM from Data Flow MEM as State Flow

slide-35
SLIDE 35

Synchron 2008 – CPL Aussois

DF Interface STOP as Data Flow

STOP

s last_s

slide-36
SLIDE 36

Synchron 2008 – CPL Aussois

SF Reaction interface „E;R“ STOP from Data Flow STOP as State Flow

STOP

s last_s

slide-37
SLIDE 37

Synchron 2008 – CPL Aussois

START

s

SEC

cnt

TDIV

last_s

slide-38
SLIDE 38

Synchron 2008 – CPL Aussois

CTRL

s env last_s STOP START CONTROL H

Leftb/ Leftb/ Rightb/

sy sx

slide-39
SLIDE 39

Synchron 2008 – CPL Aussois

CTRL

s env last_s STOP START CONTROL H

Leftb/ Leftb/ Rightb/

sy sx

slide-40
SLIDE 40

Synchron 2008 – CPL Aussois

CTRL

s env last_s

CONTROL as Data Flow

STOP START CONTROL H

Leftb/ Leftb/ Rightb/

sy sx

slide-41
SLIDE 41

Synchron 2008 – CPL Aussois

MEM

CHRONO

CONTROL

s last_s s s

CHRONO

s

user action

CHRONO as Data Flow

slide-42
SLIDE 42

Synchron 2008 – CPL Aussois

tick zs!s ys?act xs zs s ys isRbp act / s←0 i s L b p a c t / d ←

startb s d stopb s

zs!s tick ys?act isLbp act / / d←d+1 d=100 / s←s+1´mod´60 d← 0 1 2 3 2 3 1

chrono

/ s←0 d

slide-43
SLIDE 43

Haskell implementation

slide-44
SLIDE 44

Synchron 2008 – CPL Aussois

Constructive Data Flow

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-76

ESTEREL is non-sequential !

slide-45
SLIDE 45

Synchron 2008 – CPL Aussois

Concurrent AND, OR

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-88

Esterel Control Flow is concurrent (non-sequential) ! Concurrent AND Æ

xs ys zs present x else pause ; present y then emit z present x else pause ; present y then emit z x y z present x then present y then emit z; present x then present y then emit z; x z y

z is absent if at least one of x or y is absent

present x then emit z || present y then emit z present x then emit z || present y then emit z x y z

Concurrent OR z is present if at least one of x or y is present

xs ys zs

Ç

slide-46
SLIDE 46

Synchron 2008 – CPL Aussois

Constructive Data Flow

  • M. Mendler, The Otto-Friedrich University of Bamberg

Lusterel-89

Conclusion

slide-47
SLIDE 47

Synchron 2008 – CPL Aussois

Summary

Kahn‘s original model of SF-DF can be uniformely coded in lazy λ-calculus without clocks and explicit „absent“ values Kahn‘s prefix ordering is not sufficient for SF causality, need a form of Scott-ordering on state Kahn SF is weaker than (full) Esterel SF, the latter is non-sequential with true concurrency of execution Lusteral implements sequential „token ring“ broadcast of signals not concurrent „ethernet“ (like Esterel)

slide-48
SLIDE 48

Related Work

  • Nowak, Beauvais, Talpin [1999]: Signal in Coq
  • Elliott [1997], Hudak [2000]: Functional reactive

programming/animations (FRAN, FRP) in Haskell

  • Kieburtz [1998]: Reactive Functional Programming
  • Uustalu [2005]: DF with comonads and monads
  • Pouzet, Hamón, Boulmé [≈ 2001]: Lucid

Synchrone in Coq

  • Mandel [2004]: Reactive ML