source: CIVL/doc/tutorial/tutorial.tex@ 0c65483

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

Working on tutorial, small changes to comments

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

  • Property mode set to 100644
File size: 17.2 KB
RevLine 
[0c65483]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\end{frame}
140
141\begin{frame}[containsverbatim]{Test your installation}
142
143 From command line \ldots
144
145\begin{verbatim}
146concurrency$ civl
147CIVL v0.4 of 2013-12-06 -- http://vsl.cis.udel.edu/civl
148Missing command
149Type "civl help" for command line syntax.
150
151concurrency$ civl help
152...
153\end{verbatim}
154
155Copy \texttt{/opt/CIVL-\textit{tag}/examples/concurrency/adder.cvl}
156to your working directory and try
157
158\begin{verbatim}
159 civl verify -inputB=5 adder.cvl
160\end{verbatim}
161\end{frame}
162
163\begin{frame}{What features are inherited from C?}
164 \begin{itemize}
165 \item most syntax
166 \item types
167 \begin{itemize}
168 \item \texttt{{\U}Bool} $\ra$ $\{0,1\}$
169 \item \texttt{int}, \texttt{long}, \texttt{short}, \ldots $\ra$ $\Z$
170 \item \texttt{double}, \texttt{float}, \ldots $\ra$ $\R$
171 \item structure, array, pointer, and function types
172 \end{itemize}
173 \item expressions
174 \begin{itemize}
175 \item addition, multiplication, division, subtraction, unary minus (\code{+},
176 \code{*}, \code{/}, \code{-})
177 \item integer division (\code{/}) and modulus (\code{\%})
178 \item pointer dereference (\code{*}), address-of (\code{\&})
179 \item array subscript (\code{[...]})
180 \item structure navigation (\code{.})
181 \item logical and (\code{\&\&}), or (\code{||}), not (\code{!})
182 \item \code{==}, \code{!=}, \code{<}, \code{>}, \code{<=}, \code{>=}
183 \item pointer addition (\code{+}) and subtraction (\code{-})
184 \item \code{++}, \code{--}
185 \item \alert{no bit-wise operations} for now
186 \end{itemize}
187 \end{itemize}
188\end{frame}
189
190\begin{frame}{Inherited from C, cont.}
191 \begin{itemize}
192 \item statements
193 \begin{itemize}
194 \item no-op, labeled-statement, compound-statement
195 \item assignments (\code{=}, \code{+=}, \code{-=}, \ldots)
196 \item function call
197 \item \code{if}\ldots\code{else}
198 \item \code{goto}, \code{while}, \code{do}, \code{for},
199 \code{switch}, \code{break}
200 \end{itemize}
201 \item procedure (function) prototypes and definitions
202 \item \code{typedef}
203 \item preprocessing directives
204 \end{itemize}
205\end{frame}
206
207\begin{frame}{New features}
208 \begin{itemize}
209 \item functions can be declared in any scope
210 \item concurrency primitives
211 \begin{itemize}
212 \item spawning processes, waiting for a process to terminate, guarded commands
213 \item nondeterministic choice
214 \item explicit naming of scopes
215 \item scope-parameterized pointers
216 \item other primitives useful for verification
217 \begin{itemize}
218 \item input qualifier, assert, assume, procedure contracts
219 \end{itemize}
220 \end{itemize}
221 \item library-level constructs supporting message-passing, \ldots
222 \end{itemize}
223\end{frame}
224
225\begin{frame}{Some CIVL-C primtives}
226 \begin{tabular}{ll}
227 \cproc & the process type \\
228 \cself & the evaluating process (constant of type \cproc) \\
229 \cscope & the scope type \\
230 \cinput & type qualifier declaring variable to be a program input \\
231 \coutput & type qualifier declaring variable to be a program output \\
232 \cspawn & create a new process running procedure \\
233 \cwait & wait for a process to terminate \\
234 \cassert & check something holds \\
235 \ctrue & boolean value true, used in assertions \\
236 \cfalse & boolean value false, used in assertions \\
237 \cassume & assume something holds \\
238 \cwhen & guarded statement \\
239 \cchoose & nondeterministic choice statement \\
240 \cchooseint & nondeterministic choice of integer
241 \end{tabular}
242\end{frame}
243
244\begin{frame}{CIVL Command line tools}
245 \begin{itemize}
246 \item \code{civl run filename}
247 \begin{itemize}
248 \item run the CIVL program making nondeterministic choices randomly
249 \item \code{-seed=LONG} : use this random seed (reproducible)
250 \end{itemize}
251 \item \code{civl verify filename}
252 \begin{itemize}
253 \item explore reachable state space, checking properties at each state
254 \begin{itemize}
255 \item absence of deadlock, assertion violations, division by $0$,
256 invalid pointer dereference, out of bounds array access, \ldots
257 \end{itemize}
258 \item may specify bounds using \cinput{} variables and command line
259 \begin{itemize}
260 \item \code{-inputX=value}
261 \end{itemize}
262 \item \code{-errorBound=INT} specifies maximum number of errors that
263 will be logged before quitting
264 \end{itemize}
265 \item \code{civl replay}
266 \begin{itemize}
267 \item if a violation was found during \code{verify}, its trace
268 is saved to a file; this will run the trace
269 \item \code{-id=INT} can be used to specify the ID of the trace if more than one
270 \item \code{-trace=tracefile} can be used to specify the exact filename
271 containing trace
272 \end{itemize}
273 \end{itemize}
274\end{frame}
275
276\begin{frame}{Scope-parameterized pointers}
277 \begin{itemize}
278 \item a declaration of the form \code{\cscope\ s;} assigns the name
279 \code{s} to the containing scope
280 \begin{itemize}
281 \item what you can do with \code{s} is very limited
282 \item cannot be assigned, passed as parameter
283 \end{itemize}
284 \item \code{int *<s> p;}
285 \begin{itemize}
286 \item declares \code{p} to have type ``pointer-to-\code{int}-in-\code{s}''
287 \item \code{p} can only hold a pointer to an object in scope \code{s}
288 \end{itemize}
289 \end{itemize}
290\end{frame}
291
292
293% static type checking
294
295% subtype
296
297% semantics ?
298
299% scope-parameterized functions
300
301% APIs for malloc, free, memcpy
302
303% bundles
304
305% message passing
306
307\begin{frame}[containsverbatim]{Message Passing example: \code{ring.cvl}}
308
309\begin{verbatim}
310/* Create nprocs processes. Have them exchange data
311 * in a cycle. Commandline example:
312 * civl verify -inputNPROCS=3 ring.cvl -simplify=false
313 */
314#include<civlc.h>
315#include "mp_root.cvh"
316
317void MPI_Process (int rank) {
318#include "mp_proc.cvh"
319
320 double x=rank, y;
321
322 send(&x, 1, (rank+1)%NPROCS, 0);
323 recv(&y, 1, (rank+NPROCS-1)%NPROCS, 0);
324 $assert y==(rank+NPROCS-1)%NPROCS;
325}
326\end{verbatim}
327\end{frame}
328
329\begin{frame}[containsverbatim]{File \code{mp{\U}root.cvh}}
330 \scriptsize
331\begin{verbatim}
332$input int NPROCS;
333$proc __procs[NPROCS];
334_Bool __start = 0;
335$comm MPI_COMM_WORLD;
336
337void MPI_Process (int rank);
338
339void init() {
340 for (int i=0; i<NPROCS; i++)
341 __procs[i] = $spawn MPI_Process(i);
342 MPI_COMM_WORLD = $comm_create(NPROCS, __procs);
343 __start=1;
344}
345
346void finalize() {
347 for (int i=0; i<NPROCS; i++)
348 $wait __procs[i];
349}
350
351void main() {
352 init();
353 finalize();
354}
355\end{verbatim}
356\end{frame}
357
358\begin{frame}[containsverbatim]{File \code{mp{\U}proc.cvh}}
359 \scriptsize
360\begin{verbatim}
361 void send(void *buf, int count, int dest, int tag) {
362 $message out = $message_pack(rank, dest, tag, buf, count*sizeof(double));
363 $comm_enqueue(&MPI_COMM_WORLD, out);
364 }
365
366 void recv(void *buf, int count, int source, int tag) {
367 $message in = $comm_dequeue(&MPI_COMM_WORLD, source, rank, tag);
368 $message_unpack(in, buf, count*sizeof(double));
369 }
370
371 $when (__start);
372\end{verbatim}
373\end{frame}
374
375\begin{frame}{VSL Projects: Uses Relation}
376
377 \includegraphics{vsl_projects}
378
379 \begin{itemize}
380 \item reusable components
381 \begin{itemize}
382 \item ABC: A Better C compiler? ANTLR-Based C compiler?
383 \item SARL: Symbolic Algebra \& Reasoning Library
384 \item GMC: Generic Model Checking utilities
385 \begin{itemize}
386 \item DFS, command line interface, trace saving/replay, error
387 logging, random simulation
388 \end{itemize}
389 \end{itemize}
390 \item model checking applications
391 \begin{itemize}
392 \item CIVL: Concurrency Intermediate Verification Language
393 \item TASS: Toolkit for Accurate Scientific Software (C+MPI)
394 \item CVT: Chapel Verification Tool
395 \end{itemize}
396 \end{itemize}
397
398\end{frame}
399
400\begin{frame}{Engineering}
401
402 \begin{itemize}
403 \item all of the VSL software is in Java
404 \item try to maintain coding standards
405 \item clear module boundaries with interfaces
406 \end{itemize}
407
408
409 \begin{center}
410 \begin{tabular}{|ll|}
411 \hline
412 Web page & \url{http://vsl.cis.udel.edu/civl}\\
413 Subversion & \url{svn://vsl.cis.udel.edu/civl}\\
414 Trac repository & \url{https://vsl.cis.udel.edu/trac/civl}\\
415 Automated build/test & \url{http://vsl.cis.udel.edu/civl/test}\\
416 \hline
417 \end{tabular}
418 \end{center}
419
420 \begin{itemize}
421 \item replace \texttt{civl} with \texttt{sarl}, \texttt{abc}, \texttt{gmc}, or
422 \texttt{tass}
423 \end{itemize}
424
425 \includegraphics[scale=.3]{civl-trac.pdf}
426
427\end{frame}
428
429\begin{frame}{Automated Build \& Test Script}
430
431 \begin{center}
432 \includegraphics[scale=.3]{sarl-junit.pdf}
433 \end{center}
434
435 For each project \ldots
436 \begin{itemize}
437 \item script is run after each commit
438 \item one directory for each \alert{branch} and \alert{trunk}
439 \begin{itemize}
440 \item one subdirectory for each revision, up to some bounded history
441 \end{itemize}
442 \item compiles all code and displays results
443 \item runs JUnit test suite and displays results
444 \item runs Jacoco coverage anaysis and displays results
445 \item generates javadocs
446 \end{itemize}
447\end{frame}
448
449\begin{frame}{Developer Eclipse Set-up}
450 \begin{enumerate}
451 \item Download vsl dependencies archive from
452 \url{http://vsl.cis.udel.edu/tools/vsl_depend}
453 \item Download and install Eclipse IDE for Java EE Developers
454 \begin{itemize}
455 \item version Kepler or later
456 \end{itemize}
457 \item Install Apache Ant if you don't have it
458 \item Install an Eclipse SVN plugin (such as Subversive)
459 \item Create class path variable \texttt{VSL}:
460 \begin{itemize}
461 \item Preferences$\ra$Java$\ra$Build Path$\ra$ClassPath Variables
462 \item select ``New'' and create a classpath variable \texttt{VSL}
463 \item specify its value to be \texttt{/opt/vsl}
464 \end{itemize}
465 \item Create string variable \texttt{vsl{\U}lib}:
466 \begin{itemize}
467 \item Preferences$\ra$Run/Debug$\ra$String Substitution$\ra$New
468 \item define an entry \texttt{vsl{\U}lib}
469 \item set its value to be \texttt{/opt/vsl/lib}
470 \end{itemize}
471 \end{enumerate}
472\end{frame}
473
474\begin{frame}{Check out and install ABC}
475 \begin{enumerate}
476 \item Check out ABC Eclipse project
477 \begin{itemize}
478 \item ``New Project\ldots from SVN''
479 \item SVN repository: \url{svn://vsl.cis.udel.edu/abc}
480 \item Navigate and select \texttt{trunk} from within archive
481 \item Check out project using all default options
482 \end{itemize}
483 \item Build using Ant
484 \begin{itemize}
485 \item right-click on \texttt{build.xml}
486 \item Choose ``Run as Ant build''
487 \item Clean project
488 \end{itemize}
489 \item test the build
490 \begin{itemize}
491 \item select Run$\ra$Run Configurations\ldots
492 \item ceate a new JUnit 4 configuration called ``ABC Tests''
493 \item select ``Run all tests in the selected project\ldots''
494 \item navigate and select the \texttt{test} folder in the ABC project
495 \item under the Arguments tab, type \texttt{-ea} into the VM arguments field
496 \item click ``Run'' to run the tests
497 \end{itemize}
498 \end{enumerate}
499\end{frame}
500
501\begin{frame}{Check out and install GMC}
502 \begin{enumerate}
503 \item Check out GMC Eclipse project
504 \begin{itemize}
505 \item ``New Project\ldots from SVN''
506 \item SVN repository: \url{svn://vsl.cis.udel.edu/gmc}
507 \item Navigate and select \texttt{trunk} from within archive
508 \item Check out project using all default options
509 \end{itemize}
510 \item test the build
511 \begin{itemize}
512 \item select Run$\ra$Run Configurations\ldots
513 \item ceate a new JUnit 4 configuration called ``GMC Tests''
514 \item select ``Run all tests in the selected project\ldots''
515 \item navigate and select the \texttt{test} folder in the GMC project
516 \item under the Arguments tab, type \texttt{-ea} into the VM arguments field
517 \item click ``Run'' to run the tests
518 \end{itemize}
519 \end{enumerate}
520\end{frame}
521
522\begin{frame}{Check out and install SARL}
523 \begin{enumerate}
524 \item Check out SARL Eclipse project
525 \begin{itemize}
526 \item ``New Project\ldots from SVN''
527 \item SVN repository: \url{svn://vsl.cis.udel.edu/sarl}
528 \item Navigate and select \texttt{trunk} from within archive
529 \item Check out project using all default options
530 \end{itemize}
531 \item test the build
532 \begin{itemize}
533 \item select Run$\ra$Run Configurations\ldots
534 \item ceate a new JUnit 4 configuration called ``SARL Tests''
535 \item select ``Run all tests in the selected project\ldots''
536 \item navigate and select the \texttt{test} folder in the SARL project
537 \item under Arguments tab, type \texttt{-ea} into the VM arguments field
538 \item under Environment tab, create an entry
539 \texttt{DYLD{\U}LIBRARY{\U}PATH} (OS X) or
540 \texttt{LD{\U}LIBRARY{\U}PATH} (linux), specify its value by
541 clicking Variables, choose \texttt{vsl{\U}lib} from the list
542 \item click ``Run'' to run the tests
543 \end{itemize}
544 \end{enumerate}
545\end{frame}
546
547\begin{frame}{Check out and install CIVL}
548 \begin{enumerate}
549 \item Check out CIVL Eclipse project
550 \begin{itemize}
551 \item ``New Project\ldots from SVN''
552 \item SVN repository: \url{svn://vsl.cis.udel.edu/civl}
553 \item Navigate and select \texttt{trunk} from within archive
554 \item Check out project using all default options
555 \end{itemize}
556 \item test the build
557 \begin{itemize}
558 \item select Run$\ra$Run Configurations\ldots
559 \item ceate a new JUnit 4 configuration called ``CIVL Tests''
560 \item select ``Run all tests in the selected project\ldots''
561 \item navigate and select the \texttt{test} folder in the CIVL project
562 \item under Arguments tab, type \texttt{-ea} into the VM arguments field
563 \item under Environment tab, create an entry
564 \texttt{DYLD{\U}LIBRARY{\U}PATH} (OS X) or
565 \texttt{LD{\U}LIBRARY{\U}PATH} (linux), specify its value by
566 clicking Variables, choose \texttt{vsl{\U}lib} from the list
567 \item click ``Run'' to run the tests
568 \end{itemize}
569 \end{enumerate}
570\end{frame}
571
572\begin{frame}{CIVL modules}
573 \begin{tabular}{@{}ll@{}}
574 \includegraphics[scale=0.55]{civlModules}
575 &
576 \includegraphics[scale=.3]{civlEclipseModules}
577 \end{tabular}
578\end{frame}
579
580\end{document}
Note: See TracBrowser for help on using the repository browser.