A Coiteration-based Interpretation of Synchronous Stream Functions
Marc Pouzet
Ecole normale supérieure Paris Marc.Pouzet@ens.fr
2020 Notes de cours du MPRI
1 / 108
A Coiteration-based Interpretation of Synchronous Stream Functions - - PowerPoint PPT Presentation
A Coiteration-based Interpretation of Synchronous Stream Functions Marc Pouzet Ecole normale suprieure Paris Marc.Pouzet@ens.fr 2020 Notes de cours du MPRI 1 / 108 Today Today: we give an operational interpretation of a stream and
Ecole normale supérieure Paris Marc.Pouzet@ens.fr
1 / 108
2 / 108
3 / 108
4 / 108
5 / 108
k
k
1The general case will be explain in the next lesson. 6 / 108
7 / 108
k
k
8 / 108
1
1
1
1
9 / 108
10 / 108
(var)
k
(global)
k
(pair)
k
k
k
(App)
k
k
11 / 108
(let)
k
k
k
(letrec)
k
k
k
12 / 108
(if)
k
k
k
k
(present)
k
k
k
k
(reset)
k
k
k
13 / 108
(letfun)
(letnode)
1
1
(letdef)
14 / 108
let node from(x) = let rec f = x fby (f + 1) in f let incr x = x + 1
let from(x) = let rec f = x fby (f + 1) in f
2The second form ask incr to be a combinatorial function, i.e., to have a type of
the form . → .
15 / 108
16 / 108
k stands for the expression e whose type is t and kind is k.
17 / 108
18 / 108
19 / 108
0) are equal iff
n+1 = f ′ s′ n)
20 / 108
21 / 108
22 / 108
23 / 108
3In Scade 6 and Zelus, there is a single form of application. 24 / 108
25 / 108
1 → V ⊥ 2 so that f (⊥) = ⊥.
4(x < y) stands for (x ≤ y) ∧ (x = y) 26 / 108
27 / 108
28 / 108
ρ
ρ
ρ
ρ
29 / 108
ρ
ρ )
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ , [
ρ )
ρ
ρ
ρ
30 / 108
ρ
ρ
ρ
ρ
ρ
ρ
ρ+[v/x](s)
31 / 108
ρ
ρ , [
ρ
ρ
ρ+[v/x](s)) in
ρ+[v/x](s′) in
ρ
ρ+[v/x](s) in
ρ+[v/x](s′) in
32 / 108
ρ
ρ , [
ρ , [
ρ )
ρ
ρ
ρ
ρ
ρ
ρ , [
ρ , [
ρ )
ρ
ρ
ρ
ρ
33 / 108
ρ
ρ , [
ρ , [
ρ )
ρ
ρ
ρ
ρ
ρ , [
ρ )
ρ
ρ
ρ
ρ
34 / 108
let node sincos(x) = (sin, cos) where rec sin = int(0.0, cos) and cos = int(1.0, -. sin)
sincos = (int(0.0, snd sincos), int(1.0, -. fst sincos)
35 / 108
1/x1, ..., e′ n/xn] in
1
2
n
36 / 108
let node f(x) = o where rec o = o
ρ+[v/o](s)) = fix (λs, v.(v, s)) = λs, v.(⊥, s)
let node f(z) = (x, y) where rec x = y and y = x
ρ+[v/x](s))
37 / 108
x depends on y which depends on x
let node euler_forward(h, x0, xprime) = x where rec x = x0 fby (x +. h *. xprime)
5We suppose that all imported functions are total. 38 / 108
39 / 108
let node f(y) = x where rec x = if false then x else 0
40 / 108
let node good1(x) = (z, t) where rec z = t and t = 0 fby z let node good2(x) = (z, t) where rec (z, t) = (t, 0 fby z) let node good3(x) = (fst r, snd r) where rec r = (snd r, 0 fby (fst r)) let node pair(r) = (snd r, 0 fby (fst r)) let node good4(x) = r where rec r = pair(r)
41 / 108
let node mux(c, x, y) = present c then x else y let node constructive(c, x) = y where rec rec x1 = mux(c, x, y2) and x2 = mux(c, y1, x) and y1 = f(x1) and y2 = g(x2) and y = mux(c, y2, y1)
42 / 108
(x1,x2,y1,y2,y) is a non bottom stream.
let node constructive(c, x) = y where rec rec y = mux(c, g(f(x)), f(g(x)))
6See notes for references. 43 / 108
let node composition(c1, c2, y) = (x, z, t, r) where rec present c1 then do x = y + 1 and z = t + 1 done else do x = 1 and z = 2 done and present c2 then do t = x + 1 and r = z + 2 done else do t = 1 and r = 2 done
let node composition(c1, c2, y) = (x, z, t, r) where rec (x, z) = present c1 then (y + 1, t + 1) else (1, 2) and (t, r) = present c2 then (x + 1, z + 2) else (1, 2)
44 / 108
45 / 108
let node composition(c1, c2, y) = (x, z, t, r) where rec present c1 then do x = y + 1 done else do x = 1 done and present c2 then do t = x + 1 done else do t = 1 done and present c1 then do z = t + 1 done else do z = 2 done and present c2 then do r = z + 2 done else do r = 2 done
46 / 108
let rec nat = 0 fby (nat + 1) in nat
47 / 108
rec nat = (0 fby nat) + 1
48 / 108
49 / 108
50 / 108
ρ
ρ
7We reason upto bisimulation, that is, independently on the actual representation of
the internal state.
51 / 108
have an unbounded recursion — the program contains a causality loop —;
let rec nat = nat + 1 in nat
52 / 108
53 / 108
ρ
ρ
ρ
54 / 108
let rec sin = 0.0 fby (sin +. h *. cos) and cos = 1.0 -> (0.0 fby cos) +. h *. sin in sin, cos
let rec sin = 0.0 fby sin_next and pre_cos = 0.0 fby cos and sin_next = sin +. h *. cos and cos = 1.0 -> pre_cos +. h *. sin sin, cos
55 / 108
56 / 108
57 / 108
ρ
ρ
ρ
ρ
ρ
58 / 108
59 / 108
60 / 108
61 / 108
62 / 108
63 / 108
64 / 108
65 / 108
type t = Incr | Decr | Idle let f(c) = local o init 0 do match c with | Idle -> (* o keeps its previous value, i.e., o = last o *) do done | Incr -> do o = last o + 1 done | Decr -> do o = last o - 1 done in o
66 / 108
let node controller(auto, error, input) = output where rec automaton | Manual -> do output = input unless auto then Auto | Auto -> do output = run pid(p, i, d, error) unless (not auto) then Manual let node await(a) = go where rec automaton | Await -> do go = false unless a then Run | Go -> do go = true done let node abro(a, b, r) = go where rec reset automaton | Await -> do go = false unless (run await(a) && run await(b)) then Go | Go -> do go = true done every r
67 / 108
68 / 108
k
k
k
k
k
69 / 108
70 / 108
(A-weak)
k
k
1
(A-strong)
k
k
1
(Eq)
k
k
k
71 / 108
(Local)
k
k
k
(And)
k
k
k
(Last)
1
(Match)
k
k
k
72 / 108
(Local-u)
k
k
k
(Do-u)
k
k
(Until)
k
k
(Unless)
k
k
(Epsilon)
k
(Else)
k
k
k
73 / 108
(ResetTransition)
k
k
(ContinueTransition)
k
k
(varpat)
k
(init)
k
1
(default)
k
k
74 / 108
75 / 108
76 / 108
ρ
ρ
ρ , [
ρ
ρ
ρ
ρ
ρ
ρ
ρ , [
ρ )
ρ
ρ
ρ
77 / 108
ρ
ρ
ρ
ρ+ρ′ (s))(s) in
ρ
ρ
ρ
ρ )
ρ
ρ+ρ′+[v/default x](s)) in
ρ
ρ+ρ′+[w/last x](s)) in
78 / 108
79 / 108
ρ
ρ , [
ρ , [
ρ )
ρ
ρ
ρ
ρ
ρ
ρ , [
ρ , ..., [
ρ )
80 / 108
ρ
ρ
ρ
ρ
ρ
81 / 108
ρ
ρ
ρ , [
ρ )
ρ
ρ , [
ρ )
ρ
ρ , [
ρ )
ρ
ρ
ρ
ρ
ρ
ρ )i∈[1..n] in
i = [
ρ )i∈[1..n] in
1, ..., s′ n))
ρ
ρ )i∈[1..n] in
i = [
ρ )i∈[1..n] in
1, ..., s′ n))
82 / 108
ρ
ρ (s′)
ρ (s1, s2)
ρ
ρ
ρ (s2) in
ρ (s1, s2)
ρ
ρ
ρ (s2) in
83 / 108
ρ
ρ
ρ
ρ
84 / 108
ρ (s) resets u when pr is true, that is:
ρ (s) = [
ρ
ρ
ρ
1, ..., s′ n)) =
ρ (si) in
i = [
ρ
i) in
1, ..., s′ n))
i∈[1..n]
ρ
1, ..., s′ n)) =
1, ..., s′ n) =
i = [
ρ
i) in
1, ..., s′ n))
ρ (si) in
1, ..., s′ n))
85 / 108
86 / 108
87 / 108
88 / 108
8See notes of the previous class. 89 / 108
90 / 108
91 / 108
92 / 108
93 / 108
94 / 108
95 / 108
9This quite obvious result has been used and rediscovered many times since the
pioneering work of F. Boussinot [1]. Yet, the above proof may bring some insight about the need for “empty” values.
96 / 108
97 / 108
98 / 108
99 / 108
100 / 108
101 / 108
102 / 108
103 / 108
104 / 108
105 / 108
106 / 108
Réseaux de processus réactifs. Technical Report 1588, INRIA Sophia-Antipolis, janvier 1992. Paul Caspi and Marc Pouzet. A Co-iterative Characterization of Synchronous Stream Functions. In Coalgebraic Methods in Computer Science (CMCS’98), Electronic Notes in Theoretical Computer Science, March 1998. Extended version available as a VERIMAG tech. report no. 97–07 at www.di.ens.fr/∼pouzet/bib/bib.html. Jean-Louis Colaco, Bruno Pagano, and Marc Pouzet. Scade 6: A Formal Language for Embedded Critical Software Development. In Eleventh International Symposium on Theoretical Aspect of Software Engineering (TASE), Sophia Antipolis, France, September 13-15 2017.
Principal type-schemes for functional programs. In Conference on Principles of Programming Languages, 1982.
The synchronous dataflow programming language lustre. Proceedings of the IEEE, 79(9):1305–1320, September 1991. Christine Paulin-Mohring. Circuits as streams in Coq, verification of a sequential multiplier. Technical report, Laboratoire de l’Informatique du Parallélisme, September 1995. Available at http://www.ens-lyon.fr:80/LIP/lip/publis/. 107 / 108
Marc Pouzet. Lucid Synchrone, version 3. Tutorial and reference manual. Université Paris-Sud, LRI, April 2006. Distribution available at: https://www.di.ens.fr/~pouzet/lucid-synchrone/. 108 / 108