0% found this document useful (0 votes)
42 views19 pages

HL 3 - Weakest Conditions

This document discusses Hoare logic and its use in verifying program properties. Hoare-style proofs using preconditions and postconditions have been used for decades to prove properties of programs. The use of automated theorem provers along with programmer-provided annotations allows applying Hoare logic to medium-sized programs successfully. While scalability can be an issue, Hoare logic remains one of the most elegant techniques for proving program properties.

Uploaded by

Zahra Qamar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views19 pages

HL 3 - Weakest Conditions

This document discusses Hoare logic and its use in verifying program properties. Hoare-style proofs using preconditions and postconditions have been used for decades to prove properties of programs. The use of automated theorem provers along with programmer-provided annotations allows applying Hoare logic to medium-sized programs successfully. While scalability can be an issue, Hoare logic remains one of the most elegant techniques for proving program properties.

Uploaded by

Zahra Qamar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Weakest con

Dr. Yawar
Some Slides are taken from VU Formal Methods for SE
Explanation
Example
• {x+1=43}y:=x+1 {y=43}
And
{y=43}z:=y {z=43}
Using the sequencing rule, we have
{x+1=43}y:=x+1;z:=y {z=43}
Explanation
Rule of Sequential Composition

wp(S1;S2,Q)  wp(S1, wp(S2,Q))


Rule of Sequential Composition

wp(S1;S2,Q)  wp(S1, wp(S2,Q))

wp((x:= x+1; y := y+1), x = y)


Rule of Sequential Composition

wp(S1;S2,Q)  wp(S1, wp(S2,Q))

wp((x:= x+1; y := y+1), x = y)


 wp(x := x+1, wp(y := y+1, x = y))
Rule of Sequential Composition

wp(S1;S2,Q)  wp(S1, wp(S2,Q))

wp((x:= x+1; y := y+1), x = y)


 wp(x := x+1, wp(y := y+1, x = y))
 wp(x := x+1, x = y+1)
Rule of Sequential Composition

wp(S1;S2,Q)  wp(S1, wp(S2,Q))

wp((x:= x+1; y := y+1), x = y)


 wp(x := x+1, wp(y := y+1, x = y))
 wp(x := x+1, x = y+1)
 x+1 = y+1
Rule of Sequential Composition

wp(S1;S2,Q)  wp(S1, wp(S2,Q))

wp((x:= x+1; y := y+1), x = y)


 wp(x := x+1, wp(y := y+1, x = y))
 wp(x := x+1, x = y+1)
 x+1 = y+1
x=y
Rule of Sequential Composition

wp((x:= 2*x+1; y := y-1), y = 3*x)


Rule of Sequential Composition

wp((x:= 2*x+1; y := y-1), y = 3*x)


 wp(x := 2*x+1, wp(y := y-1, y = 3*x))
Rule of Sequential Composition

wp((x:= 2*x+1; y := y-1), y = 3*x)


 wp(x := 2*x+1, wp(y := y-1, y = 3*x))
 wp(x := 2*x+1, y-1 = 3*x))
Rule of Sequential Composition

wp((x:= 2*x+1; y := y-1), y = 3*x)


 wp(x := 2*x+1, wp(y := y-1, y = 3*x))
 wp(x := 2*x+1, y-1 = 3*x))
 y-1 = 3*(2*x+1)
Rule of Sequential Composition

wp((x:= 2*x+1; y := y-1), y = 3*x)


 wp(x := 2*x+1, wp(y := y-1, y = 3*x))
 wp(x := 2*x+1, y-1 = 3*x))
 y-1 = 3*(2*x+1)
 y = 6*x + 4
Summary
Hoare-style proofs have been extensively used over the past few
decades to prove subtle properties of complicated programs
This approach works best with programmer-provided annotations
The use of automated theorem provers and programmer
annotations
has allowed application of Hoare-style reasoning to medium sized
programs quite successfully.

Key-Hoare (from Chalmers University): A tool suite for


teaching/learning about Hoare logic Scalability of Hoare-style
reasoning is sometimes an issue Yet, this is one of the most elegant
techniques available for proving properties of programs.

You might also like