Skip to main content Accessibility help
×
Hostname: page-component-78c5997874-v9fdk Total loading time: 0 Render date: 2024-11-08T02:32:59.809Z Has data issue: false hasContentIssue false

6 - Proof

Published online by Cambridge University Press:  05 October 2015

John W. McCormick
Affiliation:
University of Northern Iowa
Peter C. Chapin
Affiliation:
Vermont Technical College
Get access

Summary

In this chapter we describe how you can use Spark to prove certain correctness properties of your programs. When you ask to “prove” your code, the Spark tools will by default endeavor to prove that it will never raise any of the predefined language exceptions that we describe in Section 6.1. If you additionally include pre- and postconditions, loop invariants, or other kinds of assertions, the tools will also attempt to prove that those assertions will never fail.

It is important to understand that proofs created by the Spark tools are entirely static. This means if they succeed, the thing being proved will be true for every possible execution of your program regardless of the inputs provided. This is the critical property of proof that sets it apart from testing.

However, Ada assertions are also executable under the control of the assertion policy in force at the time a unit is compiled. Assertions for which proofs could not be completed can be checked when the program is run, for example during testing, to help provide a certain level of confidence about the unproved assertions. Testing can thus be used to complement the proof techniques described here to obtain greater overall reliability. We discuss this further in Section 8.4.

Runtime Errors

A logical error is an error in the logic of the program itself that may cause the program to fail as it is executing. It is an error that, in principle, arises entirely because of programmer oversight. In contrast, an external error is an error caused by a problem in the execution environment of the program, such as being unable to open a file because it does not exist. If a program is correct, it should not contain any logical errors. However, external errors are outside of a program's control and may occur regardless of how well constructed the program might be. A properly designed program should be able to cope with any external errors that might arise. However, the handling of external errors is outside the scope of this book and is a matter for software analysis, design, and testing (see Black, 2007).

We distinguish a runtime error as a special kind of logical error that is detected by Ada-mandated checks during program execution. Examples of runtime errors include the attempt to access an array with an out of bounds index, arithmetic overflow, or division by zero.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2015

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure [email protected] is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Proof
  • John W. McCormick, University of Northern Iowa, Peter C. Chapin
  • Book: Building High Integrity Applications with SPARK
  • Online publication: 05 October 2015
  • Chapter DOI: https://doi.org/10.1017/CBO9781139629294.007
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Proof
  • John W. McCormick, University of Northern Iowa, Peter C. Chapin
  • Book: Building High Integrity Applications with SPARK
  • Online publication: 05 October 2015
  • Chapter DOI: https://doi.org/10.1017/CBO9781139629294.007
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Proof
  • John W. McCormick, University of Northern Iowa, Peter C. Chapin
  • Book: Building High Integrity Applications with SPARK
  • Online publication: 05 October 2015
  • Chapter DOI: https://doi.org/10.1017/CBO9781139629294.007
Available formats
×