35 "starts_of(A || B) = {p. fst(p):starts_of(A) & snd(p):starts_of(B)}"; |
33 "starts_of(A || B) = {p. fst(p):starts_of(A) & snd(p):starts_of(B)}"; |
36 by (simp_tac (simpset() addsimps (par_def::ioa_projections)) 1); |
34 by (simp_tac (simpset() addsimps (par_def::ioa_projections)) 1); |
37 qed "starts_of_par"; |
35 qed "starts_of_par"; |
38 |
36 |
39 Goal |
37 Goal |
40 "trans_of(A || B) = {tr. let s = fst(tr); a = fst(snd(tr)); t = snd(snd(tr)) \ |
38 "trans_of(A || B) = {tr. let s = fst(tr); a = fst(snd(tr)); t = snd(snd(tr)) \ |
41 \ in (a:act A | a:act B) & \ |
39 \ in (a:act A | a:act B) & \ |
42 \ (if a:act A then \ |
40 \ (if a:act A then \ |
43 \ (fst(s),a,fst(t)):trans_of(A) \ |
41 \ (fst(s),a,fst(t)):trans_of(A) \ |
44 \ else fst(t) = fst(s)) \ |
42 \ else fst(t) = fst(s)) \ |
45 \ & \ |
43 \ & \ |
46 \ (if a:act B then \ |
44 \ (if a:act B then \ |
47 \ (snd(s),a,snd(t)):trans_of(B) \ |
45 \ (snd(s),a,snd(t)):trans_of(B) \ |
48 \ else snd(t) = snd(s))}"; |
46 \ else snd(t) = snd(s))}"; |
49 |
47 |
50 by (simp_tac (simpset() addsimps (par_def::ioa_projections)) 1); |
48 by (simp_tac (simpset() addsimps (par_def::ioa_projections)) 1); |
51 qed "trans_of_par"; |
49 qed "trans_of_par"; |
52 |
50 |
54 (* ------------------------------------------------------------------------- *) |
52 (* ------------------------------------------------------------------------- *) |
55 |
53 |
56 section "actions and par"; |
54 section "actions and par"; |
57 |
55 |
58 |
56 |
59 Goal |
57 Goal |
60 "actions(asig_comp a b) = actions(a) Un actions(b)"; |
58 "actions(asig_comp a b) = actions(a) Un actions(b)"; |
61 by (simp_tac (simpset() addsimps |
59 by (simp_tac (simpset() addsimps |
62 ([actions_def,asig_comp_def]@asig_projections)) 1); |
60 ([actions_def,asig_comp_def]@asig_projections)) 1); |
63 by (fast_tac (set_cs addSIs [equalityI]) 1); |
61 by (fast_tac (set_cs addSIs [equalityI]) 1); |
64 qed "actions_asig_comp"; |
62 qed "actions_asig_comp"; |
71 |
69 |
72 Goal "ext (A1||A2) = \ |
70 Goal "ext (A1||A2) = \ |
73 \ (ext A1) Un (ext A2)"; |
71 \ (ext A1) Un (ext A2)"; |
74 by (asm_full_simp_tac (simpset() addsimps [externals_def,asig_of_par,asig_comp_def, |
72 by (asm_full_simp_tac (simpset() addsimps [externals_def,asig_of_par,asig_comp_def, |
75 asig_inputs_def,asig_outputs_def,Un_def,set_diff_def]) 1); |
73 asig_inputs_def,asig_outputs_def,Un_def,set_diff_def]) 1); |
76 by (rtac set_ext 1); |
74 by (rtac set_ext 1); |
77 by (fast_tac set_cs 1); |
75 by (fast_tac set_cs 1); |
78 qed"externals_of_par"; |
76 qed"externals_of_par"; |
79 |
77 |
80 Goal "act (A1||A2) = \ |
78 Goal "act (A1||A2) = \ |
81 \ (act A1) Un (act A2)"; |
79 \ (act A1) Un (act A2)"; |
82 by (asm_full_simp_tac (simpset() addsimps [actions_def,asig_of_par,asig_comp_def, |
80 by (asm_full_simp_tac (simpset() addsimps [actions_def,asig_of_par,asig_comp_def, |
83 asig_inputs_def,asig_outputs_def,asig_internals_def,Un_def,set_diff_def]) 1); |
81 asig_inputs_def,asig_outputs_def,asig_internals_def,Un_def,set_diff_def]) 1); |
84 by (rtac set_ext 1); |
82 by (rtac set_ext 1); |
85 by (fast_tac set_cs 1); |
83 by (fast_tac set_cs 1); |
86 qed"actions_of_par"; |
84 qed"actions_of_par"; |
87 |
85 |
88 Goal "inp (A1||A2) =\ |
86 Goal "inp (A1||A2) =\ |
89 \ ((inp A1) Un (inp A2)) - ((out A1) Un (out A2))"; |
87 \ ((inp A1) Un (inp A2)) - ((out A1) Un (out A2))"; |
90 by (asm_full_simp_tac (simpset() addsimps [actions_def,asig_of_par,asig_comp_def, |
88 by (asm_full_simp_tac (simpset() addsimps [actions_def,asig_of_par,asig_comp_def, |
91 asig_inputs_def,asig_outputs_def,Un_def,set_diff_def]) 1); |
89 asig_inputs_def,asig_outputs_def,Un_def,set_diff_def]) 1); |
92 qed"inputs_of_par"; |
90 qed"inputs_of_par"; |
93 |
91 |
94 Goal "out (A1||A2) =\ |
92 Goal "out (A1||A2) =\ |
95 \ (out A1) Un (out A2)"; |
93 \ (out A1) Un (out A2)"; |
96 by (asm_full_simp_tac (simpset() addsimps [actions_def,asig_of_par,asig_comp_def, |
94 by (asm_full_simp_tac (simpset() addsimps [actions_def,asig_of_par,asig_comp_def, |
97 asig_outputs_def,Un_def,set_diff_def]) 1); |
95 asig_outputs_def,Un_def,set_diff_def]) 1); |
98 qed"outputs_of_par"; |
96 qed"outputs_of_par"; |
103 asig_inputs_def,asig_outputs_def,asig_internals_def,Un_def,set_diff_def]) 1); |
101 asig_inputs_def,asig_outputs_def,asig_internals_def,Un_def,set_diff_def]) 1); |
104 qed"internals_of_par"; |
102 qed"internals_of_par"; |
105 |
103 |
106 (* ------------------------------------------------------------------------ *) |
104 (* ------------------------------------------------------------------------ *) |
107 |
105 |
108 section "actions and compatibility"; |
106 section "actions and compatibility"; |
109 |
107 |
110 Goal"compatible A B = compatible B A"; |
108 Goal"compatible A B = compatible B A"; |
111 by (asm_full_simp_tac (simpset() addsimps [compatible_def,Int_commute]) 1); |
109 by (asm_full_simp_tac (simpset() addsimps [compatible_def,Int_commute]) 1); |
112 by Auto_tac; |
110 by Auto_tac; |
113 qed"compat_commute"; |
111 qed"compat_commute"; |
156 by (Blast_tac 1); |
154 by (Blast_tac 1); |
157 qed"inpAAactB_is_inpBoroutB"; |
155 qed"inpAAactB_is_inpBoroutB"; |
158 |
156 |
159 (* ------------------------------------------------------------------------- *) |
157 (* ------------------------------------------------------------------------- *) |
160 |
158 |
161 section "input_enabledness and par"; |
159 section "input_enabledness and par"; |
162 |
160 |
163 |
161 |
164 (* ugly case distinctions. Heart of proof: |
162 (* ugly case distinctions. Heart of proof: |
165 1. inpAAactB_is_inpBoroutB ie. internals are really hidden. |
163 1. inpAAactB_is_inpBoroutB ie. internals are really hidden. |
166 2. inputs_of_par: outputs are no longer inputs of par. This is important here *) |
164 2. inputs_of_par: outputs are no longer inputs of par. This is important here *) |
167 Goalw [input_enabled_def] |
165 Goalw [input_enabled_def] |
168 "[| compatible A B; input_enabled A; input_enabled B|] \ |
166 "[| compatible A B; input_enabled A; input_enabled B|] \ |
169 \ ==> input_enabled (A||B)"; |
167 \ ==> input_enabled (A||B)"; |
170 by (asm_full_simp_tac (simpset()addsimps[Let_def,inputs_of_par,trans_of_par])1); |
168 by (asm_full_simp_tac (simpset()addsimps[Let_def,inputs_of_par,trans_of_par])1); |
171 by (safe_tac set_cs); |
169 by (safe_tac set_cs); |
172 by (asm_full_simp_tac (simpset() addsimps [inp_is_act]) 1); |
170 by (asm_full_simp_tac (simpset() addsimps [inp_is_act]) 1); |
230 |
228 |
231 (* ------------------------------------------------------------------------- *) |
229 (* ------------------------------------------------------------------------- *) |
232 |
230 |
233 section "invariants"; |
231 section "invariants"; |
234 |
232 |
235 val [p1,p2] = goalw thy [invariant_def] |
233 val [p1,p2] = goalw (the_context ()) [invariant_def] |
236 "[| !!s. s:starts_of(A) ==> P(s); \ |
234 "[| !!s. s:starts_of(A) ==> P(s); \ |
237 \ !!s t a. [|reachable A s; P(s)|] ==> (s,a,t): trans_of(A) --> P(t) |] \ |
235 \ !!s t a. [|reachable A s; P(s)|] ==> (s,a,t): trans_of(A) --> P(t) |] \ |
238 \ ==> invariant A P"; |
236 \ ==> invariant A P"; |
239 by (rtac allI 1); |
237 by (rtac allI 1); |
240 by (rtac impI 1); |
238 by (rtac impI 1); |
244 by (eres_inst_tac [("s1","sa")] (p2 RS mp) 1); |
242 by (eres_inst_tac [("s1","sa")] (p2 RS mp) 1); |
245 by (REPEAT (atac 1)); |
243 by (REPEAT (atac 1)); |
246 qed"invariantI"; |
244 qed"invariantI"; |
247 |
245 |
248 |
246 |
249 val [p1,p2] = goal thy |
247 val [p1,p2] = goal (the_context ()) |
250 "[| !!s. s : starts_of(A) ==> P(s); \ |
248 "[| !!s. s : starts_of(A) ==> P(s); \ |
251 \ !!s t a. reachable A s ==> P(s) --> (s,a,t):trans_of(A) --> P(t) \ |
249 \ !!s t a. reachable A s ==> P(s) --> (s,a,t):trans_of(A) --> P(t) \ |
252 \ |] ==> invariant A P"; |
250 \ |] ==> invariant A P"; |
253 by (fast_tac (HOL_cs addSIs [invariantI] addSDs [p1,p2]) 1); |
251 by (fast_tac (HOL_cs addSIs [invariantI] addSDs [p1,p2]) 1); |
254 qed "invariantI1"; |
252 qed "invariantI1"; |
255 |
253 |
256 Goalw [invariant_def] "[| invariant A P; reachable A s |] ==> P(s)"; |
254 Goalw [invariant_def] "[| invariant A P; reachable A s |] ==> P(s)"; |
257 by (Blast_tac 1); |
255 by (Blast_tac 1); |
258 qed "invariantE"; |
256 qed "invariantE"; |
259 |
257 |
260 (* ------------------------------------------------------------------------- *) |
258 (* ------------------------------------------------------------------------- *) |
261 |
259 |
262 section "restrict"; |
260 section "restrict"; |
373 val trans_of_defs1 = [trans_AB,trans_A_notB,trans_notA_B]; |
371 val trans_of_defs1 = [trans_AB,trans_A_notB,trans_notA_B]; |
374 val trans_of_defs2 = [trans_A_proj,trans_B_proj,trans_A_proj2, |
372 val trans_of_defs2 = [trans_A_proj,trans_B_proj,trans_A_proj2, |
375 trans_B_proj2,trans_AB_proj]; |
373 trans_B_proj2,trans_AB_proj]; |
376 |
374 |
377 |
375 |
378 Goal |
376 Goal |
379 "((s,a,t) : trans_of(A || B || C || D)) = \ |
377 "((s,a,t) : trans_of(A || B || C || D)) = \ |
380 \ ((a:actions(asig_of(A)) | a:actions(asig_of(B)) | a:actions(asig_of(C)) | \ |
378 \ ((a:actions(asig_of(A)) | a:actions(asig_of(B)) | a:actions(asig_of(C)) | \ |
381 \ a:actions(asig_of(D))) & \ |
379 \ a:actions(asig_of(D))) & \ |
382 \ (if a:actions(asig_of(A)) then (fst(s),a,fst(t)):trans_of(A) \ |
380 \ (if a:actions(asig_of(A)) then (fst(s),a,fst(t)):trans_of(A) \ |
383 \ else fst t=fst s) & \ |
381 \ else fst t=fst s) & \ |
395 qed "trans_of_par4"; |
393 qed "trans_of_par4"; |
396 |
394 |
397 |
395 |
398 (* ------------------------------------------------------------------------- *) |
396 (* ------------------------------------------------------------------------- *) |
399 |
397 |
400 section "proof obligation generator for IOA requirements"; |
398 section "proof obligation generator for IOA requirements"; |
401 |
399 |
402 (* without assumptions on A and B because is_trans_of is also incorporated in ||def *) |
400 (* without assumptions on A and B because is_trans_of is also incorporated in ||def *) |
403 Goalw [is_trans_of_def] "is_trans_of (A||B)"; |
401 Goalw [is_trans_of_def] "is_trans_of (A||B)"; |
404 by (simp_tac (simpset() addsimps [Let_def,actions_of_par,trans_of_par]) 1); |
402 by (simp_tac (simpset() addsimps [Let_def,actions_of_par,trans_of_par]) 1); |
405 qed"is_trans_of_par"; |
403 qed"is_trans_of_par"; |
406 |
404 |
407 Goalw [is_trans_of_def] |
405 Goalw [is_trans_of_def] |
408 "is_trans_of A ==> is_trans_of (restrict A acts)"; |
406 "is_trans_of A ==> is_trans_of (restrict A acts)"; |
409 by (asm_simp_tac (simpset() addsimps [cancel_restrict,acts_restrict])1); |
407 by (asm_simp_tac (simpset() addsimps [cancel_restrict,acts_restrict])1); |
410 qed"is_trans_of_restrict"; |
408 qed"is_trans_of_restrict"; |
411 |
409 |
412 Goalw [is_trans_of_def,restrict_def,restrict_asig_def] |
410 Goalw [is_trans_of_def,restrict_def,restrict_asig_def] |
413 "is_trans_of A ==> is_trans_of (rename A f)"; |
411 "is_trans_of A ==> is_trans_of (rename A f)"; |
414 by (asm_full_simp_tac |
412 by (asm_full_simp_tac |
415 (simpset() addsimps [Let_def,actions_def,trans_of_def, asig_internals_def, |
413 (simpset() addsimps [Let_def,actions_def,trans_of_def, asig_internals_def, |
416 asig_outputs_def,asig_inputs_def,externals_def, |
414 asig_outputs_def,asig_inputs_def,externals_def, |
417 asig_of_def,rename_def,rename_set_def]) 1); |
415 asig_of_def,rename_def,rename_set_def]) 1); |
418 by (Blast_tac 1); |
416 by (Blast_tac 1); |
419 qed"is_trans_of_rename"; |
417 qed"is_trans_of_rename"; |
420 |
418 |
421 Goal "[| is_asig_of A; is_asig_of B; compatible A B|] \ |
419 Goal "[| is_asig_of A; is_asig_of B; compatible A B|] \ |
422 \ ==> is_asig_of (A||B)"; |
420 \ ==> is_asig_of (A||B)"; |
426 by (asm_full_simp_tac (simpset() addsimps [asig_of_def]) 1); |
424 by (asm_full_simp_tac (simpset() addsimps [asig_of_def]) 1); |
427 by Auto_tac; |
425 by Auto_tac; |
428 qed"is_asig_of_par"; |
426 qed"is_asig_of_par"; |
429 |
427 |
430 Goalw [is_asig_of_def,is_asig_def,asig_of_def,restrict_def,restrict_asig_def, |
428 Goalw [is_asig_of_def,is_asig_def,asig_of_def,restrict_def,restrict_asig_def, |
431 asig_internals_def,asig_outputs_def,asig_inputs_def,externals_def,o_def] |
429 asig_internals_def,asig_outputs_def,asig_inputs_def,externals_def,o_def] |
432 "is_asig_of A ==> is_asig_of (restrict A f)"; |
430 "is_asig_of A ==> is_asig_of (restrict A f)"; |
433 by (Asm_full_simp_tac 1); |
431 by (Asm_full_simp_tac 1); |
434 by Auto_tac; |
432 by Auto_tac; |
435 qed"is_asig_of_restrict"; |
433 qed"is_asig_of_restrict"; |
436 |
434 |
437 Goal "is_asig_of A ==> is_asig_of (rename A f)"; |
435 Goal "is_asig_of A ==> is_asig_of (rename A f)"; |
438 by (asm_full_simp_tac (simpset() addsimps [is_asig_of_def, |
436 by (asm_full_simp_tac (simpset() addsimps [is_asig_of_def, |
439 rename_def,rename_set_def,asig_internals_def,asig_outputs_def, |
437 rename_def,rename_set_def,asig_internals_def,asig_outputs_def, |
440 asig_inputs_def,actions_def,is_asig_def,asig_of_def]) 1); |
438 asig_inputs_def,actions_def,is_asig_def,asig_of_def]) 1); |
441 by Auto_tac; |
439 by Auto_tac; |
442 by (ALLGOALS(dres_inst_tac [("s","Some ?x")] sym THEN' Asm_full_simp_tac)); |
440 by (ALLGOALS(dres_inst_tac [("s","Some ?x")] sym THEN' Asm_full_simp_tac)); |
443 by (ALLGOALS(Blast_tac)); |
441 by (ALLGOALS(Blast_tac)); |
444 qed"is_asig_of_rename"; |
442 qed"is_asig_of_rename"; |
445 |
443 |
446 |
444 |
448 is_trans_of_par,is_trans_of_restrict,is_trans_of_rename]; |
446 is_trans_of_par,is_trans_of_restrict,is_trans_of_rename]; |
449 |
447 |
450 |
448 |
451 Goalw [compatible_def] |
449 Goalw [compatible_def] |
452 "[|compatible A B; compatible A C |]==> compatible A (B||C)"; |
450 "[|compatible A B; compatible A C |]==> compatible A (B||C)"; |
453 by (asm_full_simp_tac (simpset() addsimps [internals_of_par, |
451 by (asm_full_simp_tac (simpset() addsimps [internals_of_par, |
454 outputs_of_par,actions_of_par]) 1); |
452 outputs_of_par,actions_of_par]) 1); |
455 by Auto_tac; |
453 by Auto_tac; |
456 qed"compatible_par"; |
454 qed"compatible_par"; |
457 |
455 |
458 (* better derive by previous one and compat_commute *) |
456 (* better derive by previous one and compat_commute *) |
459 Goalw [compatible_def] |
457 Goalw [compatible_def] |
460 "[|compatible A C; compatible B C |]==> compatible (A||B) C"; |
458 "[|compatible A C; compatible B C |]==> compatible (A||B) C"; |
461 by (asm_full_simp_tac (simpset() addsimps [internals_of_par, |
459 by (asm_full_simp_tac (simpset() addsimps [internals_of_par, |
462 outputs_of_par,actions_of_par]) 1); |
460 outputs_of_par,actions_of_par]) 1); |
463 by Auto_tac; |
461 by Auto_tac; |
464 qed"compatible_par2"; |
462 qed"compatible_par2"; |
465 |
463 |
466 Goalw [compatible_def] |
464 Goalw [compatible_def] |