Project

General

Profile

root / branches / compiler / cSharp / ooasCompiler / doc / manual.tex

1 3 krennw
\documentclass[11pt]{scrartcl}
2
3
\usepackage{cancel}
4
\usepackage{listings}
5
\usepackage{xspace}
6
\usepackage{longtable}
7
\usepackage{graphicx}
8
\usepackage{url}
9
10
11
\newcommand{\doodblock}{{\bf do} {\bf od}-block \xspace}
12
\newcommand{\doodblocks}{{\bf do} {\bf od}-blocks \xspace}
13
14
15
\lstdefinelanguage{ooa} {
16
  morekeywords={autocons, types, methods, do, obs, action, end, ctr, requires, od, true, and,
17
     signal, after, false, actions, var, |[, ]|, [], public, of, len,
18
     //, hd, tl, system},
19
   sensitive=true,
20
   morecomment=[s]{/*}{*/},
21
   showspaces=false,
22
   showstringspaces=false,
23
   numbers=left,
24
   numbersep=5pt,
25
   numberstyle=\tiny,
26
   tabsize=2,
27
   escapeinside={@}{@},
28
   framexleftmargin=9pt,
29
  }
30
31
32
\begin{document}
33
34
35
36
37
38
39
\begin{titlepage}
40
\begin{center}
41
42
\vspace*{15mm}
43
44
{\Large TECHNICAL REPORT}
45
46
\vspace{10mm}
47
48
{\large IST-MBT-2012-01}
49
50
\vspace{15mm}
51
52
{\huge \bf The Argos Manual}
53
54
\vspace{5mm}
55
56
{\Large for Argos version: 0.39}
57
58
\vspace{15mm}
59
60
{\Large Stefan Tiran}
61
62
\vspace{5mm}
63
64
{\large stiran@ist.tugraz.at}
65
66
\vspace{15mm}
67
68
{\large March 2012} % 13.03.2012
69
70
\vspace{10mm}
71
72
{\large
73
Institute for Software Technology (IST)\\
74
Graz University of Technology\\
75
A-8010 Graz, Austria\\}
76
77
\end{center}
78
\end{titlepage}
79
80
81
82
83
84
%\title{The Argos Manual}
85
86
%\author{Stefan Tiran}
87
88
%\subtitle{for Argos version: 0.39}
89
90
%\maketitle
91
\newpage
92
\tableofcontents
93
\listoffigures
94
95
96
\section{Introduction}
97
98
Argos is a compiler for Object-Oriented Action Systems (OOAS). It has been developed
99
by Willibald Krenn from Graz University of Technology within the MOGENTES project.
100
101
Its main target is producing Action Systems in the proprietary format that \emph{Ulysses}
102
can process. \emph{Ulysses} is an ioco-checker written by Harald Brandl also within the
103
MOGENTES project.
104
105
\section{How To Run Argos}
106
107
Argos is a .NET based command line program. To run it you need either
108
the .NET Framework or mono (\url{http://www.mono-project.com}).
109
110
\subsection{Program Invocation}
111
112
Since Argos is a command line tool you need to open a command line prompt
113
(using Windows) resp. a shell (using a UNIX-like system).
114
115
When using Windows change to the Argos directory and simply run argos.exe:
116
117
\texttt{
118
c:\textbackslash Argos \textbackslash > argos}
119
120
When using a UNIX-like system run mono with argos.exe as parameter:
121
122
\texttt{
123
\$ mono argos.exe}
124
125
In both cases one should now see this welcome screen:
126
127
\begin{verbatim}
128
          >> Mogentes OO-Action System Parser <<
129
130
          Version: 0.39 (16471)
131
  Grammar-Version: 0.06
132
133
Usage:    argos [options] <oo-actionsystem-file>
134
Options:
135
     -o<name>   ... write output to file <name> (overwrites!)
136
     -n<name>   ... use namespace <name> (default: as)
137
     -d<depth>  ... set max. search depth (default: 35)
138
     -q         ... "quiet" mode: doesn't print Warnings to console
139
140
     -a         ... create pseudo-action system code
141
     -p         ... create prolog code
142
     -c         ... create CADP implicit LTS
143
144
\end{verbatim}
145
146
\subsection{Options and Arguments}
147
148
As can be seen in the welcome screen for translating Action Systems the
149
last parameter has to be the OOAS-File you want to convert, every other
150
options has to come before.
151
152
If no other option is given, Argos will translate the given OOAS-File to
153
C\#-Pseudo-Code and print it out on the screen. Since this most probably
154
won't be something you will find extremely useful, you should at least
155
specify an output-file and the desired language.
156
157
For specifying the output-file use option \texttt{-o} followed by the
158
file name resp. the relative path of the file you want to create. There
159
should be NO space between \texttt{-o} and the file name!
160
161
For specifying the language include option \texttt{-c} for creating
162
C-Code for the CADP-Toolbox resp. option \texttt{-p} for creating
163
Prolog-Code for use with the Ulysses tool.
164
165
When creating Prolog-Code the following options are important:
166
\begin{itemize}
167
\item[-n] With this option one can specify the namespace within the Prolog-File;
168
	the only meaningful use of this option is \texttt{-nasm} for letting
169
	the Ulysses tool know, that this file represents the mutant rather
170
	then the original file.
171
\item[-d] With this option one can specify the max. depth, to which the Ulysses
172
	tool will search for differences. Please note that this option has
173
	to be followed by a number WITHOUT a space before! The default value
174
	is 35, so leaving out this option is equivalent to writing
175
	\texttt{-d35}.
176
177
\subsection{Examples}
178
179
To illustrate the use of the options, we hereby provide the following examples:
180
181
\begin{itemize}
182
\item Translate an original OOAS specification \texttt{original.ooas} to a Prolog
183
	file \texttt{original.pl} for the Ulysses tool with max. search depth
184
	42:
185
	\begin{verbatim} argos.exe -p -d42 -ooriginal.pl original.ooas \end{verbatim}
186
\item Translate a mutated OOAS specification \texttt{mutant.ooas} to a Prolog
187
	file \texttt{mutant.pl} for the Ulysses tool with max. search depth
188
	42:
189
	\begin{verbatim} argos.exe -p -d42 -nasm -omutant.pl mutant.ooas \end{verbatim}
190
\item Translate OOAS specification \texttt{original.ooas} to a C file
191
	\texttt{original.c} for the use with the CADP toolbox:
192
	\begin{verbatim} argos.exe -c -ooriginal.c original.ooas \end{verbatim}
193
194
195
\end{itemize}
196
197
\end{itemize}
198
199
\section{OOAS Language}
200
201
The Argos tool will only work if the given file is well formed according
202
to the language that is described in this section. The language is based
203
on the language proposed in \cite{Bonsangue1998} but only a subset of features
204
is actually implemented.
205
206
\subsection{Base structure}
207
208
To illustrate the base structure of an OOAS file let us consider the simple
209
Hello World program in Figure \ref{HelloWorld}.
210
211
\begin{figure}[h]
212
 \begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
213
types
214
  Greeter = autocons system
215
  |[
216
  var
217
        done : bool = false
218
  actions
219
        obs HelloWorld = requires done = false :
220
                done := true
221
                end
222
  do
223
        HelloWorld
224
  od
225
  ]|
226
system
227
        Greeter
228
229
 \end{lstlisting}
230
\caption{HelloWorld}
231
\label{HelloWorld}
232
\end{figure}
233
234
Every OOAS consists of two different regions: The type definition block and
235
the system assembling block. In the HelloWorld system the type definition block
236
consists of Lines 1 - 13 and the system assembling consists of Lines 14 and 15.
237
238
Let us now discuss the system Line by Line:
239
Line 1 just consists of the keyword \texttt{types} stating that here begins
240
the type definition block.
241
In Line 2 a class called \texttt{Greeter} is defined. The keyword
242
\texttt{autocons} states that one instance of the class will automatically
243
be created at system start. This instance is called the ``root object''.
244
The symbols in Line 3 and 13 state the begin and the end of the class
245
definition.
246
In Lines 4 and 5 there is  a variable definition
247
block. Even though this block is not formally necessary for Argos to compile
248
a file, Argos will not create a valid prolog file if this block is missing.
249
In Lines 6 - 9 there is the action block consisting of the action
250
\texttt{HelloWorld}. The keyword \texttt{obs} states that this action is
251
\emph{observable} rather then \emph{controllable} (keyword: \texttt{ctr}) or
252
internal (no keyword).
253
The keyword \texttt{requires} states the beginning of the guard, which enables
254
the action.
255
The body of this action consists of Lines 8 and 9. Line 8 contains an
256
assignment, the keyword \texttt{end} in Line 9 marks the end of the action.
257
Lines 10 - 12 contains the so-called \doodblock. The \doodblock is
258
described in Section \ref{dood}.
259
260
As already mentioned, Lines 14 + 15 contain the system assembling block. In this
261
block the system is composed of its classes. Since this example system only
262
contains of one class, the block is quite simple and needs no further
263
explanation.
264
265
\subsection{The Type Definition Block}
266
267
The type definition block has two purposes: As we have already seen it can be
268
used for defining the classes of which the system consists of. However it
269
can also be used for creating named types which is similar to the use of
270
\texttt{type-def} in C.
271
272
The latter use is quite important as OOAS has a very strict typing system.
273
For example if you want to define a variable as integer, you also have to
274
define the range of the values. This is due to the fact that too wide ranges
275
can lead to enormous efficiency problems when simulating the model.
276
277
\subsubsection{Defining Integer Types}
278
279
Integer types can be defined by the lower and upper range.
280
281
Consider you want to define a type \texttt{MyInt} that can contain values
282
between 0 and 31, then you can write
283
\begin{verbatim}
284
  MyInt = int [0..31];
285
\end{verbatim}
286
287
Please note that the semicolon has to be placed if and only if this is not
288
the last definition.
289
290
\subsubsection{Defining Enum Types}
291
292
Enums can be defined by enumerating the possible values and optionally assigning them
293
integer values. If integer values are explicitly assigned, enum types can be casted to
294
integer types.
295
296
Consider you want to define an enum type \texttt{Color} that can contain the
297
values \texttt{red}, \texttt{green}, \texttt{blue}, \texttt{yellow} and \texttt{black},
298
then you can write:
299
\begin{verbatim}
300
  Color = {red, green, blue, yellow, black};
301
\end{verbatim}
302
303
The possibility to explicitly assign integer values is especially useful when
304
dealing with equivalent classes of integers. Consider you need an integer type
305
that can only contain small number of different values but these values define
306
a range with "holes" rather then a complete one.
307
308
So in case you need a type that can hold the values 1, 42 and 1337 you can write
309
\begin{verbatim}
310
    CoolValueSet = {CoolValue1 = 1, CoolValue2 = 42, CoolValue3 = 1337};
311
\end{verbatim}
312
313
\subsubsection{Defining Complex Types (Lists, Tuples)}
314
315
Additional to the former so-called simple types the OOAS language also
316
supports so-called complex types. These are: lists and tuples.
317
318
A list is defined by the number and the type of its elements.
319
320
An example for the former variant would be:
321
\begin{verbatim}
322
  MyList = list [42] of char;
323
\end{verbatim}
324
325
A tuple is defined by the types of its elements. Unlike a list the types can
326
differ among the different elements.
327
328
An example would be:
329
\begin{verbatim}
330
  MyTuple = (MyInt, SmallInt);
331
\end{verbatim}
332
333
Even though maps and qualitative reasoning types would be specified by the
334
OOAS language, Argos does not support them yet.
335
336
\subsubsection{Defining Classes}
337
338
In the OOAS language the definition of a class (ooActionSystem) does not differ
339
from the definition of any other type.
340
341
\subsection{Structure of Classes}
342
343
\subsubsection{Inheritance}
344
345
As common in Object-Oriented languages, classes can be derived from other classes
346
and inherit their behavior.
347
A sample class \texttt{Desc} inheriting from a class \texttt{base} could look like this:
348
349
\begin{verbatim}
350
  Desc = system (base)
351
  |[
352
  ]|
353
354
\end{verbatim}
355
356
\subsubsection{Defining Variables (Attributes)}
357
\label{Variables}
358
359
Variables store the information of the state of an object. An alternative name
360
of variables often used in error messages is ``attributes''. Variables can be
361
static and have to be initialized with a valid value. For objects there is a
362
predefined object \texttt{nil}. There is also a self-reference called
363
\texttt{self}.
364
365
The definition of a variable can look like this:
366
\begin{verbatim}
367
        done : bool = false;
368
\end{verbatim}
369
370
Please note that the semicolon has to be placed if and only if this is not
371
the last definition.
372
373
\subsubsection{Creating Objects}
374
375
The only place where an object can be created is in the variable definition block.
376
Line 5 in Figure \ref{object} demonstrates how a variable with the name
377
\texttt{myOtherClassObject} can be initialized with an object with the name
378
\texttt{OtherClassObject} of a class \texttt{OtherClass}.
379
380
For details on the System Assembling Block (Lines 23 and 24) see Section
381
\ref{SAB}.
382
383
\begin{figure}[h]
384
 \begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
385
types
386
  RootClass = autocons system
387
  |[
388
  var
389
        myOtherClassObject : OtherClass = new(OtherClass,"OtherClassObject") ;
390
        initialized : bool = false
391
  actions
392
        obs init = requires initialized = false : initialized := true end
393
  do
394
        init ()
395
  od
396
  ]| ;
397
  OtherClass = system
398
  |[
399
  var
400
        initialized : bool = false
401
  actions
402
        obs init = requires initialized = false : initialized := true end
403
  do
404
        init ()
405
  od
406
  ]|
407
system
408
        RootClass [] OtherClass
409
 \end{lstlisting}
410
\caption{Creating an object}
411
\label{object}
412
\end{figure}
413
414
\subsubsection{Defining Methods}
415
416
Methods can be used for defining subroutines. Methods can have parameters,
417
variables and a return value. Methods can be called from actions and
418
from other methods, but not recursively - neither directly nor indirectly.
419
420
The body of a method isn't any different from the body of an action
421
and therefore described in Section \ref{Actions}.
422
423
A sample method, that returns the bigger of two values could look like this:
424
425
\begin{verbatim}
426
  maxValue(a : MyInt, b : MyInt) : MyInt =
427
    result := if (a > b) then a else b end
428
  end;
429
\end{verbatim}
430
431
Returning a value is done by assigning it to the variable result.
432
For a list of possible expressions we refer to Section \ref{Expressions}.
433
434
One important aspect of methods is their pureness. A method is pure
435
iff there is no assignment to a variable other than \texttt{result}.
436
This property is checked on compile
437
time. Only if a method is pure it can be used in a guard or in a list
438
comprehension.
439
440
\subsubsection{Defining Actions}
441
\label{Actions}
442
443
Named actions consist of an optional parameter list, a variable definition
444
block and a body but they lack a return value. Named actions can only be
445
called in the so-called \doodblock.
446
447
A named action can be controllable (keyword \texttt{ctr}),
448
observable (keyword \texttt{obs}) or internal (no keyword).
449
450
The definition of local variables does not differ from any
451
other variable definition so we refer to Section \ref{Variables}.
452
453
The body of a named action can consist of one or more basic actions.
454
Every action has a guard which ``enables'' it. The general form of a guard
455
is \texttt{requires p : $S_1$ end} where p is the condition
456
and $S_1$ is the action. The condition can be any expression that doesn't
457
involve the calling of a non-pure method or a non-pure assignment.
458
459
For further details about expressions see Section \ref{Expressions}!
460
461
Basic actions can be the built-in action \texttt{skip},
462
single or multiple assignment or a sequential composition of two other actions.
463
For details on the composition we refer to Section \ref{Composition}.
464
465
The built-in action \texttt{skip} doesn't do anything at all.
466
Sometimes this is called \emph{identity assignment}.
467
468
Single assignment has the simple form \texttt{v := e} where
469
v is a variable and e is an expression.
470
471
However you can also assign multiple expressions to multiple
472
variables by separating them with commas.
473
474
So if \texttt{done} and \texttt{multi} are both variables of
475
type \texttt{bool}, then you can write:
476
477
\begin{verbatim}
478
                done, multi := true, true
479
\end{verbatim}
480
481
\subsection{Composition}
482
\label{Composition}
483
\subsubsection{Sequential Composition}
484
485
The easiest way of composing two actions is the sequential
486
composition. It has the general form \texttt{A ; B} where
487
A and B are both actions and has the meaning that iff
488
A and B are \emph{enabled}, first action A is executed and then
489
action B is executed. Note that it is not necessary for B
490
to be enabled before A. It is also possible that B becomes
491
enabled because of A.
492
493
Please note that despite of the
494
apparent resemblance with the semicolon as marker of the
495
end of a line in many imperative programming languages
496
there are two very important differences:
497
498
The first difference is that since it is a composition operator,
499
there must not be a semicolon after the last action. This
500
difference seems to be more on a syntactical level, but should
501
also warn about the other very important difference:
502
503
The second difference is that since actions have guards, no
504
action of a sequence block is executed, if a single action is
505
not enabled. This also means that an action can hinder actions
506
to be executed, which were called \emph{before}!
507
508
\subsubsection{Non-deterministic Choice}
509
510
The counterpart of the ``sequential composition'' is the so
511
called ``non-deterministic choice''.
512
513
The general form of a non-deterministic choice is \texttt{ A [] B }
514
where A and B are both actions and the meaning is that either
515
A or B is executed. However an action can only be chosen if it
516
is enabled. According to the theory of action systems an action has to be
517
chosen if it is aborting. However there is no abort feature implemented yet.
518
519
\subsubsection{Prioritizing Composition}
520
521
The ``prioritizing composition'' is rather an abbreviation
522
than an actual new type of composition.
523
524
The general form is \texttt{ A // B } and it means that if A
525
is enabled, it is chosen and otherwise B is chosen.
526
527
\subsection{Expressions}
528
\label{Expressions}
529
530
Expressions can be evaluated and their values can be assigned to variables.
531
532
\subsubsection{Conditional Assignment}
533
534
Conditional Assignments are expressions. They can not be used for branching
535
the control sequence. Branching the control sequence has to be done by using
536
guards and non-deterministic choice.
537
538
A conditional assignment can look like this:
539
\begin{verbatim}
540
  c := if (a > b) then a else b end
541
\end{verbatim}
542
543
\subsubsection{Fold}
544
545
For the purpose of iterating through a list in OOAS \emph{fold} is used.
546
\emph{Fold} is a higher-order function well known from the functional
547
programming paradigm.
548
549
In the OOAS language both \emph{right fold} and \emph{left fold} are
550
defined. The symbol for the former is \texttt{:>:} whereas the symbol
551
for the latter is \texttt{:<:}. However in Argos only \emph{right fold} is
552
implemented.
553
554
The general form of a fold expression is \texttt{method :: (init\_expression) :>:  (list\_\\expression)}
555
where \texttt{method} is the name of the method, \texttt{init\_expression} is the value for the last
556
parameter of the method for the first call. For any other call the result of the former call is used instead.
557
Finally \texttt{list\_expression} is the expression that evaluates to the list to be iterated.
558
559
560
Figure \ref{Sum} shows how to define a method \texttt{Sum}
561
using a method \texttt{Add} and the \emph{fold} operator.
562
563
\begin{figure}[h]
564
 \begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
565
types
566
  MyInt = int [0..42];
567
  SmallInt = int [0..3];
568
  MyTuple = (MyInt, SmallInt);
569
  Sum = autocons system
570
  |[
571
  var
572
        my_list : list [4] of SmallInt = [5,5,5,5]
573
  methods
574
    add(a: MyInt, b: SmallInt) : MyInt =
575
        requires true :
576
          result := a + b
577
        end
578
    end ;
579
    sum(Xs : list [4] of SmallInt) : MyInt =
580
        requires true  :
581
          result := add :: (0) :>: (Xs)
582
        end
583
    end
584
  actions
585
        obs Sum(a: MyInt) =
586
                requires a = sum(my_list) :
587
                        skip
588
                end
589
  do
590
        var A : MyInt : Sum(A)
591
  od
592
  ]|
593
system
594
        Sum
595
 \end{lstlisting}
596
\caption{Defining sum of all list elements using the fold meta function}
597
\label{Sum}
598
\end{figure}
599
600
\subsubsection{Quantifier Expressions}
601
602
The OOAS language allows to use the quantifiers \texttt{forall} and
603
\texttt{exists}. The resulting expressions will evaluate to Boolean
604
values. The general form is \texttt{(quantifier : Type  : (logical sentence))}.
605
606
For example an existential quantification can look like this:
607
\texttt{(exists i : LengthInt : (primes[i] = a))}.
608
609
610
\subsubsection{List Comprehension}
611
612
The OOAS language allows to construct new list expressions based on existing lists
613
by using the set-builder notation. These expressions can be assigned to list
614
variables at any time after the initialization, but not in the declaration.
615
616
The general form of a list comprehension is:
617
618
\texttt{list := [x | var x : Type \& (condition)]}, where \texttt{Type} is the type
619
of the list elements and \texttt{condition} is a logical sentence which determines
620
whether a value should be inserted to the list.
621
622
The example in Figure \ref{Prime} illustrates both \emph{Quantifier Expressions}
623
and \emph{List Comprehension} by computing prime numbers.
624
625
\begin{figure}[h]
626
 \begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
627
types
628
  MyInt = int [2..100];
629
  LengthInt = int [0..40];
630
  Primes = autocons system
631
  |[
632
  var
633
        initialized : bool = false ;
634
        primes : list [ 40 ] of MyInt = [3]
635
  actions
636
    obs init = requires initialized = false :
637
      primes := [ x | var x: MyInt & (forall tmp : MyInt :
638
            (tmp < x => (x mod tmp <> 0 )))  ] ;
639
      initialized := true end;
640
641
    obs Prime(a: MyInt) =
642
      requires (exists i : LengthInt : (primes[i] = a)) :
643
        skip
644
      end
645
646
  do
647
        init() // var A : MyInt : Prime(A)
648
  od
649
  ]|
650
system
651
        Primes
652
 \end{lstlisting}
653
\caption{Prime number calculation}
654
\label{Prime}
655
\end{figure}
656
657
\subsubsection{Tuple Expressions}
658
659
The general form of an expression that evaluates to a tuple is:
660
\begin{verbatim}
661
	TupleType(v_1,...,v_n)
662
\end{verbatim}
663
where TupleType is the type of the tuple and v\_1,...,v\_n are the values.
664
665
An example for using Tuples can be found in Figure \ref{Tuple}
666
\begin{figure}[h]
667
 \begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
668
types
669
  MyInt = int [0..42] ;
670
  MyTuple = (MyInt, MyInt) ;
671
  TupleDemo = autocons system
672
  |[
673
  var
674
        theTuple : MyTuple = MyTuple(1,1)
675
  actions
676
        ctr change1 = requires theTuple = MyTuple(1,1) :
677
                theTuple := MyTuple(1,2)
678
                end ;
679
        ctr change2 = requires theTuple[1] = 2 :
680
                theTuple := MyTuple(1,3)
681
                end
682
  do
683
        change1 [] change2
684
  od
685
  ]|
686
system
687
        TupleDemo
688
689
\end{lstlisting}
690
\caption{Tuple Example}
691
\label{Tuple}
692
\end{figure}
693
694
695
\subsubsection{Access Expressions}
696
697
\emph{Access Expression} is the general term for the access of elements
698
in a list or tuple, call of method or access to an attribute of an object.
699
700
Accessing elements of a list is done by using the index operator \texttt{[]}
701
well known from accessing arrays in imperative languages like C.
702
The index starts with 0.
703
704
The index operator \texttt{[]} can also be used to access a specific element of
705
a tuple. This feature is illustrated in the guard of action \texttt{change2} in
706
Figure \ref{Tuple}. However this feature is not implemented in the left hand
707
side of an assignment, e. g. it is not possible to write \texttt{theTuple[0] := 1}.
708
709
\subsubsection{Cast Expressions}
710
711
When dealing with a class hierarchy it is possibly to use an object of a
712
sub class instead of an object of its super class. This is called \emph{upcast}
713
and done implicitly in most contexts. However, when concatenating two
714
lists it has to be done explicitly using the operator \texttt{as} as illustrated
715
in Line 10 in Figure \ref{Cast}.
716
717
\begin{figure}[h]
718
 \begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
719
types
720
  Class1 = autocons system
721
  |[
722
  var
723
        O2 : Class2 = new (Class2);
724
        O3 : Class3 = new (Class3);
725
        OL : list[2] of Class2 = [nil]
726
  actions
727
        ctr fill = requires true :
728
                OL := [O2]^[O3 as Class2]
729
                end
730
  do
731
        fill
732
  od
733
  ]| ;
734
  Class2 = system
735
  |[
736
  ]| ;
737
  Class3 = system (Class2)
738
  |[
739
  ]|
740
system
741
        Class1
742
\end{lstlisting}
743
\caption{Cast Example}
744
\label{Cast}
745
\end{figure}
746
747
748
\subsection{Operators}
749
750
\subsubsection{Numeric Operators}
751
752
The numeric operators are \texttt{+} for adding two numbers of an integer or
753
float type, \texttt{-} for subtracting, \texttt{*} for multiplying. The operator
754
for the division of two numbers of a float type is \texttt{/}. For the division
755
of two numbers of an integer type there are operators \texttt{div} for the
756
quotient and \texttt{mod} for the remainder.
757
758
\subsubsection{Logical Operators}
759
760
The logical operators are inspired by VDM and written \texttt{and} for logical
761
and, \texttt{or} for logical or, \texttt{not} for negation, \texttt{=>} for
762
implication, and \texttt{<=>} for bi-implication.
763
764
\subsubsection{Comparison Operators}
765
766
For comparing two values of the same type there are \texttt{=} for equality
767
768
and \texttt{<>} for inequality.
769
770
Values of integer and float types can also be compared with \texttt{>} for
771
greater, \texttt{>=} for greater or equal, \texttt{<} for less, and \texttt{<=}
772
for less or equal.
773
774
\subsubsection{List Operators (Head, Tail, Length, Concatenation)}
775
776
The OOAS language provides several basic list operators that make it
777
easy to use lists.
778
779
The first operator is \texttt{hd} which is short for \emph{head}. This
780
operator returns the first element of a list. Therefore if \texttt{my\_list}
781
is a list, then \texttt{hd my\_list} is equivalent to \texttt{my\_list[0]}.
782
783
The counterpart to \emph{head} is \emph{tail}, which returns the list without
784
the first element. In OOAS the operator token is \texttt{tl}. So if you want
785
to remove the first element from a list \texttt{my\_stack} you can write
786
\texttt{my\_stack := tl my\_stack}.
787
788
The next important operation is determining how many elements are currently
789
in a list, which is the so-called \emph{length} of a list. In OOAS this
790
operator is written \texttt{len}. For example if an action should only be
791
enabled if there are less than 10 elements in the list \texttt{my\_stack} you
792
can write \texttt{requires len my\_stack < 10}.
793
794
The last operation is creating a list that contains all the elements of two
795
given lists, which is called \emph{concatenation}. The operator is written
796
\texttt{\^}. If for instance you want to append an element \texttt{a} to
797
a list \texttt{my\_stack}, you can write
798
799
\begin{verbatim}
800
my_stack := [a] ^ my_stack
801
\end{verbatim}
802
803
The example in Figure \ref{Stack} illustrates how these operators can be used
804
to build a stack.
805
806
\begin{figure}[h]
807
 \begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
808
types
809
  SmallInt = int [0..3];
810
  Stack = autocons system
811
  |[
812
  var
813
        my_stack : list [10] of SmallInt = [0]
814
  actions
815
        obs top (a : SmallInt) = requires (a = hd my_stack) :
816
                skip
817
                end ;
818
        obs pop = requires (len my_stack > 0) :
819
                my_stack := tl my_stack
820
                end;
821
        obs push (a : SmallInt) = requires len my_stack < 10 :
822
                my_stack := [a] ^ my_stack
823
                end
824
825
  do
826
        var A : SmallInt : push(A) []  pop() [] var B : SmallInt : top(B)
827
  od
828
  ]|
829
system
830
  Stack
831
\end{lstlisting}
832
\caption{Stack}
833
\label{Stack}
834
\end{figure}
835
836
\subsection{The Dood Block}
837
\label{dood}
838
839
The actual behavior of an action system is defined in the so-called \doodblock.
840
The \doodblock was inspired by Dijkstra's guarded iteration statement. The
841
canonical form of a \doodblock is to list all named actions of the class
842
and connect them using the \texttt{[]} operator. In this case in each iteration
843
an action is available iff its guard evaluates to \texttt{true} and the system
844
terminates iff no action is enabled.
845
846
However, in OOAS actions are neither limited to named actions nor is the
847
non-deterministic choice the only possible operator.
848
849
Instead, all operators described in Section \ref{Composition} are available
850
as well as the built-in action \texttt{skip} and so-called anonymous actions.
851
An anonymous action is a guard followed by assignments, methods or built-in
852
action \texttt{skip}. In literature anonymous actions are often referred to
853
as \emph{guarded commands}.
854
855
If (named) actions are parametrized, enumeration can be used as generalization
856
of the non-deterministic choice over the values of a data type.
857
858
For instance given a data type \texttt{SmallInt = int[0..3]} and a named action
859
\texttt{doSomething ( a : SmallInt )} it is possible to write
860
\begin{verbatim}
861
do
862
	var : A : SmallInt : doSomething(A)
863
od
864
\end{verbatim}
865
866
as abbreviation for
867
\begin{verbatim}
868
do
869
	doSomething(0) [] doSomething(1) [] doSomething(2) [] doSomething(3)
870
od
871
\end{verbatim}
872
873
874
875
\subsection{The System Assembling Block}
876
\label{SAB}
877
878
In the System Assembling Block the system is assembled by its classes. All
879
the classes used by the system are connected either by the non-deterministic
880
choice operator \texttt{[]} or by the prioritized composition operator
881
\texttt{//}. This feature allows the user to manually set the priority among
882
the classes.
883
884
885
\clearpage
886
887
\subsection{Comments}
888
889
The OOAS language supports single line comments. Comments start
890
with a \texttt{\#} symbol.
891
892
\subsection{Formal Syntax}
893
894
The following EBNF grammar defines the syntax of an Object-Oriented action
895
system (OOAS). Features that are not implemented at all are left out. However
896
there are some features that are not completely implemented and do produce
897
code that doesn't work. These features are stroked out.
898
\\
899
900
\begin{longtable}[h]{lll}
901
OOAS &:=& ['\texttt{consts}' ConstList] '\texttt{types}' TypeList '\texttt{system}' ASTypeComp \\
902
ConstList &:=& NamedConst \{ '\texttt{;}' NamedConst \} \\
903
NamedConst &:=& Identifier '=' Exp \\
904
TypeList &:=& NamedType \{ '\texttt{;}' NamedType \} \\
905
NamedType &:=& Identifier '=' ( ComplexType $\vert$ OOActionSystem ) \\
906
ComplexType &:=& ( '\texttt{list}' '\texttt{[}'  ( Num $\vert$ Identifier )  '\texttt{]}'  '\texttt{of}' ComplexType ) \\
907
 & &  $\vert$ ( '\texttt{[}' Identifier \{ '\texttt{,}' Identifier \} '\texttt{]}'  ) \\
908
 & & $\vert$ ( '\texttt{(}' ComplexType \{ '\texttt{,}' ComplexType \}  '\texttt{)}'  ) \\
909
 & & $\vert$ SimpleType \\
910
SimpleType &:=& '\texttt{bool}'\\
911
 & & $\vert$ ( '\texttt{int}' '\texttt{[}' ( Num $\vert$ Identifier ) '\texttt{..}' ( Num $\vert$ Identifier )  '\texttt{]}' )\\
912
 & & $\vert$ ( '\texttt{float}' '\texttt{[}' ( FloatNum $\vert$ Identifier ) '\texttt{..}' ( FloatNum $\vert$ Identifier )  '\texttt{]}' )\\
913
 & & $\vert$ '\texttt{char}' \\
914
 & & $\vert$ '\texttt{\{}' Identifier [ '\texttt{=}' Num] \{ '\texttt{,} Identifier [ '\texttt{=}' Num ] \} '\texttt{\}}' \\
915
 & & $\vert$ Identifier \\
916
OOActionSystem &:=& [ '\texttt{autocons}' ] '\texttt{system}' [ Identifier ] \\
917
 & & '\texttt{|[}'  [ '\texttt{var}' AttrList ] [ '\texttt{methods}' MethodList ] \\
918
& & [ '\texttt{actions}' NamedActionList ] [ '\texttt{do}' [ActionBlock] '\texttt{od}'] '\texttt{]|}' \\
919
AttrList &:=& Attr \{ '\texttt{;}' Attr \} \\
920
Attr &:=& [ '\texttt{static}' ]  [ '\texttt{obs}' $\vert$ '\texttt{ctr}' ] Identifier '\texttt{:}' ComplexType [ '\texttt{=}' Exp ] \\
921
MethodList &:=& Method \{ '\texttt{;}' Method \} \\
922
Method &:=& Identifier [ '\texttt{(}' MethodParamList '\texttt{)}' ] [ '\texttt{:}' ComplexType ] '\texttt{=}' \\
923
 & & [ '\texttt{var}' LocalActionVars '\texttt{begin}' ] ActionBody '\texttt{end}' \\
924
MethodParamList &:=& Identifier '\texttt{:}' ComplexType \{ '\texttt{,}' Identifier '\texttt{:}' ComplexType  \} \\
925
NamedActionList &:=& NamedAction \{ '\texttt{;}' NamedAction \} \\
926
NamedAction &:=& [ '\texttt{obs}' $\vert$ '\texttt{ctr}' ]  Identifier [ '\texttt{(}' MethodParamList '\texttt{)}' ] \\
927
 & &  [ '\texttt{:}' ComplexType ] '\texttt{=}'  [ '\texttt{var}' LocalActionVars ] DiscreteActionBody \\
928
LocalActionVars &:=& Identifier '\texttt{:}' ComplexType \{ '\texttt{;}' Identifier '\texttt{:}' ComplexType\} \\
929
DiscreteActionBody &:=& '\texttt{requires}' Exp '\texttt{:}' ActionBody '\texttt{end}'\\
930
Exp &:=& AtomExpression BinOperator AtomExpression \\
931
AtomExpression &:=& ( [ OpUn ] ( Reference $\vert$ Constant $\vert$ InitComplexType $\vert$ QuantExp\\
932
&& $\vert$ '\texttt{(}' Exp '\texttt{)}' \{ '\texttt{.}' Identifier \} [ AccessExp] ) \\
933
&& [ '\texttt{as}' Identifier ] ) \\
934
& & $\vert$ ( '\texttt{if}' Exp '\texttt{then}' Exp '\texttt{else}' Exp '\texttt{end}' ) \\
935
OpUn &:=& '\texttt{-}'  $\vert$ '\texttt{not}' $\vert$ '\texttt{hd}' $\vert$ '\texttt{tl'} $\vert$ '\texttt{len}'\\
936
Constant &:=& ('\texttt{true}') $\vert$ ('\texttt{false'}) $\vert$ ('\texttt{nil}') $\vert$ ('\texttt{self}') $\vert$ (FloatNum) $\vert$ (Num) $\vert$ \\
937
&& (\cancel{StringLiteral}) \\
938
InitComplexType &:=& InitListType $\vert$ ('\texttt{new}' '\texttt{(}' Identifier [ '\texttt{,}' StringLiteral ] '\texttt{)}') \\
939
InitListType &:=& '\texttt{[}' Exp [ ListComp $\vert$ \{ '\texttt{,} Exp'\} ] '\texttt{]}' \\
940
ListComp &:=& '\texttt{|}' '\texttt{var}' Identifier '\texttt{:}' ComplexType \{ \texttt{;} Identifier ComplexType \} '\texttt{\&}' Exp \\
941
QuantExp &:=& ('\texttt{forall}' $\vert$ '\texttt{exists}') Identifier '\texttt{:}' SimpleType \\
942
&& \{ '\texttt{,}' Identifier '\texttt{:} SimpleType' \}  '\texttt{:}' '\texttt{(}' Exp '\texttt{)}' \\
943
ActionBody &:=& ActionBodyParallel '\texttt{//}' ActionBodyParallel \\
944
ActionBodyParallel &:=& ActionBodySeq '\texttt{[]}' ActionBodySeq \\
945
ActionBodySeq &:=& ActionBodyParen '\texttt{;}' ActionBodyParen \\
946
ActionBodyParen &:=& ( '\texttt{(}' ActionBody '\texttt{)}' ) $\vert$ ( Statement ) \\
947
Statement &:=& ( '\texttt{skip'} ) $\vert$ ( Reference \{ '\texttt{,}' Reference  \} '\texttt{:=}' Exp \{ '\texttt{,}' Exp\} ) \\
948
Reference &:=& QualId [ AccessExp ] [ [ '\texttt{::}' '\texttt{(}' Exp '\texttt{)}' ] '\texttt{:>:}' '\texttt{(}' Exp '\texttt{)}'  ] \\
949
AccessExp &:=& ( ( '\texttt{[}' Exp '\texttt{]}' )  $\vert$ ( '\texttt{(}' MethodCallParam '\texttt{)}') ) \\
950
&& \{( ( '\texttt{[}' Exp '\texttt{]}' )  | ( '\texttt{(}' MethodCallParam '\texttt{)}') ) \} \\
951
&& [ '\texttt{.}' Identifier \{ '\texttt{.}' Identifier\} AccessExp] \\
952
QualId &:=& [ '\texttt{self}' '\texttt{.}' ] Identifier \{ '\texttt{.} Identifier'\} \\
953
MethodCallParam &:=&  [ Exp \{ '\texttt{,}' Exp\}]\\
954
ActionBlock &:=& ActionBlockPar \{ '\texttt{//}' ActionBlockPar\} \\
955
ActionBlockPar &:=& ActionBlockSeq \{ '\texttt{[]}' ActionBlockSeq\} \\
956
ActionBlockSeq &:=& [ '\texttt{var}' BlockVarList [\cancel{'\texttt{\&}' Exp} ] '\texttt{:}' ] \\
957
&&ActionBlockParen  \{ '\texttt{;}' ActionBlockParen\}\\
958
ActionBlockParen &:=& ('\texttt{(}' ActionBlock '\texttt{)}' ) $\vert$ (AnonOrNamedAct)\\
959
AnonOrNamedAct &:=&  DiscreteActionBody $\vert$ '\texttt{skip}' $\vert$ \\
960
&& Identifier [ '\texttt{(}' MethodCallParam '\texttt{)}' ] [ '\texttt{:>:}' '\texttt{(}' Exp '\texttt{)}'  ]  \\
961
BlockVarList &:=& BlockVar \{ '\texttt{;} BlockVar'\} \\
962
BlockVar &:=& Identifier '\texttt{:}' ComplexType \\
963
ASTypeComp &:=& ASTypeCompPar \{ '\texttt{//}' ASTypeCompPar\} \\
964
ASTypeCompPar &:=& ASTypeCompSeq \{ '\texttt{[]}' ASTypeCompSeq\} \\
965
ASTypeCompSeq &:=& ASTypeCompBP \\
966
ASTypeCompBP &:=& ('\texttt{(}' ASTypeComp '\texttt{)}' ) \\
967
BinOperator &:=& ('\texttt{<=>}') $\vert$ ('\texttt{>}')$\vert$ ('\texttt{>=}')$\vert$ ('\texttt{<}')$\vert$ ('\texttt{<=)}')$\vert$ ('\texttt{=}')$\vert$ ('\texttt{<>}')$\vert$ ('\texttt{=>}') $\vert$ ('\texttt{-}')$\vert$ ('\texttt{+}') \\
968
&&$\vert$ ('\texttt{or}')$\vert$ ('\texttt{and}')$\vert$ ('\texttt{/}') $\vert$ ('\texttt{div}') $\vert$ ('\texttt{*}') $\vert$ ('\texttt{mod}') $\vert$ ('\texttt{\^}')\\
969
970
Identifier &:=& Letter \{Letter $\vert$ Digit\}\\
971
Num &:=& ['\texttt{+}' $\vert$ '\texttt{-}'] Digit \{ Digit \} \\
972
FloatNum &:=& ['\texttt{+}' $\vert$ '\texttt{-}'] Digit \{ Digit \} '\texttt{.}' Digit \{Digit\} ['\texttt{e}' $\vert$ '\texttt{E}' ['\texttt{+}' $\vert$ '\texttt{-}' ] Digit \{ Digit \}]\\
973
Letter &:=& '\texttt{\$}' $\vert$ '\texttt{\_}' $\vert$ '\texttt{A}'..'\texttt{Z}' $\vert$ '\texttt{a}'..'\texttt{z}'\\
974
Digit &:=& '\texttt{0}'..'\texttt{9}'\\
975
976
\end{longtable}
977
\clearpage
978
979
\section{Incomplete Features}
980
981
The following features are supported by the grammar, but do not produce
982
executable or useful code.
983
984
\subsection{Sequential Block Expression}
985
986
In the \doodblock when calling an action with a variable it is possible
987
to add an additional guard. However if the guard is true, the produced
988
Prolog-Code will not work.
989
990
Example:
991
\begin{verbatim}
992
do
993
	var A : SmallInt & A < 3 : push(A)
994
od
995
\end{verbatim}
996
997
\subsection{String}
998
999
It is possible to assign a string to a variable of any list type of char.
1000
1001
Example:
1002
\begin{verbatim}
1003
  var
1004
	my_string : list[20] of char = [0]
1005
  actions
1006
	obs fill = requires true :
1007
		my_string := "Hello World!"
1008
		end
1009
\end{verbatim}
1010
1011
However, in the produced Prolog-Code the characters stored in the list are
1012
not of type char, but instead Prolog atoms. This may lead to strange behaviour.
1013
1014
\section{CADP Target}
1015
\subsection{The Argos CADP-Target}
1016
1017
The CADP-Target is an Add-On for Argos. It produces C files for the use
1018
with the CADP toolbox available at \url{http://www.inrialpes.fr/vasy/cadp/}.
1019
It is deployed as dynamic library
1020
with the file name \texttt{ArgosCadpTarget.dll}. If this file is present
1021
an additional Argos option \texttt{-c} is available.
1022
1023
The invocation of Argos to produce C files for CADP is very similar
1024
to the invocation of Argos to produce prolog files for Ulysses. Instead
1025
of using the option \texttt{-p} one has to use the option \texttt{-c} and
1026
the options \texttt{-n} and \texttt{-d} should be omitted as they are
1027
meaningless in this context.
1028
1029
\subsection{Generating BCG}
1030
1031
The generated C file can be used to produce a graph in CADP's proprietary
1032
BCG format. This is done by compiling the file against CADP's tools using
1033
the \texttt{cadp\_cc} compiler.
1034
1035
Given a shell with the environment variables \texttt{\$CADP} set to the
1036
CADP directory and \texttt{\$ARGOS} set to the Argos directory one
1037
can compile an Argos generated C file \texttt{model.c} into an object
1038
file \texttt{model.o} using the following command:
1039
\begin{verbatim}
1040
$CADP/src/com/cadp_cc -g3 -O0 -I. -I$CADP/incl -I$CADP/src/open_caesar \
1041
-I $ARGOS/trunk/src/cadp/cadpruntime/ -c model.c -o model.o
1042
\end{verbatim}
1043
1044
Now the generator from the CADP toolbox can be compiled using the command:
1045
\begin{verbatim}
1046
$CADP/src/com/cadp_cc  -g3 -O0 -I. -I$CADP/incl -I$CADP/src/open_caesar \
1047
-c $CADP/src/open_caesar/generator.c -o generator.o
1048
\end{verbatim}
1049
1050
Finally the two object files can be linked into an executable using the command:
1051
\begin{verbatim}
1052
$CADP/src/com/cadp_cc generator.o model.o -o generator \
1053
-L${BCG:-$CADP}/bin.`$CADP/com/arch` -lcaesar -lBCG_IO -lBCG -lm
1054
\end{verbatim}
1055
1056
\subsection{Animator}
1057
1058
For debugging purposes Argos provides a so-called Animator that enables
1059
one to walk step wise through a model. The models can be either encoded as
1060
graphs in \texttt{aut} files or as dynamic link library compiled from an Argos
1061
generated C file. The compilation can be done using any C compiler that is
1062
capable of generating dynamic link libraries for 32 bit Windows platforms.
1063
1064
However, compiling the model to a dynamic link library can be a little bit
1065
tricky, so a solution file for Microsoft Visual Studio 2008 can be found
1066
in the argos source directory or to be exact in the sub-directory
1067
\texttt{cadp/model}. Unfortunately some paths in this file are absolute,
1068
so they have to be changed to match the paths that are actually used.
1069
1070
This can be done by a right-click on \emph{model} within the
1071
\emph{Solution Explorer}. Now a \emph{model Property Pages} window
1072
pops up, providing an element \emph{Configuration Properties}. This
1073
element can be expanded, and \emph{C/C++} has to be chosen. The first
1074
entry of this page, called \emph{Additional Include Directories} has
1075
to be changed to fit.
1076
1077
\section{Alarm System}
1078
1079
\subsection{Overview}
1080
In this section a model of a Car Alarm System is presented. The purpose is
1081
to show how Object-Oriented Action Systems can be used to model real world
1082
system in contrast to the examples presented so far. The Car Alarm System
1083
has been a demonstrator in the MOGENTES project. The specifications were
1084
provided by Ford. This demonstrator was also used in \cite{Aichernig2010a}.
1085
1086
1087
\subsection{Requirements}
1088
1089
In \cite{Aichernig2010a} the specification was condensed to the following three
1090
requirements:
1091
1092
\textbf{R1: Arming.} The system is armed 20 seconds
1093
after the vehicle is locked and the bonnet, luggage compartment, and
1094
all doors are closed.
1095
1096
\textbf{R2: Alarm.} The alarm sounds for 30 seconds if
1097
an unauthorized person opens the door, the luggage compartment, or the
1098
bonnet. The hazard flasher lights will flash for five minutes.
1099
1100
\textbf{R3: Deactivation.} The CAS
1101
can be deactivated at any time, even when the alarm is sounding, by
1102
unlocking the vehicle from outside.
1103
1104
\subsection{State Chart}
1105
1106
In \cite{Aichernig2010a} a UML transformation tool was used to generate an
1107
Object-Oriented action system. The paper contains a state chart which is cited
1108
in Figure \ref{statechart}. In contrast the action system presented in this
1109
manual was written by hand but it is somehow based on this State Chart
1110
regarding the interpretation of the requirements.
1111
1112
\begin{figure}[h]
1113
 \includegraphics[width=1\linewidth,keepaspectratio]{figures/SM_AlarmSystem}
1114
\caption{State Chart of Car Alarm System}
1115
\label{statechart}
1116
\end{figure}
1117
\clearpage
1118
\subsection{Object-Oriented Action System}
1119
1120
\subsubsection{Interface}
1121
1122
In the context of generating labeled transition systems for \emph{Ulysses}
1123
the interface of an Object-Oriented action system consists of named actions.
1124
According to the ioco theory, labels have to be marked as either input or
1125
output. In Object-Oriented action systems the corresponding keywords are
1126
\texttt{ctr} resp. \texttt{obs}.
1127
1128
Therefore the interface of the Car Alarm System consists of 4 controllable
1129
actions \texttt{Close}, \texttt{Open}, \texttt{Lock} and \texttt{Unlock}.
1130
In the context of the implementation these actions correspond to the input
1131
coming from various sensors. In the context of a generated test case these
1132
actions correspond to outputs to the System Under Test.
1133
1134
Also there are 6 observable actions \texttt{ArmedOn}, \texttt{ArmedOff},
1135
\texttt{SoundOn}, \texttt{SoundOff}, \texttt{FlashOn}, and \texttt{FlashOff}.
1136
In the context of the implementation these action correspond to output that
1137
triggers the resp. signals to the environment.
1138
In the context of the generated test cases these actions correspond to the
1139
expected inputs coming from the System Under Test.
1140
1141
\subsubsection{Time Handling}
1142
1143
One important aspect of modeling such a system is time handling. In former
1144
models within the MOGENTES project passing of time had been modeled by
1145
introducing an observable action \emph{after}. Later in the project this
1146
caused some problems as some test cases were not generated.
1147
1148
To solve these problems the after action in this model is removed. Instead,
1149
elapsed time is now encoded as first parameter of every remaining action.
1150
1151
\subsubsection{Protocol Layer}
1152
1153
In the context of model-ling an embedded system the \doodblock can be thought
1154
as protocol layer. To keep the model simple, the most canonical form of the
1155
\doodblock has been used. That is, all named actions are connected using
1156
the non-deterministic choice. Since the named actions are parametrized,
1157
enumeration is used. Unfortunately the size of the state space grows
1158
exponentially by number of enumerated values, so it is very important
1159
to keep the resp. ranges as small as possible. In the context of this model,
1160
where the meaning of each action's parameter is the elapsed time, this
1161
means that only ``interesting'' time periods are considered. Actually,
1162
``interesting'' events only happen immediately, 20, 30 or 270 seconds
1163
after the previous event. Exactly these values are contained in the
1164
Enum Type \texttt{TimeSteps}.
1165
1166
\subsubsection{Non-determinism}
1167
1168
This model makes use of non-determinism. That means that there are situations
1169
in which the system can choose how it responses to a certain input.
1170
More technically that means, that there sequences of controllable and
1171
observable actions, after which there is more than one observable action.
1172
In the context of using the model to specify a system that means
1173
underspecification. A system can choose among some possible options how to
1174
react.
1175
1176
In this particular model, non-determinism is used so that the implementation
1177
has some freedom with regards to the exact sequence of observable actions.
1178
For example when an intrusion is detected by the alarm system, then three
1179
events happen immediately: The arming is set off, the sound alarm is set
1180
on and the flash alarm is set on. A deterministic system would specify the
1181
exact order, in which these actions must be triggered. In the context of
1182
test case generation this could lead to some false positives, as the
1183
requirements do not specify a fixed order.
1184
1185
\subsubsection{Code}
1186
%\begin{figure}[h]
1187
 \begin{lstlisting}[language=ooa,linewidth=\textwidth,breaklines,basicstyle=\scriptsize]
1188
types
1189
	TimeSteps = {Int0 = 0 , Int20 = 20, Int30 = 30, Int270 = 270} ;
1190
	Int = int[0..270] ;
1191
	SmallInt = int[0..3] ;
1192
	AlarmSystem = autocons system
1193
	|[
1194
		var
1195
			open : bool = true ;
1196
			locked : bool = false ;
1197
			armed : bool = false ;
1198
			soundAlarm : bool = false ;
1199
			flashAlarm : bool = false ;
1200
			blockingLevel : SmallInt = 0 ;
1201
			armedOnNow : bool = false ;
1202
			armedOnLater : bool = false ;
1203
			armedOff : bool = false ;
1204
			soundOn : bool = false ;
1205
			soundOffNow : bool = false ;
1206
			soundOffLater : bool = false ;
1207
			flashOn : bool = false ;
1208
			flashOffNow : bool = false ;
1209
			flashOffLater : bool = false  ;
1210
			silent : bool = false # true after alarms turned off
1211
		actions
1212
			ctr Close ( waittime : Int) =
1213
				requires not flashAlarm and not soundAlarm :
1214
					requires open and waittime = 0 and blockingLevel = 0 and locked and silent:
1215
						open := false ;
1216
						blockingLevel := 1 ;
1217
						armedOnNow := true ;
1218
						silent := false
1219
					end []
1220
					requires open and waittime = 0 and blockingLevel = 0 and not locked and silent:
1221
						silent := false ;
1222
						open := false
1223
					end []
1224
					requires open and waittime = 0 and blockingLevel = 0 and locked and not silent:
1225
						open := false ;
1226
						blockingLevel := 1 ;
1227
						armedOnLater := true
1228
					end []
1229
					requires open and waittime = 0 and blockingLevel = 0 and not locked and not silent:
1230
						open := false
1231
					end
1232
				end ;
1233
			ctr Open ( waittime : Int) =
1234
				requires true :
1235
					requires not open and waittime = 0 and blockingLevel = 0 and not armed :
1236
						open := true
1237
					end []
1238
					requires not open and waittime = 0 and blockingLevel = 0 and armed :
1239
						open := true ;
1240
						armed := false ;
1241
						blockingLevel := 3 ;
1242
						armedOff := true ;
1243
						soundOn := true ;
1244
						flashOn := true
1245
					end
1246
				end ;
1247
			ctr Unlock ( waittime : Int) =
1248
				requires true :
1249
					requires locked and waittime = 0 and blockingLevel = 0 and not flashAlarm and soundAlarm:
1250
						locked := false ;
1251
						silent := false ;
1252
						soundOffLater := false ;
1253
						soundOffNow := true ;
1254
						blockingLevel := 1
1255
					end []
1256
					requires locked and waittime = 0 and blockingLevel = 0 and flashAlarm and soundAlarm :
1257
						locked := false ;
1258
						flashOffNow := true ;
1259
						blockingLevel := 2 ;
1260
						silent := false ;
1261
						soundOffLater := false ;
1262
						soundOffNow := true
1263
					end []
1264
					requires locked and waittime = 0 and blockingLevel = 0 and not flashAlarm and not soundAlarm:
1265
						locked := false ;
1266
						silent := false ;
1267
						armedOff := true ;
1268
						blockingLevel := 1
1269
					end []
1270
					requires locked and waittime = 0 and blockingLevel = 0 and flashAlarm and not soundAlarm:
1271
						locked := false ;
1272
						flashOffNow := true ;
1273
						flashOffLater := false ;
1274
						blockingLevel := 1 ;
1275
						silent := false
1276
					end
1277
				end;
1278
			ctr Lock ( waittime : Int) =
1279
				requires true :
1280
					requires not locked and waittime = 0 and blockingLevel = 0 and open :
1281
						locked := true
1282
					end []
1283
					requires not locked and waittime = 0 and blockingLevel = 0 and not open :
1284
						locked := true ;
1285
						blockingLevel := 1 ;
1286
						armedOnLater := true
1287
					end
1288
				end ;
1289
			obs ArmedOn (waittime : Int) =
1290
				requires (armedOnNow or armedOnLater):
1291
					requires (waittime = 20 and armedOnLater) :
1292
						armedOnLater := false ;
1293
						blockingLevel := blockingLevel - 1 ;
1294
						armed := true
1295
					end
1296
					[] requires (waittime = 0 and armedOnNow) :
1297
						armedOnNow := false ;
1298
						blockingLevel := blockingLevel - 1 ;
1299
						armed := true
1300
					end
1301
				end ;
1302
			obs ArmedOff (waittime : Int) =
1303
				requires (waittime = 0 and armedOff) :
1304
					armedOff := false ;
1305
					blockingLevel := blockingLevel - 1 ;
1306
					armed := false
1307
				end ;
1308
			obs SoundOn (waittime : Int) =
1309
				requires true :
1310
					requires (waittime = 0 and soundOn and blockingLevel = 1) :
1311
						soundOn := false ;
1312
						blockingLevel := blockingLevel - 1 ;
1313
						soundAlarm := true ;
1314
						soundOffLater := true
1315
					end []
1316
					requires (waittime = 0 and soundOn and blockingLevel <> 1) :
1317
						soundOn := false ;
1318
						blockingLevel := blockingLevel - 1 ;
1319
						soundAlarm := true
1320
					end
1321
				end ;
1322
			obs SoundOff (waittime : Int) =
1323
				requires (soundOffNow or soundOffLater) :
1324
					requires (waittime = 30 and soundOffLater) :
1325
						soundOffLater := false ;
1326
						flashOffLater := true ;
1327
						soundAlarm := false
1328
					end
1329
					[] requires (waittime = 0 and soundOffNow) :
1330
						soundOffNow := false ;
1331
						blockingLevel := blockingLevel - 1 ;
1332
						soundAlarm := false
1333
					end
1334
				end ;
1335
			obs FlashOn (waittime : Int) =
1336
				requires true :
1337
					requires (waittime = 0 and flashOn and blockingLevel = 1) :
1338
						flashOn := false ;
1339
						blockingLevel := blockingLevel - 1 ;
1340
						flashAlarm := true ;
1341
						soundOffLater := true
1342
					end []
1343
					requires (waittime = 0 and flashOn and blockingLevel <> 1) :
1344
						flashOn := false ;
1345
						blockingLevel := blockingLevel - 1 ;
1346
						flashAlarm := true
1347
				end
1348
				end ;
1349
			obs FlashOff (waittime : Int) =
1350
				requires (flashOffNow or flashOffLater) :
1351
					requires (waittime = 270 and flashOffLater) :
1352
						flashOffLater := false ;
1353
						flashAlarm := false ;
1354
						silent := true
1355
					end
1356
					[] requires (waittime = 0 and flashOffNow) :
1357
						flashOffNow := false ;
1358
						blockingLevel := blockingLevel - 1 ;
1359
						flashAlarm := false
1360
					end
1361
				end
1362
	do
1363
		var A : TimeSteps : Close (A) []
1364
		var B : TimeSteps : Open (B) []
1365
		var C : TimeSteps : Lock (C) []
1366
		var D : TimeSteps : Unlock (D) []
1367
		var E : TimeSteps : ArmedOn (E) []
1368
		var F : TimeSteps : ArmedOff (F) []
1369
		var G : TimeSteps : SoundOn (G) []
1370
		var H : TimeSteps : SoundOff (H) []
1371
		var I : TimeSteps : FlashOn (I) []
1372
		var J : TimeSteps : FlashOff (J)
1373
	od
1374
	]|
1375
system
1376
	AlarmSystem
1377
\end{lstlisting}
1378
%\caption{Car Alarm System in OOAS}
1379
%\label{Stack}
1380
%\end{figure}
1381
1382
\subsection{Labeled Transition System}
1383
1384
In Figure \ref{lts} you can find a graphical representation
1385
of labeled transition system that corresponds to the Object-Oriented
1386
action system. It is a ioco product graph produced by \emph{Ulysses}.
1387
So there is an additional observable action \emph{delta} that denotes
1388
quiescence. Iff in a given state the system has no specified output,
1389
there is a self loop labeled with \emph{delta}.
1390
1391
\begin{figure}[h]
1392
 \includegraphics[angle=90,width=0.42\linewidth,keepaspectratio]{figures/out}
1393
\caption{Labeled Transition System}
1394
\label{lts}
1395
\end{figure}
1396
1397
\section*{Acknowledgements}
1398
%Research herein was
1399
Funded by the European Artemis Joint Undertaking project
1400
MBAT, Combined Model-based Analysis and Testing of Embedded Systems %.
1401
%ART Call 2010: 269335.
1402
and by the Austrian Research Promotion Agency
1403
(FFG), program line ``Trust in IT Systems'', project number 829583, TRUst via Failed FALsification of Complex
1404
Dependable Systems Using Automated Test Case Generation through Model
1405
Mutation (TRUFAL).
1406
1407
\clearpage
1408
1409
1410
\bibliographystyle{plain}
1411
\bibliography{papers}
1412
1413
1414
\end{document}