Functional Verification I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 21.

Slides:



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

Functional Verification III Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 23.
Axiomatic Verification I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 17.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
CS 355 – Programming Languages
1 Math 306 Foundations of Mathematics I Math 306 Foundations of Mathematics I Goals of this class Introduction to important mathematical concepts Development.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Software Verification Bertrand Meyer Chair of Software Engineering Lecture 2: Axiomatic semantics.
Describing Syntax and Semantics
Copyright © 2007 Pearson Education, Inc. Slide 8-1.
CSE 755, part3 Axiomatic Semantics Will consider axiomatic semantics (A.S.) of IMP: ::=skip | | | | ; | | Only integer vars; no procedures/fns; vars declared.
Exam 2 Help Session Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification.
Proofs of Correctness: An Introduction to Axiomatic Verification Prepared by Stephen M. Thebaut, Ph.D. University of Florida CEN 5035 Software Engineering.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Joseph E. Hollingsworth
Control Structures CPS120: Introduction to Computer Science Lecture 5.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.5 Application: Correctness of Algorithms 1 [P]rogramming reliability – must be an activity.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
This Week Lecture on relational semantics Exercises on logic and relations Labs on using Isabelle to do proofs.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
White-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 7.
Proof And Strategies Chapter 2. Lecturer: Amani Mahajoub Omer Department of Computer Science and Software Engineering Discrete Structures Definition Discrete.
Axiomatic Verification II Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 18.
Functional Verification III
Cleanroom Software Engineering
Formal Methods in Software Engineering 1
White-Box Testing Techniques II
Prepared by Stephen M. Thebaut, Ph.D. University of Florida
Functional Verification IV: Revisiting Loop Invariants
Predicate Transforms II
Functional Verification IV: Revisiting Loop Invariants
Functional Verification III
White-Box Testing Techniques III
Formal Program Specification
Predicate Transforms I
White-Box Testing Techniques II
Functional Verification I
Programming Languages and Compilers (CS 421)
Exercise Solutions: Functional Verification
Programming Languages 2nd edition Tucker and Noonan
Formal Program Specification
Prepared by Stephen M. Thebaut, Ph.D. University of Florida
Exercise Solutions: Functional Verification
Axiomatic Verification II
White-Box Testing Techniques III
Functional Verification I
White-Box Testing Techniques I
Axiomatic Verification II
Axiomatic Verification I
Predicate Transformers
Proofs of Correctness: An Introduction to Axiomatic Verification
Functional Verification II
Functional Verification IV: Revisiting Loop Invariants
Axiomatic Verification I
Predicate Transforms I
Prepared by Stephen M. Thebaut, Ph.D. University of Florida
Functional Verification III
Predicate Transforms II
Functional Verification III
Algebraic Specification Software Specification Lecture 34
Functional Verification IV: Revisiting Loop Invariants
Predicate Transforms I
Prepared by Stephen M. Thebaut, Ph.D. University of Florida
Model-based vs. Functional Program Specification and Correctness
Formal Program Specification
Programming Languages 2nd edition Tucker and Noonan
Presentation transcript:

Functional Verification I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 21

Overview of Functional Verification Topics Lecture Notes #21 - Functional Verification I Introduction Verifying correctness in program reading, writing, and validation Complete and sufficient correctness Compound programs and the Axiom of Replacement Lecture Notes #22 - Functional Verification II Correctness conditions and working correctness questions: sequencing and decision statements

Lecture Notes #23 - Functional Verification III Iteration Recursion Lemma (IRL) (Very Cool!) Termination predicate Correctness conditions for while_do statement Sufficient correctness conditions Correctness conditions for repeat_until statement Subgoal Induction Lecture Notes #24 – Functional Verification IV Invariant Status Theorem (EXTREMELY Cool!) While Loop Initialization Overview of Functional Verification Topics

Today’s Topics: Introduction Verifying correctness in program reading, writing, and validation Complete and sufficient correctness Compound programs and the Axiom of Replacement

Introduction What is functional verification? A methodology originally developed by Mills for verifying program correctness with respect to an intended function specification. It represents a viable alternative to the axiomatic verification method developed by Hoare and Floyd.

Introduction (cont’d) References: Linger, Mills, & Witt, Structured Programming: Theory and Practice, Addison-Wesley, Dunlop & Basili, “A Comparative Analysis of Functional Correctness,” Computing Surveys, Vol. 14, No. 2, June † Linger, “Cleanroom Software Engineering for Zero- Defect Software,” Proceedings, 15th Int. Conf. on Soft. Eng. (1993), IEEE Computer Society Press. † † Required readings.

Tasks in Program Reading, Writing, and Verification Program Reading: –Abstract a given program construct (e.g., an if_then_ else statement) into a hypothesized function f. –To confirm that your understanding of the program is correct, show: f = [if p then G else H]

Tasks in Program Reading, Writing, and Verification (cont’d) Program Writing: –Expand a given function f into a hypothesized program construct (e.g., an if_then_else statement). –To confirm that your expansion of f into a program is correct, show: f = [if p then G else H]

Tasks in Program Reading, Writing, and Verification (cont’d) Program Verification: –You are given both function f and its hypothesized program expansion (e.g., an if_then_ else statement). –To confirm the correctness of the hypothesized program expansion with respect to f, show: f = [if p then G else H]

Tasks in Program Reading, Writing, and Verification (cont’d) In all three cases, the final task is to confirm the equivalence (or subset relationship) of two expressions, each representing the function of a program.

Complete and Sufficient Correctness Given a function f and a program P (claimed to implement f ), correctness is concerned with one of two questions: 1.Is f = [P] ? (“Is f equivalent to the function computed by P ?”) – A question of complete correctness. 2.Is f  [P] ? (“Is f a subset of the function computed by P ?”) – A question of sufficient correctness.

Complete and Sufficient Correctness (cont’d) In the case of complete correctness, P computes the correct values of f for arguments in D(f) only; [P] is undefined (P does not terminate) for arguments outside D(f). In the case of sufficient correctness, P may compute values from arguments not in D(f). Note that, by definition, f = [P] implies f  [P]

Correctness Relationships f [P][P] f [P][P] [P], f f [P][P] (X,Y) f  (X,Y)  [P] (X,Y) f  (X,Y)  [P]

Example For integers x,y consider the function: f = (y≥0  x,y := x+y,0) and the programs: P 1 = while y>0 do x,y := x+1,y-1 P 2 = while y<>0 do x,y := x+1,y-1 Use heuristics to hypothesize functions for P 1 and P 2 and compare these to f.

Example (cont’d) Consider P 1 = while y>0 do x,y := x+1,y-1 y>0  y=0  y<0  f = (y≥0  x,y := x+y,0)

Example (cont’d) Consider P 2 = while y<>0 do x,y := x+1,y-1 y>0  y=0  y<0  f = (y≥0  x,y := x+y,0)

Example (cont’d) Both programs satisfy sufficient correctness. (Both correctly compute f(x,y) for y≥0.) Only P 2 satisfies complete correctness. (P 1 terminates for negative y.)

Defensive Programming: Handling Invalid Inputs f and P can be redefined to handle invalid inputs: f’ = (y≥0  x,y,z := x+y,0,z | true  x,y,z := x,y,‘error’) P’ = if y<0 then z := ‘error’ else while y>0 do x,y := x+1,y-1 end_while end_if_then_else Does f’ = [P’] ?

Exercise Given P = if x>=y then x,y := y,x f 1 = (x>y  x,y := y,x | true  I) f 2 = (x>y  x,y := y,x | x<y  I) f 3 = (x≠y  x,y := y,x) Fill in the following “correctness table”: f1f1 f2f2 P f3f3 “Identify” function: x,y := x,y C=Complete (and Sufficient) S=Sufficient (only) N=Neither

Compound Programs and the Axiom of Replacement The algebraic structure of compound program P permits decomposition into a hierarchy of abstractions. The proof of correctness of P is thereby decomposed into a proof of correctness of each such abstraction.

Compound Programs and the Axiom of Replacement (cont’d) For example, to show that compound program F implements function f, where F = if p then G else H and G, H are themselves programs: –hypothesize functions g, h and attempt to prove g = [G] and h = [H]

Compound Programs and the Axiom of Replacement (cont’d) –If successful, use the Axiom of Replacement to reduce the problem to proving f = if p then g else h –If successful again, you will have proved f = [F]

Compound Programs and the Axiom of Replacement (cont’d) Thus, the Axiom of Replacement allows one to prove the correctness of complex programs in a bottom-up, incremental fashion. In the next lecture, we consider correctness conditions for sequencing and decision statements.

Functional Verification I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture Notes 21