Source Code Verification with Polyspace Code Prover
How Polyspace Verification Works
Polyspace® software uses static verification to prove the absence of run-time errors. Static verification derives the dynamic properties of a program without actually executing it. This differs significantly from other techniques, such as run-time debugging, in that the verification it provides is not based on a given test case or set of test cases. The dynamic properties obtained in the Polyspace verification are true for all executions of the software.
What is Static Verification
Static verification is a broad term, and is applicable to any tool that derives dynamic properties of a program without executing the program. However, most static verification tools only verify the complexity of the software, in a search for constructs that may be potentially erroneous. Polyspace verification provides deep-level verification identifying almost all run-time errors and possible access conflicts with global shared data.
Polyspace verification works by approximating the software under verification, using representative approximations of software operations and data.
For example, consider the following code:
for (i=0 ; i<1000 ; ++i) { tab[i] = foo(i); }
To check that the variable i
never overflows the range of tab
, a traditional approach would be to enumerate each possible value of i
. One thousand checks would be required.
Using the static verification approach, the variable i
is modelled by its domain variation. For instance, the model of i
is that it belongs to the static interval [0..999]. (Depending on the complexity of the data, convex polyhedrons, integer lattices and more elaborate models are also used for this purpose).
By definition, an approximation leads to information loss. For instance, the information that i
is incremented by one every cycle in the loop is lost. However, the important fact is that this information is not required to ensure that no range error will occur; it is only necessary to prove that the domain variation of i
is smaller than the range of tab
. Only one check is required to establish that — and hence the gain in efficiency compared to traditional approaches.
Static code verification has an exact solution. However, this exact solution is not practical, as it would require the enumeration of all possible test cases. As a result, approximation is required for a usable tool.
Exhaustiveness
Nothing is lost in terms of exhaustiveness. The reason is that Polyspace verification works by performing upper approximations. In other words, the computed variation domain of a program variable is a superset of its actual variation domain. As a result, Polyspace verifies run-time error items that require checking.
Value of Polyspace Code Prover Verification
Polyspace verification can help you to:
Enhance Software Reliability
Polyspace software enhances the reliability of your C/C++ applications by proving code correctness and identifying run-time errors. Using advanced verification techniques, Polyspace software performs an exhaustive verification of your source code.
Because Polyspace software verifies all executions of your code, it can identify code that:
Never has an error
Always has an error
Is unreachable
Might have an error
With this information, you know how much of your code does not contain run-time errors, and you can improve the reliability of your code by fixing errors.
You can also improve the quality of your code by using Polyspace verification software to check that your code complies with established coding standards, such as the MISRA C™, MISRA™ C++ or JSF® C++ standards.1
Decrease Development Time
Polyspace software reduces development time by automating the verification process and helping you to efficiently review verification results. You can use it at any point in the development process. However, using it during early coding phases allows you to find errors when it is less costly to fix them.
You use Polyspace software to verify source code before compile time. To verify the source code, you set up verification parameters in a project, run the verification, and review the results. This process takes significantly less time than using manual methods or using tools that require you to modify code or run test cases.
Color-coding of results helps you to quickly identify errors. You will spend less time debugging because you can see the exact location of an error in the source code. After you fix errors, you can easily run the verification again.
Polyspace verification software helps you to use your time effectively. Because you know the parts of your code that do not have errors, you can focus on the code with proven (red code) or potential errors (orange code).
Reviewing code that might have errors (orange code) can be time-consuming, but Polyspace software helps you with the review process. You can use filters to focus on certain types of errors or you can allow the software to identify the code that you should review.
Improve the Development Process
Polyspace software makes it easy to share verification parameters and results, allowing the development team to work together to improve product reliability. Once verification parameters have been set up, developers can reuse them for other files in the same application.
Polyspace verification software supports code verification throughout the development process:
An individual developer can find and fix run-time errors during the initial coding phase.
Quality assurance engineers can check overall reliability of an application.
Managers can monitor application reliability by generating reports from the verification results.
Related Topics
1 MISRA and MISRA C are registered trademarks of MISRA Ltd., held on behalf of the MISRA Consortium.