source: CIVL/doc/tutorial/tutorial.tex@ 396a765

1.23 2.0 main test-branch
Last change on this file since 396a765 was 4be7b5b, checked in by Stephen Siegel <siegel@…>, 13 years ago

Slight changes to tutorial instructions. Deleted tutorial.pdf, which I accidentally checked in!

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@311 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 17.8 KB
Line 
1\documentclass[t]{beamer}
2\input{preambular}
3\foot{CIVL Tutorial}
4\date{\today}
5\title{{\huge\bf CIVL}\\
6 Concurrency Intermediate Verification Language\\ \ \\
7 Tutorial}
8
9\begin{document}
10
11\begin{frame}[plain]
12 \titlepage
13\end{frame}
14
15\begin{frame}{What is CIVL?}
16 CIVL is \ldots
17 \begin{enumerate}
18 \item \ldots a programming language, \alert{CIVL-C}
19 \begin{itemize}
20 \item based on subset of C
21 \item extensions for concurrency, naming of scopes
22 \end{itemize}
23 \item \ldots a suite of tools for analyzing CIVL-C programs
24 \begin{itemize}
25 \item running + dynamic checking
26 \item model checking
27 \item static analyses (coming)
28 \end{itemize}
29 \item \ldots a set of translators from common programming
30 language/concurrency API combinations to CIVL-C
31 \begin{itemize}
32 \item coming
33 \end{itemize}
34 \end{enumerate}
35\end{frame}
36
37\begin{frame}[containsverbatim]{Example: \code{adder.cvl}}
38
39 \begin{tabular}[t]{l|l}
40 \begin{minipage}[t]{.45\textwidth}\scriptsize
41\begin{verbatim}
42#include <civlc.h>
43
44$input int B;
45$input int N;
46$assume 0<=N && N<=B;
47$input double a[N];
48
49double adderSeq(double *p, int n) {
50 double s = 0.0;
51
52 for (int i = 0; i < n; i++)
53 s += p[i];
54 return s;
55}
56
57double adderPar(double *p, int n) {
58 double s = 0.0;
59 _Bool mutex = 0;
60 $proc workers[n];
61
62 void worker(int i) {
63 double t;
64\end{verbatim}
65 \end{minipage}
66 &
67 \begin{minipage}[t]{.45\textwidth}\scriptsize
68\begin{verbatim}
69 $when (mutex == 0) mutex = 1;
70 t = s;
71 t += p[i];
72 s = t;
73 mutex = 0;
74 }
75
76 for (int j = 0; j < n; j++)
77 workers[j] = $spawn worker(j);
78 for (int j = 0; j < n; j++)
79 $wait workers[j];
80 return s;
81}
82
83void main() {
84 double seq = adderSeq(&a[0], N);
85 double par = adderPar(&a[0], N);
86
87 $assert seq == par;
88}
89\end{verbatim}
90 \end{minipage}
91 \end{tabular}
92\end{frame}
93
94\begin{frame}[containsverbatim]{Verifying \code{adder.cvl}}
95
96\begin{verbatim}
97concurrency$ civl verify -inputB=5 adder.cvl
98CIVL v0.4 of 2013-12-06 -- http://vsl.cis.udel.edu/civl
99=================== Stats ===================
100 validCalls : 23883
101 proverCalls : 29
102 memory (bytes) : 374341632
103 time (s) : 5.35
104 maxProcs : 6
105 statesInstantiated : 28761
106 statesSaved : 3082
107 statesSeen : 3082
108 statesMatched : 1968
109 transitions : 5049
110
111The standard properties hold for all executions.
112concurrency$
113\end{verbatim}
114\end{frame}
115
116\begin{frame}{Download and Installation}
117 \begin{enumerate}
118 \item Get a Java 7 VM.
119 \item Go to \url{http://vsl.cis.udel.edu/civl}
120 \item Navigate to downloads, \emph{latest stable release}.
121 \item Download version corresponding to your platform.
122 \begin{itemize}
123 \item for now, pre-compiled versions for OS X and linux (32- and 64-bit)
124 \item other platforms must build from source
125 \end{itemize}
126 \item Unpack and move resulting directory \texttt{CIVL-\textit{tag}}
127 under \texttt{/opt}.
128 \item Download the VSL dependencies archive.
129 \begin{itemize}
130 \item contains a number of pre-compiled open source libraries used by CIVL
131 \item \url{http://vsl.cis.udel.edu/tools/vsl\_depend}
132 \end{itemize}
133 \item Unpack and move resulting directory \texttt{vsl} under \texttt{/opt}.
134 \item Put \texttt{/opt/CIVL-\textit{tag}/bin/civl} in your path.
135 \begin{itemize}
136 \item however you want: move it, symlink, \ldots
137 \end{itemize}
138 \end{enumerate}
139
140 \alert{Note:} You can put \texttt{vsl} and \texttt{CIVL-\textit{tag}}
141 in any directories (not just \texttt{/opt}). Just edit script \texttt{civl}
142 to use the new paths.
143\end{frame}
144
145\begin{frame}[containsverbatim]{Test your installation}
146
147 From command line \ldots
148
149\begin{verbatim}
150concurrency$ civl
151CIVL v0.4 of 2013-12-06 -- http://vsl.cis.udel.edu/civl
152Missing command
153Type "civl help" for command line syntax.
154
155concurrency$ civl help
156...
157\end{verbatim}
158
159Copy \texttt{/opt/CIVL-\textit{tag}/examples/concurrency/adder.cvl}
160to your working directory and try
161
162\begin{verbatim}
163 civl verify -inputB=5 adder.cvl
164\end{verbatim}
165\end{frame}
166
167\begin{frame}{What features are inherited from C?}
168 \begin{itemize}
169 \item most syntax
170 \item types
171 \begin{itemize}
172 \item \texttt{{\U}Bool} $\ra$ $\{0,1\}$
173 \item \texttt{int}, \texttt{long}, \texttt{short}, \ldots $\ra$ $\Z$
174 \item \texttt{double}, \texttt{float}, \ldots $\ra$ $\R$
175 \item structure, array, pointer, and function types
176 \end{itemize}
177 \item expressions
178 \begin{itemize}
179 \item addition, multiplication, division, subtraction, unary minus (\code{+},
180 \code{*}, \code{/}, \code{-})
181 \item integer division (\code{/}) and modulus (\code{\%})
182 \item pointer dereference (\code{*}), address-of (\code{\&})
183 \item array subscript (\code{[...]})
184 \item structure navigation (\code{.})
185 \item logical and (\code{\&\&}), or (\code{||}), not (\code{!})
186 \item \code{==}, \code{!=}, \code{<}, \code{>}, \code{<=}, \code{>=}
187 \item pointer addition (\code{+}) and subtraction (\code{-})
188 \item \code{++}, \code{--}
189 \item \alert{no bit-wise operations} for now
190 \end{itemize}
191 \end{itemize}
192\end{frame}
193
194\begin{frame}{Inherited from C, cont.}
195 \begin{itemize}
196 \item statements
197 \begin{itemize}
198 \item no-op, labeled-statement, compound-statement
199 \item assignments (\code{=}, \code{+=}, \code{-=}, \ldots)
200 \item function call
201 \item \code{if}\ldots\code{else}
202 \item \code{goto}, \code{while}, \code{do}, \code{for},
203 \code{switch}, \code{break}
204 \end{itemize}
205 \item procedure (function) prototypes and definitions
206 \item \code{typedef}
207 \item preprocessing directives
208 \end{itemize}
209\end{frame}
210
211\begin{frame}{New features}
212 \begin{itemize}
213 \item functions can be declared in any scope
214 \item concurrency primitives
215 \begin{itemize}
216 \item spawning processes: \code{\cproc\ p = \cspawn\ f();}
217 \item waiting for a process to terminate: \code{\cwait\ p;}
218 \item guarded commands: \code{\cwhen (x>0) c=1;}
219 \end{itemize}
220 \item nondeterministic choice: \code{\cchoose ...}
221 \item explicit naming of scopes: \code{\cscope\ s;}
222 \item scope-parameterized pointers \code{double *<s> p;}
223 \item other primitives useful for verification
224 \begin{itemize}
225 \item input qualifier, assert, assume, procedure contracts
226 \end{itemize}
227 \item library-level constructs supporting message-passing, \ldots
228 \end{itemize}
229\end{frame}
230
231\begin{frame}{Some CIVL-C primtives}
232 \begin{tabular}{ll}
233 \cproc & the process type \\
234 \cself & the evaluating process (constant of type \cproc) \\
235 \cscope & the scope type \\
236 \cinput & type qualifier declaring variable to be a program input \\
237 \coutput & type qualifier declaring variable to be a program output \\
238 \cspawn & create a new process running procedure \\
239 \cwait & wait for a process to terminate \\
240 \cassert & check something holds \\
241 \ctrue & boolean value true, used in assertions \\
242 \cfalse & boolean value false, used in assertions \\
243 \cassume & assume something holds \\
244 \cwhen & guarded statement \\
245 \cchoose & nondeterministic choice statement \\
246 \cchooseint & nondeterministic choice of integer
247 \end{tabular}
248\end{frame}
249
250\begin{frame}{CIVL Command line tools}
251 \begin{itemize}
252 \item \code{civl run filename}
253 \begin{itemize}
254 \item run the CIVL program making nondeterministic choices randomly
255 \item \code{-seed=LONG} : use this random seed (reproducible)
256 \end{itemize}
257 \item \code{civl verify filename}
258 \begin{itemize}
259 \item explore reachable state space, checking properties at each state
260 \begin{itemize}
261 \item absence of deadlock, assertion violations, division by $0$,
262 invalid pointer dereference, out of bounds array access, \ldots
263 \end{itemize}
264 \item may specify bounds using \cinput{} variables and command line
265 \begin{itemize}
266 \item \code{-inputX=value}
267 \end{itemize}
268 \item \code{-errorBound=INT} specifies maximum number of errors that
269 will be logged before quitting
270 \end{itemize}
271 \item \code{civl replay}
272 \begin{itemize}
273 \item if a violation was found during \code{verify}, its trace
274 is saved to a file; this will run the trace
275 \item \code{-id=INT} can be used to specify the ID of the trace if more than one
276 \item \code{-trace=tracefile} can be used to specify the exact filename
277 containing trace
278 \end{itemize}
279 \end{itemize}
280\end{frame}
281
282\begin{frame}{Scope-parameterized pointers}
283 \begin{itemize}
284 \item a declaration of the form \code{\cscope\ s;} assigns the name
285 \code{s} to the containing scope
286 \begin{itemize}
287 \item what you can do with \code{s} is very limited
288 \item cannot be assigned, passed as parameter
289 \end{itemize}
290 \item \code{int *<s> p;}
291 \begin{itemize}
292 \item declares \code{p} to have type ``pointer-to-\code{int}-in-\code{s}''
293 \item \code{p} can only hold a pointer to an object in scope \code{s}
294 \end{itemize}
295 \end{itemize}
296\end{frame}
297
298
299% static type checking
300
301% subtype
302
303% semantics ?
304
305% scope-parameterized functions
306
307% APIs for malloc, free, memcpy
308
309% bundles
310
311% message passing
312
313\begin{frame}[containsverbatim]{Message Passing example: \code{ring.cvl}}
314
315\begin{verbatim}
316/* Create nprocs processes. Have them exchange data
317 * in a cycle. Commandline example:
318 * civl verify -inputNPROCS=3 ring.cvl -simplify=false
319 */
320#include<civlc.h>
321#include "mp_root.cvh"
322
323void MPI_Process (int rank) {
324#include "mp_proc.cvh"
325
326 double x=rank, y;
327
328 send(&x, 1, (rank+1)%NPROCS, 0);
329 recv(&y, 1, (rank+NPROCS-1)%NPROCS, 0);
330 $assert y==(rank+NPROCS-1)%NPROCS;
331}
332\end{verbatim}
333\end{frame}
334
335\begin{frame}[containsverbatim]{File \code{mp{\U}root.cvh}}
336 \scriptsize
337\begin{verbatim}
338$input int NPROCS;
339$proc __procs[NPROCS];
340_Bool __start = 0;
341$comm MPI_COMM_WORLD;
342
343void MPI_Process (int rank);
344
345void init() {
346 for (int i=0; i<NPROCS; i++)
347 __procs[i] = $spawn MPI_Process(i);
348 MPI_COMM_WORLD = $comm_create(NPROCS, __procs);
349 __start=1;
350}
351
352void finalize() {
353 for (int i=0; i<NPROCS; i++)
354 $wait __procs[i];
355}
356
357void main() {
358 init();
359 finalize();
360}
361\end{verbatim}
362\end{frame}
363
364\begin{frame}[containsverbatim]{File \code{mp{\U}proc.cvh}}
365 \scriptsize
366\begin{verbatim}
367 void send(void *buf, int count, int dest, int tag) {
368 $message out = $message_pack(rank, dest, tag, buf, count*sizeof(double));
369 $comm_enqueue(&MPI_COMM_WORLD, out);
370 }
371
372 void recv(void *buf, int count, int source, int tag) {
373 $message in = $comm_dequeue(&MPI_COMM_WORLD, source, rank, tag);
374 $message_unpack(in, buf, count*sizeof(double));
375 }
376
377 $when (__start);
378\end{verbatim}
379\end{frame}
380
381\begin{frame}{VSL Projects: Uses Relation}
382
383 \includegraphics{vsl_projects}
384
385 \begin{itemize}
386 \item reusable components
387 \begin{itemize}
388 \item ABC: A Better C compiler? ANTLR-Based C compiler?
389 \item SARL: Symbolic Algebra \& Reasoning Library
390 \item GMC: Generic Model Checking utilities
391 \begin{itemize}
392 \item DFS, command line interface, trace saving/replay, error
393 logging, random simulation
394 \end{itemize}
395 \end{itemize}
396 \item model checking applications
397 \begin{itemize}
398 \item CIVL: Concurrency Intermediate Verification Language
399 \item TASS: Toolkit for Accurate Scientific Software (C+MPI)
400 \item CVT: Chapel Verification Tool
401 \end{itemize}
402 \end{itemize}
403
404\end{frame}
405
406\begin{frame}{Engineering}
407
408 \begin{itemize}
409 \item all of the VSL software is in Java
410 \item try to maintain coding standards
411 \item clear module boundaries with interfaces
412 \end{itemize}
413
414
415 \begin{center}
416 \begin{tabular}{|ll|}
417 \hline
418 Web page & \url{http://vsl.cis.udel.edu/civl}\\
419 Subversion & \url{svn://vsl.cis.udel.edu/civl}\\
420 Trac repository & \url{https://vsl.cis.udel.edu/trac/civl}\\
421 Automated build/test & \url{http://vsl.cis.udel.edu/civl/test}\\
422 \hline
423 \end{tabular}
424 \end{center}
425
426 \begin{itemize}
427 \item replace \texttt{civl} with \texttt{sarl}, \texttt{abc}, \texttt{gmc}, or
428 \texttt{tass}
429 \end{itemize}
430
431 \includegraphics[scale=.3]{civl-trac.pdf}
432
433\end{frame}
434
435\begin{frame}{Automated Build \& Test Script}
436
437 \begin{center}
438 \includegraphics[scale=.3]{sarl-junit.pdf}
439 \end{center}
440
441 For each project \ldots
442 \begin{itemize}
443 \item script is run after each commit
444 \item one directory for each \alert{branch} and \alert{trunk}
445 \begin{itemize}
446 \item one subdirectory for each revision, up to some bounded history
447 \end{itemize}
448 \item compiles all code and displays results
449 \item runs JUnit test suite and displays results
450 \item runs Jacoco coverage anaysis and displays results
451 \item generates javadocs
452 \end{itemize}
453\end{frame}
454
455\begin{frame}{Developer Eclipse Set-up}
456 \begin{enumerate}
457 \item Download vsl dependencies archive from
458 \url{http://vsl.cis.udel.edu/tools/vsl_depend}
459 \item Download and install Eclipse IDE for Java EE Developers
460 \begin{itemize}
461 \item version Kepler or later
462 \end{itemize}
463 \item Install Apache Ant if you don't have it
464 \item Install an Eclipse SVN plugin (such as Subversive)
465 \item Create class path variable \texttt{VSL}:
466 \begin{itemize}
467 \item Preferences$\ra$Java$\ra$Build Path$\ra$ClassPath Variables
468 \item select ``New'' and create a classpath variable \texttt{VSL}
469 \item specify its value to be \texttt{/opt/vsl}
470 \end{itemize}
471 \item Create string variable \texttt{vsl{\U}lib}:
472 \begin{itemize}
473 \item Preferences$\ra$Run/Debug$\ra$String Substitution$\ra$New
474 \item define an entry \texttt{vsl{\U}lib}
475 \item set its value to be \texttt{/opt/vsl/lib}
476 \end{itemize}
477 \end{enumerate}
478\end{frame}
479
480\begin{frame}{Check out and install ABC}
481 \begin{enumerate}
482 \item Check out ABC Eclipse project
483 \begin{itemize}
484 \item ``New Project\ldots from SVN''
485 \item SVN repository: \url{svn://vsl.cis.udel.edu/abc}
486 \item Navigate and select \texttt{trunk} from within archive
487 \item Check out project using all default options
488 \end{itemize}
489 \item Build using Ant
490 \begin{itemize}
491 \item right-click on \texttt{build.xml}
492 \item Choose ``Run as Ant build''
493 \item Clean project
494 \end{itemize}
495 \item test the build
496 \begin{itemize}
497 \item select Run$\ra$Run Configurations\ldots
498 \item ceate a new JUnit 4 configuration called ``ABC Tests''
499 \item select ``Run all tests in the selected project\ldots''
500 \item navigate and select the \texttt{test} folder in the ABC project
501 \item under the Arguments tab, type \texttt{-ea} into the VM arguments field
502 \item click ``Run'' to run the tests
503 \end{itemize}
504 \end{enumerate}
505\end{frame}
506
507\begin{frame}{Check out and install GMC}
508 \begin{enumerate}
509 \item Check out GMC Eclipse project
510 \begin{itemize}
511 \item ``New Project\ldots from SVN''
512 \item SVN repository: \url{svn://vsl.cis.udel.edu/gmc}
513 \item Navigate and select \texttt{trunk} from within archive
514 \item Check out project using all default options
515 \end{itemize}
516 \item test the build
517 \begin{itemize}
518 \item select Run$\ra$Run Configurations\ldots
519 \item ceate a new JUnit 4 configuration called ``GMC Tests''
520 \item select ``Run all tests in the selected project\ldots''
521 \item navigate and select the \texttt{test} folder in the GMC project
522 \item under the Arguments tab, type \texttt{-ea} into the VM arguments field
523 \item click ``Run'' to run the tests
524 \end{itemize}
525 \end{enumerate}
526\end{frame}
527
528\begin{frame}{Check out and install SARL}
529 \begin{enumerate}
530 \item Check out SARL Eclipse project
531 \begin{itemize}
532 \item ``New Project\ldots from SVN''
533 \item SVN repository: \url{svn://vsl.cis.udel.edu/sarl}
534 \item Navigate and select \texttt{trunk} from within archive
535 \item Check out project using all default options
536 \end{itemize}
537 \item test the build
538 \begin{itemize}
539 \item select Run$\ra$Run Configurations\ldots
540 \item ceate a new JUnit 4 configuration called ``SARL Tests''
541 \item select ``Run all tests in the selected project\ldots''
542 \item navigate and select the \texttt{test} folder in the SARL project
543 \item under Arguments tab, type \texttt{-ea} into the VM arguments field
544 \item under Environment tab, create an entry
545 \texttt{DYLD{\U}LIBRARY{\U}PATH} (OS X) or
546 \texttt{LD{\U}LIBRARY{\U}PATH} (linux), specify its value by
547 clicking Variables, choose \texttt{vsl{\U}lib} from the list
548 \item click ``Run'' to run the tests
549 \end{itemize}
550 \end{enumerate}
551\end{frame}
552
553\begin{frame}{Check out and install CIVL}
554 \begin{enumerate}
555 \item Check out CIVL Eclipse project
556 \begin{itemize}
557 \item ``New Project\ldots from SVN''
558 \item SVN repository: \url{svn://vsl.cis.udel.edu/civl}
559 \item Navigate and select \texttt{trunk} from within archive
560 \item Check out project using all default options
561 \end{itemize}
562 \item test the build
563 \begin{itemize}
564 \item select Run$\ra$Run Configurations\ldots
565 \item ceate a new JUnit 4 configuration called ``CIVL Tests''
566 \item select ``Run all tests in the selected project\ldots''
567 \item navigate and select the \texttt{test} folder in the CIVL project
568 \item under Arguments tab, type \texttt{-ea} into the VM arguments field
569 \item under Environment tab, create an entry
570 \texttt{DYLD{\U}LIBRARY{\U}PATH} (OS X) or
571 \texttt{LD{\U}LIBRARY{\U}PATH} (linux), specify its value by
572 clicking Variables, choose \texttt{vsl{\U}lib} from the list
573 \item click ``Run'' to run the tests
574 \end{itemize}
575 \item \alert{optional:} configure to build and run with \texttt{ant}
576 \begin{itemize}
577 \item create file \texttt{build.properties} in root CIVL directory
578 \item base on examples in \texttt{properties} directory
579 \item from command line, type \texttt{ant test}
580 \end{itemize}
581 \end{enumerate}
582\end{frame}
583
584\begin{frame}{CIVL modules}
585 \begin{tabular}{@{}ll@{}}
586 \includegraphics[scale=0.55]{civlModules}
587 &
588 \includegraphics[scale=.3]{civlEclipseModules}
589 \end{tabular}
590\end{frame}
591
592\end{document}
Note: See TracBrowser for help on using the repository browser.