SLIDE 1
Partial and Total Correctness Natural semantics Example: ( y:=1; - - PowerPoint PPT Presentation
Partial and Total Correctness Natural semantics Example: ( y:=1; - - PowerPoint PPT Presentation
Partial and Total Correctness Natural semantics Example: ( y:=1; while (x=1) do (y:=y x; x:=x 1) , s ) s y:=1; while (x=1) do s y = ( s x )! and s x > 0 (y:=y x; x:=x 1) Partial correctness: if initially
SLIDE 2
SLIDE 3
Stage 3 (y:=1; while ¬(x=1) do (y:=y⋆x; x:=x−1), s) → s′ ⇓ s′ y = (s x)! and s x > 0 Proof: (y:=1; while ¬(x=1) do (y:=y⋆x; x:=x−1), s) → s′ ⇓ (y:=1, s) → s′′ (while ¬(x=1) do (y:=y⋆x; x:=x−1), s′′) → s′ ⇓ s′′ = s[y→1] (s′′ y) ⋆ (s′′ x)! = s′ y, s′ x = 1, s′′ x > 0 ⇓ s′ y = (s x)! and s x > 0
XXVI.5
Structural operational semantics (y:=1; while ¬(x=1) do (y:=y⋆x; x:=x−1), s) ⇒∗ s′ ⇓ s′ y = (s x)! and s x > 0 Stage 1: correctness of the while loop Stage 2: overall correctness In both cases: reconstruct the derivation sequence
XXVI.6
SLIDE 4
Denotational semantics ψfac(S[y:=1; while ¬(x=1) do (y:=y⋆x; x:=x−1)]) = tt ψfac: (State ֒ → State) → T ψfac(g) = tt
- g s = s′ implies s′ y = (s x)! and s x > 0
XXVI.7
Fixed Point Induction Let (D,⊑) be a ccpo. Then ψ: D → T is an admissible predicate if and only if ψ d = tt for all d ∈ Y ⇓ ψ(
Y ) = tt
for every chain Y in D. Theorem 6.5: Let (D,⊑) be a ccpo and let f: D → D be a continuous function and let ψ be an admissible predicate on D. If for all d ∈ D ψ d = tt implies ψ(f d) = tt then ψ(FIX f) = tt.
XXVI.8
SLIDE 5
Example (1) Define ψ′
fac(g) = tt
- g s = s′ implies s′ y = (s y)⋆(s x)!, s x>0
Then ψ′
fac is an admissible predicate.
Proof: Assume Y is a chain in State ֒ → State and ψ′
fac g = tt for all g ∈ Y .
We shall prove ψ′
fac( Y ) = tt
(
Y ) s = s′
⇓ g s = s′ for some g ∈ Y ⇓ s′ y = (s y) ⋆ (s x)! and s x > 0
XXVI.9
Example (2) S[y:=1; while ¬(x=1) do (y:=y⋆x; x:=x−1)]s = (FIX F)(s[y→1]) where F g s =
s if s x = 1 g(s[y→(s y)⋆(s x)][x→(s x)−1])
- therwise
ψfac(S[y:=1; while ¬(x=1) do (y:=y⋆x; x:=x−1)]) = tt
- ψ′
fac(FIX F) = tt
From Theorem 6.5 it is sufficient to prove
- F is continuous
- ψ′
fac is admissible
- ψ′
fac g = tt implies ψ′ fac(F g) = tt
XXVI.10
SLIDE 6