23 definition |
23 definition |
24 state_not_singleton :: bool where |
24 state_not_singleton :: bool where |
25 "state_not_singleton = (\<exists>s t::state. s ~= t)" (* at least two elements *) |
25 "state_not_singleton = (\<exists>s t::state. s ~= t)" (* at least two elements *) |
26 |
26 |
27 definition |
27 definition |
28 peek_and :: "'a assn => (state => bool) => 'a assn" (infixr "&>" 35) where |
28 peek_and :: "'a assn => (state => bool) => 'a assn" (infixr \<open>&>\<close> 35) where |
29 "peek_and P p = (%Z s. P Z s & p s)" |
29 "peek_and P p = (%Z s. P Z s & p s)" |
30 |
30 |
31 datatype 'a triple = |
31 datatype 'a triple = |
32 triple "'a assn" com "'a assn" ("{(1_)}./ (_)/ .{(1_)}" [3,60,3] 58) |
32 triple "'a assn" com "'a assn" (\<open>{(1_)}./ (_)/ .{(1_)}\<close> [3,60,3] 58) |
33 |
33 |
34 definition |
34 definition |
35 triple_valid :: "nat => 'a triple => bool" ( "|=_:_" [0 , 58] 57) where |
35 triple_valid :: "nat => 'a triple => bool" ( \<open>|=_:_\<close> [0 , 58] 57) where |
36 "|=n:t = (case t of {P}.c.{Q} => |
36 "|=n:t = (case t of {P}.c.{Q} => |
37 \<forall>Z s. P Z s \<longrightarrow> (\<forall>s'. <c,s> -n-> s' \<longrightarrow> Q Z s'))" |
37 \<forall>Z s. P Z s \<longrightarrow> (\<forall>s'. <c,s> -n-> s' \<longrightarrow> Q Z s'))" |
38 abbreviation |
38 abbreviation |
39 triples_valid :: "nat => 'a triple set => bool" ("||=_:_" [0 , 58] 57) where |
39 triples_valid :: "nat => 'a triple set => bool" (\<open>||=_:_\<close> [0 , 58] 57) where |
40 "||=n:G == Ball G (triple_valid n)" |
40 "||=n:G == Ball G (triple_valid n)" |
41 |
41 |
42 definition |
42 definition |
43 hoare_valids :: "'a triple set => 'a triple set => bool" ("_||=_" [58, 58] 57) where |
43 hoare_valids :: "'a triple set => 'a triple set => bool" (\<open>_||=_\<close> [58, 58] 57) where |
44 "G||=ts = (\<forall>n. ||=n:G --> ||=n:ts)" |
44 "G||=ts = (\<forall>n. ||=n:G --> ||=n:ts)" |
45 abbreviation |
45 abbreviation |
46 hoare_valid :: "'a triple set => 'a triple => bool" ("_|=_" [58, 58] 57) where |
46 hoare_valid :: "'a triple set => 'a triple => bool" (\<open>_|=_\<close> [58, 58] 57) where |
47 "G |=t == G||={t}" |
47 "G |=t == G||={t}" |
48 |
48 |
49 (* Most General Triples *) |
49 (* Most General Triples *) |
50 definition |
50 definition |
51 MGT :: "com => state triple" ("{=}._.{->}" [60] 58) where |
51 MGT :: "com => state triple" (\<open>{=}._.{->}\<close> [60] 58) where |
52 "{=}.c.{->} = {%Z s0. Z = s0}. c .{%Z s1. <c,Z> -c-> s1}" |
52 "{=}.c.{->} = {%Z s0. Z = s0}. c .{%Z s1. <c,Z> -c-> s1}" |
53 |
53 |
54 inductive |
54 inductive |
55 hoare_derivs :: "'a triple set => 'a triple set => bool" ("_||-_" [58, 58] 57) and |
55 hoare_derivs :: "'a triple set => 'a triple set => bool" (\<open>_||-_\<close> [58, 58] 57) and |
56 hoare_deriv :: "'a triple set => 'a triple => bool" ("_|-_" [58, 58] 57) |
56 hoare_deriv :: "'a triple set => 'a triple => bool" (\<open>_|-_\<close> [58, 58] 57) |
57 where |
57 where |
58 "G |-t == G||-{t}" |
58 "G |-t == G||-{t}" |
59 |
59 |
60 | empty: "G||-{}" |
60 | empty: "G||-{}" |
61 | insert: "[| G |-t; G||-ts |] |
61 | insert: "[| G |-t; G||-ts |] |