ANSI/ISO C Specification Language

{{multiple issues|

{{refimprove|date=February 2015}}

{{more footnotes|date=February 2015}}

}}

{{Infobox programming language

| name = ANSI/ISO C Specification Language

| paradigm = declarative with few imperative features.

| year = 2008

| designer = Commissariat à l'Énergie Atomique and INRIA

| developer = Commissariat à l'Énergie Atomique and INRIA

| latest release version = v1.16

| latest release date = 19 November 2020

| typing = static

| implementations = Frama-C

| influenced_by = JML

}}

The ANSI/ISO C Specification Language (ACSL) is a specification language for C programs, using Hoare style pre- and postconditions and invariants, that follows the design by contract paradigm. Specifications are written as C annotation comments to the C program, which hence can be compiled with any C compiler.

The current verification tool for ACSL is Frama-C. It also implements a sister language, ANSI/ISO C++ Specification Language (ACSL++), defined for C++.

Overview

In 1983, the American National Standards Institute (ANSI) commissioned a committee, X3J11, to standardize the C language. The first standard for C was published by ANSI. Although this document was subsequently adopted by International Organization for Standardization (ISO) and subsequent revisions published by ISO have been adopted by ANSI, the name ANSI C continues to be used.

ACSL is a behavioral interface specification language (BISL). It aims at specifying behavioral properties of C source code. The main inspiration for this language comes from the specification language of the Caduceus tool for deductive verification of behavioral properties of C programs. The specification language of Caduceus is itself inspired from JML which aims at similar goals for Java source code.

One difference with JML is that ACSL is intended for static verification and deductive verification whereas JML is designed both for runtime assertion checking and static verification using for instance the ESC/Java tool.

Syntax

Consider the following example for the prototype of a function named incrstar:

/*@ requires \valid(p);

@ assigns *p;

@ ensures *p == \old(*p) + 1;

@*/

void incrstar (int *p);

The contract is given by the comment which starts with /*@. Its meaning is as follows:

  • The first line is a precondition: it states that function incrstar must be called with a pointer p that points to a safely allocated memory location.
  • Second line is a frame clause, stating that function incrstar does not modify any memory location but the one pointed to by p.
  • Finally, the ensures clause is a postcondition, which specifies that the value *p is incremented by one.

A valid implementation of the above function would be:

void incrstar (int *p) {

(*p)++;

}

Tool support

Most of the features of ACSL are supported by Frama-C.

The TrustInSoft static analyzer is a commercial derivative of Frama-C. It verifies program behavior and (with builtin rules based on the language specification) catch instances of undefined behavior.{{cite web |title=ACSL Properties |url=https://man.trust-in-soft.com/man/tis-user-guide/add-acsl.html |website=TrustInSoft Documentation 1.42-dev documentation}}

References

{{Reflist}}

  • [https://doi.org/10.1007%2F978-3-540-78163-9_18 Example of ACSL usage] Sufficient Preconditions for Modular Assertion Checking in VMCAI 2008 pages 188–202.
  • [https://fraunhoferfokus.github.io/acsl-by-example/ ACSL by Example], a well-documented collection of ACSL specifications of simple algorithms has been developed by the [https://www.fokus.fraunhofer.de/en/sqc/verification/ VerificationGroup] at Fraunhofer FOKUS
  • A [http://allan-blanchard.fr/publis/frama-c-wp-tutorial-en.pdf tutorial] about Frama-C with WP and ACSL for beginners that also provides some ideas about the theory behind the tools ([http://allan-blanchard.fr/publis/frama-c-wp-tutoriel-fr.pdf available also in French]).
  • A [https://arxiv.org/abs/1508.03894 report] on using ACSL and Frama-C to formulate and verify low-level requirements in the context of a DO-178C compliant project
  • Report mentioning the use of ACSL in teaching [http://www.it-education.ru/2009/reports/Petrenko_Khoroshilov.htm], Петренко Ольга Леонидовна and Хорошилов Алексей Владимирович.
  • At Technikum Wien ACSL and Frama-C are taught in a [https://www.technikum-wien.at/en/study_programs/master_s/embedded_systems/facts___figures/ course on design and verification].