Coiterative Synchronous Semantics
Marc Pouzet
Ecole normale supérieure Paris Marc.Pouzet@ens.fr
2019
1 / 107
Coiterative Synchronous Semantics Marc Pouzet Ecole normale - - PowerPoint PPT Presentation
Coiterative Synchronous Semantics Marc Pouzet Ecole normale suprieure Paris Marc.Pouzet@ens.fr 2019 1 / 107 Today The denotational semantics we have given in the previous lesson hides ressource aspects. It cannot answer questions like
Ecole normale supérieure Paris Marc.Pouzet@ens.fr
1 / 107
2 / 107
3 / 107
4 / 107
k
k
1The general case will be explain in the next lesson. 5 / 107
6 / 107
k
k
7 / 107
1
1
1
1
8 / 107
9 / 107
(var)
k
(global)
k
(pair)
k
k
k
(App)
k
k
10 / 107
(let)
k
k
k
(letrec)
k
k
k
11 / 107
(if)
k
k
k
k
(present)
k
k
k
k
(reset)
k
k
k
12 / 107
(letfun)
(letnode)
1
1
(letdef)
13 / 107
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 . → .
14 / 107
15 / 107
k stands for the expression e whose type is t and kind is k.
16 / 107
17 / 107
18 / 107
0) are equal iff
n+1 = f ′ s′ n)
19 / 107
20 / 107
21 / 107
22 / 107
3In Scade 6 and Zelus, there is a single form of application. 23 / 107
24 / 107
1 → V ⊥ 2 so that f (⊥) = ⊥.
4(x < y) stands for (x ≤ y) ∧ (x = y) 25 / 107
26 / 107
27 / 107
ρ
ρ
ρ
ρ
28 / 107
ρ
ρ )
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ
ρ , [
ρ )
ρ
ρ
ρ
29 / 107
ρ
ρ
ρ
ρ
ρ
ρ
ρ+[v/x](s)
30 / 107
ρ
ρ , [
ρ
ρ
ρ+[v/x](s)) in
ρ+[v/x](s′) in
ρ
ρ+[v/x](s) in
ρ+[v/x](s′) in
31 / 107
ρ
ρ , [
ρ , [
ρ )
ρ
ρ
ρ
ρ
ρ
ρ , [
ρ , [
ρ )
ρ
ρ
ρ
ρ
32 / 107
ρ
ρ , [
ρ , [
ρ )
ρ
ρ
ρ
ρ
ρ , [
ρ )
ρ
ρ
ρ
ρ
33 / 107
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)
34 / 107
1/x1, ..., e′ n/xn] in
1
2
n
35 / 107
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))
36 / 107
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. 37 / 107
38 / 107
let node f(y) = x where rec x = if false then x else 0
39 / 107
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)
40 / 107
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)
41 / 107
(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. 42 / 107
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)
43 / 107
44 / 107
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
45 / 107
let rec nat = 0 fby (nat + 1) in nat
46 / 107
rec nat = (0 fby nat) + 1
47 / 107
48 / 107
49 / 107
ρ
ρ
7We reason upto bisimulation, that is, independently on the actual representation of
the internal state.
50 / 107
have an unbounded recursion — the program contains a causality loop —;
let rec nat = nat + 1 in nat
51 / 107
52 / 107
ρ
ρ
ρ
53 / 107
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
54 / 107
55 / 107
56 / 107
ρ
ρ
ρ
ρ
ρ
57 / 107
58 / 107
59 / 107
60 / 107
61 / 107
62 / 107
63 / 107
64 / 107
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
65 / 107
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
66 / 107
67 / 107
k
k
k
k
k
68 / 107
69 / 107
(A-weak)
k
k
1
(A-strong)
k
k
1
(Eq)
k
k
k
70 / 107
(Local)
k
k
k
(And)
k
k
k
(Last)
1
(Match)
k
k
k
71 / 107
(Local-u)
k
k
k
(Do-u)
k
k
(Until)
k
k
(Unless)
k
k
(Epsilon)
k
(Else)
k
k
k
72 / 107
(ResetTransition)
k
k
(ContinueTransition)
k
k
(varpat)
k
(init)
k
1
(default)
k
k
73 / 107
74 / 107
75 / 107
ρ
ρ
ρ , [
ρ
ρ
ρ
ρ
ρ
ρ
ρ , [
ρ )
ρ
ρ
ρ
76 / 107
ρ
ρ
ρ
ρ+ρ′ (s))(s) in
ρ
ρ
ρ
ρ )
ρ
ρ+ρ′+[v/default x](s)) in
ρ
ρ+ρ′+[w/last x](s)) in
77 / 107
78 / 107
ρ
ρ , [
ρ , [
ρ )
ρ
ρ
ρ
ρ
ρ
ρ , [
ρ , ..., [
ρ )
79 / 107
ρ
ρ
ρ
ρ
ρ
80 / 107
ρ
ρ
ρ , [
ρ )
ρ
ρ , [
ρ )
ρ
ρ , [
ρ )
ρ
ρ
ρ
ρ
ρ
ρ )i∈[1..n] in
i = [
ρ )i∈[1..n] in
1, ..., s′ n))
ρ
ρ )i∈[1..n] in
i = [
ρ )i∈[1..n] in
1, ..., s′ n))
81 / 107
ρ
ρ (s′)
ρ (s1, s2)
ρ
ρ
ρ (s2) in
ρ (s1, s2)
ρ
ρ
ρ (s2) in
82 / 107
ρ
ρ
ρ
ρ
83 / 107
ρ (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))
84 / 107
85 / 107
86 / 107
87 / 107
8See notes of the previous class. 88 / 107
89 / 107
90 / 107
91 / 107
92 / 107
93 / 107
94 / 107
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.
95 / 107
96 / 107
97 / 107
98 / 107
99 / 107
100 / 107
101 / 107
102 / 107
103 / 107
104 / 107
105 / 107
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/. 106 / 107
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/. 107 / 107