wiki:Introduction

Version 8 (modified by siegel, 7 years ago) ( diff )

--

Contents

Introduction

What is CIVL?

CIVL stands for Concurrency Intermediate Verification Language. The CIVL platform encompasses:

  1. the programming language CIVL-C, a dialect of C with additional primitives supporting concurrency, specification, and modeling;
  2. verification and analysis tools, including a symbolic execution-based model checker for checking various properties of, or finding defects in, CIVL-C programs; and
  3. tools that translate from commonly-used languages/APIs to CIVL-C.

A user can write programs in CIVL-C directly, or use one of the front-ends that translates from a "real" programming language to CIVL-C.

When used in the first way, CIVL-C may be considered a modeling language, similar to Promela (the language used by the model checker Spin). This is useful for exploring and verifying algorithms, especially concurrent algorithms. The main difference between CIVL-C and Promela is that CIVL-C includes almost all of the language constructs in C, including floating-point numbers, arrays of any type, structs, functions, pointers, dynamic allocation (malloc and free), and pointer arithmetic. Like Spin, the CIVL verifier can be used to perform an exhaustive search of a state space. Unlike Spin, the CIVL verifier uses symbolic execution, so in a CIVL state, variables may be assigned symbolic expressions, not just concrete values. This allows the verifier to check properties of the form the assertions hold for all possible inputs and the two given programs are functionally equivalent.

When used in the second way, a C program using MPI, CUDA, OpenMP, or Pthreads, (or even some combination of these APIs), will be automatically translated into CIVL-C and then verified. The advantages of such a framework are clear: the developer of a new verification technique could implement it for CIVL-C and then immediately see its impact across a broad range of concurrent programs. Likewise, when a new concurrency API is introduced, one only needs to implement a translator from it to CIVL-C in order to reap the benefits of all the verification tools in the platform. Programmers would have a valuable verification and debugging tool, while API designers could use CIVL as a "sandbox" to investigate possible API modifications, additions, and interactions.

This manual covers all aspects of the CIVL framework, and is organized in parts as follows:

  1. this introduction, including "quick start" instructions for downloading and installing CIVL and several examples;
  2. a complete description of the CIVL-C language;
  3. a formal semantics for the language; and
  4. a description of the tools in the framework.

Installation and Quick Start

  1. Install the automated theorem prover CVC4, following instructions at http://cvc4.cs.stanford.edu/web/. You only need the binary (cvc4), which must be in your PATH.
  2. Install the automated theorem prover Z3, following instructions at https://github.com/Z3Prover/z3. You only need the binary (z3), which must be in your PATH.
  3. Install a Java 8 SDK. Later versions of Java may also work. See https://www.oracle.com/technetwork/java/javase/downloads/index.html.
  4. Download and unpack the latest stable release of CIVL from http://vsl.cis.udel.edu/lib/sw/civl/current/latest/release/.
  5. The resulting directory should be named CIVL-tag for some string tag which identifies the version of CIVL you downloaded. Move this directory wherever you like.
  6. The JAR file in the lib directory is all you need to run CIVL. You may move this JAR file wherever you want. You run CIVL by typing a command of the form java -jar /path/to/civl-TAG.jar .... For convenience, you may instead use the shell script civl included in the bin directory. This allows you to replace java -jar /path/to/civl-TAG.jar with just civl on the command line. Simply edit the civl script to reflect the path to the JAR file and place the script somewhere in your PATH. In the following, we assume you have done this.
  7. From the command line, type civl help. You should see a help message describing the command line syntax.
  8. From the command line, type civl config. This should report that cvc4 and z3 were found, and it should create a file named .sarl in your home directory.

To test your installation, copy the file examples/concurrency/locksBad.cvl to your working directory. Look at the program: it is a simple 2-process program with two shared variables used as locks. The two processes try to obtain the locks in opposite order, which can lead to a deadlock if both processes obtain their first lock before either obtains the second. Type civl verify locksBad.cvl. You should see some output culminating in a message

The program MAY NOT be correct. See CIVLREP/locksBad_log.txt.

Type civl replay locksBad.cvl. You should see a step-by-step account of how the program arrived at the deadlock.

Verifying Different Kinds of Programs

Verifying CIVL-C Programs

Dining philosophers:

$input int B = 4; // upper bound on number of philosophers
$input int n;     // number of philosophers
$assume(2<=n && n<=B);

_Bool forks[n]; // Each fork will be on the table ($true) or in a hand ($false).

void dine(int id) {
  int left = id;
  int right = (id + 1) % n;
  while (1) {
    $when (forks[left]) forks[left] = $false;
    $when (forks[right]) forks[right] = $false;
    forks[right] = $true;
    forks[left] = $true;
  }
}

void main() {
  $for(int i: 0..n-1) forks[i] = $true;
  $parfor(int i: 0..n-1) dine(i);
}

Verifying C Programs

Verifying C/MPI Programs

Verifying C/OpenMP Programs

Verifying CUDA-C Programs

Verifying C/Pthreads Programs

Verifying Fortran Programs

(under development)

The CIVL-C Language

Semantics

Command-line Tools

Note: See TracWiki for help on using the wiki.