13857
|
1 |
(* Title: HOL/Hoare/ExamplesAbort.thy
|
|
2 |
Author: Tobias Nipkow
|
|
3 |
Copyright 1998 TUM
|
|
4 |
*)
|
|
5 |
|
72990
|
6 |
section \<open>Some small examples for programs that may abort\<close>
|
|
7 |
|
|
8 |
theory ExamplesAbort
|
|
9 |
imports Hoare_Logic_Abort
|
|
10 |
begin
|
13856
|
11 |
|
|
12 |
lemma "VARS x y z::nat
|
|
13 |
{y = z & z \<noteq> 0} z \<noteq> 0 \<rightarrow> x := y div z {x = 1}"
|
|
14 |
by vcg_simp
|
|
15 |
|
13875
|
16 |
lemma
|
|
17 |
"VARS a i j
|
|
18 |
{k <= length a & i < k & j < k} j < length a \<rightarrow> a[i] := a!j {True}"
|
42154
|
19 |
by vcg_simp
|
13875
|
20 |
|
13856
|
21 |
lemma "VARS (a::int list) i
|
|
22 |
{True}
|
|
23 |
i := 0;
|
|
24 |
WHILE i < length a
|
|
25 |
INV {i <= length a}
|
13875
|
26 |
DO a[i] := 7; i := i+1 OD
|
13856
|
27 |
{True}"
|
42154
|
28 |
by vcg_simp
|
13856
|
29 |
|
|
30 |
end
|