Hybrid Verification in SPARK 2014: Combining Formal Methods with Testing

Similar documents
Ada 2012, SPARK 2014, and Combining Proof and Test!

A Comparison of SPARK with MISRA C and Frama-C

WHITE PAPER. 10 Reasons to Use Static Analysis for Embedded Software Development

GNAT Pro Innovations for High-Integrity Development

Spark verification features

CIS 890: Safety Critical Systems

Contract-based Programming: a Route to Finding Bugs Earlier

Leveraging Formal Methods Based Software Verification to Prove Code Quality & Achieve MISRA compliance

18-642: Code Style for Compilers

AdaCore technologies

A3. Programming Languages for Writing Safety-Critical Software

Verification and Test with Model-Based Design

SPARK Update Ada Europe 2012

CS 161 Computer Security

Intro to Proving Absence of Errors in C/C++ Code

Simulink 모델과 C/C++ 코드에대한매스웍스의정형검증툴소개 The MathWorks, Inc. 1

Building Better and Safer Programs Using SPARK and Ada. William Wong 23 March 2019

Program Verification (6EC version only)

Warm-Up Problem. Let be a set of well-formed Predicate logic formulas. Let be well-formed Predicate logic formulas. Prove or disprove the following.

Implementation Guidance for the Adoption of SPARK

Practical Development of Safe, Secure, Reliable Embedded Software

Introduction to Axiomatic Semantics (1/2)

SPARKSkein A Formal and Fast Reference Implementation of Skein

Verification and Validation of Models for Embedded Software Development Prashant Hegde MathWorks India Pvt. Ltd.

Combining program verification with component-based architectures. Alexander Senier BOB 2018 Berlin, February 23rd, 2018

Behavioral Equivalence

CSC313 High Integrity Systems/CSCM13 Critical Systems. CSC313/CSCM13 Chapter 1 1/ 38

Software Security: Vulnerability Analysis

Introduction to Axiomatic Semantics (1/2)

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

CSC313 High Integrity Systems/CSCM13 Critical Systems. CSC313/CSCM13 Chapter 2 1/ 221

Statement Basics. Assignment Statements

Static Analysis in C/C++ code with Polyspace

Static Analysis Techniques

System Correctness. EEC 421/521: Software Engineering. System Correctness. The Problem at Hand. A system is correct when it meets its requirements

Advanced Programming Methods. Introduction in program analysis

SPARK 2014 User s Guide

Behavioral Equivalence

Principles of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems)

Chapter 1. Introduction

Pierce Ch. 3, 8, 11, 15. Type Systems

Lectures 20, 21: Axiomatic Semantics

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Implementing Subprograms

A Correctness Proof for a Practical Byzantine-Fault-Tolerant Replication Algorithm

Leveraging Formal Methods for Verifying Models and Embedded Code Prashant Mathapati Application Engineering Group

CSCI-GA Scripting Languages

A Gentle Introduction to Program Analysis

(See related materials in textbook.) CSE 435: Software Engineering (slides adapted from Ghezzi et al & Stirewalt

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning

Violations of the contract are exceptions, and are usually handled by special language constructs. Design by contract

Programming Languages: Lecture 12

Enhance Verification using Ghost Code

Lecture 3 Notes Arrays

Verification by Static Analysis

Testing. Prof. Clarkson Fall Today s music: Wrecking Ball by Miley Cyrus

C07: Testing and JUnit

ABSTRACT INTERPRETATION

Contents. Program 1. Java s Integral Types in PVS (p.4 of 37)

From Design to Production

Safe Dynamic Memory Management in Ada and SPARK

CITS5501 Software Testing and Quality Assurance Formal methods

Lecture Notes on Arrays

Formal Verification in Aeronautics: Current Practice and Upcoming Standard. Yannick Moy, AdaCore ACSL Workshop, Fraunhofer FIRST

Program Verification. Program Verification 307/434

Runtime Checking for Program Verification Systems

2015 The MathWorks, Inc. 1

Green Hills Software, Inc.

Model-Based Design for High Integrity Software Development Mike Anthony Senior Application Engineer The MathWorks, Inc.

Chapter 10. Implementing Subprograms ISBN

By V-cubed Solutions, Inc. Page1. All rights reserved by V-cubed Solutions, Inc.

Seminar in Software Engineering Presented by Dima Pavlov, November 2010

Synchronization SPL/2010 SPL/20 1

G Programming Languages - Fall 2012

A Verified Implementation of the Bounded List Container

GeneAuto for Ada and SPARK

Testing, Debugging, and Verification

Modular and Verified Automatic Program Repairs

Static program checking and verification

The Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England

Deductive Verification in Frama-C and SPARK2014: Past, Present and Future

Lecture 10 Design by Contract

Petri Nets ~------~ R-ES-O---N-A-N-C-E-I--se-p-te-m--be-r Applications.

Bounded Model Checking Of C Programs: CBMC Tool Overview

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context

Static Analysis by A. I. of Embedded Critical Software

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

Introduction to Axiomatic Semantics

Specification and verification of a simple machine

Verification Overview Testing Theory and Principles Testing in Practice. Verification. Miaoqing Huang University of Arkansas 1 / 80

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.

Computer Security Course. Midterm Review

Warm-Up Problem. 1. What is the definition of a Hoare triple satisfying partial correctness? 2. Recall the rule for assignment: x (assignment)

Lecture 10: Introduction to Correctness

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference

Programming Languages Third Edition

Formal Methods in Software Development

L7.2.2 Deliverable - Final report on experimentations on industrial case studies

No model may be available. Software Abstractions. Recap on Model Checking. Model Checking for SW Verif. More on the big picture. Abst -> MC -> Refine

Combining Static and Dynamic Contract Checking for Curry

Transcription:

IEEE Software Technology Conference 2015 Hybrid Verification in SPARK 2014: Combining Formal Methods with Testing Steve Baird Senior Software Engineer Copyright 2014 AdaCore Slide: 1

procedure Array_Indexing_Bug (Buffer : in out String) is -- intended to change "ABCD" into "AABC", -- but high loop bound is bad begin for I in Buffer'First.. Buffer'Last loop Buffer (I + 1) := Buffer (I); end loop; end Array_Indexing_Bug;

"Program testing can be used to show the presence of bugs, but never to show their absence!" -- Edsger Dijkstra, 1970

Contract: agreement between the client and the supplier of a service Program contract: agreement between the caller and the callee subprograms

Each assertion serves three functions: a static proof goal during proving a dynamic consistency check during testing documentation for the human reader Because the same assertion serves all three functions, consistency is guaranteed. See Chalin's "Engineering a Sound Assertion Semantics for the Verifying Compiler".

Buffer overflows in Ada? Easily avoided by programmers (array types carry their bounds) Automatically caught at run-time Integer overflows in Ada? Easily avoided by programmers (using bounded integer types) Automatically caught at run-time Buffer and integer overflows in SPARK? If present, automatically caught by analysis If absent, automatic proof that no such error can occur Buffer overflows and integer overflows are still major sources of pain in C

Two advantages of formal verification: bugs which testing would have caught may be caught earlier bugs which testing would have missed may be caught

Assertions also serve as documentation for human readers

Quantified expressions: (for all I in Vec'Range => Vec (I) <= Max_Element) (for some I in Vec'Range => Vec (I) = Max_Element) Conditional expressions: (if Y /= 0 then X / Y else Integer'Last) (case Adjustment is when Double => 2 * X, when Increment => X + 1, when None => X) The Old attribute: procedure Increment (X : in out Integer) with Pre => X /= Integer'Last, Post => X = X'Old + 1; Expression functions: function Is_Even (X : Natural) return Boolean is (X mod 2 = 0);

Ghost code: useful for assertions in verification useful for consistency checks in testing can be safely and easily disabled in the final build

SPARK 2014 supports a large Ada subset concurrency (tasks and protected objects) object oriented programming (tagged types) recursion dynamic constraints

Combining tests and proofs P is tested P Q P calls Q How do we justify assumptions made during proof? Q calls P Q is proved verification combining tests and proofs should be AT LEAST AS GOOD AS verification based on tests only Copyright 2014 AdaCore Slide: 12

Caution: contracts are not only pre/post! strong typing parameters not aliased ) data dependences parameters initialized Copyright 2014 AdaCore Slide: 13

Implicit precondition violation examples: type Rec is record F1, F2 : Integer; end record; procedure P1 (X : Rec) is... ; procedure Q1 is Y : Rec; begin Y.F1 := 123; P1 (Y); -- parameter incompletely initialized end Q1; -------- Buffer : String (1.. 100); procedure P2 (X : in out String) with Global => (In_Out => Buffer) is ; procedure Q2 is begin P2 (X => Buffer); -- unsafe aliasing end Q2; Copyright 2014 AdaCore Slide: 14

Cost of testing Cost of testing greater than cost of development 10% increase each year for avionics software (Boeing META Project) Uneven partitioning: 80% of effort! Uneven quality: 80% of errors traced to 20% of code (NASA Software Safety Guidebook) Need to reduce and focus the cost of testing Copyright 2014 AdaCore Slide: 15

Proving and testing can be combined at different levels At the level of individual run-time checks: Focus test coverage on unproven checks At the level of individual subprograms: Proven subprograms call tested and vice versa. Use proofs to completely replace unit testing and executable contracts during integration testing Copyright 2014 AdaCore Slide: 16

Resources SPARK Pro webpage http://www.adacore.com/sparkpro SPARK community page http://www.spark-2014.org SPARK User s Guide http://docs.adacore.com/spark2014-docs/html/ug AdaCore University http://u.adacore.com Copyright 2014 AdaCore Slide: 17