4 \section{Rappels sur le langage PROMELA}
5 \label{sec:spin:promela}
7 Cette section rappelle les éléments fondamentaux du langage PROMELA (Process Meta Language).
8 On peut trouver davantage de détails dans~\cite{Hol03,Wei97}.
19 bool X [N]; bool Xp [N]; int mods [N];
20 typedef vals{bool v [N]};
23 typedef a_send{chan sent[N]=[d_0] of {bool}};
26 chan unlock_elements_update=[1] of {bool};
27 chan sync_mutex=[1] of {bool};
30 \caption{Type declaration of the DDNs translation.}
31 \label{fig:arrayofchannels}
35 Les types primaires de PROMELA sont \texttt{bool}, \texttt{byte},
36 \texttt{short} et \texttt{int}. Comme dans le langage C par exemple,
37 on peut declarer des tableaux à une dimension de taille constante
38 ou des nouveaux types de données (introduites par le mot clef
39 \verb+typedef+). Ces derniers sont utilisés pour définir des tableaux à deux
43 Le programme donné à la {\sc Figure}~\ref{fig:arrayofchannels} correspond à des
44 déclarations de variables qui serviront dans l'exemple jouet de ce chapitre.
45 Il définit tout d'abord:
47 \item les constantes \verb+N+ et \verb+d_0+ qui précisent respectivement le numbre
48 $n$ d'éléments et le délais maximum $\delta_0$;
49 \item les deux tableaux (\verb+X+ et \verb+Xp+) de \verb+N+ variables booléennes;
50 les cellules \verb+X[i]+ et \verb+Xp[i]+ sont associées à la variables $X_{i+1}$
51 d'un systène dynamique discret
52 (le décallage d'un entier est dû à l'indexation à partir de zéro des cellules d'un tableau);
53 Elles memorisent les valeurs de $X_{i+1}$ respectivement avant et après sa mise à jour;
54 il suffit ainsi de comparer \verb+X+ et \verb+Xp+ pour constater si $X$ à changé ou pas;
55 \item le tableau \verb+mods+ contient les éléments qui doivent être modifiés lors de l'iteration
56 en cours; cela correspond naturellement à l'ensemble des éléments $S^t$;
57 \item le type de données structurées \verb+vals+ et le tableau de tableaux
58 \verb+Xd[+$i$\verb+].v[+$j$\verb+]+ qui vise à mémoriser $X_{j+1}^{D^{t-1}_{i+1j+1}}$
59 pour l'itération au temps $t$ (en d'autres termes, utile lors du calcul de $X^{t}$).
63 Puisque le décallage d'un indices ne change pas fondamentalement
64 le comportement de la version PROMELA par rapport au modèle initial
65 et pour des raisons de clareté, on utilisera par la suite la même
66 lettre d'indice entre les deux niveaux (pour le modèle: $X_i$ et pour PROMELA:
67 \texttt{X[i]}). Cependant, ce décallage devra être conservé mémoire.
69 Une donnée de type \texttt{channel} permet le
70 transfert de messages entre processus dans un ordre FIFO.
71 Elles serait déclarée avec le mot clef \verb+chan+ suivi par sa capacité
72 (qui est constante), son nom et le type des messages qui sont stockés dans ce cannal.
73 Dans l'exemple précédent, on déclare successivement:
75 \item un cannal \verb+sent+ qui vise à mémoriser\verb+d_0+ messages de type
76 \verb+bool+; le tableau nommé \verb+channels+ de \verb+N+*\verb+N+
77 éléments de type \verb+a_send+ est utilisé pour mémoriser les valeurs intermédiaires $X_j$;
78 Il permet donc de temporiser leur emploi par d'autres elements $i$.
79 \item les deux cannaux \verb+unlock_elements_update+ et \verb+sync_mutex+ contenant
80 chacun un message booléen et utilisé ensuite comme des sémaphores.
84 %\subsection{PROMELA Processes}
85 Le langage PROMELA exploite la notion de \emph{process} pour modéliser la concurence
86 au sein de systèmes. Un process est déclaréavec le mot-clef
87 \verb+proctype+ et est instancié soit imédiatement (lorsque sa déclaration est préfixée
88 par le mot-clef \verb+active+) ou bien au moment de l'exécution de l'instruction
90 Parmi tous les process, \verb+init+ est le process initial qui permet
91 d'initialiser les variables, lancer d'autres processes\ldots
94 Les instructions d'affecatation sont interprétées usuellement.
95 Les cannaux sont cernés par des instructions particulières d'envoi et de
96 réception de messages. Pour un cannal
97 \verb+ch+, ces instruction sont respectivement notées
98 \verb+ch ! m+ et \verb+ch ? m+.
99 L'instruction de réception consomme la valeur en tête du cannal \verb+ch+
100 et l'affecte à la variable \verb+m+ (pour peu que \verb+ch+ soit initialisé et non vide).
101 De manière similaire,l'instruction d'envoi ajoute la valeur de \verb+m+ à la queue du canal
102 \verb+ch+ (pour peu que celui-ci soit initialisé et non rempli).
103 Dans les cas problématiques, canal non initialisé et vide pour une reception ou bien rempli pour un envoi,
104 le processus est blocké jusqu'à ce que les conditions soient remplies.
106 La structures de contrôle \verb+if+ (resp. \verb+do+) définit un choix non déterministe
107 (resp. une boucle non déterministe). Que ce soit pour la conditionnelle ou la boucle,
108 si plus d'une des conditions est établie, l'ensemble des instructions correspondantes
109 sera choisi aléatoirement puis exécuté.
111 Dans le process \verb+init+ détaillé à la {\sc Figure}~\ref{fig:spin:init},
112 une boucle de taille $N$ initialise aléatoirement la variable globale de type tableau \verb+Xp+.
113 Ceci permet par la suite de verifier si les itérations sont convergentes pour n'importe
114 quelle configuration initiale $X^{(0)}$.
118 Pour chaque élément $i$, si les itérations sont asynchrones
120 \item on stocke d'abord la valeur de \verb+Xp[i]+ dans chaque \verb+Xd[j].v[i]+
121 puisque la matrice $S^0$ est égale à $(0)$,
122 \item puis, la valeur de $i$ (représentée par \verb+Xp[i]+) devrait être transmise
123 à $j$ s'il y a un arc de $i$ à $j$ dans le graphe d'incidence. Dans ce cas,
124 c'est la fonction \verb+hasnext+ (non détaillée ici)
126 qui memorise ce graphe
127 en fixant à \texttt{true} la variable \verb+is_succ+, naturellement et à
128 \texttt{false} dans le cas contraire.
129 Cela permet d'envoyer la valeur de $i$ dans le canal au travers de \verb+channels[i].sent[j]+.
133 \begin{minipage}[h]{.52\linewidth}
137 int i=0; int j=0; bool is_succ=0;
148 ::j< N -> Xd[j].v[i]=Xp[i]; j++;
156 ::(i!=j && is_succ==1) ->
157 channels[i].sent[j] ! Xp[i];
158 ::(i==j || is_succ==0) -> skip;
168 \caption{PROMELA init process.}\label{fig:spin:init}
170 \begin{minipage}[h]{.42\linewidth}
173 active proctype scheduler(){
175 ::sync_mutex ? 1 -> {
187 unlock_elements_update ! 1;
193 \caption{Scheduler process for common pseudo-periodic strategy.
194 \label{fig:scheduler}}
200 \section{Du système booléen au modèle PROMELA}
201 \label{sec:spin:translation}
202 Les éléments principaux des itérations asynchrones rappelées à l'équation
203 (\ref{eq:async}) sont la stratégie, la fonctions et la gestion des délais.
204 Dans cette section, nous présentons successivement comment chacune de
205 ces notions est traduite vers un modèle PROMELA.
208 \subsection{La stratégie}\label{sub:spin:strat}
209 Regardons comment une stratégie pseudo-périodique peut être représentée en PROMELA.
210 Intuitivement, un process \verb+scheduler+ (comme représenté à la {\sc Figure}~\ref{fig:scheduler})
211 est itérativement appelé pour construire chaque $S^t$ représentant
212 les éléments possiblement mis à jour à l'itération $t$.
214 Basiquement, le process est une boucle qui est débloquée lorsque la valeur du sémaphore
215 \verb+sync_mutex+ est 1. Dans ce cas, les éléments à modifier sont choisis
216 aléatoirement (grâce à $n$ choix successifs) et sont mémorisés dans le tableau
217 \verb+mods+, dont la taille est \verb+ar_len+.
218 Dans la séquence d'éxécution, le choix d'un élément mis à jour est directement
219 suivi par des mis àjour: ceci est réalisé grace à la modification de la valeur du sémaphore
220 \verb+unlock_elements_updates+.
222 \subsection{Applying the function $F$}\label{sub:spin:update}
223 Updating a set $S^t=\{s_1,\ldots, s_m\}$ of elements that occur in the strategy
224 $(S^t)^{t \in \Nats}$ is implemented by the \verb+update_elems+ process given
225 in~\ref{fig:proc}. This active process waits until it is unlocked by the
226 \verb+scheduler+ process through the semaphore \verb+unlock_elements_update+.
227 The implementation is then fivefold:
230 \item it starts with updating the variable \texttt{X} with the values of \texttt{Xp}
231 thanks to the \texttt{update\_X} function (not detailed here);
232 %%we recall that the variable \texttt{X} is only defined as
233 \item it stores in \texttt{Xd} the current available values of the elements thanks
234 to the function \texttt{fetch\_values} (see \Sec{sub:spin:vt});
235 \item a loop over the number \texttt{ar\_len} of elements that have to evolve
236 iteratively updates the value of $j$ (through the function call \texttt{F(j)})
237 provided this has to evolve, \textit{i.e.}, it is referenced by
238 \texttt{mods[count]}; source code of \texttt{F} is given in~\ref{fig:p} and is a
239 direct translation of the map $F$;
240 \item the new components values in \texttt{Xp} are symbolically sent to the other
241 components requiring them % for future access
242 thanks to the \texttt{diffuse\_values(Xp)} function (see \Sec{sub:spin:vt});
243 \item finally, this process informs the scheduler about the end of the task
244 (through the semaphore \texttt{sync\_mutex}).
249 \begin{minipage}[h]{.475\linewidth}
252 active proctype update_elems(){
254 ::unlock_elements_update ? 1 ->
263 ::count == ar_len -> break;
277 \caption{Updatings of the elements.}\label{fig:proc}
278 \end{minipage}\hfill%
281 \begin{minipage}[h]{.45\linewidth}
287 (Xs[j].v[0] & !Xs[j].v[1])
289 ::j==1 -> Xp[1] = Xs[j].v[0]
291 ::j==2 -> Xp[2] = Xs[j].v[1]
297 \caption{Application of function $F$.}\label{fig:p}
301 % \subsection{Modifying Values of one Element}
303 % Each element $i$ may modify its value through the coresponding
304 % active process \verb+pi+.
305 % In Fig.~\ref{fig:p4} that gives the translation of
306 % modifying the element $4$, the process is waiting until it is unlocked
307 % and then it computes the new value of $X_4$, represented by $X'_4$
308 % and memorized as \verb+Xp[4]+.
313 % First of all, the second hypothesis of the previous proof is established.
315 % In this part, we prove that for any time $t$,
317 % The proof is achieved under the hypothesis that at current time $t$,
319 % For $j$ in $J^t$, variables
320 % \verb+v0+, \ldots \verb+vn-1+ are respectively
321 % $X_0^{S_{j0}^t},\ldots, X_{n-1}^{S_{jn-1}^t}$.
322 % Since \verb+F+ is the direct translation of $F$, rest of the proof is obvious.
327 \subsection{Delays Handling}\label{sub:spin:vt}
328 This section shows how delays are translated into PROMELA through the two
329 functions \verb+fetch_values+ and \verb+diffuse_values+, given in~\ref{fig:val} and~\ref{fig:broadcast}, that respectively store and transmit the
333 \begin{minipage}[h]{.475\linewidth}
336 inline fetch_values(){
339 :: countv == ar_len -> break ;
340 :: countv < ar_len ->
344 :: (i == N) -> break;
345 :: (i < N && i == j) -> {
348 :: (i < N && i != j) -> {
353 nempty(channels[i].sent[j]) ->
354 channels[i].sent[j] ?
364 \caption{Fetching of the elements values\label{fig:val}}
365 \end{minipage}\hfill%
366 \begin{minipage}[h]{.475\linewidth}
369 inline diffuse_values(values){
372 :: countb == ar_len -> break ;
373 :: countb < ar_len ->
377 :: (i == N) -> break;
378 :: (i < N && i == j) -> i++;
379 :: (i < N && i != j) -> {
384 nfull(channels[j].sent[i]) ->
385 channels[j].sent[i] !
395 \caption{Diffusion of the elements values}\label{fig:broadcast}
399 The former potentially updates the array \verb+Xd+ needed by elements that have
400 to be modified. For each element in \verb+mods+, identified by the variable
401 $j$, the function retrieves the values of the other elements (labeled by $i$)
402 whose $j$ depends on. There are two cases:
404 \item since $i$ knows its last value (\textit{i.e.}, $D^t_{ii}$ is always $t$)
405 \verb+Xd[i].v[i]+ is then \verb+Xp[i]+.
406 \item otherwise, there are two sub-cases which potentially update the value that
407 $j$ knows about $i$ (that may be chosen in a random way):
409 \item from the viewpoint of $j$ the value of $i$ may not change (the
410 \verb+skip+ statement) or is not relevant; this latter case arises when
411 there is no edge from $i$ to $j$ in the incidence graph, \textit{i.e.}, when
412 the value of \verb+is_succ+ that is computed by \verb+hasnext(i,j)+ is 0;
413 then the value of \verb+Xd[j].v[i]+ is not modified;
414 \item otherwise, \verb+Xd[j].v[i]+ is assigned with the value stored in the
415 channel \verb+channels[i].sent[j]+ (provided this one is not empty).
416 Element values are added into this channel during the \verb+diffuse_values+
421 The \verb+diffuse_values+ function aims at storing the values of $X$ represented by
422 \verb+Xp+ in the \verb+channels+. It allows the SPIN model-checker to execute
423 the PROMELA model as if it allowed delays between processes.
424 % as if computation mode were asynchronous.
425 %For that reason, when an iteration has to synchronize the elements $i$ and
426 %$j$ (\textit{i.e.} when \verb+sync[j] == sync[i]+ is true),
427 % no delay emulation is performed.
428 %In the asynchronous mode,
429 There are two cases concerning the value of $X_{j}$:
431 \item either it is left out to allow $i$ not to take into account all the values
432 of $j$; this case occurs either through the \verb+skip+ statement or when
433 there is no edge from $j$ to $i$ in the incidence graph;
434 \item or it is stored in the channel \verb+channels[j].sent[i]+ (provided it is
438 Introducing non-determinism both in \verb+fetch_values+ and
439 \verb+diffuse_values+ functions is necessary in our context. If the
440 non-determinism would be used only in \verb+fetch_values+, then it would not be
441 possible for instance to retrieve the value $X_i^{(t)}$ without taking into
442 account the value $X_i^{(t-1)}$. On the other hand, if the non-determinism is
443 only used in \verb+diffuse_values+, then each time a value is pushed into the
444 channel, this value is immediately consumed, which contradicts the notion of
447 \subsection{Discussion}
448 A coarse approach could consist in providing one process for each element.
449 However, the distance with the mathematical model given in \Equ{eq:async} of
450 such a translation would be larger than the method presented along these lines.
451 It induces that it would be harder to prove the soundness and completeness of
452 such a translation. For that reason we have developed a PROMELA model that is
453 as close as possible to the mathematical one.
455 Notice furthermore that PROMELA is an imperative language which
456 often results in generating intermediate states
457 (to execute a matrix assignment for
459 The use of the \verb+atomic+ keyword allows the grouping of
460 instructions, making the PROMELA code and the DDN as closed as possible.
462 \subsection{Universal Convergence Property}
463 We are left to show how to formalize into the SPIN model-checker that iterations
464 of a DDN with $n$ elements are universally convergent. We first recall that the
465 variables \verb+X+ and \verb+Xp+ respectively contain the value of $X$ before
466 and after an update. Then, by applying a non-deterministic initialization of
467 \verb+Xp+ and applying a pseudo-periodic strategy, it is necessary and
468 sufficient to establish the following Linear Temporal Logic (LTL) formula:
470 \diamond (\Box \verb+Xp+ = \verb+X+)
473 where $\diamond$ and $\Box$ have the usual meaning \textit{i.e.}, respectively
474 {\em eventually} and {\em always} in the subsequent path. It is worth noticing
475 that this property only ensures the stabilization of the system, but it does not
476 provide any information over the way the system converges. In particular, some
477 indeterminism may still be present under the form of multiple fixed points
478 accessible from some initial states.
482 \section{Proof of Translation Correctness}\label{sec:spin:proof}
483 \JFC{Déplacer les preuves en annexes}
485 This section establishes the soundness and completeness of the approach
486 (Theorems~\ref{Theo:sound} and ~\ref{Theo:completeness}). Technical lemmas are
487 first shown to ease the proof of the two theorems.
490 % \begin{Lemma}[Absence of deadlock]\label{lemma:deadlock}
491 % Let $\phi$ be a DDN model and $\psi$ be its translation. There is no deadlock
492 % in any execution of $\psi$.
495 % In current translation, deadlocks of PROMELA may only be introduced through
496 % sending or receiving messages in channels. Sending (resp. receiving) a
497 % message in the \verb+diffuse_values+ (resp. \verb+fetch_values+) function is
498 % executed only if the channel is not full (resp. is not empty). In the
499 % \verb+update_elems+ and \verb+scheduler+ processes, each time one adds a value
500 % in any semaphore channel (\verb+unlock_elements_update+ and
501 % \verb+sync_mutex+), the corresponding value is read; avoiding deadlocks by the
506 \begin{lemma}[Strategy Equivalence]\label{lemma:strategy}
507 Let $\phi$ be a DDN with strategy $(S^t)^{t \in \Nats}$ and $\psi$ be its
508 translation. There exists an execution of $\psi$ with weak fairness s.t. the
509 scheduler makes \verb+update_elems+ update elements of $S^t$ at iteration $t$.
512 The proof is direct for $t=0$. Let us suppose it is established until $t$ is
513 some $t_0$. Let us consider pseudo-periodic strategies. Thanks to the weak
514 fairness equity property, \verb+update_elems+ will modify elements of $S^t$ at
518 In what follows, let $Xd^t_{ji}$ be the value of
519 \verb+Xd[+$j$\verb+].v[+$i$\verb+]+ after the $t^{\text{th}}$ call to the
520 function \verb+fetch_values+. Furthermore, let $Y^k_{ij}$ be the element at
521 index $k$ in the channel \verb+channels[i].sent[j]+ of size $m$, $m \le
522 \delta_0$; $Y^0_{ij}$ and $Y^{m-1}_{ij}$ are respectively the head and the tail
523 of the channel. Secondly, let $(M_{ij}^t)^{t \in \{1, 1.5, 2, 2.5,\ldots\}}$ be a
524 sequence such that $M_{ij}^t$ is the partial function that associates to each
525 $k$, $0 \le k \le m-1$, the tuple $(Y^k_{ij},a^k_{ij},c^k_{ij})$ while entering
526 into the \verb+update_elems+ at iteration $t$ where
529 $Y^k_{ij}$ is the value of the channel \verb+channels[i].sent[j]+
532 $a^k_{ij}$ is the date (previous to $t$) when $Y^k_{ij}$ has been added and
534 $c^k_{ij}$ is the first date at which the value is available on $j$. So,
535 the value is removed from the channel $i\rightarrow j$ at date $c^k_{ij}+1$.
537 $M_{ij}^t$ has the following signature:
541 \{0,\ldots, \textit{max}-1\} &\rightarrow & E_i\times \Nats \times \Nats \\
542 & k \in \{0,\ldots, m-1\} & \mapsto & M_{ij}(k)= (Y^k_{ij},a^k_{ij},c^k_{ij}).
546 Intuitively, $M_{ij}^t$ is the memory of \verb+channels[i].sent[j]+ while
547 starting the iteration $t$. Notice that the domain of any $M_{ij}^1$ is $\{0\}$
548 and $M_{ij}^1(0)=(\verb+Xp[i]+,0,0)$: indeed, the \verb+init+ process
549 initializes \verb+channels[i].sent[j]+ with \verb+Xp[i]+.
551 Let us show how to make the indeterminism inside the two functions\linebreak
552 \verb+fetch_values+ and \verb+diffuse_values+ compliant with \Equ{eq:async}.
553 The function $M_{ij}^{t+1}$ is obtained by the successive updates of
554 $M_{ij}^{t}$ through the two functions\linebreak \verb+fetch_values+ and
555 \verb+diffuse_values+. Abusively, let $M_{ij}^{t+1/2}$ be the value of
556 $M_{ij}^{t}$ after the former function during iteration $t$.
558 In what follows, we consider elements $i$ and $j$ both in $\llbracket 1, n
559 \rrbracket$ that are updated. At iteration $t$, $t \geq 1$, let
560 $(Y^0_{ij},a^0_{ij},c^0_{ij})$ be the value of $M_{ij}^t(0)$ at the beginning of
561 \verb+fetch_values+. If $t$ is equal to $c^0_{ij}+1$ then we execute the
562 instruction that assigns $Y^0_{ij}$ (\textit{i.e.}, the head value of
563 \verb+channels[i].sent[j]+) to $Xd_{ji}^t$. In that case, the function
564 $M_{ij}^t$ is updated as follows: $M_{ij}^{t+1/2}(k) = M_{ij}^{t}(k+1)$ for each
565 $k$, $0 \le k \le m-2$ and $m-1$ is removed from the domain of $M_{ij}^{t+1/2}$.
566 Otherwise (\textit{i.e.}, when $t < c^0_{ij}+1$ or when the domain of $M_{ij}$
567 is empty) the \verb+skip+ statement is executed and $M_{ij}^{t+1/2} =
570 In the function \verb+diffuse_values+, if there exists some $\tau$, $\tau\ge t$
571 such that \mbox{$D^{\tau}_{ji} = t$}, let $c_{ij}$ be defined by $ \min\{l \mid
572 D^{l}_{ji} = t \} $. In that case, we execute the instruction that adds the
573 value \verb+Xp[i]+ to the tail of \verb+channels[i].sent[j]+. Then,
574 $M_{ij}^{t+1}$ is defined as an extension of $M_{ij}^{t+1/2}$ in $m$ such that
575 $M_{ij}^{t+1}(m)$ is $(\verb+Xp[i]+,t,c_{ij})$. Otherwise (\textit{i.e.}, when $\forall l
576 \, . \, l \ge t \Rightarrow D^{l}_{ji} \neq t$ is established) the \verb+skip+
577 statement is executed and $M_{ij}^{t+1} = M_{ij}^{t+1/2}$.
580 \begin{lemma}[Existence of SPIN Execution]\label{lemma:execution}
581 For any sequences $(S^t)^{t \in \Nats}$,\linebreak $(D^t)^{t \in \Nats}$, for
582 any map $F$ there exists a SPIN execution such that for any iteration $t$, $t
583 \ge 1$, for any $i$ and $j$ in $\llbracket 1, n \rrbracket$ we have the
584 following properties:
586 \noindent If the domain of $M_{ij}^t$ is not empty, then
590 M_{ij}^1(0) & = & \left(X_i^{D_{ji}^{0}}, 0,0 \right) \\
591 \textrm{if $t \geq 2$ then }M_{ij}^t(0) & = &
592 \left(X_i^{D_{ji}^{c}},D_{ji}^{c},c \right) \textrm{, }
593 c = \min\{l | D_{ji}^l > D_{ji}^{t-2} \}
598 \noindent Secondly we have:
600 \forall t'\, .\, 1 \le t' \le t \Rightarrow Xd^{t'}_{ji} = X^{D^{t'-1}_{ji}}_i
601 \label{eq:correct_retrieve}
603 \noindent Thirdly, for any $k\in S^t$. Then, the value of the computed variable
604 \verb+Xp[k]+ at the end of the \verb+update_elems+ process is equal to
605 $X_k^{t}$ \textit{i.e.}, $F_{k}\left( X_1^{D_{k\,1}^{t-1}},\ldots,
606 X_{n}^{D_{k\,{n}}^{t-1}}\right)$ at the end of the $t^{\text{th}}$ iteration.
609 The proof is done by induction on the number of iterations.
611 \paragraph{Initial case:}
613 For the first item, by definition of $M_{ij}^t$, we have $M_{ij}^1(0) = \left(
614 \verb+Xp[i]+, 0,0 \right)$ that is obviously equal to $\left(X_i^{D_{ji}^{0}},
617 Next, the first call to the function \verb+fetch_value+ either assigns the head
618 of \verb+channels[i].sent[j]+ to \verb+Xd[j].v[i]+ or does not modify
619 \verb+Xd[j].v[i]+. Thanks to the \verb+init+ process, both cases are equal to
620 \verb+Xp[i]+, \textit{i.e.}, $X_i^0$. The equation (\ref{eq:correct_retrieve}) is then
624 For the last item, let $k$, $0 \le k \le n-1$. At the end of the first
625 execution\linebreak of the \verb+update_elems+ process, the value of
626 \verb+Xp[k]+ is\linebreak $F(\verb+Xd[+k\verb+].v[0]+, \ldots,
627 \verb+Xd[+k\verb+].v[+n-1\verb+]+)$. Thus, by definition of $Xd$, it is equal
628 to $F(Xd^1_{k\,0}, \ldots,Xd^1_{k\,n-1})$. Thanks to \Equ{eq:correct_retrieve},
629 we can conclude the proof.
633 \paragraph{Inductive case:}
635 Suppose now that lemma~\ref{lemma:execution} is established until iteration $l$.
637 First, if domain of definition of the function $M_{ij}^l$ is not empty, by
638 induction hypothesis $M_{ij}^{l}(0)$ is $\left(X_i^{D_{ji}^{c}}, D_{ji}^{c},c
639 \right)$ where $c$ is $\min\{k | D_{ji}^k > D_{ji}^{l-2} \}$.
641 At iteration $l$, if $l < c + 1$ then the \verb+skip+ statement is executed in
642 the \verb+fetch_values+ function. Thus, $M_{ij}^{l+1}(0)$ is equal to
643 $M_{ij}^{l}(0)$. Since $c > l-1$ then $D_{ji}^c > D_{ji}^{l-1}$ and hence, $c$
644 is $\min\{k | D_{ji}^k > D_{ji}^{l-1} \}$. Obviously, this implies also that
645 $D_{ji}^c > D_{ji}^{l-2}$ and $c=\min\{k | D_{ji}^k > D_{ji}^{l-2} \}$.
647 We now consider that at iteration $l$, $l$ is $c + 1$. In other words, $M_{ij}$
648 is modified depending on the domain $\dom(M^l_{ij})$ of $M^l_{ij}$:
650 \item if $\dom(M_{ij}^{l})=\{0\}$ and $\forall k\, . \, k\ge l \Rightarrow
651 D^{k}_{ji} \neq l$ is established then $\dom(M_{ij}^{l+1})$ is empty and the
652 first item of the lemma is established;
653 \item if $\dom(M_{ij}^{l})=\{0\}$ and $\exists k\, . \, k\ge l \land D^{k}_{ji}
654 = l$ is established then $M_{ij}^{l+1}(0)$ is $(\verb+Xp[i]+,l,c_{ij})$ that
655 is added in the \verb+diffuse_values+ function s.t.\linebreak $c_{ij} =
656 \min\{k \mid D^{k}_{ji} = l \} $. Let us prove that we can express
657 $M_{ij}^{l+1}(0)$ as $\left(X_i^{D_{ji}^{c'}},D_{ji}^{c'},c' \right)$ where
658 $c'$ is $\min\{k | D_{ji}^k > D_{ji}^{l-1} \}$. First, it is not hard to
659 establish that $D_{ji}^{c_{ij}}= l \geq D_{ji}^{l} > D_{ji}^{l-1}$ and thus
660 $c_{ij} \geq c'$. Next, since $\dom(M_{ij}^{l})=\{0\}$, then between
661 iterations $D_{ji}^{c}+1$ and $l-1$, the \texttt{diffuse\_values} function has
662 not updated $M_{ij}$. Formally we have
664 \forall t,k \, .\, D_{ji}^c < t < l \land k \geq t \Rightarrow D_{ji}^k \neq
667 Particularly, $D_{ji}^{c'} \not \in \{D_{ji}^{c}+1,\ldots,l-1\}$. We can apply
668 the third item of the induction hypothesis to deduce
669 $\verb+Xp[i]+=X_i^{D_{ji}^{c'}}$ and we can conclude.
671 \item if $\{0,1\} \subseteq \dom(M_{ij}^{l})$ then $M_{ij}^{l+1}(0)$ is
672 $M_{ij}^{l}(1)$. Let $M_{ij}^{l}(1)= \left(\verb+Xp[i]+, a_{ij} , c_{ij}
673 \right)$. By construction $a_{ij}$ is $\min\{t' | t' > D_{ji}^c \land
674 (\exists k \, .\, k \geq t' \land D_{ji}^k = t')\}$ and $c_{ij}$ is $\min\{k |
675 D_{ji}^k = a_{ij}\}$. Let us show $c_{ij}$ is equal to $\min\{k | D_{ji}^k >
676 D_{ji}^{l-1} \}$ further referred as $c'$. First we have $D_{ji}^{c_{ij}} =
677 a_{ij} > D_{ji}^c$. Since $c$ by definition is greater or equal to $l-1$ ,
678 then $D_{ji}^{c_{ij}}> D_{ji}^{l-1}$ and then $c_{ij} \geq c'$. Next, since
679 $c$ is $l-1$, $c'$ is $\min\{k | D_{ji}^k > D_{ji}^{c} \}$ and then $a_{ij}
680 \leq D_{ji}^{c'}$. Thus, $c_{ij} \leq c'$ and we can conclude as in the
685 The case where the domain $\dom(M^l_{ij})$ is empty but the formula $\exists k
686 \, .\, k \geq l \land D_{ji}^k = l$ is established is equivalent to the second
687 case given above and then is omitted.
690 Secondly, let us focus on the formula~(\ref{eq:correct_retrieve}). At iteration
691 $l+1$, let $c'$ be defined as $\min\{k | D_{ji}^k > D_{ji}^{l-1} \}$. Two cases
692 have to be considered depending on whether $D_{ji}^{l}$ and $D_{ji}^{l-1}$ are
695 \item If $D_{ji}^{l} = D_{ji}^{l-1}$, since $D_{ji}^{c'} > D_{ji}^{l-1}$, then
696 $D_{ji}^{c'} > D_{ji}^{l}$ and then $c'$ is distinct from $l$. Thus, the SPIN
697 execution detailed above does not modify $Xd_{ji}^{l+1}$. It is obvious to
698 establish that $Xd_{ji}^{l+1} = Xd_{ji}^{l} = X_i^{D_{ji}^{l-1}} =
700 \item Otherwise $D_{ji}^{l}$ is greater than $D_{ji}^{l-1}$ and $c$ is thus $l$.
701 According to \Equ{eq:Mij0} we have proved, we have
702 $M_{ij}^{l+1}(0)=(X_i^{D_{ji}^{l}},D_{ji}^{l},l)$. Then the SPIN execution
703 detailed above assigns $X_i^{D_{ji}^{l}}$ to $Xd_{ji}^{l+1}$, which ends the
704 proof of (\ref{eq:correct_retrieve}).
707 We are left to prove the induction of the third part of the lemma. Let $k$, $k
708 \in S^{l+1}$. % and $\verb+k'+ = k-1$.
709 At the end of the first execution of the \verb+update_elems+ process, we have
710 $\verb+Xp[+k\verb+]+= F(\verb+Xd[+k\verb+][0]+,
711 \ldots,\verb+Xd[+k\verb+][+n\verb+-1]+)+$. By definition of $Xd$, it is equal
712 to $F(Xd^{l+1}_{k\,0}, \ldots,Xd^{l+1}_{k\,n-1})$. Thanks to
713 \Equ{eq:correct_retrieve} we have proved, we can conclude the proof.
718 Bounding the size of channels to $\textit{max} = \delta_0$ is sufficient when
719 simulating a DDN where delays are bounded by $\delta_0$.
723 For any $i$, $j$, at each iteration $t+1$, thanks to bounded delays (by
724 $\delta_0$), element $i$ has to know at worst $\delta_0$ values that are
725 $X_j^{t}$, \ldots, $X_j^{t-\delta_0+1}$. They can be stored into any channel
730 \begin{theorem}[Soundness wrt universal convergence property]\label{Theo:sound}
731 Let $\phi$ be a DDN model and $\psi$ be its translation. If $\psi$ verifies
732 the LTL property (\ref{eq:ltl:conv}) under weak fairness property, then
733 iterations of $\phi$ are universally convergent.
736 % For the case where the strategy is finite, one notice that property
737 % verification is achieved under weak fairness property. Instructions that
738 % write or read into \verb+channels[j].sent[i]+ are continuously enabled leading
739 % to convenient available dates $D_{ji}$. It is then easy to construct
740 % corresponding iterations of the DDN that are convergent.
741 % \ANNOT{quel sens donnes-tu a \emph{convenient} ici ?}
743 Let us show the contraposition of the theorem. The previous lemmas have shown
744 that for any sequence of iterations of the DDN, there exists an execution of
745 the PROMELA model that simulates them. If some iterations of the DDN are
746 divergent, then they prevent the PROMELA model from stabilizing, \textit{i.e.}, not
747 verifying the LTL property (\ref{eq:ltl:conv}).
751 % \begin{Corol}[Soundness wrt universall convergence property]\label{Theo:sound}
752 % Let $\phi$ be a DDN model where strategy, $X^(0)$
753 % are only constrained to be pseudo-periodic and
754 % in $E$ respectively.
755 % Let $\psi$ be its translation.
756 % If all the executions of $\psi$ converge,
757 % then iterations of $\phi$ are universally convergent.
762 \begin{theorem}[Completeness wrt universal convergence property]\label{Theo:completeness}
763 Let $\phi$ be a DDN model and $\psi$ be its translation. If $\psi$ does not
764 verify the LTL property (\ref{eq:ltl:conv}) under weak fairness property then
765 the iterations of $\phi$ are divergent.
768 For models $\psi$ that do not verify the LTL property (\ref{eq:ltl:conv}) it
769 is easy to construct corresponding iterations of the DDN, whose strategy is
770 pseudo-periodic since weak fairness property is taken into account.
772 % i.e. iterations that are divergent. Executions are
773 % performed under weak fairness property; we then detail what are continuously
776 % \item if the strategy is not defined as periodic, elements $0$, \ldots, $n$ are
777 % infinitely often updated leading to pseudo-periodic strategy;
778 % \item instructions that write or read into \verb+channels[j].sent[i]+ are
779 % continuously enabled leading to convenient available dates $D_{ji}$.
781 % The simulated DDN does not stabilize and its iterations are divergent.
786 \section{Practical Issues}
787 \label{sec:spin:practical}
788 This section first gives some notes about complexity and later presents
790 %\subsection{Complexity Analysis}
791 %\label{sub:spin:complexity}
792 \begin{theorem}[Number of states]
793 Let $\phi$ be a DDN model with $n$ elements, $m$ edges in the incidence graph
794 and $\psi$ be its translation into PROMELA. The number of configurations of
795 the $\psi$ SPIN execution is bounded by $2^{m\times(\delta_0+1)+n(n+2)}$.
798 A configuration is a valuation of global variables. Their number only depends
799 on those that are not constant.
801 The variables \verb+Xp+ \verb+X+ lead to $2^{2n}$ states. The variable
802 \verb+Xs+ leads to $2^{n^2}$ states. Each channel of \verb+array_of_channels+
803 may yield $1+2^1+\ldots+2^{\delta_0}= 2^{\delta_0+1}-1$ states. Since the
804 number of edges in the incidence graph is $m$, there are $m$ non-constant
805 channels, leading to approximately $2^{m\times(\delta_0+1)}$ states. The
806 number of configurations is then bounded by $2^{m\times(\delta_0+1)+n(n+2)}$.
807 Notice that this bound is tractable by SPIN for small values of $n$,
813 The method detailed along the line of this article has been applied on the
814 running example to formally prove its universally convergence.
816 First of all, SPIN only considers weak fairness property between processes
817 whereas above proofs need such a behavior to be established each time a
818 non-deterministic choice is done.
821 A first attempt has consisted in building the following formula
822 each time an undeterministic choice between $k$ elements
823 respectively labeled $l1$, \ldots $lk$ occurs:
825 [] <> (l == l0) \Rightarrow
826 (([] <> (l== l1)) \land \ldots \land ([] <> (l == lk)))
828 where label $l0$ denotes the line before the choice.
829 This formula exactly translates the fairness property.
830 The negation of such a LTL formula may then be efficiently translated
831 into a Büchi automata with the tool ltl2ba~\cite{GO01}.
832 However due to an explosion of the size of the product
833 between this automata and the automata issued from the PROMELA program
834 SPIN did not success to verify whether the property is established or not.
836 This problem has been practically tackled by leaving spin generating all the (not necessarily fair) computations and verifying convergence property on them.
837 We are then left to interpret its output with two issues.
838 If property is established for all the computations,
839 it is particularly established for fair ones and iterations are convergent.
840 In the opposite case, when facing to a counter example, an analysis of the SPIN
843 Experiments have shown that all the iterations of the running example are
844 convergent for a delay equal to 1 in less than 10 min.
845 The example presented in~\cite{abcvs05} with five elements taking boolean
846 values has been verified with method presented in this article.
847 Immediately, SPIN computes a counter example, that unfortunately does not
848 fulfill fairness properties. Fair counter example is obtained
850 All the experimentation have been realized in a classic desktop computer.
857 %However preliminary experiments have shown the interest of the approach.
861 % The method detailed along the line of this article has been
862 % applied on some examples to formally prove their convergence
863 % (Fig.~\ref{fig:async:exp}).
864 % In these experiments, Delays are supposed to be bounded by $\delta_0$ set to 10.
866 % $P$ is true ($\top$) provided the uniform convergence property is established, false ($\bot$) otherwise,
867 % $M$ is the amount of memory usage (in MB) and
868 % $T$ is the time needed on a Intel Centrino Dual Core 2 Duo @1.8GHz with 2GB of memory, both
869 % to establish or refute the property.
871 % RE is the running example of this article,
872 % AC2D is a cellular automata with 9 elements taking boolean values
873 % according their four neighbors
874 % and BM99 is has been proposed in~\cite{BM99} and consists of 10 process
875 % modifying their boolean values, but with many connected connection graph.
884 % \begin{tabular}{|*{13}{c|}}
886 % \multicolumn{1}{c|}{ }
887 % &\multicolumn{6}{|c|}{Mixed Mode} & \multicolumn{6}{|c|}{Only Bounded} \\
889 % \multicolumn{1}{c|}{ }
890 % &\multicolumn{3}{|c|}{Parallel} & \multicolumn{3}{|c|}{Pseudo-Periodic} &
891 % \multicolumn{3}{|c|}{Parallel} & \multicolumn{3}{|c|}{Pseudo-Periodic} \\
893 % \multicolumn{1}{c|}{ }
898 % \hline %cline{2-13}
900 % $\top$ & 409 & 1m11s&
901 % $\bot$ & 370 & 0.54 &
902 % $\bot$ & 374 & 7.7s&
903 % $\bot$ & 370 & 0.51s \\
904 % \hline %\cline{2-13}
906 % &$\bot$ & 2.5 & 0.001s % RC07_async_mixed.spin
907 % &$\bot$ & 2.5 & 0.01s % RC07_async_mixed_all.spin
908 % &$\bot$ & 2.5 & 0.01s % RC07_async.spin
909 % &$\bot$ & 2.5 & 0.01s \\ % RC07_async_all.spin
910 % \hline %\cline{2-13}
912 % &$\top$ & & %BM99_mixed_para.spin
913 % &$\top$ & & % RC07_async_mixed_all.spin
914 % &$\bot$ & & % RC07_async.spin
915 % &$\bot$ & & \\ % RC07_async_all.spin
916 % \hline %\cline{2-13}
919 % \caption{Experimentations with Asynchronous Iterations}\label{fig:async:exp}
924 % The example~\cite{RC07} deals with a network composed of two genes taking their
925 % values into $\{0,1,2\}$. Since parallel iterations is already diverging,
926 % the same behavior is observed for all other modes.
927 % The Figure~\ref{fig:RC07CE} gives the trace leading to convergence property
928 % violation output by SPIN.
929 % It corresponds to peridic strategy that repeats $\{1,2\};\{1,2\};\{1\};\{1,2\};\{1,2\}$ and starts with $X=(0,0)$.
932 % In the example extracted from~\cite{BM99},
933 % we have 10 processors computing a binary value.
934 % Due to the huge number of dependencies between these calculus,
935 % $\delta_0$ is reduced to 1. It nevertheless leads to about $2^{100}$
936 % configurations in asynchronous iterations.
938 % Let us focus on checking universal convergence of asynchronous iterations
939 % of example~\cite{BCVC10:ir}.
940 % With a $\delta_0$ set to 5, SPIN generates an out of memory error.
941 % However, it succeed to prove that the property is not established even
942 % with $\delta_0$ set to 1 which is then sufficient.
948 % \begin{tabular}{|*{7}{c|}}
950 % \multicolumn{1}{c|}{ }
951 % &\multicolumn{3}{|c|}{Parallel} & \multicolumn{3}{|c|}{Pseudo-Periodic} \\
953 % \multicolumn{1}{c|}{ }&
956 % \hline %\cline{2-7}
958 % $\top$ & 2.7 & 0.01s &
959 % $\bot$ & 369.371 & 0.509s \\
960 % \hline %\cline{2-7}
961 % \cite{RC07} example &
962 % $\bot$ & 2.5 & 0.001s & % RC07_sync.spin
963 % $\bot$ & 2.5 & 0.01s \\ % RC07_sync_chao_all.spin
965 % \cite{BM99} example &
966 % $\top$ & 36.7 & 12s & % BM99_sync_para.spin
967 % $\top$ & & \\ % BM99_sync_chao.spin
972 % \caption{Experimentations with Synchronous Iterations}\label{fig:sync:exp}
980 % \begin{tabular}{|*{}{c|}}
985 % & \multicolumn{6}{|c|}{Synchronous} & \multicolumn{12}{|c|}{Asynchronous}\\
987 % Delay & \multicolumn{6}{|c|}{ }
988 % & \multicolumn{6}{|c|}
990 % & \multicolumn{6}{|c|}
991 % {Bounded+Mixed Mode}\\
993 % \multicolumn{3}{|c|}{Parallel} & \multicolumn{3}{|c|}{Chaotic} &
994 % \multicolumn{3}{|c|}{Parallel} & \multicolumn{3}{|c|}{Chaotic} &
995 % \multicolumn{3}{|c|}{Parallel} & \multicolumn{3}{|c|}{Chaotic} \\
1001 \section{Conclusion and Future Work}
1002 \label{sec:spin:concl}
1003 Stochastic based prototypes have been implemented to generate both
1004 strategies and delays for asynchronous iterations in first in~\cite{BM99,BCV02}.
1005 However, since these research softwares are not exhaustive, they really give an
1006 formal answer when they found a counterexample. When facing convergence, they only convince
1007 the user about this behavior without exhibiting a proof.
1009 As far as we know, no implemented formal method tackles the problem of
1010 proving asynchronous iterations convergence.
1011 In the theoretical work~\cite{Cha06} Chandrasekaran shows that asynchronous iterations
1012 are convergent iff we can build a decreasing Lyaponov function,
1013 but does not gives any automated method to compute it.
1015 In this work, we have shown how convergence proof for any asynchronous
1016 iterations of discrete dynamical networks with bounded delays
1017 can be automatically achieved.
1018 The key idea is to translate the network (map, strategy) into PROMELA and
1019 to leave the SPIN model checker establishing the validity
1020 of the temporal property corresponding to the convergence.
1021 The correctness and completeness of the approach have been proved, notably
1022 by computing a SPIN execution of the PROMELA model that have the same
1023 behaviors than initial network.
1024 The complexity of the problem is addressed. It shows that non trivial example
1025 may be addressed by this technique.
1027 Among drawbacks of the method, one can argue that bounded delays is only
1028 realistic in practice for close systems.
1029 However, in real large scale distributed systems where bandwidth is weak,
1030 this restriction is too strong. In that case, one should only consider that
1031 matrix $S^{t}$ follows the iterations of the system, \textit{i.e.},
1032 for all $i$, $j$, $1 \le i \le j \le n$, we have$
1033 \lim\limits_{t \to \infty} S_{ij}^t = + \infty$.
1034 One challenge of this work should consist in weakening this constraint.
1035 We plan as future work to take into account other automatic approaches
1036 to discharge proofs notably by deductive analysis~\cite{CGK05}.