| author | blanchet | 
| Wed, 06 May 2015 15:04:38 +0200 | |
| changeset 60181 | fc66055fbadf | 
| parent 59189 | ad8e0a789af6 | 
| child 60754 | 02924903a6fd | 
| permissions | -rw-r--r-- | 
| 59189 | 1 | section \<open>Generation of Verification Conditions\<close> | 
| 13020 | 2 | |
| 27104 
791607529f6d
rep_datatype command now takes list of constructors as input arguments
 haftmann parents: 
23894diff
changeset | 3 | theory OG_Tactics | 
| 
791607529f6d
rep_datatype command now takes list of constructors as input arguments
 haftmann parents: 
23894diff
changeset | 4 | imports OG_Hoare | 
| 15425 | 5 | begin | 
| 13020 | 6 | |
| 7 | lemmas ann_hoare_intros=AnnBasic AnnSeq AnnCond1 AnnCond2 AnnWhile AnnAwait AnnConseq | |
| 8 | lemmas oghoare_intros=Parallel Basic Seq Cond While Conseq | |
| 9 | ||
| 59189 | 10 | lemma ParallelConseqRule: | 
| 11 |  "\<lbrakk> p \<subseteq> (\<Inter>i\<in>{i. i<length Ts}. pre(the(com(Ts ! i))));
 | |
| 12 |   \<parallel>- (\<Inter>i\<in>{i. i<length Ts}. pre(the(com(Ts ! i))))
 | |
| 13 | (Parallel Ts) | |
| 14 |      (\<Inter>i\<in>{i. i<length Ts}. post(Ts ! i));
 | |
| 15 |   (\<Inter>i\<in>{i. i<length Ts}. post(Ts ! i)) \<subseteq> q \<rbrakk>
 | |
| 13020 | 16 | \<Longrightarrow> \<parallel>- p (Parallel Ts) q" | 
| 17 | apply (rule Conseq) | |
| 59189 | 18 | prefer 2 | 
| 13020 | 19 | apply fast | 
| 20 | apply assumption+ | |
| 21 | done | |
| 22 | ||
| 23 | lemma SkipRule: "p \<subseteq> q \<Longrightarrow> \<parallel>- p (Basic id) q" | |
| 24 | apply(rule oghoare_intros) | |
| 25 | prefer 2 apply(rule Basic) | |
| 26 | prefer 2 apply(rule subset_refl) | |
| 27 | apply(simp add:Id_def) | |
| 28 | done | |
| 29 | ||
| 30 | lemma BasicRule: "p \<subseteq> {s. (f s)\<in>q} \<Longrightarrow> \<parallel>- p (Basic f) q"
 | |
| 31 | apply(rule oghoare_intros) | |
| 32 | prefer 2 apply(rule oghoare_intros) | |
| 33 | prefer 2 apply(rule subset_refl) | |
| 34 | apply assumption | |
| 35 | done | |
| 36 | ||
| 37 | lemma SeqRule: "\<lbrakk> \<parallel>- p c1 r; \<parallel>- r c2 q \<rbrakk> \<Longrightarrow> \<parallel>- p (Seq c1 c2) q" | |
| 38 | apply(rule Seq) | |
| 39 | apply fast+ | |
| 40 | done | |
| 41 | ||
| 59189 | 42 | lemma CondRule: | 
| 43 |  "\<lbrakk> p \<subseteq> {s. (s\<in>b \<longrightarrow> s\<in>w) \<and> (s\<notin>b \<longrightarrow> s\<in>w')}; \<parallel>- w c1 q; \<parallel>- w' c2 q \<rbrakk>
 | |
| 13020 | 44 | \<Longrightarrow> \<parallel>- p (Cond b c1 c2) q" | 
| 45 | apply(rule Cond) | |
| 46 | apply(rule Conseq) | |
| 47 | prefer 4 apply(rule Conseq) | |
| 48 | apply simp_all | |
| 49 | apply force+ | |
| 50 | done | |
| 51 | ||
| 59189 | 52 | lemma WhileRule: "\<lbrakk> p \<subseteq> i; \<parallel>- (i \<inter> b) c i ; (i \<inter> (-b)) \<subseteq> q \<rbrakk> | 
| 13020 | 53 | \<Longrightarrow> \<parallel>- p (While b i c) q" | 
| 54 | apply(rule Conseq) | |
| 55 | prefer 2 apply(rule While) | |
| 56 | apply assumption+ | |
| 57 | done | |
| 58 | ||
| 59189 | 59 | text \<open>Three new proof rules for special instances of the @{text
 | 
| 13020 | 60 | AnnBasic} and the @{text AnnAwait} commands when the transformation
 | 
| 61 | performed on the state is the identity, and for an @{text AnnAwait}
 | |
| 59189 | 62 | command where the boolean condition is @{text "{s. True}"}:\<close>
 | 
| 13020 | 63 | |
| 64 | lemma AnnatomRule: | |
| 65 |   "\<lbrakk> atom_com(c); \<parallel>- r c q \<rbrakk>  \<Longrightarrow> \<turnstile> (AnnAwait r {s. True} c) q"
 | |
| 66 | apply(rule AnnAwait) | |
| 67 | apply simp_all | |
| 68 | done | |
| 69 | ||
| 70 | lemma AnnskipRule: | |
| 71 | "r \<subseteq> q \<Longrightarrow> \<turnstile> (AnnBasic r id) q" | |
| 72 | apply(rule AnnBasic) | |
| 73 | apply simp | |
| 74 | done | |
| 75 | ||
| 76 | lemma AnnwaitRule: | |
| 77 | "\<lbrakk> (r \<inter> b) \<subseteq> q \<rbrakk> \<Longrightarrow> \<turnstile> (AnnAwait r b (Basic id)) q" | |
| 78 | apply(rule AnnAwait) | |
| 79 | apply simp | |
| 80 | apply(rule BasicRule) | |
| 81 | apply simp | |
| 82 | done | |
| 83 | ||
| 59189 | 84 | text \<open>Lemmata to avoid using the definition of @{text
 | 
| 13020 | 85 | map_ann_hoare}, @{text interfree_aux}, @{text interfree_swap} and
 | 
| 59189 | 86 | @{text interfree} by splitting it into different cases:\<close>
 | 
| 13020 | 87 | |
| 88 | lemma interfree_aux_rule1: "interfree_aux(co, q, None)" | |
| 89 | by(simp add:interfree_aux_def) | |
| 90 | ||
| 59189 | 91 | lemma interfree_aux_rule2: | 
| 13020 | 92 | "\<forall>(R,r)\<in>(atomics a). \<parallel>- (q \<inter> R) r q \<Longrightarrow> interfree_aux(None, q, Some a)" | 
| 93 | apply(simp add:interfree_aux_def) | |
| 94 | apply(force elim:oghoare_sound) | |
| 95 | done | |
| 96 | ||
| 59189 | 97 | lemma interfree_aux_rule3: | 
| 13020 | 98 | "(\<forall>(R, r)\<in>(atomics a). \<parallel>- (q \<inter> R) r q \<and> (\<forall>p\<in>(assertions c). \<parallel>- (p \<inter> R) r p)) | 
| 99 | \<Longrightarrow> interfree_aux(Some c, q, Some a)" | |
| 100 | apply(simp add:interfree_aux_def) | |
| 101 | apply(force elim:oghoare_sound) | |
| 102 | done | |
| 103 | ||
| 59189 | 104 | lemma AnnBasic_assertions: | 
| 105 | "\<lbrakk>interfree_aux(None, r, Some a); interfree_aux(None, q, Some a)\<rbrakk> \<Longrightarrow> | |
| 13020 | 106 | interfree_aux(Some (AnnBasic r f), q, Some a)" | 
| 107 | apply(simp add: interfree_aux_def) | |
| 108 | by force | |
| 109 | ||
| 59189 | 110 | lemma AnnSeq_assertions: | 
| 111 | "\<lbrakk> interfree_aux(Some c1, q, Some a); interfree_aux(Some c2, q, Some a)\<rbrakk>\<Longrightarrow> | |
| 13020 | 112 | interfree_aux(Some (AnnSeq c1 c2), q, Some a)" | 
| 113 | apply(simp add: interfree_aux_def) | |
| 114 | by force | |
| 115 | ||
| 59189 | 116 | lemma AnnCond1_assertions: | 
| 117 | "\<lbrakk> interfree_aux(None, r, Some a); interfree_aux(Some c1, q, Some a); | |
| 118 | interfree_aux(Some c2, q, Some a)\<rbrakk>\<Longrightarrow> | |
| 13020 | 119 | interfree_aux(Some(AnnCond1 r b c1 c2), q, Some a)" | 
| 120 | apply(simp add: interfree_aux_def) | |
| 121 | by force | |
| 122 | ||
| 59189 | 123 | lemma AnnCond2_assertions: | 
| 124 | "\<lbrakk> interfree_aux(None, r, Some a); interfree_aux(Some c, q, Some a)\<rbrakk>\<Longrightarrow> | |
| 13020 | 125 | interfree_aux(Some (AnnCond2 r b c), q, Some a)" | 
| 126 | apply(simp add: interfree_aux_def) | |
| 127 | by force | |
| 128 | ||
| 59189 | 129 | lemma AnnWhile_assertions: | 
| 130 | "\<lbrakk> interfree_aux(None, r, Some a); interfree_aux(None, i, Some a); | |
| 131 | interfree_aux(Some c, q, Some a)\<rbrakk>\<Longrightarrow> | |
| 13020 | 132 | interfree_aux(Some (AnnWhile r b i c), q, Some a)" | 
| 133 | apply(simp add: interfree_aux_def) | |
| 134 | by force | |
| 59189 | 135 | |
| 136 | lemma AnnAwait_assertions: | |
| 137 | "\<lbrakk> interfree_aux(None, r, Some a); interfree_aux(None, q, Some a)\<rbrakk>\<Longrightarrow> | |
| 13020 | 138 | interfree_aux(Some (AnnAwait r b c), q, Some a)" | 
| 139 | apply(simp add: interfree_aux_def) | |
| 140 | by force | |
| 59189 | 141 | |
| 142 | lemma AnnBasic_atomics: | |
| 13020 | 143 | "\<parallel>- (q \<inter> r) (Basic f) q \<Longrightarrow> interfree_aux(None, q, Some (AnnBasic r f))" | 
| 144 | by(simp add: interfree_aux_def oghoare_sound) | |
| 145 | ||
| 59189 | 146 | lemma AnnSeq_atomics: | 
| 147 | "\<lbrakk> interfree_aux(Any, q, Some a1); interfree_aux(Any, q, Some a2)\<rbrakk>\<Longrightarrow> | |
| 13020 | 148 | interfree_aux(Any, q, Some (AnnSeq a1 a2))" | 
| 149 | apply(simp add: interfree_aux_def) | |
| 150 | by force | |
| 151 | ||
| 152 | lemma AnnCond1_atomics: | |
| 59189 | 153 | "\<lbrakk> interfree_aux(Any, q, Some a1); interfree_aux(Any, q, Some a2)\<rbrakk>\<Longrightarrow> | 
| 13020 | 154 | interfree_aux(Any, q, Some (AnnCond1 r b a1 a2))" | 
| 155 | apply(simp add: interfree_aux_def) | |
| 156 | by force | |
| 157 | ||
| 59189 | 158 | lemma AnnCond2_atomics: | 
| 13020 | 159 | "interfree_aux (Any, q, Some a)\<Longrightarrow> interfree_aux(Any, q, Some (AnnCond2 r b a))" | 
| 160 | by(simp add: interfree_aux_def) | |
| 161 | ||
| 59189 | 162 | lemma AnnWhile_atomics: "interfree_aux (Any, q, Some a) | 
| 13020 | 163 | \<Longrightarrow> interfree_aux(Any, q, Some (AnnWhile r b i a))" | 
| 164 | by(simp add: interfree_aux_def) | |
| 165 | ||
| 59189 | 166 | lemma Annatom_atomics: | 
| 13020 | 167 |   "\<parallel>- (q \<inter> r) a q \<Longrightarrow> interfree_aux (None, q, Some (AnnAwait r {x. True} a))"
 | 
| 59189 | 168 | by(simp add: interfree_aux_def oghoare_sound) | 
| 13020 | 169 | |
| 59189 | 170 | lemma AnnAwait_atomics: | 
| 13020 | 171 | "\<parallel>- (q \<inter> (r \<inter> b)) a q \<Longrightarrow> interfree_aux (None, q, Some (AnnAwait r b a))" | 
| 172 | by(simp add: interfree_aux_def oghoare_sound) | |
| 173 | ||
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
32621diff
changeset | 174 | definition interfree_swap :: "('a ann_triple_op * ('a ann_triple_op) list) \<Rightarrow> bool" where
 | 
| 13020 | 175 | "interfree_swap == \<lambda>(x, xs). \<forall>y\<in>set xs. interfree_aux (com x, post x, com y) | 
| 176 | \<and> interfree_aux(com y, post y, com x)" | |
| 177 | ||
| 178 | lemma interfree_swap_Empty: "interfree_swap (x, [])" | |
| 179 | by(simp add:interfree_swap_def) | |
| 180 | ||
| 59189 | 181 | lemma interfree_swap_List: | 
| 182 | "\<lbrakk> interfree_aux (com x, post x, com y); | |
| 183 | interfree_aux (com y, post y ,com x); interfree_swap (x, xs) \<rbrakk> | |
| 13020 | 184 | \<Longrightarrow> interfree_swap (x, y#xs)" | 
| 185 | by(simp add:interfree_swap_def) | |
| 186 | ||
| 59189 | 187 | lemma interfree_swap_Map: "\<forall>k. i\<le>k \<and> k<j \<longrightarrow> interfree_aux (com x, post x, c k) | 
| 188 | \<and> interfree_aux (c k, Q k, com x) | |
| 15425 | 189 | \<Longrightarrow> interfree_swap (x, map (\<lambda>k. (c k, Q k)) [i..<j])" | 
| 13020 | 190 | by(force simp add: interfree_swap_def less_diff_conv) | 
| 191 | ||
| 192 | lemma interfree_Empty: "interfree []" | |
| 193 | by(simp add:interfree_def) | |
| 194 | ||
| 59189 | 195 | lemma interfree_List: | 
| 13020 | 196 | "\<lbrakk> interfree_swap(x, xs); interfree xs \<rbrakk> \<Longrightarrow> interfree (x#xs)" | 
| 197 | apply(simp add:interfree_def interfree_swap_def) | |
| 198 | apply clarify | |
| 199 | apply(case_tac i) | |
| 200 | apply(case_tac j) | |
| 201 | apply simp_all | |
| 202 | apply(case_tac j,simp+) | |
| 203 | done | |
| 204 | ||
| 59189 | 205 | lemma interfree_Map: | 
| 206 | "(\<forall>i j. a\<le>i \<and> i<b \<and> a\<le>j \<and> j<b \<and> i\<noteq>j \<longrightarrow> interfree_aux (c i, Q i, c j)) | |
| 15425 | 207 | \<Longrightarrow> interfree (map (\<lambda>k. (c k, Q k)) [a..<b])" | 
| 13020 | 208 | by(force simp add: interfree_def less_diff_conv) | 
| 209 | ||
| 35416 
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
 haftmann parents: 
32621diff
changeset | 210 | definition map_ann_hoare :: "(('a ann_com_op * 'a assn) list) \<Rightarrow> bool " ("[\<turnstile>] _" [0] 45) where
 | 
| 13020 | 211 | "[\<turnstile>] Ts == (\<forall>i<length Ts. \<exists>c q. Ts!i=(Some c, q) \<and> \<turnstile> c q)" | 
| 212 | ||
| 213 | lemma MapAnnEmpty: "[\<turnstile>] []" | |
| 214 | by(simp add:map_ann_hoare_def) | |
| 215 | ||
| 216 | lemma MapAnnList: "\<lbrakk> \<turnstile> c q ; [\<turnstile>] xs \<rbrakk> \<Longrightarrow> [\<turnstile>] (Some c,q)#xs" | |
| 217 | apply(simp add:map_ann_hoare_def) | |
| 218 | apply clarify | |
| 219 | apply(case_tac i,simp+) | |
| 220 | done | |
| 221 | ||
| 59189 | 222 | lemma MapAnnMap: | 
| 15425 | 223 | "\<forall>k. i\<le>k \<and> k<j \<longrightarrow> \<turnstile> (c k) (Q k) \<Longrightarrow> [\<turnstile>] map (\<lambda>k. (Some (c k), Q k)) [i..<j]" | 
| 13020 | 224 | apply(simp add: map_ann_hoare_def less_diff_conv) | 
| 225 | done | |
| 226 | ||
| 227 | lemma ParallelRule:"\<lbrakk> [\<turnstile>] Ts ; interfree Ts \<rbrakk> | |
| 59189 | 228 |   \<Longrightarrow> \<parallel>- (\<Inter>i\<in>{i. i<length Ts}. pre(the(com(Ts!i))))
 | 
| 229 | Parallel Ts | |
| 13020 | 230 |         (\<Inter>i\<in>{i. i<length Ts}. post(Ts!i))"
 | 
| 231 | apply(rule Parallel) | |
| 232 | apply(simp add:map_ann_hoare_def) | |
| 233 | apply simp | |
| 234 | done | |
| 235 | (* | |
| 236 | lemma ParamParallelRule: | |
| 59189 | 237 | "\<lbrakk> \<forall>k<n. \<turnstile> (c k) (Q k); | 
| 13020 | 238 | \<forall>k l. k<n \<and> l<n \<and> k\<noteq>l \<longrightarrow> interfree_aux (Some(c k), Q k, Some(c l)) \<rbrakk> | 
| 239 |   \<Longrightarrow> \<parallel>- (\<Inter>i\<in>{i. i<n} . pre(c i)) COBEGIN SCHEME [0\<le>i<n] (c i) (Q i) COEND  (\<Inter>i\<in>{i. i<n} . Q i )"
 | |
| 240 | apply(rule ParallelConseqRule) | |
| 241 | apply simp | |
| 242 | apply clarify | |
| 243 | apply force | |
| 244 | apply(rule ParallelRule) | |
| 245 | apply(rule MapAnnMap) | |
| 246 | apply simp | |
| 247 | apply(rule interfree_Map) | |
| 248 | apply simp | |
| 249 | apply simp | |
| 250 | apply clarify | |
| 251 | apply force | |
| 252 | done | |
| 253 | *) | |
| 254 | ||
| 59189 | 255 | text \<open>The following are some useful lemmas and simplification | 
| 13020 | 256 | tactics to control which theorems are used to simplify at each moment, | 
| 257 | so that the original input does not suffer any unexpected | |
| 59189 | 258 | transformation.\<close> | 
| 13020 | 259 | |
| 260 | lemma Compl_Collect: "-(Collect b) = {x. \<not>(b x)}"
 | |
| 52597 
a8a81453833d
more precise fact declarations -- fewer warnings;
 wenzelm parents: 
51717diff
changeset | 261 | by fast | 
| 
a8a81453833d
more precise fact declarations -- fewer warnings;
 wenzelm parents: 
51717diff
changeset | 262 | |
| 
a8a81453833d
more precise fact declarations -- fewer warnings;
 wenzelm parents: 
51717diff
changeset | 263 | lemma list_length: "length []=0" "length (x#xs) = Suc(length xs)" | 
| 
a8a81453833d
more precise fact declarations -- fewer warnings;
 wenzelm parents: 
51717diff
changeset | 264 | by simp_all | 
| 
a8a81453833d
more precise fact declarations -- fewer warnings;
 wenzelm parents: 
51717diff
changeset | 265 | lemma list_lemmas: "length []=0" "length (x#xs) = Suc(length xs)" | 
| 
a8a81453833d
more precise fact declarations -- fewer warnings;
 wenzelm parents: 
51717diff
changeset | 266 | "(x#xs) ! 0 = x" "(x#xs) ! Suc n = xs ! n" | 
| 
a8a81453833d
more precise fact declarations -- fewer warnings;
 wenzelm parents: 
51717diff
changeset | 267 | by simp_all | 
| 13020 | 268 | lemma le_Suc_eq_insert: "{i. i <Suc n} = insert n {i. i< n}"
 | 
| 52597 
a8a81453833d
more precise fact declarations -- fewer warnings;
 wenzelm parents: 
51717diff
changeset | 269 | by auto | 
| 13020 | 270 | lemmas primrecdef_list = "pre.simps" "assertions.simps" "atomics.simps" "atom_com.simps" | 
| 271 | lemmas my_simp_list = list_lemmas fst_conv snd_conv | |
| 27104 
791607529f6d
rep_datatype command now takes list of constructors as input arguments
 haftmann parents: 
23894diff
changeset | 272 | not_less0 refl le_Suc_eq_insert Suc_not_Zero Zero_not_Suc nat.inject | 
| 13020 | 273 | Collect_mem_eq ball_simps option.simps primrecdef_list | 
| 52597 
a8a81453833d
more precise fact declarations -- fewer warnings;
 wenzelm parents: 
51717diff
changeset | 274 | lemmas ParallelConseq_list = INTER_eq Collect_conj_eq length_map length_upt length_append | 
| 13020 | 275 | |
| 59189 | 276 | ML \<open> | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 277 | fun before_interfree_simp_tac ctxt = | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 278 |   simp_tac (put_simpset HOL_basic_ss ctxt addsimps [@{thm com.simps}, @{thm post.simps}])
 | 
| 13020 | 279 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 280 | fun interfree_simp_tac ctxt = | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 281 | asm_simp_tac (put_simpset HOL_ss ctxt | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 282 |     addsimps [@{thm split}, @{thm ball_Un}, @{thm ball_empty}] @ @{thms my_simp_list})
 | 
| 13020 | 283 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 284 | fun ParallelConseq ctxt = | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 285 | simp_tac (put_simpset HOL_basic_ss ctxt | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 286 |     addsimps @{thms ParallelConseq_list} @ @{thms my_simp_list})
 | 
| 59189 | 287 | \<close> | 
| 13020 | 288 | |
| 59189 | 289 | text \<open>The following tactic applies @{text tac} to each conjunct in a
 | 
| 13020 | 290 | subgoal of the form @{text "A \<Longrightarrow> a1 \<and> a2 \<and> .. \<and> an"}  returning
 | 
| 59189 | 291 | @{text n} subgoals, one for each conjunct:\<close>
 | 
| 13020 | 292 | |
| 59189 | 293 | ML \<open> | 
| 13020 | 294 | fun conjI_Tac tac i st = st |> | 
| 295 | ( (EVERY [rtac conjI i, | |
| 296 | conjI_Tac tac (i+1), | |
| 297 | tac i]) ORELSE (tac i) ) | |
| 59189 | 298 | \<close> | 
| 13020 | 299 | |
| 300 | ||
| 59189 | 301 | subsubsection \<open>Tactic for the generation of the verification conditions\<close> | 
| 13020 | 302 | |
| 59189 | 303 | text \<open>The tactic basically uses two subtactics: | 
| 13020 | 304 | |
| 305 | \begin{description}
 | |
| 306 | ||
| 59189 | 307 | \item[HoareRuleTac] is called at the level of parallel programs, it | 
| 308 | uses the ParallelTac to solve parallel composition of programs. | |
| 309 | This verification has two parts, namely, (1) all component programs are | |
| 13020 | 310 |  correct and (2) they are interference free.  @{text HoareRuleTac} is
 | 
| 311 |  also called at the level of atomic regions, i.e.  @{text "\<langle> \<rangle>"} and
 | |
| 312 |  @{text "AWAIT b THEN _ END"}, and at each interference freedom test.
 | |
| 313 | ||
| 59189 | 314 | \item[AnnHoareRuleTac] is for component programs which | 
| 315 | are annotated programs and so, there are not unknown assertions | |
| 13020 | 316 | (no need to use the parameter precond, see NOTE). | 
| 317 | ||
| 318 |  NOTE: precond(::bool) informs if the subgoal has the form @{text "\<parallel>- ?p c q"},
 | |
| 59189 | 319 | in this case we have precond=False and the generated verification | 
| 320 |  condition would have the form @{text "?p \<subseteq> \<dots>"} which can be solved by
 | |
| 13020 | 321 |  @{text "rtac subset_refl"}, if True we proceed to simplify it using
 | 
| 322 | the simplification tactics above. | |
| 323 | ||
| 324 | \end{description}
 | |
| 59189 | 325 | \<close> | 
| 13020 | 326 | |
| 59189 | 327 | ML \<open> | 
| 13020 | 328 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 329 | fun WlpTac ctxt i = (rtac (@{thm SeqRule}) i) THEN (HoareRuleTac ctxt false (i+1))
 | 
| 59189 | 330 | and HoareRuleTac ctxt precond i st = st |> | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 331 | ( (WlpTac ctxt i THEN HoareRuleTac ctxt precond i) | 
| 13020 | 332 | ORELSE | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 333 |       (FIRST[rtac (@{thm SkipRule}) i,
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 334 |              rtac (@{thm BasicRule}) i,
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 335 |              EVERY[rtac (@{thm ParallelConseqRule}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 336 | ParallelConseq ctxt (i+2), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 337 | ParallelTac ctxt (i+1), | 
| 59189 | 338 | ParallelConseq ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 339 |              EVERY[rtac (@{thm CondRule}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 340 | HoareRuleTac ctxt false (i+2), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 341 | HoareRuleTac ctxt false (i+1)], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 342 |              EVERY[rtac (@{thm WhileRule}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 343 | HoareRuleTac ctxt true (i+1)], | 
| 13020 | 344 | K all_tac i ] | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 345 |        THEN (if precond then (K all_tac i) else (rtac (@{thm subset_refl}) i))))
 | 
| 13020 | 346 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 347 | and AnnWlpTac ctxt i = (rtac (@{thm AnnSeq}) i) THEN (AnnHoareRuleTac ctxt (i+1))
 | 
| 59189 | 348 | and AnnHoareRuleTac ctxt i st = st |> | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 349 | ( (AnnWlpTac ctxt i THEN AnnHoareRuleTac ctxt i ) | 
| 13020 | 350 | ORELSE | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 351 |       (FIRST[(rtac (@{thm AnnskipRule}) i),
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 352 |              EVERY[rtac (@{thm AnnatomRule}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 353 | HoareRuleTac ctxt true (i+1)], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 354 |              (rtac (@{thm AnnwaitRule}) i),
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 355 |              rtac (@{thm AnnBasic}) i,
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 356 |              EVERY[rtac (@{thm AnnCond1}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 357 | AnnHoareRuleTac ctxt (i+3), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 358 | AnnHoareRuleTac ctxt (i+1)], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 359 |              EVERY[rtac (@{thm AnnCond2}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 360 | AnnHoareRuleTac ctxt (i+1)], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 361 |              EVERY[rtac (@{thm AnnWhile}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 362 | AnnHoareRuleTac ctxt (i+2)], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 363 |              EVERY[rtac (@{thm AnnAwait}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 364 | HoareRuleTac ctxt true (i+1)], | 
| 13020 | 365 | K all_tac i])) | 
| 366 | ||
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 367 | and ParallelTac ctxt i = EVERY[rtac (@{thm ParallelRule}) i,
 | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 368 | interfree_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 369 | MapAnn_Tac ctxt i] | 
| 13020 | 370 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 371 | and MapAnn_Tac ctxt i st = st |> | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 372 |     (FIRST[rtac (@{thm MapAnnEmpty}) i,
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 373 |            EVERY[rtac (@{thm MapAnnList}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 374 | MapAnn_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 375 | AnnHoareRuleTac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 376 |            EVERY[rtac (@{thm MapAnnMap}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 377 |                  rtac (@{thm allI}) i, rtac (@{thm impI}) i,
 | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 378 | AnnHoareRuleTac ctxt i]]) | 
| 13020 | 379 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 380 | and interfree_swap_Tac ctxt i st = st |> | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 381 |     (FIRST[rtac (@{thm interfree_swap_Empty}) i,
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 382 |            EVERY[rtac (@{thm interfree_swap_List}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 383 | interfree_swap_Tac ctxt (i+2), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 384 | interfree_aux_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 385 | interfree_aux_Tac ctxt i ], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 386 |            EVERY[rtac (@{thm interfree_swap_Map}) i,
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 387 |                  rtac (@{thm allI}) i,rtac (@{thm impI}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 388 | conjI_Tac (interfree_aux_Tac ctxt) i]]) | 
| 13020 | 389 | |
| 59189 | 390 | and interfree_Tac ctxt i st = st |> | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 391 |    (FIRST[rtac (@{thm interfree_Empty}) i,
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 392 |           EVERY[rtac (@{thm interfree_List}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 393 | interfree_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 394 | interfree_swap_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 395 |           EVERY[rtac (@{thm interfree_Map}) i,
 | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 396 |                 rtac (@{thm allI}) i,rtac (@{thm allI}) i,rtac (@{thm impI}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 397 | interfree_aux_Tac ctxt i ]]) | 
| 13020 | 398 | |
| 59189 | 399 | and interfree_aux_Tac ctxt i = (before_interfree_simp_tac ctxt i ) THEN | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 400 |         (FIRST[rtac (@{thm interfree_aux_rule1}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 401 | dest_assertions_Tac ctxt i]) | 
| 13020 | 402 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 403 | and dest_assertions_Tac ctxt i st = st |> | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 404 |     (FIRST[EVERY[rtac (@{thm AnnBasic_assertions}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 405 | dest_atomics_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 406 | dest_atomics_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 407 |            EVERY[rtac (@{thm AnnSeq_assertions}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 408 | dest_assertions_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 409 | dest_assertions_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 410 |            EVERY[rtac (@{thm AnnCond1_assertions}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 411 | dest_assertions_Tac ctxt (i+2), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 412 | dest_assertions_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 413 | dest_atomics_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 414 |            EVERY[rtac (@{thm AnnCond2_assertions}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 415 | dest_assertions_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 416 | dest_atomics_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 417 |            EVERY[rtac (@{thm AnnWhile_assertions}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 418 | dest_assertions_Tac ctxt (i+2), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 419 | dest_atomics_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 420 | dest_atomics_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 421 |            EVERY[rtac (@{thm AnnAwait_assertions}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 422 | dest_atomics_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 423 | dest_atomics_Tac ctxt i], | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 424 | dest_atomics_Tac ctxt i]) | 
| 13020 | 425 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 426 | and dest_atomics_Tac ctxt i st = st |> | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 427 |     (FIRST[EVERY[rtac (@{thm AnnBasic_atomics}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 428 | HoareRuleTac ctxt true i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 429 |            EVERY[rtac (@{thm AnnSeq_atomics}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 430 | dest_atomics_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 431 | dest_atomics_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 432 |            EVERY[rtac (@{thm AnnCond1_atomics}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 433 | dest_atomics_Tac ctxt (i+1), | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 434 | dest_atomics_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 435 |            EVERY[rtac (@{thm AnnCond2_atomics}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 436 | dest_atomics_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 437 |            EVERY[rtac (@{thm AnnWhile_atomics}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 438 | dest_atomics_Tac ctxt i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 439 |            EVERY[rtac (@{thm Annatom_atomics}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 440 | HoareRuleTac ctxt true i], | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
21588diff
changeset | 441 |            EVERY[rtac (@{thm AnnAwait_atomics}) i,
 | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 442 | HoareRuleTac ctxt true i], | 
| 13020 | 443 | K all_tac i]) | 
| 59189 | 444 | \<close> | 
| 13020 | 445 | |
| 446 | ||
| 59189 | 447 | text \<open>The final tactic is given the name @{text oghoare}:\<close>
 | 
| 13020 | 448 | |
| 59189 | 449 | ML \<open> | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 450 | fun oghoare_tac ctxt = SUBGOAL (fn (_, i) => HoareRuleTac ctxt true i) | 
| 59189 | 451 | \<close> | 
| 13020 | 452 | |
| 59189 | 453 | text \<open>Notice that the tactic for parallel programs @{text
 | 
| 13020 | 454 | "oghoare_tac"} is initially invoked with the value @{text true} for
 | 
| 455 | the parameter @{text precond}.
 | |
| 456 | ||
| 457 | Parts of the tactic can be also individually used to generate the | |
| 458 | verification conditions for annotated sequential programs and to | |
| 59189 | 459 | generate verification conditions out of interference freedom tests:\<close> | 
| 13020 | 460 | |
| 59189 | 461 | ML \<open> | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 462 | fun annhoare_tac ctxt = SUBGOAL (fn (_, i) => AnnHoareRuleTac ctxt i) | 
| 13020 | 463 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
44928diff
changeset | 464 | fun interfree_aux_tac ctxt = SUBGOAL (fn (_, i) => interfree_aux_Tac ctxt i) | 
| 59189 | 465 | \<close> | 
| 13020 | 466 | |
| 59189 | 467 | text \<open>The so defined ML tactics are then ``exported'' to be used in | 
| 468 | Isabelle proofs.\<close> | |
| 13020 | 469 | |
| 59189 | 470 | method_setup oghoare = \<open> | 
| 471 | Scan.succeed (SIMPLE_METHOD' o oghoare_tac)\<close> | |
| 13020 | 472 | "verification condition generator for the oghoare logic" | 
| 473 | ||
| 59189 | 474 | method_setup annhoare = \<open> | 
| 475 | Scan.succeed (SIMPLE_METHOD' o annhoare_tac)\<close> | |
| 13020 | 476 | "verification condition generator for the ann_hoare logic" | 
| 477 | ||
| 59189 | 478 | method_setup interfree_aux = \<open> | 
| 479 | Scan.succeed (SIMPLE_METHOD' o interfree_aux_tac)\<close> | |
| 13020 | 480 | "verification condition generator for interference freedom tests" | 
| 481 | ||
| 59189 | 482 | text \<open>Tactics useful for dealing with the generated verification conditions:\<close> | 
| 13020 | 483 | |
| 59189 | 484 | method_setup conjI_tac = \<open> | 
| 485 | Scan.succeed (K (SIMPLE_METHOD' (conjI_Tac (K all_tac))))\<close> | |
| 13020 | 486 | "verification condition generator for interference freedom tests" | 
| 487 | ||
| 59189 | 488 | ML \<open> | 
| 13020 | 489 | fun disjE_Tac tac i st = st |> | 
| 490 | ( (EVERY [etac disjE i, | |
| 491 | disjE_Tac tac (i+1), | |
| 492 | tac i]) ORELSE (tac i) ) | |
| 59189 | 493 | \<close> | 
| 13020 | 494 | |
| 59189 | 495 | method_setup disjE_tac = \<open> | 
| 496 | Scan.succeed (K (SIMPLE_METHOD' (disjE_Tac (K all_tac))))\<close> | |
| 13020 | 497 | "verification condition generator for interference freedom tests" | 
| 498 | ||
| 13187 | 499 | end |