Qualkitdo Codeprover TF
Qualkitdo Codeprover TF
www.mathworks.com
www.mathworks.com/sales_and_services
User community:
www.mathworks.com/matlabcentral
Technical support:
www.mathworks.com/support/contact_us
Phone:
508-647-7000
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a
list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective
holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for more
information.
Revision History
September 2013
March 2014
October 2014
March 2015
September 2015
Contents
1 Introduction ...................................................................................................................................... 1-1
2 Initial Specification .......................................................................................................................... 2-1
3 High-Level Semantics of Programming Languages ......................................................................... 3-1
Definition 1. (Operational Semantics) ......................................................................................... 3-2
Definition 2. (Kripke Structures with Single Failure) .................................................................. 3-3
Definition 3. (Run-Time Errors) .................................................................................................. 3-4
Definition 4. (Strongest Invariant at k) ........................................................................................ 3-5
Definition 5. (Run-Time Error Modalities/Colors) ...................................................................... 3-6
Proposition 6. (Run-Time Error Modalities Are Noncomputable) ............................................... 3-7
Definition 7. (Admissible Check Modalities) .............................................................................. 3-9
Proposition 8. (Semantics of C#(k))............................................................................................ 3-10
4 References ........................................................................................................................................ 4-1
4.1 Reference Documents.............................................................................................................. 4-2
vi
1 Introduction
This document describes the Theoretical Foundation for the Polyspace Code ProverTM
verification tool. It is intended for use in the DO-178C tool qualification process for verification
tools.
This document is a high-level specification of Polyspace Code Prover code verification
technology for ANSI C and ISO C++. It starts from the user need to detect more bugs earlier on
in the development process and in a more automated way. Conventional technologies, such as
testing, should be disruptively improved. MathWorks particularly focuses on run-time errors,
which typically represent 30-40% of the total program errors that occur after delivery. These
errors are both difficult to detect through conventional means, and can have significant negative
impact, which can range from erroneous outputs to system crash or security breaches.
This document describes the formal, theoretical background of Polyspace Code Prover
technology. Detecting automatically and exhaustively run-time errors in general programs is
very complex. The seminal idea, introduced by Ben Wegbreit in 1974 and 1975, is to perform
approximate computations in which the direction of approximation is controlled. These
approximations are formalized by closure operators on algebraic structures called complete
lattices, starting with a mathematical model of program execution via operational semantics and
Kripke structures.
Polyspace Bug FinderTM identifies run-time errors in C and C++ embedded software. Polyspace
Bug Finder does not prove the absence of run-time errors. Polyspace Bug Finder uses the same
theoretical foundation as Polyspace Code Prover, but it is not irrefutable with respect to
identification of run-time errors.
1-2
2 Initial Specification
Designing a bridge, choosing the trajectory for the launch of a communication satellite,
optimizing the shape of a plane wing, estimating the multiple echo effects of urban buildings in
cellular phone communications: what is common among these industrial activities is high-speed
processors and applied mathematics. The central paradigm is to model a physical world system
as a set of mathematical equations, solving these equations using high-speed processors, and
finally using the solutions to these equations to predict the behavior of the physical system.
The software industry has not yet really leveraged this paradigm to optimize its own verification
and validation processes. Polyspace Code Prover brings to the software industry the power of
applied mathematics and high-speed modern processors. The Polyspace Code Prover software
aims at helping users simultaneously:
Automate specific software development and verification processes
Increase the reliability of software
The main criteria for software are:
Functional correctness: computes expected outputs
Temporal correctness: computes outputs within specified time bounds
Robustness: does not halt, crash, or behave erratically because of run-time errors
Run-time errors are an important cause of software defects. The study of Sullivan and
Chillarege1 conducted at Berkeley and IBM Watson found that many software defects
addressed during a four-year maintenance phase on large IBM codes are due to run-time errors.
Memory allocation errors, array out of bounds, uninitialized pointers, and pointer management
errors accounted for 26% of all observed software faults and more than 57% of the highest
severity faults, causing system outage or major disruption.
M. SULLIVAN AND R. CHILLAREGE, Software defects and their impact on system availability, proc. 21th International
Symposium on Fault-Tolerant Computing (FTCS-21), Montreal, 1991, 2-9, IEEE Press.
The Polyspace Code Prover software targets the mathematical modeling paradigm regarding
run-time errors. Polyspace Code Prover addresses two essential needs:
Static verification: statically predicting specific classes of run-time errors and sources of
nondeterminism
Semantic browsing: statically computing data and control flow to ease program
understanding, verification, or qualification
Given a source program, P, written in source programming language L, you want to compute
statically (without specific input data) and automatically a conservative model of the future
dynamic, run-time behavior of P. You also want to extract from this model predictions about the
possible occurrences of run-time errors and sources of nondeterminism (for static verification),
as well as data and control flow information (for semantic browsing).
This document serves as a reference for the design of Polyspace Code Prover and as a criterion
for functional validation testing. MathWorks uses an established tool life cycle process to
address tool development and verification activities. Hardware errors, coding errors, testing
errors, documentation errors, or other unforeseen circumstances may cause significant
deviations between expected behavior and actual behavior of the software tool. Therefore, this
document and the associated documents do not imply that MathWorks explicitly or implicitly
guarantees that Polyspace Code Prover is fully compliant to the specification, that it always
delivers correct results, or that it conforms to the user needs.
2-2
3 High-Level Semantics of
Programming Languages
Program behavior and run-time errors are formalized to provide a firm basis for the specification
of Polyspace Code Prover outputs.
3-2
3-3
3-4
R. FLOYD, Assigning meaning to programs. In Mathematical Aspects of Computer Science, Proc. of Symposia on Applied
Mathematics, American Mathematical Society, 19-32, Providence, 1967.
D. PARK, Fixpoint induction and proofs of program properties, in Machine Intelligence, Edinburgh Univ. Press, 5 : 59-78, 1969.
3-5
3-6
C. HOARE AND D. ALLISON. Incomputability, ACM Computing Surveys, 4(3) :169-178, 1972.
10
B. WEGBREIT, Property extraction in well-founded property sets, IEEE Transactions on Software Engineering, 1(3):270-285,
1975.
3-7
The key idea of Wegbreits work is that while the exact program property may not be
computable, a weaker property implied by the exact one may be computable. He also devises a
means to compute these approximate properties by replacing the exact invariant propagation of a
Floyd-style equation system by its image in a weaker space through an approximation operator
. If properly designed, the approximated system is solvable and its solution, called SGI#(k) at a
particular program point k, is related to that of strongest global invariant by: (SGI(k))
SGI#(k).
This approximate invariant can in turn be used in the computation of run-time error modalities
(colors) according to Definition 5. Replacing the exact invariant SGI(k) at point k in this
definition by its supersets yields an approximate check color C#(k) that is related to the exact
color C(k) by the following relation.
3-8
Gray
Red
Green
Orange
Gray
Red
Green
Orange
1
1
1
1
1
1
In turn, this induces the following meanings for the color defined by C#(k).
3-9
3-10
4 References
4-2