PRECiSA

PRECiSA (Program Round-off Error Certifier via Static Analysis) is a fully automatic static analyzer for floating-point programs.

The main functionality of PRECiSA is the round-off error estimation. Given a floating-point program, PRECiSA computes a sound overapproximation of the round-off error that may occur together with PVS certificates ensuring its correctness. Here you can try the PRECiSA web-interface and find more information on the tool.

In addition, PRECiSA implements a program transformation from a PVS real-valued program to floating-point C code. This transformation corrects unstable tests by over-approximating the conditional guards in the if-then-else statements. The resulting transformed program emits a warning when an unstable test is detected (i.e., the floating-point computational flow diverges with respect to the ideal real number one). The generated C code is annotated with ACSL contracts that relate the floating-point implementation with the real-valued program specification.

Installation

PRECiSA runs on Linux and Mac OS X operating systems.

Prerequisites

To build and install PRECiSA you need:

To verify certificates generated by PRECiSA you need:

If you want to use the SMT optimization you need FPRock.

Build

  1. Install Kodiak producing a dynamic library libKodiakDynamic.so (for Linux) or libKodiakDynamic.dylib (for MacOS).

  2. Make accessible the Kodiak dynamic library to your linker. Normally, this is done by updating the LD_LIBRARY_PATH environment variable with the directory in which the libKodiakDynamic.so (or libKodiakDynamic.dylib) file is present. Let <kodiak-directory> represent this directory. In a bourne shell that environment variable can be set like this:
    $ export LD_LIBRARY_PATH="<directory-containing-libKodiakDynamic.so>:$LD_LIBRARY_PATH"
    

    You can add the previous line to your shell initialization script (for example, ~/.profile or ~/.bashrc) to make the LD_LIBRARY_PATH change permanent.

  3. Go to the PRECiSA sub-directory of the repository.
    $ cd <repository-root>/PRECiSA
    
  4. Use the following commands to create a cabal sandbox in this folder and install the executable in <repository-root>/.cabal-sandbox/bin/precisa
    $ cabal v1-sandbox init    # Creates a new sandbox.
                               # Old cabal versions may need the command `cabal sandbox init` instead
    
    $ cabal v1-install --enable-optimization --extra-lib-dirs=<kodiak-directory>
    
  5. Now, the precisa executable can be run with:
    $ .cabal-sandbox/bin/precisa
    

Floating-Point Round-Off Error Estimation

The input to the PRECiSA round-off error estimator are the following files:

More examples can be found in the PRECiSA benchmarks folder.

The analysis performed by PRECiSA results in one upper-bound of the floating-point round-off error for each decision path of interest, an overall upper-bound for the rest of decision paths, and an overall upper-bound for the unstable test cases (when real and floating-point flows diverge). Additionally, PRECiSA generates two PVS theories:

All the generated lemmas are equipped with PVS proof scripts that automatically discharge them.

How to run the PRECiSA round-off error estimator

We assume that precisa (the executable of PRECiSA) is in the current directory.

To launch the round-off error analysis of PRECiSA with the default parameters run:

$ ./precisa analyze "example.pvs" "example.input"

Command Line Options

An example of how to execute PRECiSA by manually setting some options is the following:

$ ./precisa analyze "example.pvs" "example.input" --paths "example.path" --max-depth 7 --precision 14 --max-lemmas 40

How to verify the PVS certificates

PVS version 6.0 and the development version of the NASA PVS Library are required to proof-check the symbolic and the numerical certificates generated by PRECiSA in PVS. Furthermore, the directory PVS has to be added to the Unix environment variable PVS_LIBRARY_PATH. Depending upon your shell, one of the following lines has to be added to your startup script. In C shell (csh or tcsh), put this line in ~/.cshrc, where <precisapvsdir> is the absolute path to the directory PVS:

setenv PVS_LIBRARY_PATH "<precisapvsdir>:$PVS_LIBRARY_PATH"

In Borne shell (bash or sh), put this line in either ~/.bashrc or ~/.profile:

export PVS_LIBRARY_PATH="<precisapvsdir>:$PVS_LIBRARY_PATH"

You can use the proveit shell script to automatically check the proofs in the symbolic and numerical certificates generated by PRECiSA. For example, if you analyzed the program example.pvs, in the same folder you will find two files: cert_example.pvs and num_cert_example.pvs.

To check the correctness of the PVS theories in cert_example.pvs and num_cert_example.pvs you can run:

$ proveit -sc cert_example.pvs
$ proveit -sc num_cert_example.pvs

PVS basic troubleshooting

If the PVS verification is not behaving as expected, try cleaning the PVS binaries in the NASA PVS library. Simply run cleanbin-all in the NASA PVS library folder of your installation and try again.

Automatic generation of stable C code from PVS

The input to the PRECiSA C code generator are the following files:

The output is a C floating-point program example.c instrumented to detect unstable tests. This program is annotated with ACSL contracts stating the relation between the floating-point program and the real number specification. This annotated program can be analyzed with the Frama-C static analyzer.

Besides, PVS certificates are provided for ensuring that all the unstable tests are detected. These certificates can be automatically checked as explained here.

How to run the PRECiSA stable C code generator

We assume that precisa (the executable of PRECiSA) is in the current directory.

To launch the round-off error analysis of PRECiSA with the default parameters run:

$ ./precisa gen-code "example.pvs" "example.input"

Command Line Options

Additional information

Version

PRECiSA v-3.0.0 (July 2020)

Contact information

If you have any question or problem, please contact:

The code in this repository is released under NASA’s Open Source Agreement. See the directory LICENSES.

Notices:

Copyright 2020 United States Government as represented by the Administrator of the National Aeronautics
and Space Administration. All Rights Reserved.

Disclaimers
No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND,
EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY
THAT THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT,
ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT,
IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF
ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS
RESULTING FROM USE OF THE SUBJECT SOFTWARE.  FURTHER, GOVERNMENT AGENCY DISCLAIMS
ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL
SOFTWARE, AND DISTRIBUTES IT "AS IS."

Waiver and Indemnity:  RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES
GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. 
IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES,
EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED
ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY
AND HOLD HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS,
AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW.  RECIPIENT'S SOLE REMEDY
FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.