author | berghofe |
Wed, 11 Jul 2007 11:14:51 +0200 | |
changeset 23746 | a455e69c31cc |
parent 15425 | 6356d2523f73 |
permissions | -rw-r--r-- |
13020 | 1 |
header {* \section{Operational Semantics} *} |
2 |
||
15425 | 3 |
theory RG_Tran |
4 |
imports RG_Com |
|
5 |
begin |
|
13020 | 6 |
|
7 |
subsection {* Semantics of Component Programs *} |
|
8 |
||
9 |
subsubsection {* Environment transitions *} |
|
10 |
||
11 |
types 'a conf = "(('a com) option) \<times> 'a" |
|
12 |
||
23746 | 13 |
inductive_set |
14 |
etran :: "('a conf \<times> 'a conf) set" |
|
15 |
and etran' :: "'a conf \<Rightarrow> 'a conf \<Rightarrow> bool" ("_ -e\<rightarrow> _" [81,81] 80) |
|
16 |
where |
|
17 |
"P -e\<rightarrow> Q \<equiv> (P,Q) \<in> etran" |
|
18 |
| Env: "(P, s) -e\<rightarrow> (P, t)" |
|
19 |
||
20 |
lemma etranE: "c -e\<rightarrow> c' \<Longrightarrow> (\<And>P s t. c = (P, s) \<Longrightarrow> c' = (P, t) \<Longrightarrow> Q) \<Longrightarrow> Q" |
|
21 |
by (induct c, induct c', erule etran.cases, blast) |
|
13020 | 22 |
|
23 |
subsubsection {* Component transitions *} |
|
24 |
||
23746 | 25 |
inductive_set |
26 |
ctran :: "('a conf \<times> 'a conf) set" |
|
27 |
and ctran' :: "'a conf \<Rightarrow> 'a conf \<Rightarrow> bool" ("_ -c\<rightarrow> _" [81,81] 80) |
|
28 |
and ctrans :: "'a conf \<Rightarrow> 'a conf \<Rightarrow> bool" ("_ -c*\<rightarrow> _" [81,81] 80) |
|
29 |
where |
|
30 |
"P -c\<rightarrow> Q \<equiv> (P,Q) \<in> ctran" |
|
31 |
| "P -c*\<rightarrow> Q \<equiv> (P,Q) \<in> ctran^*" |
|
13020 | 32 |
|
23746 | 33 |
| Basic: "(Some(Basic f), s) -c\<rightarrow> (None, f s)" |
13020 | 34 |
|
23746 | 35 |
| Seq1: "(Some P0, s) -c\<rightarrow> (None, t) \<Longrightarrow> (Some(Seq P0 P1), s) -c\<rightarrow> (Some P1, t)" |
13020 | 36 |
|
23746 | 37 |
| Seq2: "(Some P0, s) -c\<rightarrow> (Some P2, t) \<Longrightarrow> (Some(Seq P0 P1), s) -c\<rightarrow> (Some(Seq P2 P1), t)" |
13020 | 38 |
|
23746 | 39 |
| CondT: "s\<in>b \<Longrightarrow> (Some(Cond b P1 P2), s) -c\<rightarrow> (Some P1, s)" |
40 |
| CondF: "s\<notin>b \<Longrightarrow> (Some(Cond b P1 P2), s) -c\<rightarrow> (Some P2, s)" |
|
13020 | 41 |
|
23746 | 42 |
| WhileF: "s\<notin>b \<Longrightarrow> (Some(While b P), s) -c\<rightarrow> (None, s)" |
43 |
| WhileT: "s\<in>b \<Longrightarrow> (Some(While b P), s) -c\<rightarrow> (Some(Seq P (While b P)), s)" |
|
13020 | 44 |
|
23746 | 45 |
| Await: "\<lbrakk>s\<in>b; (Some P, s) -c*\<rightarrow> (None, t)\<rbrakk> \<Longrightarrow> (Some(Await b P), s) -c\<rightarrow> (None, t)" |
13020 | 46 |
|
47 |
monos "rtrancl_mono" |
|
48 |
||
49 |
subsection {* Semantics of Parallel Programs *} |
|
50 |
||
51 |
types 'a par_conf = "('a par_com) \<times> 'a" |
|
23746 | 52 |
|
53 |
inductive_set |
|
13020 | 54 |
par_etran :: "('a par_conf \<times> 'a par_conf) set" |
23746 | 55 |
and par_etran' :: "['a par_conf,'a par_conf] \<Rightarrow> bool" ("_ -pe\<rightarrow> _" [81,81] 80) |
56 |
where |
|
57 |
"P -pe\<rightarrow> Q \<equiv> (P,Q) \<in> par_etran" |
|
58 |
| ParEnv: "(Ps, s) -pe\<rightarrow> (Ps, t)" |
|
59 |
||
60 |
inductive_set |
|
13020 | 61 |
par_ctran :: "('a par_conf \<times> 'a par_conf) set" |
23746 | 62 |
and par_ctran' :: "['a par_conf,'a par_conf] \<Rightarrow> bool" ("_ -pc\<rightarrow> _" [81,81] 80) |
63 |
where |
|
64 |
"P -pc\<rightarrow> Q \<equiv> (P,Q) \<in> par_ctran" |
|
65 |
| ParComp: "\<lbrakk>i<length Ps; (Ps!i, s) -c\<rightarrow> (r, t)\<rbrakk> \<Longrightarrow> (Ps, s) -pc\<rightarrow> (Ps[i:=r], t)" |
|
13020 | 66 |
|
23746 | 67 |
lemma par_ctranE: "c -pc\<rightarrow> c' \<Longrightarrow> |
68 |
(\<And>i Ps s r t. c = (Ps, s) \<Longrightarrow> c' = (Ps[i := r], t) \<Longrightarrow> i < length Ps \<Longrightarrow> |
|
69 |
(Ps ! i, s) -c\<rightarrow> (r, t) \<Longrightarrow> P) \<Longrightarrow> P" |
|
70 |
by (induct c, induct c', erule par_ctran.cases, blast) |
|
13020 | 71 |
|
72 |
subsection {* Computations *} |
|
73 |
||
74 |
subsubsection {* Sequential computations *} |
|
75 |
||
76 |
types 'a confs = "('a conf) list" |
|
23746 | 77 |
|
78 |
inductive_set cptn :: "('a confs) set" |
|
79 |
where |
|
13020 | 80 |
CptnOne: "[(P,s)] \<in> cptn" |
23746 | 81 |
| CptnEnv: "(P, t)#xs \<in> cptn \<Longrightarrow> (P,s)#(P,t)#xs \<in> cptn" |
82 |
| CptnComp: "\<lbrakk>(P,s) -c\<rightarrow> (Q,t); (Q, t)#xs \<in> cptn \<rbrakk> \<Longrightarrow> (P,s)#(Q,t)#xs \<in> cptn" |
|
13020 | 83 |
|
84 |
constdefs |
|
85 |
cp :: "('a com) option \<Rightarrow> 'a \<Rightarrow> ('a confs) set" |
|
86 |
"cp P s \<equiv> {l. l!0=(P,s) \<and> l \<in> cptn}" |
|
87 |
||
88 |
subsubsection {* Parallel computations *} |
|
89 |
||
90 |
types 'a par_confs = "('a par_conf) list" |
|
23746 | 91 |
|
92 |
inductive_set par_cptn :: "('a par_confs) set" |
|
93 |
where |
|
13020 | 94 |
ParCptnOne: "[(P,s)] \<in> par_cptn" |
23746 | 95 |
| ParCptnEnv: "(P,t)#xs \<in> par_cptn \<Longrightarrow> (P,s)#(P,t)#xs \<in> par_cptn" |
96 |
| ParCptnComp: "\<lbrakk> (P,s) -pc\<rightarrow> (Q,t); (Q,t)#xs \<in> par_cptn \<rbrakk> \<Longrightarrow> (P,s)#(Q,t)#xs \<in> par_cptn" |
|
13020 | 97 |
|
98 |
constdefs |
|
99 |
par_cp :: "'a par_com \<Rightarrow> 'a \<Rightarrow> ('a par_confs) set" |
|
100 |
"par_cp P s \<equiv> {l. l!0=(P,s) \<and> l \<in> par_cptn}" |
|
101 |
||
102 |
subsection{* Modular Definition of Computation *} |
|
103 |
||
104 |
constdefs |
|
105 |
lift :: "'a com \<Rightarrow> 'a conf \<Rightarrow> 'a conf" |
|
106 |
"lift Q \<equiv> \<lambda>(P, s). (if P=None then (Some Q,s) else (Some(Seq (the P) Q), s))" |
|
107 |
||
23746 | 108 |
inductive_set cptn_mod :: "('a confs) set" |
109 |
where |
|
13020 | 110 |
CptnModOne: "[(P, s)] \<in> cptn_mod" |
23746 | 111 |
| CptnModEnv: "(P, t)#xs \<in> cptn_mod \<Longrightarrow> (P, s)#(P, t)#xs \<in> cptn_mod" |
112 |
| CptnModNone: "\<lbrakk>(Some P, s) -c\<rightarrow> (None, t); (None, t)#xs \<in> cptn_mod \<rbrakk> \<Longrightarrow> (Some P,s)#(None, t)#xs \<in>cptn_mod" |
|
113 |
| CptnModCondT: "\<lbrakk>(Some P0, s)#ys \<in> cptn_mod; s \<in> b \<rbrakk> \<Longrightarrow> (Some(Cond b P0 P1), s)#(Some P0, s)#ys \<in> cptn_mod" |
|
114 |
| CptnModCondF: "\<lbrakk>(Some P1, s)#ys \<in> cptn_mod; s \<notin> b \<rbrakk> \<Longrightarrow> (Some(Cond b P0 P1), s)#(Some P1, s)#ys \<in> cptn_mod" |
|
115 |
| CptnModSeq1: "\<lbrakk>(Some P0, s)#xs \<in> cptn_mod; zs=map (lift P1) xs \<rbrakk> |
|
13020 | 116 |
\<Longrightarrow> (Some(Seq P0 P1), s)#zs \<in> cptn_mod" |
23746 | 117 |
| CptnModSeq2: |
13020 | 118 |
"\<lbrakk>(Some P0, s)#xs \<in> cptn_mod; fst(last ((Some P0, s)#xs)) = None; |
119 |
(Some P1, snd(last ((Some P0, s)#xs)))#ys \<in> cptn_mod; |
|
120 |
zs=(map (lift P1) xs)@ys \<rbrakk> \<Longrightarrow> (Some(Seq P0 P1), s)#zs \<in> cptn_mod" |
|
121 |
||
23746 | 122 |
| CptnModWhile1: |
13020 | 123 |
"\<lbrakk> (Some P, s)#xs \<in> cptn_mod; s \<in> b; zs=map (lift (While b P)) xs \<rbrakk> |
124 |
\<Longrightarrow> (Some(While b P), s)#(Some(Seq P (While b P)), s)#zs \<in> cptn_mod" |
|
23746 | 125 |
| CptnModWhile2: |
13020 | 126 |
"\<lbrakk> (Some P, s)#xs \<in> cptn_mod; fst(last ((Some P, s)#xs))=None; s \<in> b; |
127 |
zs=(map (lift (While b P)) xs)@ys; |
|
128 |
(Some(While b P), snd(last ((Some P, s)#xs)))#ys \<in> cptn_mod\<rbrakk> |
|
129 |
\<Longrightarrow> (Some(While b P), s)#(Some(Seq P (While b P)), s)#zs \<in> cptn_mod" |
|
130 |
||
131 |
subsection {* Equivalence of Both Definitions.*} |
|
132 |
||
133 |
lemma last_length: "((a#xs)!(length xs))=last (a#xs)" |
|
134 |
apply simp |
|
135 |
apply(induct xs,simp+) |
|
15236
f289e8ba2bb3
Proofs needed to be updated because induction now preserves name of
nipkow
parents:
13601
diff
changeset
|
136 |
apply(case_tac xs) |
13020 | 137 |
apply simp_all |
138 |
done |
|
139 |
||
140 |
lemma div_seq [rule_format]: "list \<in> cptn_mod \<Longrightarrow> |
|
141 |
(\<forall>s P Q zs. list=(Some (Seq P Q), s)#zs \<longrightarrow> |
|
142 |
(\<exists>xs. (Some P, s)#xs \<in> cptn_mod \<and> (zs=(map (lift Q) xs) \<or> |
|
143 |
( fst(((Some P, s)#xs)!length xs)=None \<and> |
|
144 |
(\<exists>ys. (Some Q, snd(((Some P, s)#xs)!length xs))#ys \<in> cptn_mod |
|
145 |
\<and> zs=(map (lift (Q)) xs)@ys)))))" |
|
146 |
apply(erule cptn_mod.induct) |
|
147 |
apply simp_all |
|
148 |
apply clarify |
|
149 |
apply(force intro:CptnModOne) |
|
150 |
apply clarify |
|
151 |
apply(erule_tac x=Pa in allE) |
|
152 |
apply(erule_tac x=Q in allE) |
|
153 |
apply simp |
|
154 |
apply clarify |
|
155 |
apply(erule disjE) |
|
156 |
apply(rule_tac x="(Some Pa,t)#xsa" in exI) |
|
157 |
apply(rule conjI) |
|
158 |
apply clarify |
|
159 |
apply(erule CptnModEnv) |
|
160 |
apply(rule disjI1) |
|
161 |
apply(simp add:lift_def) |
|
162 |
apply clarify |
|
163 |
apply(rule_tac x="(Some Pa,t)#xsa" in exI) |
|
164 |
apply(rule conjI) |
|
165 |
apply(erule CptnModEnv) |
|
166 |
apply(rule disjI2) |
|
167 |
apply(rule conjI) |
|
168 |
apply(case_tac xsa,simp,simp) |
|
169 |
apply(rule_tac x="ys" in exI) |
|
170 |
apply(rule conjI) |
|
171 |
apply simp |
|
172 |
apply(simp add:lift_def) |
|
173 |
apply clarify |
|
23746 | 174 |
apply(erule ctran.cases,simp_all) |
13020 | 175 |
apply clarify |
176 |
apply(rule_tac x="xs" in exI) |
|
177 |
apply simp |
|
178 |
apply clarify |
|
179 |
apply(rule_tac x="xs" in exI) |
|
180 |
apply(simp add: last_length) |
|
181 |
done |
|
182 |
||
183 |
lemma cptn_onlyif_cptn_mod_aux [rule_format]: |
|
184 |
"\<forall>s Q t xs.((Some a, s), Q, t) \<in> ctran \<longrightarrow> (Q, t) # xs \<in> cptn_mod |
|
185 |
\<longrightarrow> (Some a, s) # (Q, t) # xs \<in> cptn_mod" |
|
186 |
apply(induct a) |
|
187 |
apply simp_all |
|
188 |
--{* basic *} |
|
189 |
apply clarify |
|
23746 | 190 |
apply(erule ctran.cases,simp_all) |
13020 | 191 |
apply(rule CptnModNone,rule Basic,simp) |
192 |
apply clarify |
|
23746 | 193 |
apply(erule ctran.cases,simp_all) |
13020 | 194 |
--{* Seq1 *} |
195 |
apply(rule_tac xs="[(None,ta)]" in CptnModSeq2) |
|
196 |
apply(erule CptnModNone) |
|
197 |
apply(rule CptnModOne) |
|
198 |
apply simp |
|
199 |
apply simp |
|
200 |
apply(simp add:lift_def) |
|
201 |
--{* Seq2 *} |
|
202 |
apply(erule_tac x=sa in allE) |
|
203 |
apply(erule_tac x="Some P2" in allE) |
|
204 |
apply(erule allE,erule impE, assumption) |
|
205 |
apply(drule div_seq,simp) |
|
206 |
apply force |
|
207 |
apply clarify |
|
208 |
apply(erule disjE) |
|
209 |
apply clarify |
|
210 |
apply(erule allE,erule impE, assumption) |
|
211 |
apply(erule_tac CptnModSeq1) |
|
212 |
apply(simp add:lift_def) |
|
213 |
apply clarify |
|
214 |
apply(erule allE,erule impE, assumption) |
|
215 |
apply(erule_tac CptnModSeq2) |
|
216 |
apply (simp add:last_length) |
|
217 |
apply (simp add:last_length) |
|
218 |
apply(simp add:lift_def) |
|
219 |
--{* Cond *} |
|
220 |
apply clarify |
|
23746 | 221 |
apply(erule ctran.cases,simp_all) |
13020 | 222 |
apply(force elim: CptnModCondT) |
223 |
apply(force elim: CptnModCondF) |
|
224 |
--{* While *} |
|
225 |
apply clarify |
|
23746 | 226 |
apply(erule ctran.cases,simp_all) |
13020 | 227 |
apply(rule CptnModNone,erule WhileF,simp) |
228 |
apply(drule div_seq,force) |
|
229 |
apply clarify |
|
230 |
apply (erule disjE) |
|
231 |
apply(force elim:CptnModWhile1) |
|
232 |
apply clarify |
|
233 |
apply(force simp add:last_length elim:CptnModWhile2) |
|
234 |
--{* await *} |
|
235 |
apply clarify |
|
23746 | 236 |
apply(erule ctran.cases,simp_all) |
13020 | 237 |
apply(rule CptnModNone,erule Await,simp+) |
238 |
done |
|
239 |
||
240 |
lemma cptn_onlyif_cptn_mod [rule_format]: "c \<in> cptn \<Longrightarrow> c \<in> cptn_mod" |
|
241 |
apply(erule cptn.induct) |
|
242 |
apply(rule CptnModOne) |
|
243 |
apply(erule CptnModEnv) |
|
244 |
apply(case_tac P) |
|
245 |
apply simp |
|
23746 | 246 |
apply(erule ctran.cases,simp_all) |
13020 | 247 |
apply(force elim:cptn_onlyif_cptn_mod_aux) |
248 |
done |
|
249 |
||
250 |
lemma lift_is_cptn: "c\<in>cptn \<Longrightarrow> map (lift P) c \<in> cptn" |
|
251 |
apply(erule cptn.induct) |
|
252 |
apply(force simp add:lift_def CptnOne) |
|
253 |
apply(force intro:CptnEnv simp add:lift_def) |
|
23746 | 254 |
apply(force simp add:lift_def intro:CptnComp Seq2 Seq1 elim:ctran.cases) |
13020 | 255 |
done |
256 |
||
257 |
lemma cptn_append_is_cptn [rule_format]: |
|
258 |
"\<forall>b a. b#c1\<in>cptn \<longrightarrow> a#c2\<in>cptn \<longrightarrow> (b#c1)!length c1=a \<longrightarrow> b#c1@c2\<in>cptn" |
|
259 |
apply(induct c1) |
|
260 |
apply simp |
|
261 |
apply clarify |
|
23746 | 262 |
apply(erule cptn.cases,simp_all) |
13020 | 263 |
apply(force intro:CptnEnv) |
264 |
apply(force elim:CptnComp) |
|
265 |
done |
|
266 |
||
267 |
lemma last_lift: "\<lbrakk>xs\<noteq>[]; fst(xs!(length xs - (Suc 0)))=None\<rbrakk> |
|
268 |
\<Longrightarrow> fst((map (lift P) xs)!(length (map (lift P) xs)- (Suc 0)))=(Some P)" |
|
269 |
apply(case_tac "(xs ! (length xs - (Suc 0)))") |
|
270 |
apply (simp add:lift_def) |
|
271 |
done |
|
272 |
||
273 |
lemma last_fst [rule_format]: "P((a#x)!length x) \<longrightarrow> \<not>P a \<longrightarrow> P (x!(length x - (Suc 0)))" |
|
274 |
apply(induct x,simp+) |
|
275 |
done |
|
276 |
||
277 |
lemma last_fst_esp: |
|
278 |
"fst(((Some a,s)#xs)!(length xs))=None \<Longrightarrow> fst(xs!(length xs - (Suc 0)))=None" |
|
279 |
apply(erule last_fst) |
|
280 |
apply simp |
|
281 |
done |
|
282 |
||
283 |
lemma last_snd: "xs\<noteq>[] \<Longrightarrow> |
|
284 |
snd(((map (lift P) xs))!(length (map (lift P) xs) - (Suc 0)))=snd(xs!(length xs - (Suc 0)))" |
|
285 |
apply(case_tac "(xs ! (length xs - (Suc 0)))",simp) |
|
286 |
apply (simp add:lift_def) |
|
287 |
done |
|
288 |
||
289 |
lemma Cons_lift: "(Some (Seq P Q), s) # (map (lift Q) xs) = map (lift Q) ((Some P, s) # xs)" |
|
290 |
by(simp add:lift_def) |
|
291 |
||
292 |
lemma Cons_lift_append: |
|
293 |
"(Some (Seq P Q), s) # (map (lift Q) xs) @ ys = map (lift Q) ((Some P, s) # xs)@ ys " |
|
294 |
by(simp add:lift_def) |
|
295 |
||
296 |
lemma lift_nth: "i<length xs \<Longrightarrow> map (lift Q) xs ! i = lift Q (xs! i)" |
|
297 |
by (simp add:lift_def) |
|
298 |
||
299 |
lemma snd_lift: "i< length xs \<Longrightarrow> snd(lift Q (xs ! i))= snd (xs ! i)" |
|
300 |
apply(case_tac "xs!i") |
|
301 |
apply(simp add:lift_def) |
|
302 |
done |
|
303 |
||
304 |
lemma cptn_if_cptn_mod: "c \<in> cptn_mod \<Longrightarrow> c \<in> cptn" |
|
305 |
apply(erule cptn_mod.induct) |
|
306 |
apply(rule CptnOne) |
|
307 |
apply(erule CptnEnv) |
|
308 |
apply(erule CptnComp,simp) |
|
309 |
apply(rule CptnComp) |
|
310 |
apply(erule CondT,simp) |
|
311 |
apply(rule CptnComp) |
|
312 |
apply(erule CondF,simp) |
|
313 |
--{* Seq1 *} |
|
23746 | 314 |
apply(erule cptn.cases,simp_all) |
13020 | 315 |
apply(rule CptnOne) |
316 |
apply clarify |
|
317 |
apply(drule_tac P=P1 in lift_is_cptn) |
|
318 |
apply(simp add:lift_def) |
|
319 |
apply(rule CptnEnv,simp) |
|
320 |
apply clarify |
|
321 |
apply(simp add:lift_def) |
|
322 |
apply(rule conjI) |
|
323 |
apply clarify |
|
324 |
apply(rule CptnComp) |
|
325 |
apply(rule Seq1,simp) |
|
326 |
apply(drule_tac P=P1 in lift_is_cptn) |
|
327 |
apply(simp add:lift_def) |
|
328 |
apply clarify |
|
329 |
apply(rule CptnComp) |
|
330 |
apply(rule Seq2,simp) |
|
331 |
apply(drule_tac P=P1 in lift_is_cptn) |
|
332 |
apply(simp add:lift_def) |
|
333 |
--{* Seq2 *} |
|
334 |
apply(rule cptn_append_is_cptn) |
|
335 |
apply(drule_tac P=P1 in lift_is_cptn) |
|
336 |
apply(simp add:lift_def) |
|
337 |
apply simp |
|
338 |
apply(case_tac "xs\<noteq>[]") |
|
339 |
apply(drule_tac P=P1 in last_lift) |
|
340 |
apply(rule last_fst_esp) |
|
341 |
apply (simp add:last_length) |
|
342 |
apply(simp add:Cons_lift del:map.simps) |
|
343 |
apply(rule conjI, clarify, simp) |
|
344 |
apply(case_tac "(((Some P0, s) # xs) ! length xs)") |
|
345 |
apply clarify |
|
346 |
apply (simp add:lift_def last_length) |
|
347 |
apply (simp add:last_length) |
|
348 |
--{* While1 *} |
|
349 |
apply(rule CptnComp) |
|
350 |
apply(rule WhileT,simp) |
|
351 |
apply(drule_tac P="While b P" in lift_is_cptn) |
|
352 |
apply(simp add:lift_def) |
|
353 |
--{* While2 *} |
|
354 |
apply(rule CptnComp) |
|
355 |
apply(rule WhileT,simp) |
|
356 |
apply(rule cptn_append_is_cptn) |
|
357 |
apply(drule_tac P="While b P" in lift_is_cptn) |
|
358 |
apply(simp add:lift_def) |
|
359 |
apply simp |
|
360 |
apply(case_tac "xs\<noteq>[]") |
|
361 |
apply(drule_tac P="While b P" in last_lift) |
|
362 |
apply(rule last_fst_esp,simp add:last_length) |
|
363 |
apply(simp add:Cons_lift del:map.simps) |
|
364 |
apply(rule conjI, clarify, simp) |
|
365 |
apply(case_tac "(((Some P, s) # xs) ! length xs)") |
|
366 |
apply clarify |
|
367 |
apply (simp add:last_length lift_def) |
|
368 |
apply simp |
|
369 |
done |
|
370 |
||
371 |
theorem cptn_iff_cptn_mod: "(c \<in> cptn) = (c \<in> cptn_mod)" |
|
372 |
apply(rule iffI) |
|
373 |
apply(erule cptn_onlyif_cptn_mod) |
|
374 |
apply(erule cptn_if_cptn_mod) |
|
375 |
done |
|
376 |
||
377 |
section {* Validity of Correctness Formulas*} |
|
378 |
||
379 |
subsection {* Validity for Component Programs. *} |
|
380 |
||
381 |
types 'a rgformula = "'a com \<times> 'a set \<times> ('a \<times> 'a) set \<times> ('a \<times> 'a) set \<times> 'a set" |
|
382 |
||
383 |
constdefs |
|
384 |
assum :: "('a set \<times> ('a \<times> 'a) set) \<Rightarrow> ('a confs) set" |
|
385 |
"assum \<equiv> \<lambda>(pre, rely). {c. snd(c!0) \<in> pre \<and> (\<forall>i. Suc i<length c \<longrightarrow> |
|
386 |
c!i -e\<rightarrow> c!(Suc i) \<longrightarrow> (snd(c!i), snd(c!Suc i)) \<in> rely)}" |
|
387 |
||
388 |
comm :: "(('a \<times> 'a) set \<times> 'a set) \<Rightarrow> ('a confs) set" |
|
389 |
"comm \<equiv> \<lambda>(guar, post). {c. (\<forall>i. Suc i<length c \<longrightarrow> |
|
390 |
c!i -c\<rightarrow> c!(Suc i) \<longrightarrow> (snd(c!i), snd(c!Suc i)) \<in> guar) \<and> |
|
391 |
(fst (last c) = None \<longrightarrow> snd (last c) \<in> post)}" |
|
392 |
||
393 |
com_validity :: "'a com \<Rightarrow> 'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a set \<Rightarrow> bool" |
|
394 |
("\<Turnstile> _ sat [_, _, _, _]" [60,0,0,0,0] 45) |
|
395 |
"\<Turnstile> P sat [pre, rely, guar, post] \<equiv> |
|
396 |
\<forall>s. cp (Some P) s \<inter> assum(pre, rely) \<subseteq> comm(guar, post)" |
|
397 |
||
398 |
subsection {* Validity for Parallel Programs. *} |
|
399 |
||
400 |
constdefs |
|
401 |
All_None :: "(('a com) option) list \<Rightarrow> bool" |
|
402 |
"All_None xs \<equiv> \<forall>c\<in>set xs. c=None" |
|
403 |
||
404 |
par_assum :: "('a set \<times> ('a \<times> 'a) set) \<Rightarrow> ('a par_confs) set" |
|
405 |
"par_assum \<equiv> \<lambda>(pre, rely). {c. snd(c!0) \<in> pre \<and> (\<forall>i. Suc i<length c \<longrightarrow> |
|
406 |
c!i -pe\<rightarrow> c!Suc i \<longrightarrow> (snd(c!i), snd(c!Suc i)) \<in> rely)}" |
|
407 |
||
408 |
par_comm :: "(('a \<times> 'a) set \<times> 'a set) \<Rightarrow> ('a par_confs) set" |
|
409 |
"par_comm \<equiv> \<lambda>(guar, post). {c. (\<forall>i. Suc i<length c \<longrightarrow> |
|
410 |
c!i -pc\<rightarrow> c!Suc i \<longrightarrow> (snd(c!i), snd(c!Suc i)) \<in> guar) \<and> |
|
411 |
(All_None (fst (last c)) \<longrightarrow> snd( last c) \<in> post)}" |
|
412 |
||
13022
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
413 |
par_com_validity :: "'a par_com \<Rightarrow> 'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
414 |
\<Rightarrow> 'a set \<Rightarrow> bool" ("\<Turnstile> _ SAT [_, _, _, _]" [60,0,0,0,0] 45) |
13020 | 415 |
"\<Turnstile> Ps SAT [pre, rely, guar, post] \<equiv> |
416 |
\<forall>s. par_cp Ps s \<inter> par_assum(pre, rely) \<subseteq> par_comm(guar, post)" |
|
417 |
||
418 |
subsection {* Compositionality of the Semantics *} |
|
419 |
||
420 |
subsubsection {* Definition of the conjoin operator *} |
|
421 |
||
422 |
constdefs |
|
423 |
same_length :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool" |
|
424 |
"same_length c clist \<equiv> (\<forall>i<length clist. length(clist!i)=length c)" |
|
425 |
||
426 |
same_state :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool" |
|
427 |
"same_state c clist \<equiv> (\<forall>i <length clist. \<forall>j<length c. snd(c!j) = snd((clist!i)!j))" |
|
428 |
||
429 |
same_program :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool" |
|
430 |
"same_program c clist \<equiv> (\<forall>j<length c. fst(c!j) = map (\<lambda>x. fst(nth x j)) clist)" |
|
431 |
||
432 |
compat_label :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool" |
|
433 |
"compat_label c clist \<equiv> (\<forall>j. Suc j<length c \<longrightarrow> |
|
434 |
(c!j -pc\<rightarrow> c!Suc j \<and> (\<exists>i<length clist. (clist!i)!j -c\<rightarrow> (clist!i)! Suc j \<and> |
|
13022
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
435 |
(\<forall>l<length clist. l\<noteq>i \<longrightarrow> (clist!l)!j -e\<rightarrow> (clist!l)! Suc j))) \<or> |
13020 | 436 |
(c!j -pe\<rightarrow> c!Suc j \<and> (\<forall>i<length clist. (clist!i)!j -e\<rightarrow> (clist!i)! Suc j)))" |
437 |
||
438 |
conjoin :: "'a par_confs \<Rightarrow> ('a confs) list \<Rightarrow> bool" ("_ \<propto> _" [65,65] 64) |
|
439 |
"c \<propto> clist \<equiv> (same_length c clist) \<and> (same_state c clist) \<and> (same_program c clist) \<and> (compat_label c clist)" |
|
440 |
||
441 |
subsubsection {* Some previous lemmas *} |
|
442 |
||
13022
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
443 |
lemma list_eq_if [rule_format]: |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
444 |
"\<forall>ys. xs=ys \<longrightarrow> (length xs = length ys) \<longrightarrow> (\<forall>i<length xs. xs!i=ys!i)" |
13020 | 445 |
apply (induct xs) |
446 |
apply simp |
|
447 |
apply clarify |
|
448 |
done |
|
449 |
||
450 |
lemma list_eq: "(length xs = length ys \<and> (\<forall>i<length xs. xs!i=ys!i)) = (xs=ys)" |
|
451 |
apply(rule iffI) |
|
452 |
apply clarify |
|
453 |
apply(erule nth_equalityI) |
|
454 |
apply simp+ |
|
455 |
done |
|
456 |
||
457 |
lemma nth_tl: "\<lbrakk> ys!0=a; ys\<noteq>[] \<rbrakk> \<Longrightarrow> ys=(a#(tl ys))" |
|
458 |
apply(case_tac ys) |
|
459 |
apply simp+ |
|
460 |
done |
|
461 |
||
462 |
lemma nth_tl_if [rule_format]: "ys\<noteq>[] \<longrightarrow> ys!0=a \<longrightarrow> P ys \<longrightarrow> P (a#(tl ys))" |
|
463 |
apply(induct ys) |
|
464 |
apply simp+ |
|
465 |
done |
|
466 |
||
467 |
lemma nth_tl_onlyif [rule_format]: "ys\<noteq>[] \<longrightarrow> ys!0=a \<longrightarrow> P (a#(tl ys)) \<longrightarrow> P ys" |
|
468 |
apply(induct ys) |
|
469 |
apply simp+ |
|
470 |
done |
|
471 |
||
472 |
lemma seq_not_eq1: "Seq c1 c2\<noteq>c1" |
|
473 |
apply(rule com.induct) |
|
474 |
apply simp_all |
|
475 |
apply clarify |
|
476 |
done |
|
477 |
||
478 |
lemma seq_not_eq2: "Seq c1 c2\<noteq>c2" |
|
479 |
apply(rule com.induct) |
|
480 |
apply simp_all |
|
481 |
apply clarify |
|
482 |
done |
|
483 |
||
484 |
lemma if_not_eq1: "Cond b c1 c2 \<noteq>c1" |
|
485 |
apply(rule com.induct) |
|
486 |
apply simp_all |
|
487 |
apply clarify |
|
488 |
done |
|
489 |
||
490 |
lemma if_not_eq2: "Cond b c1 c2\<noteq>c2" |
|
491 |
apply(rule com.induct) |
|
492 |
apply simp_all |
|
493 |
apply clarify |
|
494 |
done |
|
495 |
||
496 |
lemmas seq_and_if_not_eq [simp] = seq_not_eq1 seq_not_eq2 |
|
497 |
seq_not_eq1 [THEN not_sym] seq_not_eq2 [THEN not_sym] |
|
498 |
if_not_eq1 if_not_eq2 if_not_eq1 [THEN not_sym] if_not_eq2 [THEN not_sym] |
|
499 |
||
23746 | 500 |
lemma prog_not_eq_in_ctran_aux: |
501 |
assumes c: "(P,s) -c\<rightarrow> (Q,t)" |
|
502 |
shows "P\<noteq>Q" using c |
|
503 |
by (induct x1 \<equiv> "(P,s)" x2 \<equiv> "(Q,t)" arbitrary: P s Q t) auto |
|
13020 | 504 |
|
505 |
lemma prog_not_eq_in_ctran [simp]: "\<not> (P,s) -c\<rightarrow> (P,t)" |
|
506 |
apply clarify |
|
507 |
apply(drule prog_not_eq_in_ctran_aux) |
|
508 |
apply simp |
|
509 |
done |
|
510 |
||
511 |
lemma prog_not_eq_in_par_ctran_aux [rule_format]: "(P,s) -pc\<rightarrow> (Q,t) \<Longrightarrow> (P\<noteq>Q)" |
|
512 |
apply(erule par_ctran.induct) |
|
513 |
apply(drule prog_not_eq_in_ctran_aux) |
|
514 |
apply clarify |
|
515 |
apply(drule list_eq_if) |
|
516 |
apply simp_all |
|
517 |
apply force |
|
518 |
done |
|
519 |
||
520 |
lemma prog_not_eq_in_par_ctran [simp]: "\<not> (P,s) -pc\<rightarrow> (P,t)" |
|
521 |
apply clarify |
|
522 |
apply(drule prog_not_eq_in_par_ctran_aux) |
|
523 |
apply simp |
|
524 |
done |
|
525 |
||
526 |
lemma tl_in_cptn: "\<lbrakk> a#xs \<in>cptn; xs\<noteq>[] \<rbrakk> \<Longrightarrow> xs\<in>cptn" |
|
23746 | 527 |
apply(force elim:cptn.cases) |
13020 | 528 |
done |
529 |
||
13022
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
530 |
lemma tl_zero[rule_format]: |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
531 |
"P (ys!Suc j) \<longrightarrow> Suc j<length ys \<longrightarrow> ys\<noteq>[] \<longrightarrow> P (tl(ys)!j)" |
13020 | 532 |
apply(induct ys) |
533 |
apply simp_all |
|
534 |
done |
|
535 |
||
536 |
subsection {* The Semantics is Compositional *} |
|
537 |
||
538 |
lemma aux_if [rule_format]: |
|
539 |
"\<forall>xs s clist. (length clist = length xs \<and> (\<forall>i<length xs. (xs!i,s)#clist!i \<in> cptn) |
|
540 |
\<and> ((xs, s)#ys \<propto> map (\<lambda>i. (fst i,s)#snd i) (zip xs clist)) |
|
541 |
\<longrightarrow> (xs, s)#ys \<in> par_cptn)" |
|
542 |
apply(induct ys) |
|
543 |
apply(clarify) |
|
544 |
apply(rule ParCptnOne) |
|
545 |
apply(clarify) |
|
546 |
apply(simp add:conjoin_def compat_label_def) |
|
547 |
apply clarify |
|
548 |
apply(erule_tac x="0" and P="\<lambda>j. ?H j \<longrightarrow> (?P j \<or> ?Q j)" in all_dupE,simp) |
|
549 |
apply(erule disjE) |
|
550 |
--{* first step is a Component step *} |
|
551 |
apply clarify |
|
552 |
apply simp |
|
553 |
apply(subgoal_tac "a=(xs[i:=(fst(clist!i!0))])") |
|
554 |
apply(subgoal_tac "b=snd(clist!i!0)",simp) |
|
555 |
prefer 2 |
|
556 |
apply(simp add: same_state_def) |
|
557 |
apply(erule_tac x=i in allE,erule impE,assumption, |
|
558 |
erule_tac x=1 and P="\<lambda>j. (?H j) \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
559 |
prefer 2 |
|
560 |
apply(simp add:same_program_def) |
|
561 |
apply(erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (fst (?s j))=(?t j)" in allE,simp) |
|
562 |
apply(rule nth_equalityI,simp) |
|
563 |
apply clarify |
|
564 |
apply(case_tac "i=ia",simp,simp) |
|
565 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) |
|
566 |
apply(drule_tac t=i in not_sym,simp) |
|
23746 | 567 |
apply(erule etranE,simp) |
13020 | 568 |
apply(rule ParCptnComp) |
569 |
apply(erule ParComp,simp) |
|
570 |
--{* applying the induction hypothesis *} |
|
571 |
apply(erule_tac x="xs[i := fst (clist ! i ! 0)]" in allE) |
|
572 |
apply(erule_tac x="snd (clist ! i ! 0)" in allE) |
|
573 |
apply(erule mp) |
|
574 |
apply(rule_tac x="map tl clist" in exI,simp) |
|
575 |
apply(rule conjI,clarify) |
|
576 |
apply(case_tac "i=ia",simp) |
|
577 |
apply(rule nth_tl_if) |
|
578 |
apply(force simp add:same_length_def length_Suc_conv) |
|
579 |
apply simp |
|
580 |
apply(erule allE,erule impE,assumption,erule tl_in_cptn) |
|
581 |
apply(force simp add:same_length_def length_Suc_conv) |
|
582 |
apply(rule nth_tl_if) |
|
583 |
apply(force simp add:same_length_def length_Suc_conv) |
|
584 |
apply(simp add:same_state_def) |
|
585 |
apply(erule_tac x=ia in allE, erule impE, assumption, |
|
586 |
erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) |
|
587 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) |
|
588 |
apply(drule_tac t=i in not_sym,simp) |
|
23746 | 589 |
apply(erule etranE,simp) |
13020 | 590 |
apply(erule allE,erule impE,assumption,erule tl_in_cptn) |
591 |
apply(force simp add:same_length_def length_Suc_conv) |
|
592 |
apply(simp add:same_length_def same_state_def) |
|
593 |
apply(rule conjI) |
|
594 |
apply clarify |
|
595 |
apply(case_tac j,simp,simp) |
|
596 |
apply(erule_tac x=ia in allE, erule impE, assumption, |
|
597 |
erule_tac x="Suc(Suc nat)" and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
598 |
apply(force simp add:same_length_def length_Suc_conv) |
|
599 |
apply(rule conjI) |
|
600 |
apply(simp add:same_program_def) |
|
601 |
apply clarify |
|
602 |
apply(case_tac j,simp) |
|
603 |
apply(rule nth_equalityI,simp) |
|
604 |
apply clarify |
|
605 |
apply(case_tac "i=ia",simp,simp) |
|
606 |
apply(erule_tac x="Suc(Suc nat)" and P="\<lambda>j. ?H j \<longrightarrow> (fst (?s j))=(?t j)" in allE,simp) |
|
607 |
apply(rule nth_equalityI,simp,simp) |
|
608 |
apply(force simp add:length_Suc_conv) |
|
609 |
apply(rule allI,rule impI) |
|
610 |
apply(erule_tac x="Suc j" and P="\<lambda>j. ?H j \<longrightarrow> (?I j \<or> ?J j)" in allE,simp) |
|
611 |
apply(erule disjE) |
|
612 |
apply clarify |
|
613 |
apply(rule_tac x=ia in exI,simp) |
|
614 |
apply(case_tac "i=ia",simp) |
|
615 |
apply(rule conjI) |
|
616 |
apply(force simp add: length_Suc_conv) |
|
617 |
apply clarify |
|
618 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE,assumption) |
|
619 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE,assumption) |
|
620 |
apply simp |
|
621 |
apply(case_tac j,simp) |
|
622 |
apply(rule tl_zero) |
|
623 |
apply(erule_tac x=l in allE, erule impE, assumption, |
|
624 |
erule_tac x=1 and P="\<lambda>j. (?H j) \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
23746 | 625 |
apply(force elim:etranE intro:Env) |
13020 | 626 |
apply force |
627 |
apply force |
|
628 |
apply simp |
|
629 |
apply(rule tl_zero) |
|
630 |
apply(erule tl_zero) |
|
631 |
apply force |
|
632 |
apply force |
|
633 |
apply force |
|
634 |
apply force |
|
635 |
apply(rule conjI,simp) |
|
636 |
apply(rule nth_tl_if) |
|
637 |
apply force |
|
638 |
apply(erule_tac x=ia in allE, erule impE, assumption, |
|
639 |
erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) |
|
640 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) |
|
641 |
apply(drule_tac t=i in not_sym,simp) |
|
23746 | 642 |
apply(erule etranE,simp) |
13020 | 643 |
apply(erule tl_zero) |
644 |
apply force |
|
645 |
apply force |
|
646 |
apply clarify |
|
647 |
apply(case_tac "i=l",simp) |
|
648 |
apply(rule nth_tl_if) |
|
649 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
650 |
apply simp |
|
651 |
apply(erule_tac P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE,assumption,erule impE,assumption) |
|
652 |
apply(erule tl_zero,force) |
|
653 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
654 |
apply(rule nth_tl_if) |
|
655 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
656 |
apply(erule_tac x=l in allE, erule impE, assumption, |
|
657 |
erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) |
|
658 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE, assumption,simp) |
|
23746 | 659 |
apply(erule etranE,simp) |
13020 | 660 |
apply(rule tl_zero) |
661 |
apply force |
|
662 |
apply force |
|
663 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
664 |
apply(rule disjI2) |
|
665 |
apply(case_tac j,simp) |
|
666 |
apply clarify |
|
667 |
apply(rule tl_zero) |
|
668 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j\<in>etran" in allE,erule impE, assumption) |
|
669 |
apply(case_tac "i=ia",simp,simp) |
|
670 |
apply(erule_tac x=ia in allE, erule impE, assumption, |
|
671 |
erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) |
|
672 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE,erule impE, assumption,simp) |
|
23746 | 673 |
apply(force elim:etranE intro:Env) |
13020 | 674 |
apply force |
675 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
676 |
apply simp |
|
677 |
apply clarify |
|
678 |
apply(rule tl_zero) |
|
679 |
apply(rule tl_zero,force) |
|
680 |
apply force |
|
681 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
682 |
apply force |
|
683 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
684 |
--{* first step is an environmental step *} |
|
685 |
apply clarify |
|
23746 | 686 |
apply(erule par_etran.cases) |
13020 | 687 |
apply simp |
688 |
apply(rule ParCptnEnv) |
|
689 |
apply(erule_tac x="Ps" in allE) |
|
690 |
apply(erule_tac x="t" in allE) |
|
691 |
apply(erule mp) |
|
692 |
apply(rule_tac x="map tl clist" in exI,simp) |
|
693 |
apply(rule conjI) |
|
694 |
apply clarify |
|
695 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (?I ?s j) \<in> cptn" in allE,simp) |
|
23746 | 696 |
apply(erule cptn.cases) |
13020 | 697 |
apply(simp add:same_length_def) |
698 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
699 |
apply(simp add:same_state_def) |
|
700 |
apply(erule_tac x=i in allE, erule impE, assumption, |
|
701 |
erule_tac x=1 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
702 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> ?J j \<in>etran" in allE,simp) |
|
23746 | 703 |
apply(erule etranE,simp) |
13020 | 704 |
apply(simp add:same_state_def same_length_def) |
705 |
apply(rule conjI,clarify) |
|
706 |
apply(case_tac j,simp,simp) |
|
707 |
apply(erule_tac x=i in allE, erule impE, assumption, |
|
708 |
erule_tac x="Suc(Suc nat)" and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
709 |
apply(rule tl_zero) |
|
710 |
apply(simp) |
|
711 |
apply force |
|
712 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
713 |
apply(rule conjI) |
|
714 |
apply(simp add:same_program_def) |
|
715 |
apply clarify |
|
716 |
apply(case_tac j,simp) |
|
717 |
apply(rule nth_equalityI,simp) |
|
718 |
apply clarify |
|
719 |
apply simp |
|
720 |
apply(erule_tac x="Suc(Suc nat)" and P="\<lambda>j. ?H j \<longrightarrow> (fst (?s j))=(?t j)" in allE,simp) |
|
721 |
apply(rule nth_equalityI,simp,simp) |
|
722 |
apply(force simp add:length_Suc_conv) |
|
723 |
apply(rule allI,rule impI) |
|
724 |
apply(erule_tac x="Suc j" and P="\<lambda>j. ?H j \<longrightarrow> (?I j \<or> ?J j)" in allE,simp) |
|
725 |
apply(erule disjE) |
|
726 |
apply clarify |
|
727 |
apply(rule_tac x=i in exI,simp) |
|
728 |
apply(rule conjI) |
|
729 |
apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> ?J i \<in>etran" in allE, erule impE, assumption) |
|
23746 | 730 |
apply(erule etranE,simp) |
13020 | 731 |
apply(erule_tac x=i in allE, erule impE, assumption, |
732 |
erule_tac x=1 and P="\<lambda>j. (?H j) \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
733 |
apply(rule nth_tl_if) |
|
734 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
735 |
apply simp |
|
736 |
apply(erule tl_zero,force) |
|
737 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
738 |
apply clarify |
|
739 |
apply(erule_tac x=l and P="\<lambda>i. ?H i \<longrightarrow> ?J i \<in>etran" in allE, erule impE, assumption) |
|
23746 | 740 |
apply(erule etranE,simp) |
13020 | 741 |
apply(erule_tac x=l in allE, erule impE, assumption, |
742 |
erule_tac x=1 and P="\<lambda>j. (?H j) \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
743 |
apply(rule nth_tl_if) |
|
744 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
745 |
apply simp |
|
746 |
apply(rule tl_zero,force) |
|
747 |
apply force |
|
748 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
749 |
apply(rule disjI2) |
|
750 |
apply simp |
|
751 |
apply clarify |
|
752 |
apply(case_tac j,simp) |
|
753 |
apply(rule tl_zero) |
|
754 |
apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> ?J i \<in>etran" in allE, erule impE, assumption) |
|
755 |
apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> ?J i \<in>etran" in allE, erule impE, assumption) |
|
23746 | 756 |
apply(force elim:etranE intro:Env) |
13020 | 757 |
apply force |
758 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
759 |
apply simp |
|
760 |
apply(rule tl_zero) |
|
761 |
apply(rule tl_zero,force) |
|
762 |
apply force |
|
763 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
764 |
apply force |
|
765 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
766 |
done |
|
767 |
||
768 |
lemma less_Suc_0 [iff]: "(n < Suc 0) = (n = 0)" |
|
769 |
by auto |
|
770 |
||
771 |
lemma aux_onlyif [rule_format]: "\<forall>xs s. (xs, s)#ys \<in> par_cptn \<longrightarrow> |
|
772 |
(\<exists>clist. (length clist = length xs) \<and> |
|
773 |
(xs, s)#ys \<propto> map (\<lambda>i. (fst i,s)#(snd i)) (zip xs clist) \<and> |
|
774 |
(\<forall>i<length xs. (xs!i,s)#(clist!i) \<in> cptn))" |
|
775 |
apply(induct ys) |
|
776 |
apply(clarify) |
|
15425 | 777 |
apply(rule_tac x="map (\<lambda>i. []) [0..<length xs]" in exI) |
13020 | 778 |
apply(simp add: conjoin_def same_length_def same_state_def same_program_def compat_label_def) |
779 |
apply(rule conjI) |
|
780 |
apply(rule nth_equalityI,simp,simp) |
|
781 |
apply(force intro: cptn.intros) |
|
782 |
apply(clarify) |
|
23746 | 783 |
apply(erule par_cptn.cases,simp) |
13020 | 784 |
apply simp |
785 |
apply(erule_tac x="xs" in allE) |
|
786 |
apply(erule_tac x="t" in allE,simp) |
|
787 |
apply clarify |
|
15425 | 788 |
apply(rule_tac x="(map (\<lambda>j. (P!j, t)#(clist!j)) [0..<length P])" in exI,simp) |
13020 | 789 |
apply(rule conjI) |
790 |
prefer 2 |
|
791 |
apply clarify |
|
792 |
apply(rule CptnEnv,simp) |
|
793 |
apply(simp add:conjoin_def same_length_def same_state_def) |
|
794 |
apply (rule conjI) |
|
795 |
apply clarify |
|
796 |
apply(case_tac j,simp,simp) |
|
797 |
apply(rule conjI) |
|
798 |
apply(simp add:same_program_def) |
|
799 |
apply clarify |
|
800 |
apply(case_tac j,simp) |
|
801 |
apply(rule nth_equalityI,simp,simp) |
|
802 |
apply simp |
|
803 |
apply(rule nth_equalityI,simp,simp) |
|
804 |
apply(simp add:compat_label_def) |
|
805 |
apply clarify |
|
806 |
apply(case_tac j,simp) |
|
807 |
apply(simp add:ParEnv) |
|
808 |
apply clarify |
|
809 |
apply(simp add:Env) |
|
810 |
apply simp |
|
811 |
apply(erule_tac x=nat in allE,erule impE, assumption) |
|
812 |
apply(erule disjE,simp) |
|
813 |
apply clarify |
|
814 |
apply(rule_tac x=i in exI,simp) |
|
815 |
apply force |
|
23746 | 816 |
apply(erule par_ctran.cases,simp) |
13020 | 817 |
apply(erule_tac x="Ps[i:=r]" in allE) |
818 |
apply(erule_tac x="ta" in allE,simp) |
|
819 |
apply clarify |
|
15425 | 820 |
apply(rule_tac x="(map (\<lambda>j. (Ps!j, ta)#(clist!j)) [0..<length Ps]) [i:=((r, ta)#(clist!i))]" in exI,simp) |
13020 | 821 |
apply(rule conjI) |
822 |
prefer 2 |
|
823 |
apply clarify |
|
824 |
apply(case_tac "i=ia",simp) |
|
825 |
apply(erule CptnComp) |
|
826 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (?I j \<in> cptn)" in allE,simp) |
|
827 |
apply simp |
|
828 |
apply(erule_tac x=ia in allE) |
|
829 |
apply(rule CptnEnv,simp) |
|
830 |
apply(simp add:conjoin_def) |
|
831 |
apply (rule conjI) |
|
832 |
apply(simp add:same_length_def) |
|
833 |
apply clarify |
|
834 |
apply(case_tac "i=ia",simp,simp) |
|
835 |
apply(rule conjI) |
|
836 |
apply(simp add:same_state_def) |
|
837 |
apply clarify |
|
13601 | 838 |
apply(case_tac j, simp, simp (no_asm_simp)) |
13020 | 839 |
apply(case_tac "i=ia",simp,simp) |
840 |
apply(rule conjI) |
|
841 |
apply(simp add:same_program_def) |
|
842 |
apply clarify |
|
843 |
apply(case_tac j,simp) |
|
844 |
apply(rule nth_equalityI,simp,simp) |
|
845 |
apply simp |
|
846 |
apply(rule nth_equalityI,simp,simp) |
|
847 |
apply(erule_tac x=nat and P="\<lambda>j. ?H j \<longrightarrow> (fst (?a j))=((?b j))" in allE) |
|
848 |
apply(case_tac nat) |
|
849 |
apply clarify |
|
850 |
apply(case_tac "i=ia",simp,simp) |
|
851 |
apply clarify |
|
852 |
apply(case_tac "i=ia",simp,simp) |
|
853 |
apply(simp add:compat_label_def) |
|
854 |
apply clarify |
|
855 |
apply(case_tac j) |
|
856 |
apply(rule conjI,simp) |
|
857 |
apply(erule ParComp,assumption) |
|
858 |
apply clarify |
|
859 |
apply(rule_tac x=i in exI,simp) |
|
860 |
apply clarify |
|
861 |
apply(rule Env) |
|
862 |
apply simp |
|
863 |
apply(erule_tac x=nat and P="\<lambda>j. ?H j \<longrightarrow> (?P j \<or> ?Q j)" in allE,simp) |
|
864 |
apply(erule disjE) |
|
865 |
apply clarify |
|
866 |
apply(rule_tac x=ia in exI,simp) |
|
867 |
apply(rule conjI) |
|
868 |
apply(case_tac "i=ia",simp,simp) |
|
869 |
apply clarify |
|
870 |
apply(case_tac "i=l",simp) |
|
871 |
apply(case_tac "l=ia",simp,simp) |
|
872 |
apply(erule_tac x=l in allE,erule impE,assumption,erule impE, assumption,simp) |
|
873 |
apply simp |
|
874 |
apply(erule_tac x=l in allE,erule impE,assumption,erule impE, assumption,simp) |
|
875 |
apply clarify |
|
876 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (?P j)\<in>etran" in allE, erule impE, assumption) |
|
13601 | 877 |
apply(case_tac "i=ia",simp,simp) |
13020 | 878 |
done |
879 |
||
880 |
lemma one_iff_aux: "xs\<noteq>[] \<Longrightarrow> (\<forall>ys. ((xs, s)#ys \<in> par_cptn) = |
|
881 |
(\<exists>clist. length clist= length xs \<and> |
|
882 |
((xs, s)#ys \<propto> map (\<lambda>i. (fst i,s)#(snd i)) (zip xs clist)) \<and> |
|
883 |
(\<forall>i<length xs. (xs!i,s)#(clist!i) \<in> cptn))) = |
|
884 |
(par_cp (xs) s = {c. \<exists>clist. (length clist)=(length xs) \<and> |
|
885 |
(\<forall>i<length clist. (clist!i) \<in> cp(xs!i) s) \<and> c \<propto> clist})" |
|
886 |
apply (rule iffI) |
|
887 |
apply(rule subset_antisym) |
|
888 |
apply(rule subsetI) |
|
889 |
apply(clarify) |
|
890 |
apply(simp add:par_cp_def cp_def) |
|
891 |
apply(case_tac x) |
|
23746 | 892 |
apply(force elim:par_cptn.cases) |
13020 | 893 |
apply simp |
894 |
apply(erule_tac x="list" in allE) |
|
895 |
apply clarify |
|
896 |
apply simp |
|
897 |
apply(rule_tac x="map (\<lambda>i. (fst i, s) # snd i) (zip xs clist)" in exI,simp) |
|
898 |
apply(rule subsetI) |
|
899 |
apply(clarify) |
|
900 |
apply(case_tac x) |
|
901 |
apply(erule_tac x=0 in allE) |
|
902 |
apply(simp add:cp_def conjoin_def same_length_def same_program_def same_state_def compat_label_def) |
|
903 |
apply clarify |
|
23746 | 904 |
apply(erule cptn.cases,force,force,force) |
13020 | 905 |
apply(simp add:par_cp_def conjoin_def same_length_def same_program_def same_state_def compat_label_def) |
906 |
apply clarify |
|
907 |
apply(erule_tac x=0 and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in all_dupE) |
|
908 |
apply(subgoal_tac "a = xs") |
|
909 |
apply(subgoal_tac "b = s",simp) |
|
910 |
prefer 3 |
|
911 |
apply(erule_tac x=0 and P="\<lambda>j. ?H j \<longrightarrow> (fst (?s j))=((?t j))" in allE) |
|
912 |
apply (simp add:cp_def) |
|
913 |
apply(rule nth_equalityI,simp,simp) |
|
914 |
prefer 2 |
|
915 |
apply(erule_tac x=0 in allE) |
|
916 |
apply (simp add:cp_def) |
|
917 |
apply(erule_tac x=0 and P="\<lambda>j. ?H j \<longrightarrow> (\<forall>i. ?T i \<longrightarrow> (snd (?d j i))=(snd (?e j i)))" in allE,simp) |
|
918 |
apply(erule_tac x=0 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
919 |
apply(erule_tac x=list in allE) |
|
920 |
apply(rule_tac x="map tl clist" in exI,simp) |
|
921 |
apply(rule conjI) |
|
922 |
apply clarify |
|
923 |
apply(case_tac j,simp) |
|
924 |
apply(erule_tac x=i in allE, erule impE, assumption, |
|
925 |
erule_tac x="0" and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
926 |
apply(erule_tac x=i in allE, erule impE, assumption, |
|
927 |
erule_tac x="Suc nat" and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) |
|
928 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
929 |
apply(case_tac "clist!i",simp,simp) |
|
930 |
apply(rule conjI) |
|
931 |
apply clarify |
|
932 |
apply(rule nth_equalityI,simp,simp) |
|
933 |
apply(case_tac j) |
|
934 |
apply clarify |
|
935 |
apply(erule_tac x=i in allE) |
|
936 |
apply(simp add:cp_def) |
|
937 |
apply clarify |
|
938 |
apply simp |
|
939 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
940 |
apply(case_tac "clist!i",simp,simp) |
|
941 |
apply(thin_tac "?H = (\<exists>i. ?J i)") |
|
942 |
apply(rule conjI) |
|
943 |
apply clarify |
|
944 |
apply(erule_tac x=j in allE,erule impE, assumption,erule disjE) |
|
945 |
apply clarify |
|
946 |
apply(rule_tac x=i in exI,simp) |
|
947 |
apply(case_tac j,simp) |
|
948 |
apply(rule conjI) |
|
949 |
apply(erule_tac x=i in allE) |
|
950 |
apply(simp add:cp_def) |
|
951 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
952 |
apply(case_tac "clist!i",simp,simp) |
|
953 |
apply clarify |
|
954 |
apply(erule_tac x=l in allE) |
|
955 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) |
|
956 |
apply clarify |
|
957 |
apply(simp add:cp_def) |
|
958 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
959 |
apply(case_tac "clist!l",simp,simp) |
|
960 |
apply simp |
|
961 |
apply(rule conjI) |
|
962 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
963 |
apply(case_tac "clist!i",simp,simp) |
|
964 |
apply clarify |
|
965 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) |
|
966 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
967 |
apply(case_tac "clist!l",simp,simp) |
|
968 |
apply clarify |
|
969 |
apply(erule_tac x=i in allE) |
|
970 |
apply(simp add:cp_def) |
|
971 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
972 |
apply(case_tac "clist!i",simp) |
|
973 |
apply(rule nth_tl_if,simp,simp) |
|
974 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (?P j)\<in>etran" in allE, erule impE, assumption,simp) |
|
975 |
apply(simp add:cp_def) |
|
976 |
apply clarify |
|
977 |
apply(rule nth_tl_if) |
|
978 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
979 |
apply(case_tac "clist!i",simp,simp) |
|
980 |
apply force |
|
981 |
apply force |
|
982 |
apply clarify |
|
983 |
apply(rule iffI) |
|
984 |
apply(simp add:par_cp_def) |
|
985 |
apply(erule_tac c="(xs, s) # ys" in equalityCE) |
|
986 |
apply simp |
|
987 |
apply clarify |
|
988 |
apply(rule_tac x="map tl clist" in exI) |
|
989 |
apply simp |
|
990 |
apply (rule conjI) |
|
991 |
apply(simp add:conjoin_def cp_def) |
|
992 |
apply(rule conjI) |
|
993 |
apply clarify |
|
994 |
apply(unfold same_length_def) |
|
995 |
apply clarify |
|
996 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,simp) |
|
997 |
apply(rule conjI) |
|
998 |
apply(simp add:same_state_def) |
|
999 |
apply clarify |
|
1000 |
apply(erule_tac x=i in allE, erule impE, assumption, |
|
1001 |
erule_tac x=j and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) |
|
1002 |
apply(case_tac j,simp) |
|
1003 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
1004 |
apply(case_tac "clist!i",simp,simp) |
|
1005 |
apply(rule conjI) |
|
1006 |
apply(simp add:same_program_def) |
|
1007 |
apply clarify |
|
1008 |
apply(rule nth_equalityI,simp,simp) |
|
1009 |
apply(case_tac j,simp) |
|
1010 |
apply clarify |
|
1011 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
1012 |
apply(case_tac "clist!i",simp,simp) |
|
1013 |
apply clarify |
|
1014 |
apply(simp add:compat_label_def) |
|
1015 |
apply(rule allI,rule impI) |
|
1016 |
apply(erule_tac x=j in allE,erule impE, assumption) |
|
1017 |
apply(erule disjE) |
|
1018 |
apply clarify |
|
1019 |
apply(rule_tac x=i in exI,simp) |
|
1020 |
apply(rule conjI) |
|
1021 |
apply(erule_tac x=i in allE) |
|
1022 |
apply(case_tac j,simp) |
|
1023 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
1024 |
apply(case_tac "clist!i",simp,simp) |
|
1025 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
1026 |
apply(case_tac "clist!i",simp,simp) |
|
1027 |
apply clarify |
|
1028 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<longrightarrow> ?J j" in allE) |
|
1029 |
apply(erule_tac x=l and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE) |
|
1030 |
apply(case_tac "clist!l",simp,simp) |
|
1031 |
apply(erule_tac x=l in allE,simp) |
|
1032 |
apply(rule disjI2) |
|
1033 |
apply clarify |
|
1034 |
apply(rule tl_zero) |
|
1035 |
apply(case_tac j,simp,simp) |
|
1036 |
apply(rule tl_zero,force) |
|
1037 |
apply force |
|
1038 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
1039 |
apply force |
|
1040 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (length (?s j) = ?t)" in allE,force) |
|
1041 |
apply clarify |
|
1042 |
apply(erule_tac x=i in allE) |
|
1043 |
apply(simp add:cp_def) |
|
1044 |
apply(rule nth_tl_if) |
|
1045 |
apply(simp add:conjoin_def) |
|
1046 |
apply clarify |
|
1047 |
apply(simp add:same_length_def) |
|
1048 |
apply(erule_tac x=i in allE,simp) |
|
1049 |
apply simp |
|
1050 |
apply simp |
|
1051 |
apply simp |
|
1052 |
apply clarify |
|
1053 |
apply(erule_tac c="(xs, s) # ys" in equalityCE) |
|
1054 |
apply(simp add:par_cp_def) |
|
1055 |
apply simp |
|
1056 |
apply(erule_tac x="map (\<lambda>i. (fst i, s) # snd i) (zip xs clist)" in allE) |
|
1057 |
apply simp |
|
1058 |
apply clarify |
|
1059 |
apply(simp add:cp_def) |
|
1060 |
done |
|
1061 |
||
1062 |
theorem one: "xs\<noteq>[] \<Longrightarrow> |
|
1063 |
par_cp xs s = {c. \<exists>clist. (length clist)=(length xs) \<and> |
|
1064 |
(\<forall>i<length clist. (clist!i) \<in> cp(xs!i) s) \<and> c \<propto> clist}" |
|
1065 |
apply(frule one_iff_aux) |
|
1066 |
apply(drule sym) |
|
1067 |
apply(erule iffD2) |
|
1068 |
apply clarify |
|
1069 |
apply(rule iffI) |
|
1070 |
apply(erule aux_onlyif) |
|
1071 |
apply clarify |
|
1072 |
apply(force intro:aux_if) |
|
1073 |
done |
|
1074 |
||
13187 | 1075 |
end |