author | wenzelm |
Mon, 26 Jun 2023 23:20:32 +0200 | |
changeset 78209 | 50c5be88ad59 |
parent 69597 | ff784d5a5bfb |
child 80768 | c7723cc15de8 |
permissions | -rw-r--r-- |
5252 | 1 |
(* Title: HOL/UNITY/Union.thy |
2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
3 |
Copyright 1998 University of Cambridge |
|
4 |
||
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30304
diff
changeset
|
5 |
Partly from Misra's Chapter 5: Asynchronous Compositions of Programs. |
5252 | 6 |
*) |
7 |
||
63146 | 8 |
section\<open>Unions of Programs\<close> |
13798 | 9 |
|
16417 | 10 |
theory Union imports SubstAx FP begin |
5252 | 11 |
|
13805 | 12 |
(*FIXME: conjoin Init F \<inter> Init G \<noteq> {} *) |
36866 | 13 |
definition |
13792 | 14 |
ok :: "['a program, 'a program] => bool" (infixl "ok" 65) |
36866 | 15 |
where "F ok G == Acts F \<subseteq> AllowedActs G & |
13805 | 16 |
Acts G \<subseteq> AllowedActs F" |
10064
1a77667b21ef
added compatibility relation: AllowedActs, Allowed, ok,
paulson
parents:
9685
diff
changeset
|
17 |
|
13805 | 18 |
(*FIXME: conjoin (\<Inter>i \<in> I. Init (F i)) \<noteq> {} *) |
36866 | 19 |
definition |
13792 | 20 |
OK :: "['a set, 'a => 'b program] => bool" |
36866 | 21 |
where "OK I F = (\<forall>i \<in> I. \<forall>j \<in> I-{i}. Acts (F i) \<subseteq> AllowedActs (F j))" |
10064
1a77667b21ef
added compatibility relation: AllowedActs, Allowed, ok,
paulson
parents:
9685
diff
changeset
|
22 |
|
36866 | 23 |
definition |
13792 | 24 |
JOIN :: "['a set, 'a => 'b program] => 'b program" |
36866 | 25 |
where "JOIN I F = mk_program (\<Inter>i \<in> I. Init (F i), \<Union>i \<in> I. Acts (F i), |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30304
diff
changeset
|
26 |
\<Inter>i \<in> I. AllowedActs (F i))" |
5252 | 27 |
|
36866 | 28 |
definition |
60773 | 29 |
Join :: "['a program, 'a program] => 'a program" (infixl "\<squnion>" 65) |
30 |
where "F \<squnion> G = mk_program (Init F \<inter> Init G, Acts F \<union> Acts G, |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30304
diff
changeset
|
31 |
AllowedActs F \<inter> AllowedActs G)" |
5252 | 32 |
|
60773 | 33 |
definition SKIP :: "'a program" ("\<bottom>") |
34 |
where "\<bottom> = mk_program (UNIV, {}, UNIV)" |
|
10064
1a77667b21ef
added compatibility relation: AllowedActs, Allowed, ok,
paulson
parents:
9685
diff
changeset
|
35 |
|
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
36 |
(*Characterizes safety properties. Used with specifying Allowed*) |
36866 | 37 |
definition |
10064
1a77667b21ef
added compatibility relation: AllowedActs, Allowed, ok,
paulson
parents:
9685
diff
changeset
|
38 |
safety_prop :: "'a program set => bool" |
69313 | 39 |
where "safety_prop X \<longleftrightarrow> SKIP \<in> X \<and> (\<forall>G. Acts G \<subseteq> \<Union>(Acts ` X) \<longrightarrow> G \<in> X)" |
5259 | 40 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5259
diff
changeset
|
41 |
syntax |
60586
1d31e3a50373
proper spacing, as for other syntax for these symbols;
wenzelm
parents:
58889
diff
changeset
|
42 |
"_JOIN1" :: "[pttrns, 'b set] => 'b set" ("(3\<Squnion>_./ _)" 10) |
1d31e3a50373
proper spacing, as for other syntax for these symbols;
wenzelm
parents:
58889
diff
changeset
|
43 |
"_JOIN" :: "[pttrn, 'a set, 'b set] => 'b set" ("(3\<Squnion>_\<in>_./ _)" 10) |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5259
diff
changeset
|
44 |
translations |
60773 | 45 |
"\<Squnion>x \<in> A. B" == "CONST JOIN A (\<lambda>x. B)" |
46 |
"\<Squnion>x y. B" == "\<Squnion>x. \<Squnion>y. B" |
|
47 |
"\<Squnion>x. B" == "CONST JOIN (CONST UNIV) (\<lambda>x. B)" |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5259
diff
changeset
|
48 |
|
13792 | 49 |
|
63146 | 50 |
subsection\<open>SKIP\<close> |
13792 | 51 |
|
52 |
lemma Init_SKIP [simp]: "Init SKIP = UNIV" |
|
53 |
by (simp add: SKIP_def) |
|
54 |
||
55 |
lemma Acts_SKIP [simp]: "Acts SKIP = {Id}" |
|
56 |
by (simp add: SKIP_def) |
|
57 |
||
58 |
lemma AllowedActs_SKIP [simp]: "AllowedActs SKIP = UNIV" |
|
59 |
by (auto simp add: SKIP_def) |
|
60 |
||
61 |
lemma reachable_SKIP [simp]: "reachable SKIP = UNIV" |
|
62 |
by (force elim: reachable.induct intro: reachable.intros) |
|
63 |
||
63146 | 64 |
subsection\<open>SKIP and safety properties\<close> |
13792 | 65 |
|
13805 | 66 |
lemma SKIP_in_constrains_iff [iff]: "(SKIP \<in> A co B) = (A \<subseteq> B)" |
13792 | 67 |
by (unfold constrains_def, auto) |
68 |
||
13805 | 69 |
lemma SKIP_in_Constrains_iff [iff]: "(SKIP \<in> A Co B) = (A \<subseteq> B)" |
13792 | 70 |
by (unfold Constrains_def, auto) |
71 |
||
13805 | 72 |
lemma SKIP_in_stable [iff]: "SKIP \<in> stable A" |
13792 | 73 |
by (unfold stable_def, auto) |
74 |
||
75 |
declare SKIP_in_stable [THEN stable_imp_Stable, iff] |
|
76 |
||
77 |
||
63146 | 78 |
subsection\<open>Join\<close> |
13792 | 79 |
|
13819 | 80 |
lemma Init_Join [simp]: "Init (F\<squnion>G) = Init F \<inter> Init G" |
13792 | 81 |
by (simp add: Join_def) |
82 |
||
13819 | 83 |
lemma Acts_Join [simp]: "Acts (F\<squnion>G) = Acts F \<union> Acts G" |
13792 | 84 |
by (auto simp add: Join_def) |
85 |
||
86 |
lemma AllowedActs_Join [simp]: |
|
13819 | 87 |
"AllowedActs (F\<squnion>G) = AllowedActs F \<inter> AllowedActs G" |
13792 | 88 |
by (auto simp add: Join_def) |
89 |
||
90 |
||
63146 | 91 |
subsection\<open>JN\<close> |
13792 | 92 |
|
13805 | 93 |
lemma JN_empty [simp]: "(\<Squnion>i\<in>{}. F i) = SKIP" |
13792 | 94 |
by (unfold JOIN_def SKIP_def, auto) |
95 |
||
13819 | 96 |
lemma JN_insert [simp]: "(\<Squnion>i \<in> insert a I. F i) = (F a)\<squnion>(\<Squnion>i \<in> I. F i)" |
13792 | 97 |
apply (rule program_equalityI) |
98 |
apply (auto simp add: JOIN_def Join_def) |
|
99 |
done |
|
100 |
||
13805 | 101 |
lemma Init_JN [simp]: "Init (\<Squnion>i \<in> I. F i) = (\<Inter>i \<in> I. Init (F i))" |
13792 | 102 |
by (simp add: JOIN_def) |
103 |
||
13805 | 104 |
lemma Acts_JN [simp]: "Acts (\<Squnion>i \<in> I. F i) = insert Id (\<Union>i \<in> I. Acts (F i))" |
13792 | 105 |
by (auto simp add: JOIN_def) |
106 |
||
107 |
lemma AllowedActs_JN [simp]: |
|
13805 | 108 |
"AllowedActs (\<Squnion>i \<in> I. F i) = (\<Inter>i \<in> I. AllowedActs (F i))" |
13792 | 109 |
by (auto simp add: JOIN_def) |
110 |
||
111 |
||
112 |
lemma JN_cong [cong]: |
|
13805 | 113 |
"[| I=J; !!i. i \<in> J ==> F i = G i |] ==> (\<Squnion>i \<in> I. F i) = (\<Squnion>i \<in> J. G i)" |
13792 | 114 |
by (simp add: JOIN_def) |
115 |
||
116 |
||
63146 | 117 |
subsection\<open>Algebraic laws\<close> |
13792 | 118 |
|
13819 | 119 |
lemma Join_commute: "F\<squnion>G = G\<squnion>F" |
13792 | 120 |
by (simp add: Join_def Un_commute Int_commute) |
121 |
||
13819 | 122 |
lemma Join_assoc: "(F\<squnion>G)\<squnion>H = F\<squnion>(G\<squnion>H)" |
13792 | 123 |
by (simp add: Un_ac Join_def Int_assoc insert_absorb) |
124 |
||
13819 | 125 |
lemma Join_left_commute: "A\<squnion>(B\<squnion>C) = B\<squnion>(A\<squnion>C)" |
13792 | 126 |
by (simp add: Un_ac Int_ac Join_def insert_absorb) |
127 |
||
13819 | 128 |
lemma Join_SKIP_left [simp]: "SKIP\<squnion>F = F" |
13792 | 129 |
apply (unfold Join_def SKIP_def) |
130 |
apply (rule program_equalityI) |
|
131 |
apply (simp_all (no_asm) add: insert_absorb) |
|
132 |
done |
|
133 |
||
13819 | 134 |
lemma Join_SKIP_right [simp]: "F\<squnion>SKIP = F" |
13792 | 135 |
apply (unfold Join_def SKIP_def) |
136 |
apply (rule program_equalityI) |
|
137 |
apply (simp_all (no_asm) add: insert_absorb) |
|
138 |
done |
|
139 |
||
13819 | 140 |
lemma Join_absorb [simp]: "F\<squnion>F = F" |
13792 | 141 |
apply (unfold Join_def) |
142 |
apply (rule program_equalityI, auto) |
|
143 |
done |
|
144 |
||
13819 | 145 |
lemma Join_left_absorb: "F\<squnion>(F\<squnion>G) = F\<squnion>G" |
13792 | 146 |
apply (unfold Join_def) |
147 |
apply (rule program_equalityI, auto) |
|
148 |
done |
|
149 |
||
150 |
(*Join is an AC-operator*) |
|
151 |
lemmas Join_ac = Join_assoc Join_left_absorb Join_commute Join_left_commute |
|
152 |
||
153 |
||
63146 | 154 |
subsection\<open>Laws Governing \<open>\<Squnion>\<close>\<close> |
13792 | 155 |
|
156 |
(*Also follows by JN_insert and insert_absorb, but the proof is longer*) |
|
13819 | 157 |
lemma JN_absorb: "k \<in> I ==> F k\<squnion>(\<Squnion>i \<in> I. F i) = (\<Squnion>i \<in> I. F i)" |
13792 | 158 |
by (auto intro!: program_equalityI) |
159 |
||
13819 | 160 |
lemma JN_Un: "(\<Squnion>i \<in> I \<union> J. F i) = ((\<Squnion>i \<in> I. F i)\<squnion>(\<Squnion>i \<in> J. F i))" |
13792 | 161 |
by (auto intro!: program_equalityI) |
162 |
||
13805 | 163 |
lemma JN_constant: "(\<Squnion>i \<in> I. c) = (if I={} then SKIP else c)" |
13792 | 164 |
by (rule program_equalityI, auto) |
165 |
||
166 |
lemma JN_Join_distrib: |
|
13819 | 167 |
"(\<Squnion>i \<in> I. F i\<squnion>G i) = (\<Squnion>i \<in> I. F i) \<squnion> (\<Squnion>i \<in> I. G i)" |
13792 | 168 |
by (auto intro!: program_equalityI) |
169 |
||
170 |
lemma JN_Join_miniscope: |
|
13819 | 171 |
"i \<in> I ==> (\<Squnion>i \<in> I. F i\<squnion>G) = ((\<Squnion>i \<in> I. F i)\<squnion>G)" |
13792 | 172 |
by (auto simp add: JN_Join_distrib JN_constant) |
173 |
||
174 |
(*Used to prove guarantees_JN_I*) |
|
13819 | 175 |
lemma JN_Join_diff: "i \<in> I ==> F i\<squnion>JOIN (I - {i}) F = JOIN I F" |
13792 | 176 |
apply (unfold JOIN_def Join_def) |
177 |
apply (rule program_equalityI, auto) |
|
178 |
done |
|
179 |
||
180 |
||
63146 | 181 |
subsection\<open>Safety: co, stable, FP\<close> |
13792 | 182 |
|
13805 | 183 |
(*Fails if I={} because it collapses to SKIP \<in> A co B, i.e. to A \<subseteq> B. So an |
184 |
alternative precondition is A \<subseteq> B, but most proofs using this rule require |
|
13792 | 185 |
I to be nonempty for other reasons anyway.*) |
186 |
lemma JN_constrains: |
|
13805 | 187 |
"i \<in> I ==> (\<Squnion>i \<in> I. F i) \<in> A co B = (\<forall>i \<in> I. F i \<in> A co B)" |
13792 | 188 |
by (simp add: constrains_def JOIN_def, blast) |
189 |
||
190 |
lemma Join_constrains [simp]: |
|
13819 | 191 |
"(F\<squnion>G \<in> A co B) = (F \<in> A co B & G \<in> A co B)" |
13792 | 192 |
by (auto simp add: constrains_def Join_def) |
193 |
||
194 |
lemma Join_unless [simp]: |
|
13819 | 195 |
"(F\<squnion>G \<in> A unless B) = (F \<in> A unless B & G \<in> A unless B)" |
46577 | 196 |
by (simp add: unless_def) |
13792 | 197 |
|
198 |
(*Analogous weak versions FAIL; see Misra [1994] 5.4.1, Substitution Axiom. |
|
13819 | 199 |
reachable (F\<squnion>G) could be much bigger than reachable F, reachable G |
13792 | 200 |
*) |
201 |
||
202 |
||
203 |
lemma Join_constrains_weaken: |
|
13805 | 204 |
"[| F \<in> A co A'; G \<in> B co B' |] |
13819 | 205 |
==> F\<squnion>G \<in> (A \<inter> B) co (A' \<union> B')" |
13792 | 206 |
by (simp, blast intro: constrains_weaken) |
207 |
||
13805 | 208 |
(*If I={}, it degenerates to SKIP \<in> UNIV co {}, which is false.*) |
13792 | 209 |
lemma JN_constrains_weaken: |
13805 | 210 |
"[| \<forall>i \<in> I. F i \<in> A i co A' i; i \<in> I |] |
211 |
==> (\<Squnion>i \<in> I. F i) \<in> (\<Inter>i \<in> I. A i) co (\<Union>i \<in> I. A' i)" |
|
13792 | 212 |
apply (simp (no_asm_simp) add: JN_constrains) |
213 |
apply (blast intro: constrains_weaken) |
|
214 |
done |
|
215 |
||
13805 | 216 |
lemma JN_stable: "(\<Squnion>i \<in> I. F i) \<in> stable A = (\<forall>i \<in> I. F i \<in> stable A)" |
13792 | 217 |
by (simp add: stable_def constrains_def JOIN_def) |
218 |
||
219 |
lemma invariant_JN_I: |
|
13805 | 220 |
"[| !!i. i \<in> I ==> F i \<in> invariant A; i \<in> I |] |
221 |
==> (\<Squnion>i \<in> I. F i) \<in> invariant A" |
|
13792 | 222 |
by (simp add: invariant_def JN_stable, blast) |
223 |
||
224 |
lemma Join_stable [simp]: |
|
13819 | 225 |
"(F\<squnion>G \<in> stable A) = |
13805 | 226 |
(F \<in> stable A & G \<in> stable A)" |
13792 | 227 |
by (simp add: stable_def) |
228 |
||
229 |
lemma Join_increasing [simp]: |
|
13819 | 230 |
"(F\<squnion>G \<in> increasing f) = |
13805 | 231 |
(F \<in> increasing f & G \<in> increasing f)" |
46577 | 232 |
by (auto simp add: increasing_def) |
13792 | 233 |
|
234 |
lemma invariant_JoinI: |
|
13805 | 235 |
"[| F \<in> invariant A; G \<in> invariant A |] |
13819 | 236 |
==> F\<squnion>G \<in> invariant A" |
46577 | 237 |
by (auto simp add: invariant_def) |
13792 | 238 |
|
13805 | 239 |
lemma FP_JN: "FP (\<Squnion>i \<in> I. F i) = (\<Inter>i \<in> I. FP (F i))" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
36866
diff
changeset
|
240 |
by (simp add: FP_def JN_stable INTER_eq) |
13792 | 241 |
|
242 |
||
63146 | 243 |
subsection\<open>Progress: transient, ensures\<close> |
13792 | 244 |
|
245 |
lemma JN_transient: |
|
13805 | 246 |
"i \<in> I ==> |
247 |
(\<Squnion>i \<in> I. F i) \<in> transient A = (\<exists>i \<in> I. F i \<in> transient A)" |
|
13792 | 248 |
by (auto simp add: transient_def JOIN_def) |
249 |
||
250 |
lemma Join_transient [simp]: |
|
13819 | 251 |
"F\<squnion>G \<in> transient A = |
13805 | 252 |
(F \<in> transient A | G \<in> transient A)" |
13792 | 253 |
by (auto simp add: bex_Un transient_def Join_def) |
254 |
||
13819 | 255 |
lemma Join_transient_I1: "F \<in> transient A ==> F\<squnion>G \<in> transient A" |
46577 | 256 |
by simp |
13792 | 257 |
|
13819 | 258 |
lemma Join_transient_I2: "G \<in> transient A ==> F\<squnion>G \<in> transient A" |
46577 | 259 |
by simp |
13792 | 260 |
|
13805 | 261 |
(*If I={} it degenerates to (SKIP \<in> A ensures B) = False, i.e. to ~(A \<subseteq> B) *) |
13792 | 262 |
lemma JN_ensures: |
13805 | 263 |
"i \<in> I ==> |
264 |
(\<Squnion>i \<in> I. F i) \<in> A ensures B = |
|
265 |
((\<forall>i \<in> I. F i \<in> (A-B) co (A \<union> B)) & (\<exists>i \<in> I. F i \<in> A ensures B))" |
|
13792 | 266 |
by (auto simp add: ensures_def JN_constrains JN_transient) |
267 |
||
268 |
lemma Join_ensures: |
|
13819 | 269 |
"F\<squnion>G \<in> A ensures B = |
13805 | 270 |
(F \<in> (A-B) co (A \<union> B) & G \<in> (A-B) co (A \<union> B) & |
271 |
(F \<in> transient (A-B) | G \<in> transient (A-B)))" |
|
46577 | 272 |
by (auto simp add: ensures_def) |
13792 | 273 |
|
274 |
lemma stable_Join_constrains: |
|
13805 | 275 |
"[| F \<in> stable A; G \<in> A co A' |] |
13819 | 276 |
==> F\<squnion>G \<in> A co A'" |
13792 | 277 |
apply (unfold stable_def constrains_def Join_def) |
278 |
apply (simp add: ball_Un, blast) |
|
279 |
done |
|
280 |
||
13805 | 281 |
(*Premise for G cannot use Always because F \<in> Stable A is weaker than |
282 |
G \<in> stable A *) |
|
13792 | 283 |
lemma stable_Join_Always1: |
13819 | 284 |
"[| F \<in> stable A; G \<in> invariant A |] ==> F\<squnion>G \<in> Always A" |
13792 | 285 |
apply (simp (no_asm_use) add: Always_def invariant_def Stable_eq_stable) |
286 |
apply (force intro: stable_Int) |
|
287 |
done |
|
288 |
||
289 |
(*As above, but exchanging the roles of F and G*) |
|
290 |
lemma stable_Join_Always2: |
|
13819 | 291 |
"[| F \<in> invariant A; G \<in> stable A |] ==> F\<squnion>G \<in> Always A" |
13792 | 292 |
apply (subst Join_commute) |
293 |
apply (blast intro: stable_Join_Always1) |
|
294 |
done |
|
295 |
||
296 |
lemma stable_Join_ensures1: |
|
13819 | 297 |
"[| F \<in> stable A; G \<in> A ensures B |] ==> F\<squnion>G \<in> A ensures B" |
13792 | 298 |
apply (simp (no_asm_simp) add: Join_ensures) |
299 |
apply (simp add: stable_def ensures_def) |
|
300 |
apply (erule constrains_weaken, auto) |
|
301 |
done |
|
302 |
||
303 |
(*As above, but exchanging the roles of F and G*) |
|
304 |
lemma stable_Join_ensures2: |
|
13819 | 305 |
"[| F \<in> A ensures B; G \<in> stable A |] ==> F\<squnion>G \<in> A ensures B" |
13792 | 306 |
apply (subst Join_commute) |
307 |
apply (blast intro: stable_Join_ensures1) |
|
308 |
done |
|
309 |
||
310 |
||
63146 | 311 |
subsection\<open>the ok and OK relations\<close> |
13792 | 312 |
|
313 |
lemma ok_SKIP1 [iff]: "SKIP ok F" |
|
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
314 |
by (simp add: ok_def) |
13792 | 315 |
|
316 |
lemma ok_SKIP2 [iff]: "F ok SKIP" |
|
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
317 |
by (simp add: ok_def) |
13792 | 318 |
|
319 |
lemma ok_Join_commute: |
|
13819 | 320 |
"(F ok G & (F\<squnion>G) ok H) = (G ok H & F ok (G\<squnion>H))" |
13792 | 321 |
by (auto simp add: ok_def) |
322 |
||
323 |
lemma ok_commute: "(F ok G) = (G ok F)" |
|
324 |
by (auto simp add: ok_def) |
|
325 |
||
45605 | 326 |
lemmas ok_sym = ok_commute [THEN iffD1] |
13792 | 327 |
|
328 |
lemma ok_iff_OK: |
|
13819 | 329 |
"OK {(0::int,F),(1,G),(2,H)} snd = (F ok G & (F\<squnion>G) ok H)" |
16977 | 330 |
apply (simp add: Ball_def conj_disj_distribR ok_def Join_def OK_def insert_absorb |
331 |
all_conj_distrib) |
|
332 |
apply blast |
|
333 |
done |
|
13792 | 334 |
|
13819 | 335 |
lemma ok_Join_iff1 [iff]: "F ok (G\<squnion>H) = (F ok G & F ok H)" |
13792 | 336 |
by (auto simp add: ok_def) |
337 |
||
13819 | 338 |
lemma ok_Join_iff2 [iff]: "(G\<squnion>H) ok F = (G ok F & H ok F)" |
13792 | 339 |
by (auto simp add: ok_def) |
340 |
||
341 |
(*useful? Not with the previous two around*) |
|
13819 | 342 |
lemma ok_Join_commute_I: "[| F ok G; (F\<squnion>G) ok H |] ==> F ok (G\<squnion>H)" |
13792 | 343 |
by (auto simp add: ok_def) |
344 |
||
13805 | 345 |
lemma ok_JN_iff1 [iff]: "F ok (JOIN I G) = (\<forall>i \<in> I. F ok G i)" |
13792 | 346 |
by (auto simp add: ok_def) |
347 |
||
13805 | 348 |
lemma ok_JN_iff2 [iff]: "(JOIN I G) ok F = (\<forall>i \<in> I. G i ok F)" |
13792 | 349 |
by (auto simp add: ok_def) |
350 |
||
13805 | 351 |
lemma OK_iff_ok: "OK I F = (\<forall>i \<in> I. \<forall>j \<in> I-{i}. (F i) ok (F j))" |
13792 | 352 |
by (auto simp add: ok_def OK_def) |
353 |
||
13805 | 354 |
lemma OK_imp_ok: "[| OK I F; i \<in> I; j \<in> I; i \<noteq> j|] ==> (F i) ok (F j)" |
13792 | 355 |
by (auto simp add: OK_iff_ok) |
356 |
||
357 |
||
63146 | 358 |
subsection\<open>Allowed\<close> |
13792 | 359 |
|
360 |
lemma Allowed_SKIP [simp]: "Allowed SKIP = UNIV" |
|
361 |
by (auto simp add: Allowed_def) |
|
362 |
||
13819 | 363 |
lemma Allowed_Join [simp]: "Allowed (F\<squnion>G) = Allowed F \<inter> Allowed G" |
13792 | 364 |
by (auto simp add: Allowed_def) |
365 |
||
13805 | 366 |
lemma Allowed_JN [simp]: "Allowed (JOIN I F) = (\<Inter>i \<in> I. Allowed (F i))" |
13792 | 367 |
by (auto simp add: Allowed_def) |
368 |
||
13805 | 369 |
lemma ok_iff_Allowed: "F ok G = (F \<in> Allowed G & G \<in> Allowed F)" |
13792 | 370 |
by (simp add: ok_def Allowed_def) |
371 |
||
13805 | 372 |
lemma OK_iff_Allowed: "OK I F = (\<forall>i \<in> I. \<forall>j \<in> I-{i}. F i \<in> Allowed(F j))" |
13792 | 373 |
by (auto simp add: OK_iff_ok ok_iff_Allowed) |
374 |
||
69597 | 375 |
subsection\<open>\<^term>\<open>safety_prop\<close>, for reasoning about |
63146 | 376 |
given instances of "ok"\<close> |
13792 | 377 |
|
378 |
lemma safety_prop_Acts_iff: |
|
69313 | 379 |
"safety_prop X ==> (Acts G \<subseteq> insert Id (\<Union>(Acts ` X))) = (G \<in> X)" |
13792 | 380 |
by (auto simp add: safety_prop_def) |
381 |
||
382 |
lemma safety_prop_AllowedActs_iff_Allowed: |
|
69313 | 383 |
"safety_prop X ==> (\<Union>(Acts ` X) \<subseteq> AllowedActs F) = (X \<subseteq> Allowed F)" |
13792 | 384 |
by (auto simp add: Allowed_def safety_prop_Acts_iff [symmetric]) |
385 |
||
386 |
lemma Allowed_eq: |
|
69313 | 387 |
"safety_prop X ==> Allowed (mk_program (init, acts, \<Union>(Acts ` X))) = X" |
13792 | 388 |
by (simp add: Allowed_def safety_prop_Acts_iff) |
389 |
||
390 |
(*For safety_prop to hold, the property must be satisfiable!*) |
|
13805 | 391 |
lemma safety_prop_constrains [iff]: "safety_prop (A co B) = (A \<subseteq> B)" |
13792 | 392 |
by (simp add: safety_prop_def constrains_def, blast) |
393 |
||
394 |
lemma safety_prop_stable [iff]: "safety_prop (stable A)" |
|
395 |
by (simp add: stable_def) |
|
396 |
||
397 |
lemma safety_prop_Int [simp]: |
|
56248
67dc9549fa15
generalized and strengthened cong rules on compound operators, similar to 1ed737a98198
haftmann
parents:
46577
diff
changeset
|
398 |
"safety_prop X \<Longrightarrow> safety_prop Y \<Longrightarrow> safety_prop (X \<inter> Y)" |
62343
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
399 |
proof (clarsimp simp add: safety_prop_def) |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
400 |
fix G |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
401 |
assume "\<forall>G. Acts G \<subseteq> (\<Union>x\<in>X. Acts x) \<longrightarrow> G \<in> X" |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
402 |
then have X: "Acts G \<subseteq> (\<Union>x\<in>X. Acts x) \<Longrightarrow> G \<in> X" by blast |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
403 |
assume "\<forall>G. Acts G \<subseteq> (\<Union>x\<in>Y. Acts x) \<longrightarrow> G \<in> Y" |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
404 |
then have Y: "Acts G \<subseteq> (\<Union>x\<in>Y. Acts x) \<Longrightarrow> G \<in> Y" by blast |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
405 |
assume Acts: "Acts G \<subseteq> (\<Union>x\<in>X \<inter> Y. Acts x)" |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
406 |
with X and Y show "G \<in> X \<and> G \<in> Y" by auto |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
407 |
qed |
56248
67dc9549fa15
generalized and strengthened cong rules on compound operators, similar to 1ed737a98198
haftmann
parents:
46577
diff
changeset
|
408 |
|
67dc9549fa15
generalized and strengthened cong rules on compound operators, similar to 1ed737a98198
haftmann
parents:
46577
diff
changeset
|
409 |
lemma safety_prop_INTER [simp]: |
67dc9549fa15
generalized and strengthened cong rules on compound operators, similar to 1ed737a98198
haftmann
parents:
46577
diff
changeset
|
410 |
"(\<And>i. i \<in> I \<Longrightarrow> safety_prop (X i)) \<Longrightarrow> safety_prop (\<Inter>i\<in>I. X i)" |
62343
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
411 |
proof (clarsimp simp add: safety_prop_def) |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
412 |
fix G and i |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
413 |
assume "\<And>i. i \<in> I \<Longrightarrow> \<bottom> \<in> X i \<and> |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
414 |
(\<forall>G. Acts G \<subseteq> (\<Union>x\<in>X i. Acts x) \<longrightarrow> G \<in> X i)" |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
415 |
then have *: "i \<in> I \<Longrightarrow> Acts G \<subseteq> (\<Union>x\<in>X i. Acts x) \<Longrightarrow> G \<in> X i" |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
416 |
by blast |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
417 |
assume "i \<in> I" |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
418 |
moreover assume "Acts G \<subseteq> (\<Union>j\<in>\<Inter>i\<in>I. X i. Acts j)" |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
419 |
ultimately have "Acts G \<subseteq> (\<Union>i\<in>X i. Acts i)" |
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
420 |
by auto |
63146 | 421 |
with * \<open>i \<in> I\<close> show "G \<in> X i" by blast |
62343
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61941
diff
changeset
|
422 |
qed |
13792 | 423 |
|
424 |
lemma safety_prop_INTER1 [simp]: |
|
56248
67dc9549fa15
generalized and strengthened cong rules on compound operators, similar to 1ed737a98198
haftmann
parents:
46577
diff
changeset
|
425 |
"(\<And>i. safety_prop (X i)) \<Longrightarrow> safety_prop (\<Inter>i. X i)" |
67dc9549fa15
generalized and strengthened cong rules on compound operators, similar to 1ed737a98198
haftmann
parents:
46577
diff
changeset
|
426 |
by (rule safety_prop_INTER) simp |
13792 | 427 |
|
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
428 |
lemma def_prg_Allowed: |
69313 | 429 |
"[| F == mk_program (init, acts, \<Union>(Acts ` X)) ; safety_prop X |] |
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
430 |
==> Allowed F = X" |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
431 |
by (simp add: Allowed_eq) |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
432 |
|
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
433 |
lemma Allowed_totalize [simp]: "Allowed (totalize F) = Allowed F" |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
434 |
by (simp add: Allowed_def) |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
435 |
|
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
436 |
lemma def_total_prg_Allowed: |
69313 | 437 |
"[| F = mk_total_program (init, acts, \<Union>(Acts ` X)) ; safety_prop X |] |
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
438 |
==> Allowed F = X" |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
439 |
by (simp add: mk_total_program_def def_prg_Allowed) |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
440 |
|
13792 | 441 |
lemma def_UNION_ok_iff: |
69313 | 442 |
"[| F = mk_program(init,acts,\<Union>(Acts ` X)); safety_prop X |] |
13805 | 443 |
==> F ok G = (G \<in> X & acts \<subseteq> AllowedActs G)" |
13792 | 444 |
by (auto simp add: ok_def safety_prop_Acts_iff) |
9685 | 445 |
|
63146 | 446 |
text\<open>The union of two total programs is total.\<close> |
13819 | 447 |
lemma totalize_Join: "totalize F\<squnion>totalize G = totalize (F\<squnion>G)" |
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
448 |
by (simp add: program_equalityI totalize_def Join_def image_Un) |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
449 |
|
13819 | 450 |
lemma all_total_Join: "[|all_total F; all_total G|] ==> all_total (F\<squnion>G)" |
13812
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
451 |
by (simp add: all_total_def, blast) |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
452 |
|
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
453 |
lemma totalize_JN: "(\<Squnion>i \<in> I. totalize (F i)) = totalize(\<Squnion>i \<in> I. F i)" |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
454 |
by (simp add: program_equalityI totalize_def JOIN_def image_UN) |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
455 |
|
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
456 |
lemma all_total_JN: "(!!i. i\<in>I ==> all_total (F i)) ==> all_total(\<Squnion>i\<in>I. F i)" |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
457 |
by (simp add: all_total_iff_totalize totalize_JN [symmetric]) |
91713a1915ee
converting HOL/UNITY to use unconditional fairness
paulson
parents:
13805
diff
changeset
|
458 |
|
5252 | 459 |
end |