fixed bug in WP

This commit is contained in:
Jean-Christophe Filliatre
2011-05-16 11:11:10 +02:00
parent e294f64d4d
commit b7c7d6f937
7 changed files with 55 additions and 45 deletions

View File

@@ -24,14 +24,15 @@ module Decrease1
{ decrease1 a }
let i = ref 0 in
while !i < length a do
invariant { 0 <= i and forall j: int. 0 <= j < i -> a[j] <> 0 }
invariant { 0 <= i and
forall j: int. 0 <= j < i -> j < length a -> a[j] <> 0 }
variant { length a - i }
if get a !i = 0 then raise (Found !i);
if get a !i > 0 then i := !i + get a !i else i := !i + 1
done
{ forall j: int. 0 <= j < length a -> a[j] <> 0 }
| Found -> { 0 <= result < length a and a[result] = 0 and
forall j: int. 0 <= j < result -> a[j] <> 1 }
forall j: int. 0 <= j < result -> a[j] <> 0 }
end