A CIL Tutorial - Department of Computer Science - ETH Zürich

A CIL Tutorial - Department of Computer Science - ETH Zürich A CIL Tutorial - Department of Computer Science - ETH Zürich

29.01.2014 Views

CHAPTER 11. PROGRAM VERIFICATION 102 $ ciltutcc --enable-tut11 --prover=Alt-Ergo prover-version=0.94 -o tut11 test/tut11.c 11.3 Exercises 1. Use a chain of Why3 if-then-else terms to calculate the VC for C's switch statement. 2. Handle structure elds. 3. Verify an array sorting function. 4. Extend the translation of attribute parameters and terms to handle not only integer arithmetic, but also oating point arithmetic. To achieve this, the relevant theory must be added to the Why3 context, and the operations from these theories must be added to the ops type. 5. Extend the checking here to also verify that function preconditions are satised. Project: Create a tool that nds loop invariants given a post-condition and pre-condition for the loop. There are several approaches you might take. You could execute the program symbolically at the same time as it executes concretely (which we'll see how to do in Chapter 15), and assume to be symbolic invariants relationships that are concretely true at runtime. Alternately, you could repeatedly construct trial invariants out of every relationship among program variables that are live in the loop.

CHAPTER 11. PROGRAM VERIFICATION 103 11.4 Further Reading There are many approaches to, and implementations of, program verication. Here is a dated and incomplete list. This is a big area with many ongoing projects, so ask your local PL professor to point you in the right direction. • VC generation and checking: Boogie [1] • Software model checking: BLAST [4] • Explicit path model checking: CUTE [4]

CHAPTER 11. PROGRAM VERIFICATION 102<br />

$ ciltutcc --enable-tut11 --prover=Alt-Ergo prover-version=0.94 -o tut11 test/tut11.c<br />

11.3 Exercises<br />

1. Use a chain <strong>of</strong> Why3 if-then-else terms to calculate the VC for C's switch statement.<br />

2. Handle structure elds.<br />

3. Verify an array sorting function.<br />

4. Extend the translation <strong>of</strong> attribute parameters and terms to handle not only integer arithmetic,<br />

but also oating point arithmetic. To achieve this, the relevant theory must be added to the<br />

Why3 context, and the operations from these theories must be added to the ops type.<br />

5. Extend the checking here to also verify that function preconditions are satised.<br />

Project: Create a tool that nds loop invariants given a post-condition and<br />

pre-condition for the loop. There are several approaches you might take. You<br />

could execute the program symbolically at the same time as it executes concretely<br />

(which we'll see how to do in Chapter 15), and assume to be symbolic<br />

invariants relationships that are concretely true at runtime. Alternately, you<br />

could repeatedly construct trial invariants out <strong>of</strong> every relationship among<br />

program variables that are live in the loop.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!