author | wenzelm |
Sun, 01 Mar 2009 14:45:23 +0100 | |
changeset 30186 | 1f836e949ac2 |
parent 27104 | 791607529f6d |
child 30510 | 4120fc59dd85 |
permissions | -rw-r--r-- |
13020 | 1 |
header {* \section{Generation of Verification Conditions} *} |
2 |
||
27104
791607529f6d
rep_datatype command now takes list of constructors as input arguments
haftmann
parents:
23894
diff
changeset
|
3 |
theory OG_Tactics |
791607529f6d
rep_datatype command now takes list of constructors as input arguments
haftmann
parents:
23894
diff
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 |
||
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> |
|
16 |
\<Longrightarrow> \<parallel>- p (Parallel Ts) q" |
|
17 |
apply (rule Conseq) |
|
18 |
prefer 2 |
|
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 |
||
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> |
|
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 |
||
52 |
lemma WhileRule: "\<lbrakk> p \<subseteq> i; \<parallel>- (i \<inter> b) c i ; (i \<inter> (-b)) \<subseteq> q \<rbrakk> |
|
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 |
||
59 |
text {* Three new proof rules for special instances of the @{text |
|
60 |
AnnBasic} and the @{text AnnAwait} commands when the transformation |
|
61 |
performed on the state is the identity, and for an @{text AnnAwait} |
|
62 |
command where the boolean condition is @{text "{s. True}"}: *} |
|
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 |
||
84 |
text {* Lemmata to avoid using the definition of @{text |
|
85 |
map_ann_hoare}, @{text interfree_aux}, @{text interfree_swap} and |
|
86 |
@{text interfree} by splitting it into different cases: *} |
|
87 |
||
88 |
lemma interfree_aux_rule1: "interfree_aux(co, q, None)" |
|
89 |
by(simp add:interfree_aux_def) |
|
90 |
||
91 |
lemma interfree_aux_rule2: |
|
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 |
||
97 |
lemma interfree_aux_rule3: |
|
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 |
||
104 |
lemma AnnBasic_assertions: |
|
105 |
"\<lbrakk>interfree_aux(None, r, Some a); interfree_aux(None, q, Some a)\<rbrakk> \<Longrightarrow> |
|
106 |
interfree_aux(Some (AnnBasic r f), q, Some a)" |
|
107 |
apply(simp add: interfree_aux_def) |
|
108 |
by force |
|
109 |
||
110 |
lemma AnnSeq_assertions: |
|
111 |
"\<lbrakk> interfree_aux(Some c1, q, Some a); interfree_aux(Some c2, q, Some a)\<rbrakk>\<Longrightarrow> |
|
112 |
interfree_aux(Some (AnnSeq c1 c2), q, Some a)" |
|
113 |
apply(simp add: interfree_aux_def) |
|
114 |
by force |
|
115 |
||
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> |
|
119 |
interfree_aux(Some(AnnCond1 r b c1 c2), q, Some a)" |
|
120 |
apply(simp add: interfree_aux_def) |
|
121 |
by force |
|
122 |
||
123 |
lemma AnnCond2_assertions: |
|
124 |
"\<lbrakk> interfree_aux(None, r, Some a); interfree_aux(Some c, q, Some a)\<rbrakk>\<Longrightarrow> |
|
125 |
interfree_aux(Some (AnnCond2 r b c), q, Some a)" |
|
126 |
apply(simp add: interfree_aux_def) |
|
127 |
by force |
|
128 |
||
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> |
|
132 |
interfree_aux(Some (AnnWhile r b i c), q, Some a)" |
|
133 |
apply(simp add: interfree_aux_def) |
|
134 |
by force |
|
135 |
||
136 |
lemma AnnAwait_assertions: |
|
137 |
"\<lbrakk> interfree_aux(None, r, Some a); interfree_aux(None, q, Some a)\<rbrakk>\<Longrightarrow> |
|
138 |
interfree_aux(Some (AnnAwait r b c), q, Some a)" |
|
139 |
apply(simp add: interfree_aux_def) |
|
140 |
by force |
|
141 |
||
142 |
lemma AnnBasic_atomics: |
|
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 |
||
146 |
lemma AnnSeq_atomics: |
|
147 |
"\<lbrakk> interfree_aux(Any, q, Some a1); interfree_aux(Any, q, Some a2)\<rbrakk>\<Longrightarrow> |
|
148 |
interfree_aux(Any, q, Some (AnnSeq a1 a2))" |
|
149 |
apply(simp add: interfree_aux_def) |
|
150 |
by force |
|
151 |
||
152 |
lemma AnnCond1_atomics: |
|
153 |
"\<lbrakk> interfree_aux(Any, q, Some a1); interfree_aux(Any, q, Some a2)\<rbrakk>\<Longrightarrow> |
|
154 |
interfree_aux(Any, q, Some (AnnCond1 r b a1 a2))" |
|
155 |
apply(simp add: interfree_aux_def) |
|
156 |
by force |
|
157 |
||
158 |
lemma AnnCond2_atomics: |
|
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 |
||
162 |
lemma AnnWhile_atomics: "interfree_aux (Any, q, Some a) |
|
163 |
\<Longrightarrow> interfree_aux(Any, q, Some (AnnWhile r b i a))" |
|
164 |
by(simp add: interfree_aux_def) |
|
165 |
||
166 |
lemma Annatom_atomics: |
|
167 |
"\<parallel>- (q \<inter> r) a q \<Longrightarrow> interfree_aux (None, q, Some (AnnAwait r {x. True} a))" |
|
168 |
by(simp add: interfree_aux_def oghoare_sound) |
|
169 |
||
170 |
lemma AnnAwait_atomics: |
|
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 |
||
174 |
constdefs |
|
175 |
interfree_swap :: "('a ann_triple_op * ('a ann_triple_op) list) \<Rightarrow> bool" |
|
176 |
"interfree_swap == \<lambda>(x, xs). \<forall>y\<in>set xs. interfree_aux (com x, post x, com y) |
|
177 |
\<and> interfree_aux(com y, post y, com x)" |
|
178 |
||
179 |
lemma interfree_swap_Empty: "interfree_swap (x, [])" |
|
180 |
by(simp add:interfree_swap_def) |
|
181 |
||
182 |
lemma interfree_swap_List: |
|
183 |
"\<lbrakk> interfree_aux (com x, post x, com y); |
|
184 |
interfree_aux (com y, post y ,com x); interfree_swap (x, xs) \<rbrakk> |
|
185 |
\<Longrightarrow> interfree_swap (x, y#xs)" |
|
186 |
by(simp add:interfree_swap_def) |
|
187 |
||
188 |
lemma interfree_swap_Map: "\<forall>k. i\<le>k \<and> k<j \<longrightarrow> interfree_aux (com x, post x, c k) |
|
189 |
\<and> interfree_aux (c k, Q k, com x) |
|
15425 | 190 |
\<Longrightarrow> interfree_swap (x, map (\<lambda>k. (c k, Q k)) [i..<j])" |
13020 | 191 |
by(force simp add: interfree_swap_def less_diff_conv) |
192 |
||
193 |
lemma interfree_Empty: "interfree []" |
|
194 |
by(simp add:interfree_def) |
|
195 |
||
196 |
lemma interfree_List: |
|
197 |
"\<lbrakk> interfree_swap(x, xs); interfree xs \<rbrakk> \<Longrightarrow> interfree (x#xs)" |
|
198 |
apply(simp add:interfree_def interfree_swap_def) |
|
199 |
apply clarify |
|
200 |
apply(case_tac i) |
|
201 |
apply(case_tac j) |
|
202 |
apply simp_all |
|
203 |
apply(case_tac j,simp+) |
|
204 |
done |
|
205 |
||
206 |
lemma interfree_Map: |
|
207 |
"(\<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 | 208 |
\<Longrightarrow> interfree (map (\<lambda>k. (c k, Q k)) [a..<b])" |
13020 | 209 |
by(force simp add: interfree_def less_diff_conv) |
210 |
||
211 |
constdefs map_ann_hoare :: "(('a ann_com_op * 'a assn) list) \<Rightarrow> bool " ("[\<turnstile>] _" [0] 45) |
|
212 |
"[\<turnstile>] Ts == (\<forall>i<length Ts. \<exists>c q. Ts!i=(Some c, q) \<and> \<turnstile> c q)" |
|
213 |
||
214 |
lemma MapAnnEmpty: "[\<turnstile>] []" |
|
215 |
by(simp add:map_ann_hoare_def) |
|
216 |
||
217 |
lemma MapAnnList: "\<lbrakk> \<turnstile> c q ; [\<turnstile>] xs \<rbrakk> \<Longrightarrow> [\<turnstile>] (Some c,q)#xs" |
|
218 |
apply(simp add:map_ann_hoare_def) |
|
219 |
apply clarify |
|
220 |
apply(case_tac i,simp+) |
|
221 |
done |
|
222 |
||
223 |
lemma MapAnnMap: |
|
15425 | 224 |
"\<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 | 225 |
apply(simp add: map_ann_hoare_def less_diff_conv) |
226 |
done |
|
227 |
||
228 |
lemma ParallelRule:"\<lbrakk> [\<turnstile>] Ts ; interfree Ts \<rbrakk> |
|
229 |
\<Longrightarrow> \<parallel>- (\<Inter>i\<in>{i. i<length Ts}. pre(the(com(Ts!i)))) |
|
230 |
Parallel Ts |
|
231 |
(\<Inter>i\<in>{i. i<length Ts}. post(Ts!i))" |
|
232 |
apply(rule Parallel) |
|
233 |
apply(simp add:map_ann_hoare_def) |
|
234 |
apply simp |
|
235 |
done |
|
236 |
(* |
|
237 |
lemma ParamParallelRule: |
|
238 |
"\<lbrakk> \<forall>k<n. \<turnstile> (c k) (Q k); |
|
239 |
\<forall>k l. k<n \<and> l<n \<and> k\<noteq>l \<longrightarrow> interfree_aux (Some(c k), Q k, Some(c l)) \<rbrakk> |
|
240 |
\<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 )" |
|
241 |
apply(rule ParallelConseqRule) |
|
242 |
apply simp |
|
243 |
apply clarify |
|
244 |
apply force |
|
245 |
apply(rule ParallelRule) |
|
246 |
apply(rule MapAnnMap) |
|
247 |
apply simp |
|
248 |
apply(rule interfree_Map) |
|
249 |
apply simp |
|
250 |
apply simp |
|
251 |
apply clarify |
|
252 |
apply force |
|
253 |
done |
|
254 |
*) |
|
255 |
||
256 |
text {* The following are some useful lemmas and simplification |
|
257 |
tactics to control which theorems are used to simplify at each moment, |
|
258 |
so that the original input does not suffer any unexpected |
|
259 |
transformation. *} |
|
260 |
||
261 |
lemma Compl_Collect: "-(Collect b) = {x. \<not>(b x)}" |
|
262 |
by fast |
|
263 |
lemma list_length: "length []=0 \<and> length (x#xs) = Suc(length xs)" |
|
264 |
by simp |
|
265 |
lemma list_lemmas: "length []=0 \<and> length (x#xs) = Suc(length xs) |
|
266 |
\<and> (x#xs) ! 0=x \<and> (x#xs) ! Suc n = xs ! n" |
|
267 |
by simp |
|
268 |
lemma le_Suc_eq_insert: "{i. i <Suc n} = insert n {i. i< n}" |
|
13187 | 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:
23894
diff
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 |
274 |
lemmas ParallelConseq_list = INTER_def Collect_conj_eq length_map length_upt length_append list_length |
|
275 |
||
276 |
ML {* |
|
277 |
val before_interfree_simp_tac = (simp_tac (HOL_basic_ss addsimps [thm "com.simps", thm "post.simps"])) |
|
278 |
||
279 |
val interfree_simp_tac = (asm_simp_tac (HOL_ss addsimps [thm "split", thm "ball_Un", thm "ball_empty"]@(thms "my_simp_list"))) |
|
280 |
||
281 |
val ParallelConseq = (simp_tac (HOL_basic_ss addsimps (thms "ParallelConseq_list")@(thms "my_simp_list"))) |
|
282 |
*} |
|
283 |
||
284 |
text {* The following tactic applies @{text tac} to each conjunct in a |
|
285 |
subgoal of the form @{text "A \<Longrightarrow> a1 \<and> a2 \<and> .. \<and> an"} returning |
|
286 |
@{text n} subgoals, one for each conjunct: *} |
|
287 |
||
288 |
ML {* |
|
289 |
fun conjI_Tac tac i st = st |> |
|
290 |
( (EVERY [rtac conjI i, |
|
291 |
conjI_Tac tac (i+1), |
|
292 |
tac i]) ORELSE (tac i) ) |
|
293 |
*} |
|
294 |
||
295 |
||
296 |
subsubsection {* Tactic for the generation of the verification conditions *} |
|
297 |
||
298 |
text {* The tactic basically uses two subtactics: |
|
299 |
||
300 |
\begin{description} |
|
301 |
||
302 |
\item[HoareRuleTac] is called at the level of parallel programs, it |
|
303 |
uses the ParallelTac to solve parallel composition of programs. |
|
304 |
This verification has two parts, namely, (1) all component programs are |
|
305 |
correct and (2) they are interference free. @{text HoareRuleTac} is |
|
306 |
also called at the level of atomic regions, i.e. @{text "\<langle> \<rangle>"} and |
|
307 |
@{text "AWAIT b THEN _ END"}, and at each interference freedom test. |
|
308 |
||
309 |
\item[AnnHoareRuleTac] is for component programs which |
|
310 |
are annotated programs and so, there are not unknown assertions |
|
311 |
(no need to use the parameter precond, see NOTE). |
|
312 |
||
313 |
NOTE: precond(::bool) informs if the subgoal has the form @{text "\<parallel>- ?p c q"}, |
|
314 |
in this case we have precond=False and the generated verification |
|
315 |
condition would have the form @{text "?p \<subseteq> \<dots>"} which can be solved by |
|
316 |
@{text "rtac subset_refl"}, if True we proceed to simplify it using |
|
317 |
the simplification tactics above. |
|
318 |
||
319 |
\end{description} |
|
320 |
*} |
|
321 |
||
322 |
ML {* |
|
323 |
||
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
324 |
fun WlpTac i = (rtac (@{thm SeqRule}) i) THEN (HoareRuleTac false (i+1)) |
13020 | 325 |
and HoareRuleTac precond i st = st |> |
326 |
( (WlpTac i THEN HoareRuleTac precond i) |
|
327 |
ORELSE |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
328 |
(FIRST[rtac (@{thm SkipRule}) i, |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
329 |
rtac (@{thm BasicRule}) i, |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
330 |
EVERY[rtac (@{thm ParallelConseqRule}) i, |
13020 | 331 |
ParallelConseq (i+2), |
332 |
ParallelTac (i+1), |
|
333 |
ParallelConseq i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
334 |
EVERY[rtac (@{thm CondRule}) i, |
13020 | 335 |
HoareRuleTac false (i+2), |
336 |
HoareRuleTac false (i+1)], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
337 |
EVERY[rtac (@{thm WhileRule}) i, |
13020 | 338 |
HoareRuleTac true (i+1)], |
339 |
K all_tac i ] |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
340 |
THEN (if precond then (K all_tac i) else (rtac (@{thm subset_refl}) i)))) |
13020 | 341 |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
342 |
and AnnWlpTac i = (rtac (@{thm AnnSeq}) i) THEN (AnnHoareRuleTac (i+1)) |
13020 | 343 |
and AnnHoareRuleTac i st = st |> |
344 |
( (AnnWlpTac i THEN AnnHoareRuleTac i ) |
|
345 |
ORELSE |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
346 |
(FIRST[(rtac (@{thm AnnskipRule}) i), |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
347 |
EVERY[rtac (@{thm AnnatomRule}) i, |
13020 | 348 |
HoareRuleTac true (i+1)], |
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
349 |
(rtac (@{thm AnnwaitRule}) i), |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
350 |
rtac (@{thm AnnBasic}) i, |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
351 |
EVERY[rtac (@{thm AnnCond1}) i, |
13020 | 352 |
AnnHoareRuleTac (i+3), |
353 |
AnnHoareRuleTac (i+1)], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
354 |
EVERY[rtac (@{thm AnnCond2}) i, |
13020 | 355 |
AnnHoareRuleTac (i+1)], |
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
356 |
EVERY[rtac (@{thm AnnWhile}) i, |
13020 | 357 |
AnnHoareRuleTac (i+2)], |
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
358 |
EVERY[rtac (@{thm AnnAwait}) i, |
13020 | 359 |
HoareRuleTac true (i+1)], |
360 |
K all_tac i])) |
|
361 |
||
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
362 |
and ParallelTac i = EVERY[rtac (@{thm ParallelRule}) i, |
13020 | 363 |
interfree_Tac (i+1), |
364 |
MapAnn_Tac i] |
|
365 |
||
366 |
and MapAnn_Tac i st = st |> |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
367 |
(FIRST[rtac (@{thm MapAnnEmpty}) i, |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
368 |
EVERY[rtac (@{thm MapAnnList}) i, |
13020 | 369 |
MapAnn_Tac (i+1), |
370 |
AnnHoareRuleTac i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
371 |
EVERY[rtac (@{thm MapAnnMap}) i, |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
372 |
rtac (@{thm allI}) i,rtac (@{thm impI}) i, |
13020 | 373 |
AnnHoareRuleTac i]]) |
374 |
||
375 |
and interfree_swap_Tac i st = st |> |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
376 |
(FIRST[rtac (@{thm interfree_swap_Empty}) i, |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
377 |
EVERY[rtac (@{thm interfree_swap_List}) i, |
13020 | 378 |
interfree_swap_Tac (i+2), |
379 |
interfree_aux_Tac (i+1), |
|
380 |
interfree_aux_Tac i ], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
381 |
EVERY[rtac (@{thm interfree_swap_Map}) i, |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
382 |
rtac (@{thm allI}) i,rtac (@{thm impI}) i, |
13020 | 383 |
conjI_Tac (interfree_aux_Tac) i]]) |
384 |
||
385 |
and interfree_Tac i st = st |> |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
386 |
(FIRST[rtac (@{thm interfree_Empty}) i, |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
387 |
EVERY[rtac (@{thm interfree_List}) i, |
13020 | 388 |
interfree_Tac (i+1), |
389 |
interfree_swap_Tac i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
390 |
EVERY[rtac (@{thm interfree_Map}) i, |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
391 |
rtac (@{thm allI}) i,rtac (@{thm allI}) i,rtac (@{thm impI}) i, |
13020 | 392 |
interfree_aux_Tac i ]]) |
393 |
||
394 |
and interfree_aux_Tac i = (before_interfree_simp_tac i ) THEN |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
395 |
(FIRST[rtac (@{thm interfree_aux_rule1}) i, |
13020 | 396 |
dest_assertions_Tac i]) |
397 |
||
398 |
and dest_assertions_Tac i st = st |> |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
399 |
(FIRST[EVERY[rtac (@{thm AnnBasic_assertions}) i, |
13020 | 400 |
dest_atomics_Tac (i+1), |
401 |
dest_atomics_Tac i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
402 |
EVERY[rtac (@{thm AnnSeq_assertions}) i, |
13020 | 403 |
dest_assertions_Tac (i+1), |
404 |
dest_assertions_Tac i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
405 |
EVERY[rtac (@{thm AnnCond1_assertions}) i, |
13020 | 406 |
dest_assertions_Tac (i+2), |
407 |
dest_assertions_Tac (i+1), |
|
408 |
dest_atomics_Tac i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
409 |
EVERY[rtac (@{thm AnnCond2_assertions}) i, |
13020 | 410 |
dest_assertions_Tac (i+1), |
411 |
dest_atomics_Tac i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
412 |
EVERY[rtac (@{thm AnnWhile_assertions}) i, |
13020 | 413 |
dest_assertions_Tac (i+2), |
414 |
dest_atomics_Tac (i+1), |
|
415 |
dest_atomics_Tac i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
416 |
EVERY[rtac (@{thm AnnAwait_assertions}) i, |
13020 | 417 |
dest_atomics_Tac (i+1), |
418 |
dest_atomics_Tac i], |
|
419 |
dest_atomics_Tac i]) |
|
420 |
||
421 |
and dest_atomics_Tac i st = st |> |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
422 |
(FIRST[EVERY[rtac (@{thm AnnBasic_atomics}) i, |
13020 | 423 |
HoareRuleTac true i], |
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
424 |
EVERY[rtac (@{thm AnnSeq_atomics}) i, |
13020 | 425 |
dest_atomics_Tac (i+1), |
426 |
dest_atomics_Tac i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
427 |
EVERY[rtac (@{thm AnnCond1_atomics}) i, |
13020 | 428 |
dest_atomics_Tac (i+1), |
429 |
dest_atomics_Tac i], |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
430 |
EVERY[rtac (@{thm AnnCond2_atomics}) i, |
13020 | 431 |
dest_atomics_Tac i], |
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
432 |
EVERY[rtac (@{thm AnnWhile_atomics}) i, |
13020 | 433 |
dest_atomics_Tac i], |
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
434 |
EVERY[rtac (@{thm Annatom_atomics}) i, |
13020 | 435 |
HoareRuleTac true i], |
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
436 |
EVERY[rtac (@{thm AnnAwait_atomics}) i, |
13020 | 437 |
HoareRuleTac true i], |
438 |
K all_tac i]) |
|
439 |
*} |
|
440 |
||
441 |
||
442 |
text {* The final tactic is given the name @{text oghoare}: *} |
|
443 |
||
444 |
ML {* |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
445 |
val oghoare_tac = SUBGOAL (fn (_, i) => |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
446 |
(HoareRuleTac true i)) |
13020 | 447 |
*} |
448 |
||
449 |
text {* Notice that the tactic for parallel programs @{text |
|
450 |
"oghoare_tac"} is initially invoked with the value @{text true} for |
|
451 |
the parameter @{text precond}. |
|
452 |
||
453 |
Parts of the tactic can be also individually used to generate the |
|
454 |
verification conditions for annotated sequential programs and to |
|
455 |
generate verification conditions out of interference freedom tests: *} |
|
456 |
||
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
457 |
ML {* val annhoare_tac = SUBGOAL (fn (_, i) => |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
458 |
(AnnHoareRuleTac i)) |
13020 | 459 |
|
23894
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
460 |
val interfree_aux_tac = SUBGOAL (fn (_, i) => |
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
wenzelm
parents:
21588
diff
changeset
|
461 |
(interfree_aux_Tac i)) |
13020 | 462 |
*} |
463 |
||
464 |
text {* The so defined ML tactics are then ``exported'' to be used in |
|
465 |
Isabelle proofs. *} |
|
466 |
||
467 |
method_setup oghoare = {* |
|
21588 | 468 |
Method.no_args (Method.SIMPLE_METHOD' oghoare_tac) *} |
13020 | 469 |
"verification condition generator for the oghoare logic" |
470 |
||
471 |
method_setup annhoare = {* |
|
21588 | 472 |
Method.no_args (Method.SIMPLE_METHOD' annhoare_tac) *} |
13020 | 473 |
"verification condition generator for the ann_hoare logic" |
474 |
||
475 |
method_setup interfree_aux = {* |
|
21588 | 476 |
Method.no_args (Method.SIMPLE_METHOD' interfree_aux_tac) *} |
13020 | 477 |
"verification condition generator for interference freedom tests" |
478 |
||
479 |
text {* Tactics useful for dealing with the generated verification conditions: *} |
|
480 |
||
481 |
method_setup conjI_tac = {* |
|
21588 | 482 |
Method.no_args (Method.SIMPLE_METHOD' (conjI_Tac (K all_tac))) *} |
13020 | 483 |
"verification condition generator for interference freedom tests" |
484 |
||
485 |
ML {* |
|
486 |
fun disjE_Tac tac i st = st |> |
|
487 |
( (EVERY [etac disjE i, |
|
488 |
disjE_Tac tac (i+1), |
|
489 |
tac i]) ORELSE (tac i) ) |
|
490 |
*} |
|
491 |
||
492 |
method_setup disjE_tac = {* |
|
21588 | 493 |
Method.no_args (Method.SIMPLE_METHOD' (disjE_Tac (K all_tac))) *} |
13020 | 494 |
"verification condition generator for interference freedom tests" |
495 |
||
13187 | 496 |
end |