Axiomatic Semantics
Axiomatic Semantics
CS 565
Lecture 6
2/04/09
Axiomatic Semantics
States
!
"
"
!
!
!
!
!
"
!
!
"
!
!
" !
"
Hoare Triples
!
"
!
!
"
"
!
!
!
Satisfiability
!
"
"
!
"
"
#
!
! !
! !
! !
! !
Examples
!
!
!
Partial correctness
!
!
"
"
"
Soundness
!
"
"
"
!
"
Proof Rules
Skip:
{ P } skip { P }
Assignment:
{ P[t/x] } x := t { P }
Example: Suppose t = x + 1
Then, { x+1 = 2 } x := x + 1 { x = 2 }
Sequencing:
{P} c0 {Q} {Q} c1 {Q}
{P} c0;c1 {Q}
Example
Example
Prove the program:
z := 0;
n : = y;
while n > 0 do
z := z + x;
n := n 1
computes the product of x and y (assuming y
is not negative).
Invariants
Example
Example
Example