a functional synchronous language with integer...

102
A Functional Synchronous Language with Integer Clocks Adrien Guatto ENS - PARKAS Gallium Seminar Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 1 / 28

Upload: others

Post on 03-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

A Functional Synchronous Languagewith Integer Clocks

Adrien Guatto

ENS - PARKAS

Gallium Seminar

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 1 / 28

Page 2: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Reactive Systems

Critical Control Software:

Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

Synchronous Digital Hardware:

Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

State machine-like implementations; how to program them?

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 2 / 28

Page 3: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Reactive Systems

Critical Control Software:

Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

Synchronous Digital Hardware:

Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

State machine-like implementations; how to program them?

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 2 / 28

Page 4: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Reactive Systems

Critical Control Software:Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

Synchronous Digital Hardware:

Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

State machine-like implementations; how to program them?

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 2 / 28

Page 5: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Reactive Systems

Critical Control Software:Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

Synchronous Digital Hardware:

Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

State machine-like implementations; how to program them?

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 2 / 28

Page 6: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Reactive Systems

Critical Control Software:Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

Synchronous Digital Hardware:Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

State machine-like implementations; how to program them?

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 2 / 28

Page 7: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Reactive Systems

Critical Control Software:Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

Synchronous Digital Hardware:Process unbounded sequences of data. . . within bounded memory. . . and bounded reaction time.

State machine-like implementations; how to program them?

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 2 / 28

Page 8: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Functional Synchronous Programming

Kahn, 1974: networks of state machines as functions

M(I ,O) I ω → Oω

Caspi, Halbwachs et al., 1987: compile functions to state machines

I ω → Oω M(I ,O)

In practice, compilers generate transition functions looking like

void f_step(struct f_state *self, int in, int *out);

Typically: only assignments, conditionals and function calls in f_step

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 3 / 28

Page 9: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Functional Synchronous Programming

Kahn, 1974: networks of state machines as functions

M(I ,O) I ω → Oω

Caspi, Halbwachs et al., 1987: compile functions to state machines

I ω → Oω M(I ,O)

In practice, compilers generate transition functions looking like

void f_step(struct f_state *self, int in, int *out);

Typically: only assignments, conditionals and function calls in f_step

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 3 / 28

Page 10: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Functional Synchronous Programming

Kahn, 1974: networks of state machines as functions

M(I ,O) I ω → Oω

Caspi, Halbwachs et al., 1987: compile functions to state machines

I ω → Oω M(I ,O)

In practice, compilers generate transition functions looking like

void f_step(struct f_state *self, int in, int *out);

Typically: only assignments, conditionals and function calls in f_step

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 3 / 28

Page 11: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Synchrony and Performance-Sensitive Code

Traditional use cases: control laws, protocols, etc.Signal processing: involve. . .

subtle space/time tradeoffsarchitecture-dependent optimizations

Can we use Synchronous Languages for such applications?

My Long-Term ObjectiveDesign and implement a. . .

synchronous functional languagecompiling to hardware and softwarewith the usual safety guaranteesbut generating code of a different shape

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 4 / 28

Page 12: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Synchrony and Performance-Sensitive Code

Traditional use cases: control laws, protocols, etc.Signal processing: involve. . .

subtle space/time tradeoffsarchitecture-dependent optimizations

Can we use Synchronous Languages for such applications?

My Long-Term ObjectiveDesign and implement a. . .

synchronous functional languagecompiling to hardware and softwarewith the usual safety guaranteesbut generating code of a different shape

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 4 / 28

Page 13: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Ingredients

Integer ClocksCompute streams by bursts of valueGenerate array-oriented code from purely functional source

Local Time ScalesTime may pass faster inside than outsideCompile to counted loopsMake the type system more uniform

Linear Higher-Order FunctionsCall every function you receive exactly onceEnable modular compilation to hardware

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 5 / 28

Page 14: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

This Talk

Present Integer Clocks and Local Time Scales intuitivelyReason purely on stream functions à la Lustre, Lucid S., Lucy-nFocus on first-order parts

Show how the intuitions can be implemented as a type system(Check buffers sizes)Reject non-causal programs

Discuss soundness resultsProof by realizability

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 6 / 28

Page 15: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Outline

1 Introduction

2 Stream Functions and Clocks

3 From Clocks to Clock Types

4 Conclusion

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 6 / 28

Page 16: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Streams and Partiality

Streams are infinite sequences of valuesThink of them as produced by programs running forever

However, streams may be partial, i.e. block after some time!Happens when the producer program does an infinite, silent loop.

Here is a picture of Stream(B), ordered by information:

0.⊥

0.0.⊥ 0.1.⊥

1.⊥

1.0.⊥ 1.1.⊥

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 7 / 28

Page 17: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Streams and Partiality

Streams are infinite sequences of valuesThink of them as produced by programs running forever

However, streams may be partial, i.e. block after some time!Happens when the producer program does an infinite, silent loop.

Here is a picture of Stream(B), ordered by information:

0.⊥

0.0.⊥ 0.1.⊥

1.⊥

1.0.⊥ 1.1.⊥

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 7 / 28

Page 18: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Stream Functions (1/2)

Consider the following function

f : Stream(N)→ Stream(N)f (x .xs) = (x + 1).(f xs)

Can it be implemented as a state machine?

Yes. For example:

m : M(N,N)m = ({∗}, ∗, λ(∗, x).(∗, x + 1))

The machine m processes one element per transition.It was easy since the function is length-preserving.

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 8 / 28

Page 19: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Stream Functions (1/2)

Consider the following function

f : Stream(N)→ Stream(N)f (x .xs) = (x + 1).(f xs)

Can it be implemented as a state machine? Yes. For example:

m : M(N,N)m = ({∗}, ∗, λ(∗, x).(∗, x + 1))

The machine m processes one element per transition.It was easy since the function is length-preserving.

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 8 / 28

Page 20: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Stream Functions (2/2)

What about the following function?

g : Stream(N)→ Stream(N)g(x .xs) = (x + 1).(x − 1).(g xs)

Yes, if we cheat a bit.

m1 : M(N, List(N))m1 = ({∗}, ∗, λ(∗, x).(∗, [x + 1; x − 1]))

Another possibility:

m2 : M(List(N),N)m2 = (N ∪ {∗}, ∗,

λ(s, x).if s = ∗ then (hd x , hd x + 1) else (∗, s − 1))

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 9 / 28

Page 21: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Stream Functions (2/2)

What about the following function?

g : Stream(N)→ Stream(N)g(x .xs) = (x + 1).(x − 1).(g xs)

Yes, if we cheat a bit.

m1 : M(N, List(N))m1 = ({∗}, ∗, λ(∗, x).(∗, [x + 1; x − 1]))

Another possibility:

m2 : M(List(N),N)m2 = (N ∪ {∗}, ∗,

λ(s, x).if s = ∗ then (hd x , hd x + 1) else (∗, s − 1))

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 9 / 28

Page 22: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Stream Functions and Clocks

Naively speaking, the function g is not length-preserving.

g : Stream(N)→ Stream(N)g (x .xs) = (x + 1).(x − 1).(g xs)

However, we can make it so by changing its (co)domain!

g1 : Stream(List(N))→ Stream(List(N))g1 ([x ].xs) = [x + 1; x − 1].(g1 xs)

g2 : Stream(List(N))→ Stream(List(N))g2 ([x ].xs) = [x + 1].(let [].xs ′ = xs in

[x − 1].(g2 xs ′))

Functions g1 and g2 are length-preserving.

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 10 / 28

Page 23: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Stream Functions and Clocks

Naively speaking, the function g is not length-preserving.

g : Stream(N)→ Stream(N)g (x .xs) = (x + 1).(x − 1).(g xs)

However, we can make it so by changing its (co)domain!

g1 : Stream(List(N))→ Stream(List(N))g1 ([x ].xs) = [x + 1; x − 1].(g1 xs)

g2 : Stream(List(N))→ Stream(List(N))g2 ([x ].xs) = [x + 1].(let [].xs ′ = xs in

[x − 1].(g2 xs ′))

Functions g1 and g2 are length-preserving.

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 10 / 28

Page 24: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Synchronizing FunctionsHow to describe the relationship between g , g1 and g2?

g : Stream(N) → Stream(N)g1 : Stream(List(N)) → Stream(List(N))g2 : Stream(List(N)) → Stream(List(N))

Remember that g1 and g2 work only for specific list sizes:

Input list sizes Output list sizesg1 (1)ω (2)ω

g2 (1 0)ω (1)ω

These integer streams, clocks, fully characterize g1 and g2.We write:

g1 :: (1) ( (2)g2 :: (1 0) ( (1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 11 / 28

Page 25: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Synchronizing FunctionsHow to describe the relationship between g , g1 and g2?

g : Stream(N) → Stream(N)g1 : Stream(List(N)) → Stream(List(N))g2 : Stream(List(N)) → Stream(List(N))

Remember that g1 and g2 work only for specific list sizes:

Input list sizes Output list sizesg1 (1)ω (2)ω

g2 (1 0)ω (1)ω

These integer streams, clocks, fully characterize g1 and g2.We write:

g1 :: (1) ( (2)g2 :: (1 0) ( (1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 11 / 28

Page 26: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Synchronizing FunctionsHow to describe the relationship between g , g1 and g2?

g : Stream(N) → Stream(N)g1 : Stream(List(N)) → Stream(List(N))g2 : Stream(List(N)) → Stream(List(N))

Remember that g1 and g2 work only for specific list sizes:

Input list sizes Output list sizesg1 (1)ω (2)ω

g2 (1 0)ω (1)ω

These integer streams, clocks, fully characterize g1 and g2.We write:

g1 :: (1) ( (2)g2 :: (1 0) ( (1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 11 / 28

Page 27: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

From Streams to Clocked Streams, and backA clock w is just a stream of integers!

What can we do with such a w ∈ Stream(N)?

Stream(V ) Stream(List(V ))

packw

unpack

For example:

x = pack1 (1 0)ω (a.b.c .d . . . ) [a] [b] [] [c] [] . . .

y = pack (0 2)ω (a.b.c .d . . . ) [] [a; b] [] [c ; d ] [] . . .

Obviously:unpack x = unpack y

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 12 / 28

Page 28: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

From Streams to Clocked Streams, and backA clock w is just a stream of integers!What can we do with such a w ∈ Stream(N)?

Stream(V ) Stream(List(V ))

packw

unpack

For example:

x = pack1 (1 0)ω (a.b.c .d . . . ) [a] [b] [] [c] [] . . .

y = pack (0 2)ω (a.b.c .d . . . ) [] [a; b] [] [c ; d ] [] . . .

Obviously:unpack x = unpack y

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 12 / 28

Page 29: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

From Streams to Clocked Streams, and backA clock w is just a stream of integers!What can we do with such a w ∈ Stream(N)?

Stream(V ) Stream(List(V ))

packw

unpack

For example:

x = pack1 (1 0)ω (a.b.c .d . . . ) [a] [b] [] [c] [] . . .

y = pack (0 2)ω (a.b.c .d . . . ) [] [a; b] [] [c ; d ] [] . . .

Obviously:unpack x = unpack y

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 12 / 28

Page 30: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

From Streams to Clocked Streams, and backA clock w is just a stream of integers!What can we do with such a w ∈ Stream(N)?

Stream(V ) Stream(List(V ))

packw

unpack

For example:

x = pack1 (1 0)ω (a.b.c .d . . . ) [a] [b] [] [c] [] . . .

y = pack (0 2)ω (a.b.c .d . . . ) [] [a; b] [] [c ; d ] [] . . .

Obviously:unpack x = unpack y

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 12 / 28

Page 31: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

From Streams to Clocked Streams, and backA clock w is just a stream of integers!What can we do with such a w ∈ Stream(N)?

Stream(V ) Stream(List(V ))

packw

unpack

For example:

x = pack1 (1 0)ω (a.b.c .d . . . ) [a] [b] [] [c] [] . . .

y = pack (0 2)ω (a.b.c .d . . . ) [] [a; b] [] [c ; d ] [] . . .

Obviously:unpack x = unpack y

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 12 / 28

Page 32: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

From Streams to Clocked Streams, and backA clock w is just a stream of integers!What can we do with such a w ∈ Stream(N)?

Stream(V ) Stream(List(V ))

packw

unpack

For example:

x = pack1 (1 0)ω (a.b.c .d . . . ) [a] [b] [] [c] [] . . .

y = pack (0 2)ω (a.b.c .d . . . ) [] [a; b] [] [c ; d ] [] . . .

Obviously:unpack x = unpack y

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 12 / 28

Page 33: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

From Streams to Clocked Streams, and backA clock w is just a stream of integers!What can we do with such a w ∈ Stream(N)?

Stream(V ) Stream(List(V ))

packw

unpack

For example:

x = pack1 (1 0)ω (a.b.c .d . . . ) [a] [b] [] [c] [] . . .

y = pack (0 2)ω (a.b.c .d . . . ) [] [a; b] [] [c ; d ] [] . . .

Obviously:unpack x = unpack y

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 12 / 28

Page 34: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Synchronous Stream FunctionsWe now define the functions g1 and g2 purely from their clocks:

g1 :: (1)( (2)g1 = pack (2) ◦ g ◦ unpackg2 :: (1 0)( (1)g2 = pack (1) ◦ g ◦ unpack

What about the following signature?

g3 ::? (0 1)( (1)g3 = pack (1) ◦ g ◦ unpack

It is unsound: g breaks this contract at the first time step:

g3 ([].⊥) = ⊥

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 13 / 28

Page 35: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Synchronous Stream FunctionsWe now define the functions g1 and g2 purely from their clocks:

g1 :: (1)( (2)g1 = pack (2) ◦ g ◦ unpackg2 :: (1 0)( (1)g2 = pack (1) ◦ g ◦ unpack

What about the following signature?

g3 ::? (0 1)( (1)g3 = pack (1) ◦ g ◦ unpack

It is unsound: g breaks this contract at the first time step:

g3 ([].⊥) = ⊥

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 13 / 28

Page 36: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (1/3)

x :: (1 0) [a] [] [b] [] [c] [] . . .x ′ :: (0 1) [] [a] [] [b] [] [c] . . .

i

Data

O(1 0)(i)

O(0 1)(i)O(0 1)(i + 1)

(1 0) <: (0 1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 14 / 28

Page 37: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (1/3)

x :: (1 0) [a] [] [b] [] [c] [] . . .x ′ :: (0 1) [] [a] [] [b] [] [c] . . .

i

DataO(1 0)(i)

O(0 1)(i)O(0 1)(i + 1)

(1 0) <: (0 1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 14 / 28

Page 38: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (1/3)

x :: (1 0) [a] [] [b] [] [c] [] . . .x ′ :: (0 1) [] [a] [] [b] [] [c] . . .

i

Data

O(1 0)(i)

O(0 1)(i)

O(0 1)(i + 1)

(1 0) <: (0 1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 14 / 28

Page 39: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (1/3)

x :: (1 0) [a] [] [b] [] [c] [] . . .x ′ :: (0 1) [] [a] [] [b] [] [c] . . .

i

DataO(1 0)(i)

O(0 1)(i)

O(0 1)(i + 1)

(1 0) <:0 (0 1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 14 / 28

Page 40: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (1/3)

x :: (1 0) [a] [] [b] [] [c] [] . . .x ′ :: (0 1) [] [a] [] [b] [] [c] . . .

i

Data

O(1 0)(i)

O(0 1)(i)

O(0 1)(i + 1)

(1 0) <: (0 1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 14 / 28

Page 41: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (1/3)

x :: (1 0) [a] [] [b] [] [c] [] . . .x ′ :: (0 1) [] [a] [] [b] [] [c] . . .

i

Data

O(1 0)(i)

O(0 1)(i)

O(0 1)(i + 1)

(1 0) <: (0 1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 14 / 28

Page 42: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (1/3)

x :: (1 0) [a] [] [b] [] [c] [] . . .x ′ :: (0 1) [] [a] [] [b] [] [c] . . .

i

DataO(1 0)(i)

O(0 1)(i)

O(0 1)(i + 1)

(1 0) <:1 (0 1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 14 / 28

Page 43: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (2/3)

x :: (1 0 1) [a] [] [b] [c] [] [d ] . . .x ′ :: (0 0 2) [] [] [a; b] [] [] [c ; d ] . . .

i

Data

O(1 0 1)(i)

O(0 0 2)(i)O(0 0 2)(i + 1)

(1 0 1) <: (0 0 2)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 15 / 28

Page 44: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (2/3)

x :: (1 0 1) [a] [] [b] [c] [] [d ] . . .x ′ :: (0 0 2) [] [] [a; b] [] [] [c ; d ] . . .

i

Data O(1 0 1)(i)

O(0 0 2)(i)O(0 0 2)(i + 1)

(1 0 1) <: (0 0 2)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 15 / 28

Page 45: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (2/3)

x :: (1 0 1) [a] [] [b] [c] [] [d ] . . .x ′ :: (0 0 2) [] [] [a; b] [] [] [c ; d ] . . .

i

Data

O(1 0 1)(i)

O(0 0 2)(i)

O(0 0 2)(i + 1)

(1 0 1) <: (0 0 2)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 15 / 28

Page 46: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (2/3)

x :: (1 0 1) [a] [] [b] [c] [] [d ] . . .x ′ :: (0 0 2) [] [] [a; b] [] [] [c ; d ] . . .

i

Data O(1 0 1)(i)

O(0 0 2)(i)

O(0 0 2)(i + 1)

(1 0 1) <:0 (0 0 2)Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 15 / 28

Page 47: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (2/3)

x :: (1 0 1) [a] [] [b] [c] [] [d ] . . .x ′ :: (0 0 2) [] [] [a; b] [] [] [c ; d ] . . .

i

Data

O(1 0 1)(i)

O(0 0 2)(i)

O(0 0 2)(i + 1)

(1 0 1) <: (0 0 2)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 15 / 28

Page 48: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (2/3)

x :: (1 0 1) [a] [] [b] [c] [] [d ] . . .x ′ :: (0 0 2) [] [] [a; b] [] [] [c ; d ] . . .

i

Data

O(1 0 1)(i)

O(0 0 2)(i)

O(0 0 2)(i + 1)

(1 0 1) <: (0 0 2)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 15 / 28

Page 49: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (2/3)

x :: (1 0 1) [a] [] [b] [c] [] [d ] . . .x ′ :: (0 0 2) [] [] [a; b] [] [] [c ; d ] . . .

i

Data O(1 0 1)(i)

O(0 0 2)(i)

O(0 0 2)(i + 1)

not (1 0 1) <:1 (0 0 2)Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 15 / 28

Page 50: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (3/3)Now, given a function h :: w1 ( w2, we may put a buffer on its. . .

Output: if w2 <:k w ′2, we define

h′ :: w1 ( w ′2h′ = bufferw2<:kw

′2◦ h

For example:(1)( (1 0) <: (1)( (0 1)

Input: if w ′1 <:k w1, we define

h′′ :: w ′1 ( w2

h′′ = h ◦ bufferw ′1<:kw1

For example:(0 1)( (1) <: (1 0)( (1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 16 / 28

Page 51: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (3/3)Now, given a function h :: w1 ( w2, we may put a buffer on its. . .

Output: if w2 <:k w ′2, we define

h′ :: w1 ( w ′2h′ = bufferw2<:kw

′2◦ h

For example:(1)( (1 0) <: (1)( (0 1)

Input: if w ′1 <:k w1, we define

h′′ :: w ′1 ( w2

h′′ = h ◦ bufferw ′1<:kw1

For example:(0 1)( (1) <: (1 0)( (1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 16 / 28

Page 52: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Buffers (3/3)Now, given a function h :: w1 ( w2, we may put a buffer on its. . .

Output: if w2 <:k w ′2, we define

h′ :: w1 ( w ′2h′ = bufferw2<:kw

′2◦ h

For example:(1)( (1 0) <: (1)( (0 1)

Input: if w ′1 <:k w1, we define

h′′ :: w ′1 ( w2

h′′ = h ◦ bufferw ′1<:kw1

For example:(0 1)( (1) <: (1 0)( (1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 16 / 28

Page 53: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Feedback

Given a function h :: w1 ( w2, is it safe to compute x = h x?

What about. . .

h1 :: (1) ( (1)

KO

h2 :: (0 1) ( (1 0)

OK

h3 :: (0 1 1) ( (1 0 1)

KO

We allow feedback only when w2 <:1 w1.This makes sure that x = h x is total.

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 17 / 28

Page 54: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Feedback

Given a function h :: w1 ( w2, is it safe to compute x = h x?What about. . .

h1 :: (1) ( (1)

KO

h2 :: (0 1) ( (1 0)

OK

h3 :: (0 1 1) ( (1 0 1)

KO

We allow feedback only when w2 <:1 w1.This makes sure that x = h x is total.

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 17 / 28

Page 55: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Feedback

Given a function h :: w1 ( w2, is it safe to compute x = h x?What about. . .

h1 :: (1) ( (1) KOh2 :: (0 1) ( (1 0) OKh3 :: (0 1 1) ( (1 0 1) KO

We allow feedback only when w2 <:1 w1.This makes sure that x = h x is total.

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 17 / 28

Page 56: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Feedback

Given a function h :: w1 ( w2, is it safe to compute x = h x?What about. . .

h1 :: (1) ( (1) KOh2 :: (0 1) ( (1 0) OKh3 :: (0 1 1) ( (1 0 1) KO

We allow feedback only when w2 <:1 w1.This makes sure that x = h x is total.

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 17 / 28

Page 57: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Local Time

Take any function f implemented by state machine m, with

f :: (1 0)( (0 1)

We can transform f into f ′ such that

f ′ :: (1)( (1)

What would be m′, the implementation of f ′?

A single transition of m′ performs two transitions of mWe write

(1 0)( (0 1) ↑(2) (1)( (1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 18 / 28

Page 58: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Playing with Synchronous Functions: Local Time

Take any function f implemented by state machine m, with

f :: (1 0)( (0 1)

We can transform f into f ′ such that

f ′ :: (1)( (1)

What would be m′, the implementation of f ′?

A single transition of m′ performs two transitions of mWe write

(1 0)( (0 1) ↑(2) (1)( (1)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 18 / 28

Page 59: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Local Time Scales and Scatter/Gather

A local time scale comes with a clock w driving its internal timeE.g. (2 1) begins with two internal steps for one external, etc.

How does the inside sees the outside? The converse?

w1 ( w2 ↑w w ′1 ( w ′2: leaving local time

(1 0 1)( (0 1 1) ↑(2 1) (1)( (1) OK(0 1 1)( (1 0 1) ↑(2 1) (1)( (1) OK

w1 ( w2 ↓w w ′1 ( w ′2: entering local time

(1)( (1) ↓(2 1) (1 0 1)( (0 1 1) OK(1)( (1) ↓(2 1) (0 1 1)( (1 0 1) KO

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 19 / 28

Page 60: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Local Time Scales and Scatter/Gather

A local time scale comes with a clock w driving its internal timeE.g. (2 1) begins with two internal steps for one external, etc.

How does the inside sees the outside? The converse?w1 ( w2 ↑w w ′1 ( w ′2: leaving local time

(1 0 1)( (0 1 1) ↑(2 1) (1)( (1) OK(0 1 1)( (1 0 1) ↑(2 1) (1)( (1) OK

w1 ( w2 ↓w w ′1 ( w ′2: entering local time

(1)( (1) ↓(2 1) (1 0 1)( (0 1 1) OK(1)( (1) ↓(2 1) (0 1 1)( (1 0 1) KO

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 19 / 28

Page 61: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Local Time Scales and Scatter/Gather

A local time scale comes with a clock w driving its internal timeE.g. (2 1) begins with two internal steps for one external, etc.

How does the inside sees the outside? The converse?w1 ( w2 ↑w w ′1 ( w ′2: leaving local time

(1 0 1)( (0 1 1) ↑(2 1) (1)( (1) OK(0 1 1)( (1 0 1) ↑(2 1) (1)( (1) OK

w1 ( w2 ↓w w ′1 ( w ′2: entering local time

(1)( (1) ↓(2 1) (1 0 1)( (0 1 1) OK(1)( (1) ↓(2 1) (0 1 1)( (1 0 1) KO

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 19 / 28

Page 62: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: StreamsConsider two simple examples:

(1 0) ↑(2) (1)

What is the action of (2) on (1 0) that gives (1)?

Let us define clock composition as

_ on _ : Stream(N)× Stream(N)→ Stream(N)(n.w) on (m1 . . .mn.w

′) = (∑

1≤i≤nmi).(w on w ′)

We can now define:

w1 ↑w w2 ⇔ w on w1 = w2

Similarly, (1) ↓(2) (0 1) because (1) = (2) on (1 0)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 20 / 28

Page 63: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: StreamsConsider two simple examples:

(1 0) ↑(2) (1)

What is the action of (2) on (1 0) that gives (1)?

Let us define clock composition as

_ on _ : Stream(N)× Stream(N)→ Stream(N)(n.w) on (m1 . . .mn.w

′) = (∑

1≤i≤nmi).(w on w ′)

We can now define:

w1 ↑w w2 ⇔ w on w1 = w2

Similarly, (1) ↓(2) (0 1) because (1) = (2) on (1 0)

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 20 / 28

Page 64: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: StreamsConsider two simple examples:

(1 0) ↑(2) (1)

What is the action of (2) on (1 0) that gives (1)?

Let us define clock composition as

_ on _ : Stream(N)× Stream(N)→ Stream(N)(n.w) on (m1 . . .mn.w

′) = (∑

1≤i≤nmi).(w on w ′)

We can now define:

w1 ↑w w2 ⇔ w on w1 = w2

Similarly, (1) ↓(2) (0 1) because (1) = (2) on (1 0)Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 20 / 28

Page 65: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: FunctionsGoing back to our first example: (1 0)( (0 1) ↑(2) (1)( (1). Why?

(1) (1)f ′

↓(2)

f

↑(2)

This suggests the reasoning principle

w ′1 ↓w w1 w2 ↑w w ′2w1 ( w2 ↑w w ′1 ( w ′2

More complex principles can be found for w1 ( w2 ↓w w ′1 ( w ′2

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 21 / 28

Page 66: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: FunctionsGoing back to our first example: (1 0)( (0 1) ↑(2) (1)( (1). Why?

(1) (1)f ′

↓(2)

f

↑(2)

This suggests the reasoning principle

w ′1 ↓w w1 w2 ↑w w ′2w1 ( w2 ↑w w ′1 ( w ′2

More complex principles can be found for w1 ( w2 ↓w w ′1 ( w ′2

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 21 / 28

Page 67: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: FunctionsGoing back to our first example: (1 0)( (0 1) ↑(2) (1)( (1). Why?

(1) (1)f ′

↓(2)

f

↑(2)

This suggests the reasoning principle

w ′1 ↓w w1 w2 ↑w w ′2w1 ( w2 ↑w w ′1 ( w ′2

More complex principles can be found for w1 ( w2 ↓w w ′1 ( w ′2

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 21 / 28

Page 68: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: FunctionsGoing back to our first example: (1 0)( (0 1) ↑(2) (1)( (1). Why?

(1) (1)f ′

(1 0) (0 1)

↓(2)

f

↑(2)

This suggests the reasoning principle

w ′1 ↓w w1 w2 ↑w w ′2w1 ( w2 ↑w w ′1 ( w ′2

More complex principles can be found for w1 ( w2 ↓w w ′1 ( w ′2

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 21 / 28

Page 69: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: FunctionsGoing back to our first example: (1 0)( (0 1) ↑(2) (1)( (1). Why?

(1) (1)f ′

(1 0) (0 1)

↓(2)

f

↑(2)

This suggests the reasoning principle

w ′1 ↓w w1 w2 ↑w w ′2w1 ( w2 ↑w w ′1 ( w ′2

More complex principles can be found for w1 ( w2 ↓w w ′1 ( w ′2

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 21 / 28

Page 70: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: FunctionsGoing back to our first example: (1 0)( (0 1) ↑(2) (1)( (1). Why?

(1) (1)f ′

(1 0) (0 1)

↓(2)

f

↑(2)

This suggests the reasoning principle

w ′1 ↓w w1 w2 ↑w w ′2w1 ( w2 ↑w w ′1 ( w ′2

More complex principles can be found for w1 ( w2 ↓w w ′1 ( w ′2

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 21 / 28

Page 71: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: FunctionsGoing back to our first example: (1 0)( (0 1) ↑(2) (1)( (1). Why?

(1) (1)f ′

(1 0) (0 1)

↓(2)

f

↑(2)

This suggests the reasoning principle

w ′1 ↓w w1 w2 ↑w w ′2w1 ( w2 ↑w w ′1 ( w ′2

More complex principles can be found for w1 ( w2 ↓w w ′1 ( w ′2Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 21 / 28

Page 72: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Outline

1 Introduction

2 Stream Functions and Clocks

3 From Clocks to Clock Types

4 Conclusion

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 21 / 28

Page 73: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

From Semantics to Syntax

e ::= x| λx .e| e e| (e, e)| let (x , x) = e in e| fix e| c| op e| merge p e e| e when p

p ::= c∗(c+)

t ::= dt :: ct| t ⊗ t| t ( t

dt ::= bool | int | . . .ct ::= p

| ct on ct

Γ ::= �| Γ, x : t

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 22 / 28

Page 74: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Typing Buffers

SubΓ ` e : t ` t <:k t

Γ ` e : t ′

AdaptFun

t ′1 <:k1 t1 t2 <:k2 t′2

t1 ( t2 <:0 t′1 ( t ′2

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 23 / 28

Page 75: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Typing Feedback

FixΓ ` e : t ( t ′ ` t ′ <:1 t ` t ′ value

Γ ` fix e : t ′

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 24 / 28

Page 76: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Typing Local Time Scales

Scale` Γ ↓ct Γ′ Γ′ ` e : t ′ ` t ′ ↑ct t

Γ ` e : t

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 25 / 28

Page 77: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness and Realizability

Two semantics: untyped KJ_K and typed SJ_K, look like

KJeK : K with K ∼= Stream(S)⊕ (K×K)⊕ (K⇒c K)SJ` e : int :: ct ( int :: ctK : Stream(List(N))→ Stream(List(N))

Soundness theoremThe statics (typing) and dynamics (semantics) agree:

∀e, dt, ct, clock SJ` e : dt :: ctK = JctK

Some interesting, more or less direct corollaries:The typed semantics is causal

∀e, dt, ct,SJ` e : dt :: ctK is totalSynchronizing the clocked semantics gives clocked one

∀e, t,SJ` e : tK = sync t KJ` e : tK

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 26 / 28

Page 78: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness and Realizability

Two semantics: untyped KJ_K and typed SJ_K, look like

KJeK : K

with K ∼= Stream(S)⊕ (K×K)⊕ (K⇒c K)SJ` e : int :: ct ( int :: ctK : Stream(List(N))→ Stream(List(N))

Soundness theoremThe statics (typing) and dynamics (semantics) agree:

∀e, dt, ct, clock SJ` e : dt :: ctK = JctK

Some interesting, more or less direct corollaries:The typed semantics is causal

∀e, dt, ct,SJ` e : dt :: ctK is totalSynchronizing the clocked semantics gives clocked one

∀e, t,SJ` e : tK = sync t KJ` e : tK

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 26 / 28

Page 79: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness and Realizability

Two semantics: untyped KJ_K and typed SJ_K, look like

KJeK : K with K ∼= Stream(S)⊕ (K×K)⊕ (K⇒c K)

SJ` e : int :: ct ( int :: ctK : Stream(List(N))→ Stream(List(N))

Soundness theoremThe statics (typing) and dynamics (semantics) agree:

∀e, dt, ct, clock SJ` e : dt :: ctK = JctK

Some interesting, more or less direct corollaries:The typed semantics is causal

∀e, dt, ct,SJ` e : dt :: ctK is totalSynchronizing the clocked semantics gives clocked one

∀e, t,SJ` e : tK = sync t KJ` e : tK

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 26 / 28

Page 80: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness and Realizability

Two semantics: untyped KJ_K and typed SJ_K, look like

KJeK : K with K ∼= Stream(S)⊕ (K×K)⊕ (K⇒c K)SJ` e : int :: ct ( int :: ctK : Stream(List(N))→ Stream(List(N))

Soundness theoremThe statics (typing) and dynamics (semantics) agree:

∀e, dt, ct, clock SJ` e : dt :: ctK = JctK

Some interesting, more or less direct corollaries:The typed semantics is causal

∀e, dt, ct,SJ` e : dt :: ctK is totalSynchronizing the clocked semantics gives clocked one

∀e, t,SJ` e : tK = sync t KJ` e : tK

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 26 / 28

Page 81: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness and Realizability

Two semantics: untyped KJ_K and typed SJ_K, look like

KJeK : K with K ∼= Stream(S)⊕ (K×K)⊕ (K⇒c K)SJ` e : int :: ct ( int :: ctK : Stream(List(N))→ Stream(List(N))

Soundness theoremThe statics (typing) and dynamics (semantics) agree:

∀e, dt, ct, clock SJ` e : dt :: ctK = JctK

Some interesting, more or less direct corollaries:The typed semantics is causal

∀e, dt, ct,SJ` e : dt :: ctK is totalSynchronizing the clocked semantics gives clocked one

∀e, t,SJ` e : tK = sync t KJ` e : tK

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 26 / 28

Page 82: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness and Realizability

Two semantics: untyped KJ_K and typed SJ_K, look like

KJeK : K with K ∼= Stream(S)⊕ (K×K)⊕ (K⇒c K)SJ` e : int :: ct ( int :: ctK : Stream(List(N))→ Stream(List(N))

Soundness theoremThe statics (typing) and dynamics (semantics) agree:

∀e, dt, ct, clock SJ` e : dt :: ctK = JctK

Some interesting, more or less direct corollaries:The typed semantics is causal

∀e, dt, ct,SJ` e : dt :: ctK is totalSynchronizing the clocked semantics gives clocked one

∀e, t,SJ` e : tK = sync t KJ` e : tK

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 26 / 28

Page 83: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness proof (1/2)

First, define the set of realizers of some type t:

Wt ⊆ SJtKWdt :: ct = {xs | clock xs = JctK}Wt1⊗t2 = Wt1

×Wt2

Wt(t′ = {f | ∀x ∈ Wt , (f x) ∈ Wt′}WΓ ⊆ SJΓK

. . .

The soundness theorem then becomes a corollary ofthe adequacy lemma: for all Γ, e and t, we have

∀γ ∈ WΓ, (SJΓ ` e : tK γ) ∈ Wt

Unfortunately, it does not work!

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 27 / 28

Page 84: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness proof (1/2)

First, define the set of realizers of some type t:

Wt ⊆ SJtKWdt :: ct = {xs | clock xs = JctK}Wt1⊗t2 = Wt1

×Wt2

Wt(t′ = {f | ∀x ∈ Wt , (f x) ∈ Wt′}WΓ ⊆ SJΓK

. . .

The soundness theorem then becomes a corollary ofthe adequacy lemma: for all Γ, e and t, we have

∀γ ∈ WΓ, (SJΓ ` e : tK γ) ∈ Wt

Unfortunately, it does not work!

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 27 / 28

Page 85: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness proof (1/2)

First, define the set of realizers of some type t:

Wt ⊆ SJtKWdt :: ct = {xs | clock xs = JctK}Wt1⊗t2 = Wt1

×Wt2

Wt(t′ = {f | ∀x ∈ Wt , (f x) ∈ Wt′}WΓ ⊆ SJΓK

. . .

The soundness theorem then becomes a corollary ofthe adequacy lemma: for all Γ, e and t, we have

∀γ ∈ WΓ, (SJΓ ` e : tK γ) ∈ Wt

Unfortunately, it does not work!

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 27 / 28

Page 86: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness proof (2/2)

The proof attempt fails on fixpoints: we need information onpartial streams.

Let us refine realizers as follows:Wn∈N

t ⊆ SJtKWn

dt :: ct = {xs | clock xs =n SJctK}Wn

t1⊗t2 = Wnt1×Wn

t2

Wnt(t′ = {f | ∀m ≤ n, ∀x ∈ Wm

t , (f x) ∈ Wmt′ }

Wn∈NΓ ⊆ SJΓK

. . .

And restate the adequacy lemma:

∀n ∈ N, ∀γ ∈ WnΓ , (SJΓ ` e : tK γ) ∈ Wn

t

An essential lemma for fixpoints:

∀t, t ′, ∀k , n ∈ N,∀xs ∈ Wnt , (SJ` t <:k t ′K xs) ∈ Wn+k

t′

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 28 / 28

Page 87: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness proof (2/2)

The proof attempt fails on fixpoints: we need information onpartial streams.Let us refine realizers as follows:

Wn∈Nt ⊆ SJtKWn

dt :: ct = {xs | clock xs =n SJctK}Wn

t1⊗t2 = Wnt1×Wn

t2

Wnt(t′ = {f | ∀m ≤ n, ∀x ∈ Wm

t , (f x) ∈ Wmt′ }

Wn∈NΓ ⊆ SJΓK

. . .

And restate the adequacy lemma:

∀n ∈ N, ∀γ ∈ WnΓ , (SJΓ ` e : tK γ) ∈ Wn

t

An essential lemma for fixpoints:

∀t, t ′, ∀k , n ∈ N,∀xs ∈ Wnt , (SJ` t <:k t ′K xs) ∈ Wn+k

t′

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 28 / 28

Page 88: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness proof (2/2)

The proof attempt fails on fixpoints: we need information onpartial streams.Let us refine realizers as follows:

Wn∈Nt ⊆ SJtKWn

dt :: ct = {xs | clock xs =n SJctK}Wn

t1⊗t2 = Wnt1×Wn

t2

Wnt(t′ = {f | ∀m ≤ n, ∀x ∈ Wm

t , (f x) ∈ Wmt′ }

Wn∈NΓ ⊆ SJΓK

. . .

And restate the adequacy lemma:

∀n ∈ N, ∀γ ∈ WnΓ , (SJΓ ` e : tK γ) ∈ Wn

t

An essential lemma for fixpoints:

∀t, t ′, ∀k , n ∈ N,∀xs ∈ Wnt , (SJ` t <:k t ′K xs) ∈ Wn+k

t′

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 28 / 28

Page 89: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Soundness proof (2/2)

The proof attempt fails on fixpoints: we need information onpartial streams.Let us refine realizers as follows:

Wn∈Nt ⊆ SJtKWn

dt :: ct = {xs | clock xs =n SJctK}Wn

t1⊗t2 = Wnt1×Wn

t2

Wnt(t′ = {f | ∀m ≤ n, ∀x ∈ Wm

t , (f x) ∈ Wmt′ }

Wn∈NΓ ⊆ SJΓK

. . .

And restate the adequacy lemma:

∀n ∈ N, ∀γ ∈ WnΓ , (SJΓ ` e : tK γ) ∈ Wn

t

An essential lemma for fixpoints:

∀t, t ′, ∀k , n ∈ N,∀xs ∈ Wnt , (SJ` t <:k t ′K xs) ∈ Wn+k

t′

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 28 / 28

Page 90: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Outline

1 Introduction

2 Stream Functions and Clocks

3 From Clocks to Clock Types

4 Conclusion

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 28 / 28

Page 91: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Related work and Inspiration

Lustre (Caspi, Halbwachs et al.)General conceptual setting

Lucid Synchrone (Caspi, Pouzet et al.)Clocks as typesSeparate compilation

Lucy-n (Mandel, Plateau, Pouzet)Buffers, adaptabilityUltimately periodic clocks

Clock Domains in ReactiveML (Mandel, Pasteur)Local time scales

Geometry of Synthesis, Verity (Ghica)Linear HOFs to circuits via G() (from Abramsky, Girard)

Cyclic Scheduling of *DFs (Lee, Munier-Kordon, etc.)Algorithms for type inference with periodic clocks

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 29 / 28

Page 92: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Conclusion and Perspectives

A setting for unified clocking / initialization / causality analysisThe full type system is not overly complexLocal time scales important for modularityNo need for a scheduling pass after typing

Relies on standard programming language theoryDenotational semantics, Types, RealizabilityRealizability is a powerful tool. Too powerful?

Lots of remaining questionsTheoretical: principality, better semantic setting, full abstractionPractical: type inference, optimizations, parallel code generation

Thank you!

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 30 / 28

Page 93: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Conclusion and Perspectives

A setting for unified clocking / initialization / causality analysisThe full type system is not overly complexLocal time scales important for modularityNo need for a scheduling pass after typing

Relies on standard programming language theoryDenotational semantics, Types, RealizabilityRealizability is a powerful tool. Too powerful?

Lots of remaining questionsTheoretical: principality, better semantic setting, full abstractionPractical: type inference, optimizations, parallel code generation

Thank you!

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 30 / 28

Page 94: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Bonus Slides

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 30 / 28

Page 95: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Scatter/Gather: The Whole Story

DownArrowBin` t ′1 ↑ct t1 ` t2 ↓ct t ′2 ct ≤ (1)

` t1 ( t2 ↓ct t ′1 ( t ′2

DownArrowPos` t ′1 ↓ct′ t1 ` t2 ↑ct′ t ′2 ct on ct ′ = (1)

` t1 ( t2 ↓ct t ′1 ( t ′2

DownOn` t ↓ct t ′′ ` t ′′ ↓ct′ t ′

` t ↓ct on ct′ t′

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 30 / 28

Page 96: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Putting it all together (1/2)Take f (x , y) = (0.y , x). Is the smallest fixpoint of f total? Why?

This problem is equivalent to the scheduling of this Lustre code:

x = 0 fby yy = x

Consider the signature below:

f :: (0 1)⊗ 0(0 1)( (1 0)⊗ (0 1)

It mimics the growth of partial streams in lfp f =⊔

i≥0(f i⊥):

x f x(⊥,⊥) (0.⊥,⊥)

(0.⊥,⊥) (0.⊥, 0.⊥)(0.⊥, 0.⊥) (0.0.⊥, 0.⊥)

(0.0.⊥, 0.⊥) (0.0.⊥, 0.0.⊥). . . . . .

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 29 / 28

Page 97: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Putting it all together (1/2)Take f (x , y) = (0.y , x). Is the smallest fixpoint of f total? Why?

This problem is equivalent to the scheduling of this Lustre code:

x = 0 fby yy = x

Consider the signature below:

f :: (0 1)⊗ 0(0 1)( (1 0)⊗ (0 1)

It mimics the growth of partial streams in lfp f =⊔

i≥0(f i⊥):

x f x(⊥,⊥) (0.⊥,⊥)

(0.⊥,⊥) (0.⊥, 0.⊥)(0.⊥, 0.⊥) (0.0.⊥, 0.⊥)

(0.0.⊥, 0.⊥) (0.0.⊥, 0.0.⊥). . . . . .

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 29 / 28

Page 98: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Putting it all together (1/2)Take f (x , y) = (0.y , x). Is the smallest fixpoint of f total? Why?

This problem is equivalent to the scheduling of this Lustre code:

x = 0 fby yy = x

Consider the signature below:

f :: (0 1)⊗ 0(0 1)( (1 0)⊗ (0 1)

It mimics the growth of partial streams in lfp f =⊔

i≥0(f i⊥):

x f x(⊥,⊥) (0.⊥,⊥)

(0.⊥,⊥) (0.⊥, 0.⊥)(0.⊥, 0.⊥) (0.0.⊥, 0.⊥)

(0.0.⊥, 0.⊥) (0.0.⊥, 0.0.⊥). . . . . .

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 29 / 28

Page 99: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Putting it all together (2/2)So, with f :: (0 1)⊗ 0(0 1)( (1 0)⊗ (0 1), since

(1 0) <:1 (0 1)(0 1) <:1 0(0 1)

we know that the fixpoint is total, and get

lfp f :: (1 0)⊗ (0 1)

Now, we can wrap it into a local time scale going twice faster

(1 0)⊗ (0 1) ↑(2) (1)⊗ (1)

Interestingly, something happens to the internal buffers

Inside view Outside view(1 0) <:1 (0 1) (1) <:0 (1)

Wire

(0 1) <:1 0(0 1) (1) <:1 0(1)

Memory

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 28 / 28

Page 100: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Putting it all together (2/2)So, with f :: (0 1)⊗ 0(0 1)( (1 0)⊗ (0 1), since

(1 0) <:1 (0 1)(0 1) <:1 0(0 1)

we know that the fixpoint is total, and get

lfp f :: (1 0)⊗ (0 1)

Now, we can wrap it into a local time scale going twice faster

(1 0)⊗ (0 1) ↑(2) (1)⊗ (1)

Interestingly, something happens to the internal buffers

Inside view Outside view(1 0) <:1 (0 1) (1) <:0 (1)

Wire

(0 1) <:1 0(0 1) (1) <:1 0(1)

Memory

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 28 / 28

Page 101: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Putting it all together (2/2)So, with f :: (0 1)⊗ 0(0 1)( (1 0)⊗ (0 1), since

(1 0) <:1 (0 1)(0 1) <:1 0(0 1)

we know that the fixpoint is total, and get

lfp f :: (1 0)⊗ (0 1)

Now, we can wrap it into a local time scale going twice faster

(1 0)⊗ (0 1) ↑(2) (1)⊗ (1)

Interestingly, something happens to the internal buffers

Inside view Outside view(1 0) <:1 (0 1) (1) <:0 (1)

Wire

(0 1) <:1 0(0 1) (1) <:1 0(1)

Memory

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 28 / 28

Page 102: A Functional Synchronous Language with Integer Clocksgallium.inria.fr/seminaires/transparents/20150202.Adrien.Guatto.pdf · AFunctionalSynchronousLanguage withIntegerClocks AdrienGuatto

Putting it all together (2/2)So, with f :: (0 1)⊗ 0(0 1)( (1 0)⊗ (0 1), since

(1 0) <:1 (0 1)(0 1) <:1 0(0 1)

we know that the fixpoint is total, and get

lfp f :: (1 0)⊗ (0 1)

Now, we can wrap it into a local time scale going twice faster

(1 0)⊗ (0 1) ↑(2) (1)⊗ (1)

Interestingly, something happens to the internal buffers

Inside view Outside view(1 0) <:1 (0 1) (1) <:0 (1) Wire

(0 1) <:1 0(0 1) (1) <:1 0(1) Memory

Adrien Guatto (ENS - PARKAS) Integer Clocks Gallium Seminar 28 / 28