ArticleslgStudy

science

ANSI/ISO C Specification Language

ANSI/ISO C Specification Language is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand ANSI/ISO C Specification Language rather than just read about it. In short: 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.

Key takeaways

  • ANSI/ISO C Specification Language belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect ANSI/ISO C Specification Language to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of ANSI/ISO C Specification Language from memory before moving on to harder problems.

Reference excerpt

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:

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:

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.

References

Example of ACSL usage Sufficient Preconditions for Modular Assertion Checking in VMCAI 2008 pages 188–202. ACSL by Example, a well-documented collection of ACSL specifications of simple algorithms has been developed by the VerificationGroup at Fraunhofer FOKUS A tutorial about Frama-C with WP and ACSL for beginners that also provides some ideas about the theory behind the tools (available also in French). A 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 [1], Петренко Ольга Леонидовна and Хорошилов Алексей Владимирович. At Technikum Wien ACSL and Frama-C are taught in a course on design and verification.

External links The complete ACSL specification is available from the download page of Frama-C. TSnippet from TrustInSoft allows for in-browser testing of C snippets using ACSL.

Worked examples

Example 1 — a first encounter with ANSI/ISO C Specification Language

Start with the simplest possible case. Write down what ANSI/ISO C Specification Language claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to ANSI/ISO C Specification Language before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about ANSI/ISO C Specification Language ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of ANSI/ISO C Specification Language

In research
ANSI/ISO C Specification Language appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses ANSI/ISO C Specification Language in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
ANSI/ISO C Specification Language is common in secondary-school and first-year university syllabi. It links to neighbouring topics C (programming language), Specification languages, so understanding it makes those chapters shorter.
In everyday life
Look for ANSI/ISO C Specification Language outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “ANSI/ISO C Specification Language” →

How to study ANSI/ISO C Specification Language in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what ANSI/ISO C Specification Language means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain ANSI/ISO C Specification Language out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is ANSI/ISO C Specification Language in simple terms?

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…

Why does ANSI/ISO C Specification Language matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study ANSI/ISO C Specification Language?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on ANSI/ISO C Specification Language.

Tags

  • C (programming language)
  • Specification languages

Keep exploring