Introducing Formal Methods. Software Engineering and Formal Methods



Similar documents
Structure of Presentation. Stages in Teaching Formal Methods. Motivation (1) Motivation (2) The Scope of Formal Methods (1)

Rigorous Software Development CSCI-GA

Specification and Analysis of Contracts Lecture 1 Introduction

Automated Theorem Proving - summary of lecture 1

TECH. Requirements. Why are requirements important? The Requirements Process REQUIREMENTS ELICITATION AND ANALYSIS. Requirements vs.

Formal Verification and Linear-time Model Checking

Verifying Specifications with Proof Scores in CafeOBJ

CHAPTER 7 GENERAL PROOF SYSTEMS

VDM vs. Programming Language Extensions or their Integration

Trust but Verify: Authorization for Web Services. The University of Vermont

LECTURE NOTES ON SOFTWARE ENGINEERING Course Code: BCS-306

Manufacturing View. User View. Product View. User View Models. Product View Models

The Model Checker SPIN

CSE4213 Lecture Notes

How To Improve Software Quality

The ProB Animator and Model Checker for B

Automated Program Behavior Analysis

Overview of the TACITUS Project

Chapter 8 Software Testing

CSTE Mock Test - Part I - Questions Along with Answers

Temporal Logics. Computation Tree Logic

META DATA QUALITY CONTROL ARCHITECTURE IN DATA WAREHOUSING

Chapter 10. Practical Database Design Methodology. The Role of Information Systems in Organizations. Practical Database Design Methodology

Fundamentals of Measurements

Software Testing. Quality & Testing. Software Testing

Industrial case study: Zero defect secure software for the National Security Agency

Software Engineering Reference Framework

Engineering Process Software Qualities Software Architectural Design

Execution of A Requirement Model in Software Development

InvGen: An Efficient Invariant Generator

Model Checking: An Introduction

Requirements Analysis that Works!

From Workflow Design Patterns to Logical Specifications

Towards a Framework for Generating Tests to Satisfy Complex Code Coverage in Java Pathfinder

Adversary Modelling 1

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Software Requirements

An Automated Development Process for Interlocking Software that. Cuts Costs and Provides Improved Methods for Checking Quality.

Neighborhood Data and Database Security

StaRVOOrS: A Tool for Combined Static and Runtime Verification of Java

Chapter 1: Introduction

4 Testing General and Automated Controls

Certification Authorities Software Team (CAST) Position Paper CAST-13

Foundational Proof Certificates

Formal Methods for Software Engineering

Introduction to Formal Methods. Các Phương Pháp Hình Thức Cho Phát Triển Phần Mềm

Language-oriented Software Development and Rewriting Logic

Goal-Oriented Requirements Engineering: An Overview of the Current Research. by Alexei Lapouchnian

Algorithms are the threads that tie together most of the subfields of computer science.

Object-Oriented Software Specification in Programming Language Design and Implementation

Java Programming (10155)

Development of dynamically evolving and self-adaptive software. 1. Background

CS Master Level Courses and Areas COURSE DESCRIPTIONS. CSCI 521 Real-Time Systems. CSCI 522 High Performance Computing

The SPES Methodology Modeling- and Analysis Techniques

Software Modeling and Verification

An Approach for Generating Concrete Test Cases Utilizing Formal Specifications of Web Applications

Automated Test Generation

Semester Review. CSC 301, Fall 2015

Questions? Assignment. Techniques for Gathering Requirements. Gathering and Analysing Requirements

Journal of Mathematics Volume 1, Number 1, Summer 2006 pp

Lesson 8: Introduction to Databases E-R Data Modeling

(Refer Slide Time: 01:52)

[Refer Slide Time: 05:10]

Formal Software Testing. Terri Grenda, CSTE IV&V Testing Solutions, LLC

Chapter 8 The Enhanced Entity- Relationship (EER) Model

How To Develop Software

How To Validate Software

Total Quality Management (TQM) Quality, Success and Failure. Total Quality Management (TQM) vs. Process Reengineering (BPR)

VeriTech - A Framework for Translating among Model Description Notations

02-201: Programming for Scientists

How To Write A Program Verification And Programming Book

The Import & Export of Data from a Database

Fourth generation techniques (4GT)

CS510 Software Engineering

Modelling and Verification of Business Processes

Software Requirements. Descriptions and specifications of a system. Ian Sommerville 2000 Software Engineering, 6th edition.

! " # The Logic of Descriptions. Logics for Data and Knowledge Representation. Terminology. Overview. Three Basic Features. Some History on DLs

How To Develop Software

BUSINESS RULES CONCEPTS... 2 BUSINESS RULE ENGINE ARCHITECTURE By using the RETE Algorithm Benefits of RETE Algorithm...

Software testing. Objectives

TRU Math Conversation Guide

WOLLONGONG COLLEGE AUSTRALIA. Diploma in Information Technology

Budapest University of Technology and Economics Department of Measurement and Information Systems. Business Process Modeling

A Framework for the Semantics of Behavioral Contracts

Axiomatic design of software systems

Ontologies for Enterprise Integration

Functional Decomposition Top-Down Development

Process Models and Metrics

ML for the Working Programmer

Rigorous Methods for Software Engineering (F21RS1) High Integrity Software Development

On the Modeling and Verification of Security-Aware and Process-Aware Information Systems

Data Governance. David Loshin Knowledge Integrity, inc. (301)

Transcription:

Introducing Formal Methods Formal Methods for Software Specification and Analysis: An Overview 1 Software Engineering and Formal Methods Every Software engineering methodology is based on a recommended development process proceeding through several phases:» Analysis,Specification,Design,Coding,Unit Testing, Integration and System Testing, Maintenance Formal methods can:» Be a foundation for describing complex systems» Be a foundation for reasoning about systems» Provide support for program development Complimentary approach to methodology! 2

Testing: Static vs Dynamic Analysis Static analysis of code Does not require execution of code» Lexical analysis of the program syntax and investigates and checks the structure and usage of individual statements; often automated Dynamic Analysis of code Involves running the system (testing)» Program run formally under controlled conditions with specific results expected» Path and Branch Testing 3 What are Formal Methods? Techniques and tools based on mathematics and formal logic Can assume various forms and levels of rigor least rigorous Occasional mathematical notation embedded in English specifications spectrum of rigor most rigorous Fully formal specification languages with a precise semantics 4

Why Consider Formal Methods? Systems are increasingly dependent on software components Complexity of systems with embedded software has increased rapidly Maintaining reliability in software-intensive systems is very difficult System Complexity Time 5 Formal Methods Concepts Formal Specification Methods Formal Formal Model Abstraction Specifications Proofs Checking 6

Formal Specifications Translation of a non-mathematical description (diagrams, tables, English text) into a formal specification language Concise description of high-level behavior and properties of a system Well-defined language semantics support formal deduction about specification L 4 7 Types of Specifications I Informal» Free form, natural language» Ambiguity and lack of organization can lead to incompleteness, inconsistency, and misunderstandings Formatted» Standardized Syntax» Basic consistency and completeness checks» Imprecise semantics implies other sources of error may still be present 8

Types of Specifications II Formal» Syntax and semantics rigorously defined» Precise form, perhaps mathematical» Eliminate imprecision and ambiguity» Provide basis for mathematically verifying equivalence between specification and implementation» May be hard to read without training» Semantic distance? 9 Formal Specifications Goal: Describe external behaviour without describing or constraining implementation Formal Method has 2 parts:» Logical Theory: Means by which one reasons about specifications, properties and programs First order predicate calculus (quantification over variables) Second order predicate calculus (quantification over relations) Temporal logic» Structuring Theory: Defines elements being reasoned about 10

Types of Formal Specifications Property Oriented: State desired properties in a purely declarative way» Algebraic: Data type viewed as an algebra, axioms state properties of data type s operations» Axiomatic: Uses first order predicate logic, pre and post conditions Operational Specification: Describe desired behaviour by providing model of system Model Oriented: Provide direct way of describing system behaviour (sets, sequences, tuples, maps) :» Abstract Model (in terms previously defined mathematical objects eg. sets, sequences, functions, mappings)» State machines 11 Property Oriented: Algebraic Specifications Uses» Input-Output Assertions» Sets of operations» Axioms specifying behaviour of operations Two parts to a specification» syntax» axioms 12

Model Oriented: Abstract Model Specifications Build an abstract model of required software behaviour using mathematically defined types (sets, relations) Define operations by showing effects of that operation on the model Specification includes:» Model Type» Invariant properties of model» For each operation Name, parameters, return values» Pre- and Post- conditions 13 Example Problem: The English Specification A space platform contains a number of instruments. Several communications channels are provided allowing both input and output instrument communications. Platform instruments may be placed in active or inactive states. Only active instruments may be assigned to I/O-channels. Active instruments may be assigned to more than one I/O-channel, up to some maximum number of I/O-channels per instrument. Further, I/O-channels may be shared by several active instruments, up to some maximum number of instruments shared per I/O-channel. The objective is to construct a specification, that will manage the assignment of communication I/O-channels to spacecraft platform instruments. 14

Example Assignments A B C1 C C2 D C3 Instruments I/O Channels 15 Z Specification: Basic Variables and Invariants Invariants are stated as the predicate IO_Channel_Assignments Basic_Types active_instruments : P Platform_Instruments assigned_to : Communications_Channels «Platform_Instruments available, busy: P Communications_Channels range assigned_to [subset of] active_instruments available busy = f 16

Completed Make_An_Assignment 0 Schema Make_An_Assignment 0 IO_Channel_Assignments instrument? : Platform_Instruments channel? : Communications_Channels instrument? active_instruments channel? available #(assigned_to > {instrument?}) < Max_Channels channel? -> instrument? assigned_to active_instruments' = active_instruments assigned_to' = assigned_to {channel?->instrument?} [#({channel?} < assigned_to) < Max_Instruments-1] \/ [#({channel?} < assigned_to) = Max_Instruments-1 /\ available' = available - {channel?} /\ busy' = busy {channel?}] 17 Z Specification: Schema for Error Condition Instrument_Not_Active X IO_Channel_Assignments instrument? : Platform_Instruments message! : Possible_Message instrument? ˇ active_instruments message! = instrument_not_active 18

Interesting Thought Problem Alice and Bill throw a party, and invite 4 other couples. As each couple arrived, there are greetings and handshakes. At the end of the party, Bill asked everyone, including Alice, how many people they shook hands with: Every answer was different! How many hands did Alice shake?»n.b: No one shakes hands with their own partner or themselves. You greet a person only once. 19 Formal Methods Concepts Formal Specification Methods Formal Formal Model Abstraction Specifications Proofs Checking 20

Formal Proofs Complete and convincing argument for validity of some property of the system description Constructed as a series of steps, each of which is justified from a small set of rules Eliminates ambiguity and subjectivity inherent when drawing informal conclusions May be manual but usually constructed with automated assistance L 4 21 Model Checking Operational rather than analytic State machine model of a system is expressed in a suitable language Model checker determines if the given finite state machine model satisfies requirements expressed as formulas in a given logic Basic method is to explore all reachable paths in a computational tree derived from the state machine model L 4 22

Abstraction Simplify and ignore irrelevant details Focus on and generalize important central properties and characteristics Avoid premature commitment to design and implementation choices L 4 23 Program as Mathematical Object Program Mathematical Object Programming Language Mathematical Language Can prove properties about the program I F O F(I) O 24

Formal Specification Languages Based on formal mathematical logic, with some programming language enhancements (such as type systems and parameterization) Generally non-executable -- designed to specify what is to be computed, not how the computation is to accomplished Most are based on axiomatic set theory or higher-order logic 25 Features of Specification Languages Explicit semantics. Language must have a mathematically secure basis. Expressiveness» flexibility» convenience» economy of expression Programming language data types» records» tuples» etc. 26

Features of Specification Languages (cont d) Convenient syntax Diagrammatic notation Strong typing» can be much richer than programming languages» provides economy and clarity of expression» type-checking provides consistency checks Total vs. partial functions» most logics assume total functions» subtypes can help make total functions more flexible 27 Features of Specification Languages (cont d) Axioms and definitions» axioms can introduce inconsistencies and should be used judiciously» definitional principle assures that definitions are well- formed» in some languages (e.g. PVS) type-checking conditions (to be proved) will be generated to assure sound definitions Modularization» breaking a specification into modules is an important organizational feature» parameterized modules allow reusability 28

Features of Specification Languages (cont d) Built-in model of computation» to discharge simple type-checking constraints» enhance proof-checking Maturity» documentation» tool support» associated literature» libraries of proven specifications» some measure of standardization 29 Logical Errors in Formal Specifications Logical inconsistency. Easiest logical errors to detect. Categories of Logical Anomalies Likely Accuracy -- does the specification mean what is intended? System invariants can help in detection. Completeness -- does the specification identify all contingencies and specify appropriate behavior for all cases? Peer review can aid in detection. 30

Techniques for Detection of Errors in Formal Specifications The following error detection techniques are listed in increasing order of rigor and cost of application. Inspection of the formal specification (manual) Parsing for syntactic correctness (automated) Type-checking for semantic consistency (automated) Simulation/animation based on the specification (automated). Only possible if the language provides an execution option. Theorem proving, proof-checking, model-checking for logical anomalies 31 Formal Specifications as a System Description Clarify requirements and high-level design Articulate implicit assumptions Identify undocumented or unexpected assumptions Expose flaws Identify exceptions Evaluate test coverage 32

Benefits of Formal Specifications Higher level of rigor enables a better understanding of the problem Defects are uncovered that would likely go unnoticed with traditional specification methods Identify defects earlier in life cycle Can guarantee the absence of certain defects L 4 33 Benefits of Formal Specifications (cont d) Formal specification language semantics allow checks for self-consistency of a problem specification Formal specifications enable formal proofs which can establish fundamental system properties and invariants Repeatable analysis means reasoning and conclusions can be checked by colleagues L 4 34

Benefits of Formal Specifications (cont d) Encourages an abstract view of system -- focusing on what a proposed system should accomplish as opposed to how to accomplish it Abstract formal view helps separate specification from design Enhances existing review processes by adding a degree of rigor L 4 35 Limitations to Formal Methods Used as an adjunct to, not a replacement for, standard quality assurance methods Formal methods are not a panacea, but can increase confidence in a product s reliability if applied with care and skill Very useful for consistency checks, but can not assure completeness of a specification 36

Cautions in the Use of Formal Methods Judicious application to suitable project environments is critical if benefits are to exceed costs FM and problem domain expertise must be fully integrated to achieve positive results 37 Conclusion FM are no panacea FM can detect defects earlier in life cycle FM can be applied at various levels of resource investment FM can be integrated within existing project process models FM can improve quality assurance when applied judiciously to appropriate projects 38