Top Banner
Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)
31

Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

Mar 27, 2015

Download

Documents

Melissa Carter
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

Program Verification: Theory and Practice

Sriram K. RajamaniMicrosoft Research India

(with thanks to Tom Ball for material from his course)

Page 2: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

2

Organization

• Instructors– Deepak D’Souza, IISc– Aditya Nori, MSR India– Sriram K. Rajamani, MSR India

• Teaching Assistant– Madhu Gopinathan, IISc

Page 3: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

3

PROBLEM

Page 4: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

4

Software validation problem

Does the software work?

Page 5: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

5

Software validation problem

Does the software work?

I hope it doesn’t crash!

I hope it still interoperates with my other software in the same way as the previous

version!

I hope some hacker cannot steal all my

money, and publish all my email on the web

I hope it can handle my peak

transaction load

Page 6: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

6

How do we do software validation?

Testing:

• The “old-fashioned” way

• Run it and see if it works

• Fix it if it doesn’t work

• Ship it if it doesn’t crash!

Page 7: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

7

What is wrong with testing?

Page 8: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

8

Page 9: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

9

Program Verification

The algorithmic discovery of properties of a program by inspection of the source text

- Manna and Pnueli, “Algorithmic Verification”

Also known as: static analysis, static program analysis, formal methods,….

Page 10: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

10

Difficulty of program verification

• What will you prove?– Specification of a complex software is as

complex as the software itself

• “Deep” specifications of software are hard to prove– State-of-art in tools and automation not good

enough

Page 11: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

11

Elusive triangle

11

Large programs

Deep properties Automation

We will let go of this one!

Page 12: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

12

Page 13: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

13

void Foo( int * ptr, int const * ptrToConst, int * const constPtr, int const * const constPtrToConst ) {

*ptr = 0; ptr = 0;

*ptrToConst = 0; ptrToConst = 0;

*constPtr = 0; constPtr = 0;

*constPtrToConst = 0; constPtrToConst = 0; }

Page 14: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

14

void Foo( int * ptr, int const * ptrToConst, int * const constPtr, int const * const constPtrToConst ) {

*ptr = 0; // OK: modifies the pointee ptr = 0; // OK: modifies the pointer

*ptrToConst = 0; // Error! Cannot modify the pointee ptrToConst = 0; // OK: modifies the pointer

*constPtr = 0; // OK: modifies the pointee constPtr = 0; // Error! Cannot modify the pointer

*constPtrToConst = 0; // Error! Cannot modify the pointee constPtrToConst = 0; // Error! Cannot modify the pointer }

Page 15: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

15

Page 16: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

16

Page 17: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

17

http://en.wikipedia.org/wiki/Microsoft_Platform_SDK

http://www.microsoft.com/whdc/devtools/tools/sdv.mspx

http://www.gotdotnet.com/team/fxcop/

http://research.microsoft.com/specsharp/

Page 18: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

18

Page 19: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

19

Page 20: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

20

Page 21: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

21

Worse is better, also called the New Jersey style, is the name of a computer software design approach (or design philosophy) in which simplicity of both interface and implementation is more important than any other system attribute (including correctness, consistency, and completeness).

http://en.wikipedia.org/wiki/Worse_is_Better

Page 22: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

22

http://en.wikipedia.org/wiki/Robert_Tappan_Morris

Page 23: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

2323

Page 24: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

2424

Page 25: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

25

Page 26: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

26

Page 27: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

27

unreachable

States

reachable

init

unsafe

unsafe

Page 28: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

28

Page 29: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

29

Page 30: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

30

Page 31: Program Verification: Theory and Practice Sriram K. Rajamani Microsoft Research India (with thanks to Tom Ball for material from his course)

31

Reading assignment…

• Read “Findbugs” paper

http://portal.acm.org/citation.cfm?doid=1108792.1108798

• Read “Java Bytecode Verification” paperhttp://Gallium.inria.fr/~xleroy/publi/survey-

bytecode-verification.ps.gz