integrating formal program verification with testing · myth 4: formal methods require highly...

25
Integrating Formal Program Verification with Testing Cyrille Comar, Johannes Kanig and Yannick Moy

Upload: others

Post on 18-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Integrating Formal Program

Verification with Testing

Cyrille Comar, Johannes Kanig and Yannick Moy

Page 2: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Integrating Formal Program

Verificationwith Testing

Cyrille Comar, Johannes Kanig and Yannick Moy

Page 3: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Integrating Formal Program

Verificationwith

Cyrille Comar, Johannes Kanig and Yannick Moy

Page 4: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Motivation

Page 5: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •
Page 6: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Formal methods […] might be the

primary source of evidence for

the satisfaction of many of the

objectives concerned with

development and verification.

2011: Formal Methods Supplement (DO-333)

DO-178C: formal methods can replace testing

Page 7: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

• Myth 4: Formal methods require highly trained mathematicians

• Myth 5: Formal methods increase the cost of development

• Myth 6: Formal methods are unacceptable to users

• Myth 7: Formal methods are not used on real, large-scale software

(Anthony Hall, Praxis Systems, 1990)

Myths of formal methods

Page 8: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Since 2001, Airbus has been

integrating several tool supported

formal verification techniques into

the development process of

avionics software products.

2009: Formal Verification of Avionics Software Products

(Souyris, Wiels, Delmas, Delseny)

Practice of formal methods

Page 9: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •
Page 10: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Proof + Test

Page 11: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Programming Contracts

{P}C{Q} Hoare logic (1969)

logic contracts

for proofs

SPARK (1987)

executable contracts

for tests

Eiffel DbC (1986)

Hi-Lite: executable annotation language???

Page 12: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Project

Page 13: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Ada 2012

Page 14: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Testing vs. Formal Verification

RQ

P

PQ

P calls Q

prove pre of Q

assume post of Q

assume pre of Q

prove post of Q

PQ

P calls Q

use Q code

cover P constructs

actual body of Q

or stub…

global soundness argument:

all functions proved

all assumptions justified

local exhaustivity argument:

each function covered

enough behaviors

explored

Page 15: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Combining tests and proofs

verification combining tests and proofs should be

AT LEAST AS GOOD AS

verification based on tests only

PQ

P calls QP is tested

Q is provedQ calls P

How so we justify

assumptions made

during proof?

Page 16: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

) …

Caution: contracts are not only pre/post!

data dependences

parameters

not aliased

parameters

initialized

strong typing

Page 17: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Combination 1: tested calls proved

PQ

P calls QP is tested

Q is proved

during testing:

check that

precondition of Q

is respected

assumption for proof:

precondition of Q

is respected

Page 18: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Combination 2: proved calls tested

PQ

P is tested

Q is provedQ calls P

during testing:

check that

postcondition of P

is respected

assumption for proof:

postcondition of P

is respected

Page 19: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Testing + Formal Verification

RQ

P

global soundness argument:

- proof: assumptions proved

- test: assumptions tested

tested

proved

proved

local exhaustivity argument:

- test: function covered

- proof: by nature of proof

Testing must check additional properties

Done by compiler instrumentation

Page 20: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

GNAT toolsuite

GNAT

compiler

GNATtest

unit testing

GNATprove

unit proof

executable

aggregated

verification

results

Page 21: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Conclusion

Page 22: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

• Soundness

• Applicability to the code

• Usability by normal engineers on normal computers

• Improve on classical methods

• Certifiability

Airbus 5 “must-have” of formal methods

current work

Page 23: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Benefits of openness

.org

• public:

meeting minutes

technical work

69 members

• private:

management

partner code

• announcements

• meeting slides

• articles / docs

• all code

• dev docs

• user docs

external collaborations with industry and academia

Page 24: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

Project Partners

Page 25: Integrating Formal Program Verification with Testing · Myth 4: Formal methods require highly trained mathematicians • Myth 5: Formal methods increase the cost of development •

www.open-do.org/projects/hi-lite