/
Specification and 	Verification of Specification and 	Verification of

Specification and Verification of - PowerPoint Presentation

partysilly
partysilly . @partysilly
Follow
342 views
Uploaded On 2020-06-18

Specification and Verification of - PPT Presentation

ObjectOriented Software K Rustan M Leino Research in Software Engineering RiSE Microsoft Research Redmond WA part 1 International Summer School Marktoberdorf Marktoberdorf Germany ID: 781059

satisfying assert assume true assert satisfying true assume check state traces command execution length lines language wrong trace terminating

Share:

Link:

Embed:

Download Presentation from below link

Download The PPT/PDF document "Specification and Verification of" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Specification and Verification of Object-Oriented Software

K. Rustan M. LeinoResearch in Software Engineering (RiSE)Microsoft Research, Redmond, WA

part 1

International Summer School

Marktoberdorf

Marktoberdorf

, Germany

7 August 2008

Slide2

Verification condition (logical formula)

Source language

Intermediate verification language

Basic verifier architecture

Slide3

Command language

x := Ex := x + 1x := 10havoc x

assert

P

assume

P

P

¬

P

P

Dotted lines indicate traces whose length may be greater than 1

Solid lines indicate traces whose length is 1

Slide4

Command language

S ; T

Dotted lines indicate traces whose length may be greater than 1

Solid lines indicate traces whose length is 1

Slide5

Command language

x := Ex := x + 1x := 10havoc xS ; T

assert

P

assume

PS  T

P

¬

P

P

Dotted lines indicate traces whose length may be greater than 1

Solid lines indicate traces whose length is 1

Slide6

Reasoning about execution traces

Hoare triple { P } S { Q } says that every terminating execution trace of S that starts in a state satisfying Pdoes not go wrong, andterminates in a state satisfying QGiven P and Q, what is the largest

S’

satisfying {P}

S’

{Q} ?to check {P} S {Q}, check S  S’

Slide7

Reasoning about execution traces

Hoare triple { P } S { Q } says that every terminating execution trace of S that starts in a state satisfying Pdoes not go wrong, andterminates in a state satisfying QGiven S and Q, what is the weakest

P’

satisfying {

P’

} S {Q} ?P' is called the weakest precondition of S with respect to Q, written wp(S, Q)to check {P} S {Q}, check P  P’

Slide8

Reasoning about execution traces

Hoare triple { P } S { Q }

says that

every terminating execution trace of S that starts in a state satisfying P

does not go wrong, and

terminates in a state satisfying QGiven P and S, what is the strongest Q’ satisfying {P} S {Q’} ?to check {P} S {Q}, check

Q'  Q

For example, what is the strongest Q’ satisfying { true } assert false { Q’ } ? (there isn’t one)

not

well defined

Slide9

Checking correctness with sp

{ x < 10 } x := x + 1;

assert

P(x); x := x + 1 {

true

}

sp( x < 10, x := x + 1 ) =

x ≤ 10

need to check the

assert

:

x ≤ 10  P(x)

sp( x ≤ 10,

assert

P(x) ) =

x ≤ 10

 P(x)sp( x ≤ 10  P(x), x := x + 1 ) =

x ≤ 11  P(x-1)check: x ≤ 11  P(x-1)  true

Slide10

Checking correctness with wp

{ x < 10 } x := x + 1;

assert

P(x); x := x + 1 {

true

}

=

wp

( x := x + 1,

true

)

true

=

wp

( assert P(x), true )

P(x) = wp( x := x + 1, P(x) ) P(x+1) check: x < 10  P(x+1)

Slide11

Advanced: wp, wlp, sp, Galois

sp treats assert as it treats assumewlp is like wp but treats assert

as

assume

wlp

and sp form a Galois connection: [spS(P)  Q]  [P  wlpS(Q)]one adjoint uniquely determines the otheran upper adjoint is universally conjunctive

wp is not univerally conjunctiveso, wp has no lower adjunctthat is, there is no function f such that

[f(P)  Q]  [P  wpS(Q)]

lower

adjoint

upper

adjoint

(

wp

assert

false

(true) ≠ true)

Slide12

Weakest preconditions

wp

( x := E, Q ) =

wp

(

havoc x, Q ) =wp( assert P, Q ) =wp( assume P, Q ) =

wp( S ; T, Q ) =wp( S  T, Q ) =Q[ E / x ]

(x  Q )P  QP  Qwp( S, wp( T, Q ))wp( S, Q )  wp( T, Q )For any command S and post-state predicate Q,

wp

(S,Q)

is the pre-state predicate that characterizes those initial states from which every terminating trace of S:

does not go wrong, and

terminates in a state satisfying Q

Slide13

Command correctness

A command S is correct iff wp(S, true) is valid

Slide14

Structured if statement

if E then S else T end

=

assume

E; S  assume ¬E; T

Slide15

Dijkstra's guarded command

if E  S | F  T fi =

assert

E

 F; ( assume E; S  assume F; T )

Slide16

Picking any good value

assign x such that P = havoc

x;

assume

P

assign x such that x*x = yWhat if we want assign to be total? assert (x  P); havoc

x; assume P

P

¬

P

;

=

Example:

Slide17

Definedness of expressions

x := a / b

// possible div-by-0

assert

b ≠ 0;

x := a / b

x := a + b // possible overflow

assert

-2

31

≤ a + b;

assert

a + b < 231; x := a + bx := a + b // use modular arith. x := PlusWrap(a, b)

Slide18

Complex data values: Arrays

An array is a map from indices to valuesarray update is map update:a[ j ] := Emeansa := a[ j  E ]

apply/select/get/rd and update/store/set/

wr

follow the familiar properties:

(a,j,k,x  j = k  a[ j  x ][ k ] = x )(a,j,k,x  j ≠ k  a[ j  x ][ k ] = a[ k ] )

Slide19

While loop with loop invariant

while E invariant Jdo

S

end

= ?

Homework