Formal Techniques (CS340 © John C. Knight 2004)

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

© Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn 2.4 The Z Notation [Reference: M. Spivey: The Z Notation, Prentice Hall]
Copyright W. Howden1 Programming by Contract CSE 111 6/4/2014.
Semantics Static semantics Dynamic semantics attribute grammars
PZ03D Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03D - Program verification Programming Language Design.
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
© Colin Potts C6-1 Some future trends in requirements engineering Colin Potts Georgia Tech.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Software system modeling
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
ISBN Chapter 3 Describing Syntax and Semantics.
Formal Specification and Verification. Specifications Imprecise specifications can cause serious problems downstream Lots of interpretations even with.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
CS 355 – Programming Languages
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor Formal Methods in Software Engineering1.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Formal Methods: Z CS 415, Software Engineering II Mark Ardis, Rose-Hulman Institute March 18, 2003.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
CS 425/625 Software Engineering System Models
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
C SC 520 Principles of Programming Languages 1 C SC 520: Principles of Programming Languages Peter J. Downey Department of Computer Science Spring 2006.
©Ian Sommerville 2000Software Engineering, 6/e, Chapter 91 Formal Specification l Techniques for the unambiguous specification of software.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Describing Syntax and Semantics
School of Computer ScienceG53FSP Formal Specification1 Dr. Rong Qu Introduction to Formal Specification
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 10 Slide 1 Formal Specification.
MCA –Software Engineering Kantipur City College. Topics include  Formal Methods Concept  Formal Specification Language Test plan creation Test-case.
Specifications Liskov Chapter 9 SWE 619 Last Updated Fall 2008.
University of Toronto Department of Computer Science © 2001, Steve Easterbrook CSC444 Lec17 1 Lecture 17: Formal Modeling Methods Formal Modeling Techniques.
02/06/05 “Investigating a Finite–State Machine Notation for Discrete–Event Systems” Nikolay Stoimenov.
Requirements Expression and Modelling
Overview of Formal Methods. Topics Introduction and terminology FM and Software Engineering Applications of FM Propositional and Predicate Logic Program.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
School of Computing and Mathematics, University of Huddersfield CIA2326: Week 11 LECTURE: Formal Specification TUTORIAL/PRACTICAL: Finish off last weeks.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
ISBN Chapter 3 Describing Semantics.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Semantics In Text: Chapter 3.
ECSE Software Engineering 1I HO 4 © HY 2012 Lecture 4 Formal Methods A Library System Specification (Continued) From Specification to Design.
Software Engineering 2 -Prakash Shrestha.
CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Duminda WijesekeraSWSE 623: Introduction1 Introduction to Formal and Semi- formal Methods Based on A Specifier's Introduction to Formal Methods (J. Wing)
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Course: Software Engineering – Design I IntroductionSlide Number 1 What is a specification Description of a (computer) system, which:  is precise;  defines.
Formal Methods. What Are Formal Methods Formal methods refers to a variety of mathematical modeling techniques that are applicable to computer system.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11b: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
Requirements Specification
Formal Specification.
Describing Syntax and Semantics
Analysis Classes Unit 5.
Introduction to Formal Methods
Experiences and Status
Software Engineering: A Practitioner’s Approach, 6/e Chapter 11 Component-Level Design copyright © 1996, 2001, 2005 R.S. Pressman & Associates, Inc.
Specifications Liskov Chapter 9
Formal Verification/Methods
B (The language of B-Method )
Logical architecture refinement
Programming Languages and Compilers (CS 421)
IS 2935: Developing Secure Systems
Programming Languages 2nd edition Tucker and Noonan
Department of Computer Science Abdul Wali Khan University Mardan
Chapter 3 Describing Syntax and Semantics.
Software system modeling
Programming Languages 2nd edition Tucker and Noonan
Presentation transcript:

Formal Techniques (CS340 © John C. Knight 2004) Dependable Computing Formal Techniques Formal Techniques (CS340 © John C. Knight 2004) CS551/651 Fall 2003

Formal Techniques Syntax Checking Formal Specification Type Checking Analysis is possible because of mathematical semantics Formal specification uses a formal language with mathematical semantics Syntax Checking Type Checking Putative Theorems Formal Specification Establish useful properties of the specification Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques Formal Specification Direct Synthesis Correctness by construction Formal Specification Direct Synthesis Code Create software by a synthesis process Correctness the result of correct synthesis Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques Formal Specification Design & Code Refinement/Proof Correctness by construction Design & Code Refinement/Proof Create software by a series of refinements Prove that each refinement is correct Design & Code Refinement/Proof Code Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Formal Specification Correctness by chance Correctness proof Conventional Design And Code Formal Verification Correctness Proof Code Proof of partial correctness Proof of total correctness Correctness? Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques Formal Specification Model Checking Syntax Checking Analysis is possible because of mathematical semantics Model Checking Syntax Checking Type Checking Putative Theorems Formal specification uses a formal language with mathematical semantics Correctness by construction Formal Specification Direct Synthesis Code Correctness by construction Design & Code Refinement/Proof Code Correctness proof Formal Verification Correctness Proof Code Conventional Design And Code Correctness by chance Formal Techniques (CS340 © John C. Knight 2004)

Notations For Formal Specification Any notation with precise semantics can be used Formalism typically applied to just part of a specification Notations often use discrete mathematics, some with graphics Several notations are sometimes used in the same specification: Z or VDM for data manipulation Statecharts for system states and transitions Natural language for non-functional specifications Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Formal Specification There are lots of good notations, e.g.: PVS Statecharts Z SCR RSML Larch Experimental case studies have been quite positive but techniques not perfect Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Formal Specification Goals of formal specification: Complete, consistent, concise, unambiguous specifications Valid specifications—state exactly what the user wants Specifications based on formal semantic model Formal semantics permit dependable communication between all parties Case studies of use are very positive Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Formal Specification High-level language programs are just specifications! So this stuff should be familiar Declarative: Statement of the desired effect on system state Procedural: Statement of desired actions and their sequence Major approaches—declarative: Model-based specification Axiomatic specification Formal Techniques (CS340 © John C. Knight 2004)

Model-Based Specification Literally Build A Model Of The System You Want Components: System State Sets and functions State Changes Pre- & Post Conditions Predicate Calculus This is why and where discrete math comes in A model-based specification is much like a program But a model-based specification is NOT a procedural program Formal Techniques (CS340 © John C. Knight 2004)

Model-Based Specifications State Description (Sets, relations, etc) Invariants (Predicate Calculus) Operation Name & Pre/Post Condx REALLY Important REALLY Important (Pred Calculus) Pre Condition What Has To Be True Before An Operation Can Be Applied Post Condition What Has To Be True After An Operation Is Applied Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Z—Pronounced “Zed” Notation for model-based specification Similar to many other notations, e.g.: PVS VDM Using Z as an example, principles apply to other notations Z relatively popular, especially in Europe (see range of textbooks) Formal Techniques (CS340 © John C. Knight 2004)

Simple Z Example Simple Telephone Database (A. Diller) Add User System State Set of users, map from names to numbers Add User (Pre- And Post-Conditions) Change No. (Pre- And Post-Conditions) Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Simple Z Example Given sets State schema—set and relation Simple invariant Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Simple Z Example Before and after state Pre- and post-conditions Operation schema, one of many Formal Techniques (CS340 © John C. Knight 2004)

Some Other Z Components Functions Sequences Bags Schema calculus: Decoration Inclusion Composition Logical expressions Precondition analysis Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Statecharts Developed for specifying reactive systems Graphic! Overall, its VERY clever stuff First introduced in mid 1980’s Developed by David Harel at the Weizmann institute Original application was avionics for Lavi fighter, Israeli Aircraft Industries Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Statecharts Very Popular In U.S. Industry—Most Used “Formal” Technique Supported By Powerful Toolset: Statemate (iLogix, Inc) Adapted By Other Notations, E.g. RSML Incorporated Wholesale Into Others, E.g. UML Many Extensions Developed Formal Techniques (CS340 © John C. Knight 2004)

Part of Harel’s Stopwatch Formal Techniques (CS340 © John C. Knight 2004)

Basic States, State Transitions, Initial State States A, B, C Transitions r, s, t, u s(Y) Means Event s And Condition Y True Unlabeled Arc Represents Initial Transition (Entry To Initial State) Formal Techniques (CS340 © John C. Knight 2004)

Clustering And Refinement State D Is A Cluster—A State That Has Substates Cluster is XOR—System Will Be In State A Or B, Not Both Transition u Has Been Unified Formal Techniques (CS340 © John C. Knight 2004)

State Transition Example “a” and “d” are watch buttons Complex idea stated simply, easily, precisely Formal Techniques (CS340 © John C. Knight 2004)

Formal Techniques (CS340 © John C. Knight 2004) Orthogonality Dashed Line Reads “AND”—Exactly One State From Each Side Examples: D & A, D & B, D & C, E & B Formal Techniques (CS340 © John C. Knight 2004)

Part of Harel’s Stopwatch (Again) Formal Techniques (CS340 © John C. Knight 2004)