Addressing the Challenges of Current Software. Questions to Address Why? What? Where? How?

Slides:



Advertisements
Similar presentations
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Advertisements

.NET Technology. Introduction Overview of.NET What.NET means for Developers, Users and Businesses Two.NET Research Projects:.NET Generics AsmL.
This research is funded in part the U. S. National Science Foundation grant CCR DEET for Component-Based Software Murali Sitaraman, Durga P. Gandi.
Building Bug-Free O-O Software: An Introduction to Design By Contract A presentation about Design By Contract and the Eiffel software development tool.
Computer Science School of Computing Clemson University Introduction to Mathematical Reasoning Jason Hallstrom and Murali Sitaraman Clemson University.
School of Computing Clemson University Mathematical Reasoning  Goal: To prove correctness  Method: Use a reasoning table  Prove correctness on all valid.
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
(c) 2007 Mauro Pezzè & Michal Young Ch 7, slide 1 Symbolic Execution and Proof of Properties.
CS 355 – Programming Languages
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Formal Methods. Importance of high quality software ● Software has increasingly significant in our everyday activities - manages our bank accounts - pays.
1 Specifying Object Interfaces. 2 Major tasks in this stage: --are there any missing attributes or operations? --how can we reduce coupling, make interface.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
Describing Syntax and Semantics
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Mathematics throughout the CS Curriculum Support by NSF #
Jason Hallstrom (Clemson), Joan Krone (Denison), Joseph E. Hollingsworth (IU Southeast), and Murali Sitaraman(Clemson) This workshop is funded in part.
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Murali Sitaraman
Object Oriented Data Structures
Object-Oriented Software Testing. C-S 5462 Object-Oriented Software Testing Research confirms that testing methods proposed for procedural approach are.
Computer Science School of Computing Clemson University Specification and Reasoning in SE Projects Using a Web IDE Charles T. Cook (Clemson) Svetlana V.
Computer Science School of Computing Clemson University Mathematical Reasoning across the Curriculum Software Development Foundations and Software Engineering.
Lecture 16 March 22, 2011 Formal Methods CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
Introduction Ellen Walker CPSC 201 Data Structures Hiram College.
Computer Science School of Computing Clemson University Introduction to Formal Specification Murali Sitaraman Clemson University.
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Lecture 17 March 24, 2011 Formal Methods 2 CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
Overview of Formal Methods. Topics Introduction and terminology FM and Software Engineering Applications of FM Propositional and Predicate Logic Program.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Joseph E. Hollingsworth
Introduction to Data Structures and Algorithms CS 110: Data Structures and Algorithms First Semester,
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
Data Abstaraction Chapter 10.
Chapter 3 Part II Describing Syntax and Semantics.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
This research is funded in part by grant CCR from the U. S. National Science Foundation. Profiles: A Compositional Mechanism for Performance Specification.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Computer Science School of Computing Clemson University Mathematical Reasoning with Objects.
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
Course: Software Engineering – Design I IntroductionSlide Number 1 What is a specification Description of a (computer) system, which:  is precise;  defines.
Integrating Math Units and Proof Checking for Specification and Verification SAVCBS Workshop 2008 SIGSOFT 2008 / FSE 16 November 9th, 2008 Hampton Smith.
Lecture 18 March 29, 2011 Formal Methods 3 CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
Software Testing.
Modular Alternatives to Testing
Component Implementations Using RESOLVE
Formal Specification of Java Interfaces
Cinda Heeren / Geoffrey Tien
Design by Contract Fall 2016 Version.
Specifying Object Interfaces
Introduction to Data Structures
Introduction to Components and Specifications Using RESOLVE
Programming Languages 2nd edition Tucker and Noonan
Hoare-style program verification
Formal Specification of Interfaces
Introduction to Components and Specifications Using RESOLVE
Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract, Computer,
Mathematical Reasoning
Programming Languages and Paradigms
Mathematical Reasoning with Data Abstractions
CSE 1020:Software Development
Programming Languages 2nd edition Tucker and Noonan
Formal Methods Lecture 16 March 22, 2011 CS 315 Spring 2011
Presentation transcript:

Addressing the Challenges of Current Software

Questions to Address Why? What? Where? How?

Some Work Binary search specifications Java C++ Any other language Are the algorithms correct? Do the implementations work? What’s the difference?

Why? Current software is too large for one person to understand. Students need tools for dealing with all sizes of projects. Maintenance makes up the majority of jobs. Students need to separate specifications from implementations.

What reasoning skills are necessary? Concept Inventory Boolean LogicStandard Logic Symbols, Standard Proof Techniques Discrete Math StructuresSets, Strings, Numbers, Relations, and other mathematical theories as needed Precise SpecificationsMathematical Descriptions of Software interfaces for clients and implementers. Math models for structures Pre and Post conditions for operations. Modular ReasoningEach Module needs to be proven correct only once. Verification ConditionsMathematical Assertions equivalent to the correctness of the program. Correctness ProofsApplication of Proof Techniques to the program

Specifications for Increment Operation Increment(updates i: int) requires i < max_int; ensures i = #i + 1;

Implementation of Increment Increment(updates i: int); i = i + 1; end Increment;

Reason about Increment Does the implementation meet the specification? How does the requires clause it in? Are there other possible implementations? Subtract 4 and add 5? Why not?

Work Write specifications for Decrement (requires and ensures clauses) Write an implementation assuming that there is a built in minus for integers.

Work Specify (write requires and ensures clauses )an operation that receives an integer and returns the value of that integer plus two. Implement your operation assuming you can access the operation “Increment.”

Operation PlusTwo(updates i: int); requires i < max_int – 1; ensures i = #i + 2; PlusTwo( updates i: int) Increment(i); end PlusTwo

Reason about the Program

Reasoning Table Operation PlusTwo State NumberAssumeConfirm 0i < max_int - 1 Increment(i) 1i1 = i0 + 1i < max_int Increment(i) 2i2 = i1 + 1i2 = i0 + 2

Work Specification: Operation Exchange(updates I, J: Integer); ensures I = #J and J = #I; Code: Procedure Exchange(updates I, J: Integer); I := Sum(I, J); J := Difference(I, J); I := Difference(I, J); End Exchange;

Are the Specs Sufficient? What about min_int and max_int? Add a requires clause

Need to Know Operation Difference (updates I: int, preserves J: int); requires I – J min_int; ensures I = I – J; Operation Sum (updates I: int, preserves J: int); requires I + J min_int; ensures I = I + J;

Reasoning Table State NumberAssumeConfirm 0I0 – J0 < max_int and I0 – J0 > min_int I = Difference(I, J); 1I1 = I0 – J0 and J1 = J0 J = Difference(I, J); 2J2 = I1 – J1 and I2 = I1 I = Difference(I, J); 3I3 = I2 - J2 and J3 = J2I3 = J0 and J3 = I0 Operation Exchange

More examples asoning.html asoning.html

Beyond Arithmetic Specifying components Work: How do java and C++ (or your favorite language) specify stacks?

Specify a stack mathematically Describe in terms of mathematical strings For generality, describe all stacks with one spec Allow for multiple implementations to promote efficiency

Requirements vs. Specifications Requirements definition Intended for customers in addition to software developers Informal descriptions are necessary Specification For use by members of a software development team Formal (mathematical) descriptions are necessary 21

Informal Specification: Examples C++ STL Template specifications Java util component specifications Questions for discussion Do they support information hiding? Do they support abstraction? Can they generalize? Is it possible to make them unambiguous? 22

Informal Specifications Straightforward descriptions Push pushes an item onto the top of this stack How much do they help? Use of metaphors A Queue is like a line at a fast food restaurant Do they generalize? Use of implementation details Push behaves like addElement method on Vector Is this appropriate for a user-oriented cover story? 23

Formal Interface Specification Communicates precisely the demands and responsibilities to component users and developers Allows for independent development of client and implementation components in parallel in a team environment Minimizes integration costs 24

Reasoning Benefits Formal Specifications make it possible to formally reason about correctness of software Such reasoning may be manual or mechanical (i.e. with automate support) 25

Languages for Formal Specification ANNA (and SPARK) for Ada JML for Java Larch/C++ for C++ Spec# for C3 … Eiffel RESOLVE … VDM Z 26

Specification Language Summary Some specification languages are designed for particular programming languages Some are general purpose Some specification languages are integrated with programming constructs A few additionally integrate the ability to perform formal mathematical reasoning 27

Meaning of Specifications Requirements and guarantees Requires clauses are preconditions Ensures clauses are postconditions Callers are responsible for requirements Caller of Increment is responsible for making sure I < max_int Guarantees hold only if callers meet their requirements 28

Mathematical Strings Unlike sets, strings have order Example: Str(Z) for String of integers Notations Empty string (written: empty_string or  ) Concatenation: alpha o beta Length (written: |alpha| ) String containing one entry (e.g., ) 29

General Stack Template Specification We will use general stacks for this example reasoning Suppose Stack_Template is parameterized by type Entry and Integer Max_Depth Mathematical Modeling Type_Family Stack ⊆ Str(Entry); exemplar S; constraints |S| ≤ Max_Depth; initialization ensures S = Λ; 30

Specification of Stack Operations Operation Push (alters E: Entry; updates S: Stack) requires |S| < Max_Depth; ensures S = o #S; Operation Pop (replaces R: Entry; updates S: Stack) requires |S| > 0; ensures #S = o S; Operation Depth (restores S: Stack): Integer ensures Depth = |S|; 31

Example Specification Operation Do_Nothing (restores S: Stack) ensures S = #S Code: (Same as S.Push(S.Pop()) in Java) Procedure Do_Nothing (restores S: Stack) Var E: Entry Pop(E,S); Push(E,S); end Do_Nothing; 32

Exercise: Complete Table and Prove AssumeConfirm 0…… Pop(E, S); 1…… Push(E, S); 2…… CS 315 Spring

Example Specification Operation Do_Nothing (restores S: Stack) requires |S| > 0; ensures S = #S Code: (Same as S.Push(S.Pop()) in Java) Procedure Do_Nothing (restores S: Stack) Var E: Entry Pop(E,S); Push(E,S); end Do_Nothing; 34

Exercise: Complete Table and Prove AssumeConfirm 0…|S0| > 0 Pop(E, S); 1S0 = o S1|S1| < Max_Depth Push(E, S); 2S2 = o S1S2 = S0 CS 315 Spring Answers

What’s the Problem? Can you guarantee that Pop will do the right thing? What if your code first did a Push and then a Pop?

Work Write a generic specification for Queues.

Generic Component Examples

Proof Rules

Proof Rules for Verification code: Assume B; code1; Confirm Q; code; Assume B; code2; Confirm Q; code; If B then code1 else code2; endif; Confirm Q; No need to consider individual states.

Example Assume y ≠ 0; z := w/y; if z ≥ 0 then abs := z else abs := -z endif; Confirm abs = |w/y|;

Apply the rule automatically (1) Assume y ≠ 0; z := w/y; Assume z ≥ 0 ; abs := z; Confirm abs = |w/y|; (2) Assume y ≠ 0; z := w/y; Assume  (z ≥ 0); abs := z; Confirm abs = |w/y|;