9 |
9 |
10 constdefs |
10 constdefs |
11 stable :: "'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool" |
11 stable :: "'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool" |
12 "stable \<equiv> \<lambda>f g. (\<forall>x y. x \<in> f \<longrightarrow> (x, y) \<in> g \<longrightarrow> y \<in> f)" |
12 "stable \<equiv> \<lambda>f g. (\<forall>x y. x \<in> f \<longrightarrow> (x, y) \<in> g \<longrightarrow> y \<in> f)" |
13 |
13 |
14 consts rghoare :: "('a rgformula) set" |
14 inductive |
15 syntax |
15 rghoare :: "['a com, 'a set, ('a \<times> 'a) set, ('a \<times> 'a) set, 'a set] \<Rightarrow> bool" |
16 "_rghoare" :: "['a com, 'a set, ('a \<times> 'a) set, ('a \<times> 'a) set, 'a set] \<Rightarrow> bool" |
16 ("\<turnstile> _ sat [_, _, _, _]" [60,0,0,0,0] 45) |
17 ("\<turnstile> _ sat [_, _, _, _]" [60,0,0,0,0] 45) |
17 where |
18 translations |
|
19 "\<turnstile> P sat [pre, rely, guar, post]" \<rightleftharpoons> "(P, pre, rely, guar, post) \<in> rghoare" |
|
20 |
|
21 inductive rghoare |
|
22 intros |
|
23 Basic: "\<lbrakk> pre \<subseteq> {s. f s \<in> post}; {(s,t). s \<in> pre \<and> (t=f s \<or> t=s)} \<subseteq> guar; |
18 Basic: "\<lbrakk> pre \<subseteq> {s. f s \<in> post}; {(s,t). s \<in> pre \<and> (t=f s \<or> t=s)} \<subseteq> guar; |
24 stable pre rely; stable post rely \<rbrakk> |
19 stable pre rely; stable post rely \<rbrakk> |
25 \<Longrightarrow> \<turnstile> Basic f sat [pre, rely, guar, post]" |
20 \<Longrightarrow> \<turnstile> Basic f sat [pre, rely, guar, post]" |
26 |
21 |
27 Seq: "\<lbrakk> \<turnstile> P sat [pre, rely, guar, mid]; \<turnstile> Q sat [mid, rely, guar, post] \<rbrakk> |
22 | Seq: "\<lbrakk> \<turnstile> P sat [pre, rely, guar, mid]; \<turnstile> Q sat [mid, rely, guar, post] \<rbrakk> |
28 \<Longrightarrow> \<turnstile> Seq P Q sat [pre, rely, guar, post]" |
23 \<Longrightarrow> \<turnstile> Seq P Q sat [pre, rely, guar, post]" |
29 |
24 |
30 Cond: "\<lbrakk> stable pre rely; \<turnstile> P1 sat [pre \<inter> b, rely, guar, post]; |
25 | Cond: "\<lbrakk> stable pre rely; \<turnstile> P1 sat [pre \<inter> b, rely, guar, post]; |
31 \<turnstile> P2 sat [pre \<inter> -b, rely, guar, post]; \<forall>s. (s,s)\<in>guar \<rbrakk> |
26 \<turnstile> P2 sat [pre \<inter> -b, rely, guar, post]; \<forall>s. (s,s)\<in>guar \<rbrakk> |
32 \<Longrightarrow> \<turnstile> Cond b P1 P2 sat [pre, rely, guar, post]" |
27 \<Longrightarrow> \<turnstile> Cond b P1 P2 sat [pre, rely, guar, post]" |
33 |
28 |
34 While: "\<lbrakk> stable pre rely; (pre \<inter> -b) \<subseteq> post; stable post rely; |
29 | While: "\<lbrakk> stable pre rely; (pre \<inter> -b) \<subseteq> post; stable post rely; |
35 \<turnstile> P sat [pre \<inter> b, rely, guar, pre]; \<forall>s. (s,s)\<in>guar \<rbrakk> |
30 \<turnstile> P sat [pre \<inter> b, rely, guar, pre]; \<forall>s. (s,s)\<in>guar \<rbrakk> |
36 \<Longrightarrow> \<turnstile> While b P sat [pre, rely, guar, post]" |
31 \<Longrightarrow> \<turnstile> While b P sat [pre, rely, guar, post]" |
37 |
32 |
38 Await: "\<lbrakk> stable pre rely; stable post rely; |
33 | Await: "\<lbrakk> stable pre rely; stable post rely; |
39 \<forall>V. \<turnstile> P sat [pre \<inter> b \<inter> {V}, {(s, t). s = t}, |
34 \<forall>V. \<turnstile> P sat [pre \<inter> b \<inter> {V}, {(s, t). s = t}, |
40 UNIV, {s. (V, s) \<in> guar} \<inter> post] \<rbrakk> |
35 UNIV, {s. (V, s) \<in> guar} \<inter> post] \<rbrakk> |
41 \<Longrightarrow> \<turnstile> Await b P sat [pre, rely, guar, post]" |
36 \<Longrightarrow> \<turnstile> Await b P sat [pre, rely, guar, post]" |
42 |
37 |
43 Conseq: "\<lbrakk> pre \<subseteq> pre'; rely \<subseteq> rely'; guar' \<subseteq> guar; post' \<subseteq> post; |
38 | Conseq: "\<lbrakk> pre \<subseteq> pre'; rely \<subseteq> rely'; guar' \<subseteq> guar; post' \<subseteq> post; |
44 \<turnstile> P sat [pre', rely', guar', post'] \<rbrakk> |
39 \<turnstile> P sat [pre', rely', guar', post'] \<rbrakk> |
45 \<Longrightarrow> \<turnstile> P sat [pre, rely, guar, post]" |
40 \<Longrightarrow> \<turnstile> P sat [pre, rely, guar, post]" |
46 |
41 |
47 constdefs |
42 constdefs |
48 Pre :: "'a rgformula \<Rightarrow> 'a set" |
43 Pre :: "'a rgformula \<Rightarrow> 'a set" |
58 |
53 |
59 subsection {* Proof System for Parallel Programs *} |
54 subsection {* Proof System for Parallel Programs *} |
60 |
55 |
61 types 'a par_rgformula = "('a rgformula) list \<times> 'a set \<times> ('a \<times> 'a) set \<times> ('a \<times> 'a) set \<times> 'a set" |
56 types 'a par_rgformula = "('a rgformula) list \<times> 'a set \<times> ('a \<times> 'a) set \<times> ('a \<times> 'a) set \<times> 'a set" |
62 |
57 |
63 consts par_rghoare :: "('a par_rgformula) set" |
58 inductive |
64 syntax |
59 par_rghoare :: "('a rgformula) list \<Rightarrow> 'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a set \<Rightarrow> bool" |
65 "_par_rghoare" :: "('a rgformula) list \<Rightarrow> 'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a set \<Rightarrow> bool" ("\<turnstile> _ SAT [_, _, _, _]" [60,0,0,0,0] 45) |
60 ("\<turnstile> _ SAT [_, _, _, _]" [60,0,0,0,0] 45) |
66 translations |
61 where |
67 "\<turnstile> Ps SAT [pre, rely, guar, post]" \<rightleftharpoons> "(Ps, pre, rely, guar, post) \<in> par_rghoare" |
|
68 |
|
69 inductive par_rghoare |
|
70 intros |
|
71 Parallel: |
62 Parallel: |
72 "\<lbrakk> \<forall>i<length xs. rely \<union> (\<Union>j\<in>{j. j<length xs \<and> j\<noteq>i}. Guar(xs!j)) \<subseteq> Rely(xs!i); |
63 "\<lbrakk> \<forall>i<length xs. rely \<union> (\<Union>j\<in>{j. j<length xs \<and> j\<noteq>i}. Guar(xs!j)) \<subseteq> Rely(xs!i); |
73 (\<Union>j\<in>{j. j<length xs}. Guar(xs!j)) \<subseteq> guar; |
64 (\<Union>j\<in>{j. j<length xs}. Guar(xs!j)) \<subseteq> guar; |
74 pre \<subseteq> (\<Inter>i\<in>{i. i<length xs}. Pre(xs!i)); |
65 pre \<subseteq> (\<Inter>i\<in>{i. i<length xs}. Pre(xs!i)); |
75 (\<Inter>i\<in>{i. i<length xs}. Post(xs!i)) \<subseteq> post; |
66 (\<Inter>i\<in>{i. i<length xs}. Post(xs!i)) \<subseteq> post; |
111 done |
102 done |
112 |
103 |
113 lemma takecptn_is_cptn [rule_format, elim!]: |
104 lemma takecptn_is_cptn [rule_format, elim!]: |
114 "\<forall>j. c \<in> cptn \<longrightarrow> take (Suc j) c \<in> cptn" |
105 "\<forall>j. c \<in> cptn \<longrightarrow> take (Suc j) c \<in> cptn" |
115 apply(induct "c") |
106 apply(induct "c") |
116 apply(force elim: cptn.elims) |
107 apply(force elim: cptn.cases) |
117 apply clarify |
108 apply clarify |
118 apply(case_tac j) |
109 apply(case_tac j) |
119 apply simp |
110 apply simp |
120 apply(rule CptnOne) |
111 apply(rule CptnOne) |
121 apply simp |
112 apply simp |
122 apply(force intro:cptn.intros elim:cptn.elims) |
113 apply(force intro:cptn.intros elim:cptn.cases) |
123 done |
114 done |
124 |
115 |
125 lemma dropcptn_is_cptn [rule_format,elim!]: |
116 lemma dropcptn_is_cptn [rule_format,elim!]: |
126 "\<forall>j<length c. c \<in> cptn \<longrightarrow> drop j c \<in> cptn" |
117 "\<forall>j<length c. c \<in> cptn \<longrightarrow> drop j c \<in> cptn" |
127 apply(induct "c") |
118 apply(induct "c") |
128 apply(force elim: cptn.elims) |
119 apply(force elim: cptn.cases) |
129 apply clarify |
120 apply clarify |
130 apply(case_tac j,simp+) |
121 apply(case_tac j,simp+) |
131 apply(erule cptn.elims) |
122 apply(erule cptn.cases) |
132 apply simp |
123 apply simp |
133 apply force |
124 apply force |
134 apply force |
125 apply force |
135 done |
126 done |
136 |
127 |
137 lemma takepar_cptn_is_par_cptn [rule_format,elim]: |
128 lemma takepar_cptn_is_par_cptn [rule_format,elim]: |
138 "\<forall>j. c \<in> par_cptn \<longrightarrow> take (Suc j) c \<in> par_cptn" |
129 "\<forall>j. c \<in> par_cptn \<longrightarrow> take (Suc j) c \<in> par_cptn" |
139 apply(induct "c") |
130 apply(induct "c") |
140 apply(force elim: cptn.elims) |
131 apply(force elim: cptn.cases) |
141 apply clarify |
132 apply clarify |
142 apply(case_tac j,simp) |
133 apply(case_tac j,simp) |
143 apply(rule ParCptnOne) |
134 apply(rule ParCptnOne) |
144 apply(force intro:par_cptn.intros elim:par_cptn.elims) |
135 apply(force intro:par_cptn.intros elim:par_cptn.cases) |
145 done |
136 done |
146 |
137 |
147 lemma droppar_cptn_is_par_cptn [rule_format]: |
138 lemma droppar_cptn_is_par_cptn [rule_format]: |
148 "\<forall>j<length c. c \<in> par_cptn \<longrightarrow> drop j c \<in> par_cptn" |
139 "\<forall>j<length c. c \<in> par_cptn \<longrightarrow> drop j c \<in> par_cptn" |
149 apply(induct "c") |
140 apply(induct "c") |
150 apply(force elim: par_cptn.elims) |
141 apply(force elim: par_cptn.cases) |
151 apply clarify |
142 apply clarify |
152 apply(case_tac j,simp+) |
143 apply(case_tac j,simp+) |
153 apply(erule par_cptn.elims) |
144 apply(erule par_cptn.cases) |
154 apply simp |
145 apply simp |
155 apply force |
146 apply force |
156 apply force |
147 apply force |
157 done |
148 done |
158 |
149 |
163 |
154 |
164 lemma not_ctran_None [rule_format]: |
155 lemma not_ctran_None [rule_format]: |
165 "\<forall>s. (None, s)#xs \<in> cptn \<longrightarrow> (\<forall>i<length xs. ((None, s)#xs)!i -e\<rightarrow> xs!i)" |
156 "\<forall>s. (None, s)#xs \<in> cptn \<longrightarrow> (\<forall>i<length xs. ((None, s)#xs)!i -e\<rightarrow> xs!i)" |
166 apply(induct xs,simp+) |
157 apply(induct xs,simp+) |
167 apply clarify |
158 apply clarify |
168 apply(erule cptn.elims,simp) |
159 apply(erule cptn.cases,simp) |
169 apply simp |
160 apply simp |
170 apply(case_tac i,simp) |
161 apply(case_tac i,simp) |
171 apply(rule Env) |
162 apply(rule Env) |
172 apply simp |
163 apply simp |
173 apply(force elim:ctran.elims) |
164 apply(force elim:ctran.cases) |
174 done |
165 done |
175 |
166 |
176 lemma cptn_not_empty [simp]:"[] \<notin> cptn" |
167 lemma cptn_not_empty [simp]:"[] \<notin> cptn" |
177 apply(force elim:cptn.elims) |
168 apply(force elim:cptn.cases) |
178 done |
169 done |
179 |
170 |
180 lemma etran_or_ctran [rule_format]: |
171 lemma etran_or_ctran [rule_format]: |
181 "\<forall>m i. x\<in>cptn \<longrightarrow> m \<le> length x |
172 "\<forall>m i. x\<in>cptn \<longrightarrow> m \<le> length x |
182 \<longrightarrow> (\<forall>i. Suc i < m \<longrightarrow> \<not> x!i -c\<rightarrow> x!Suc i) \<longrightarrow> Suc i < m |
173 \<longrightarrow> (\<forall>i. Suc i < m \<longrightarrow> \<not> x!i -c\<rightarrow> x!Suc i) \<longrightarrow> Suc i < m |
183 \<longrightarrow> x!i -e\<rightarrow> x!Suc i" |
174 \<longrightarrow> x!i -e\<rightarrow> x!Suc i" |
184 apply(induct x,simp) |
175 apply(induct x,simp) |
185 apply clarify |
176 apply clarify |
186 apply(erule cptn.elims,simp) |
177 apply(erule cptn.cases,simp) |
187 apply(case_tac i,simp) |
178 apply(case_tac i,simp) |
188 apply(rule Env) |
179 apply(rule Env) |
189 apply simp |
180 apply simp |
190 apply(erule_tac x="m - 1" in allE) |
181 apply(erule_tac x="m - 1" in allE) |
191 apply(case_tac m,simp,simp) |
182 apply(case_tac m,simp,simp) |
239 (\<forall>i. (Suc i)<length x \<longrightarrow> |
230 (\<forall>i. (Suc i)<length x \<longrightarrow> |
240 (x!i -e\<rightarrow> x!(Suc i)) \<longrightarrow> (snd(x!i), snd(x!(Suc i))) \<in> rely) \<longrightarrow> |
231 (x!i -e\<rightarrow> x!(Suc i)) \<longrightarrow> (snd(x!i), snd(x!(Suc i))) \<in> rely) \<longrightarrow> |
241 (\<forall>i. j\<le>i \<and> i<k \<longrightarrow> x!i -e\<rightarrow> x!Suc i) \<longrightarrow> snd(x!k)\<in>p \<and> fst(x!j)=fst(x!k)" |
232 (\<forall>i. j\<le>i \<and> i<k \<longrightarrow> x!i -e\<rightarrow> x!Suc i) \<longrightarrow> snd(x!k)\<in>p \<and> fst(x!j)=fst(x!k)" |
242 apply(induct x) |
233 apply(induct x) |
243 apply clarify |
234 apply clarify |
244 apply(force elim:cptn.elims) |
235 apply(force elim:cptn.cases) |
245 apply clarify |
236 apply clarify |
246 apply(erule cptn.elims,simp) |
237 apply(erule cptn.cases,simp) |
247 apply simp |
238 apply simp |
248 apply(case_tac k,simp,simp) |
239 apply(case_tac k,simp,simp) |
249 apply(case_tac j,simp) |
240 apply(case_tac j,simp) |
250 apply(erule_tac x=0 in allE) |
241 apply(erule_tac x=0 in allE) |
251 apply(erule_tac x="nat" and P="\<lambda>j. (0\<le>j) \<longrightarrow> (?J j)" in allE,simp) |
242 apply(erule_tac x="nat" and P="\<lambda>j. (0\<le>j) \<longrightarrow> (?J j)" in allE,simp) |
272 apply clarify |
263 apply clarify |
273 apply(erule_tac x="Suc i" and P="\<lambda>j. (?H j) \<longrightarrow> (?J j) \<longrightarrow> (?T j)\<in>rely" in allE,simp) |
264 apply(erule_tac x="Suc i" and P="\<lambda>j. (?H j) \<longrightarrow> (?J j) \<longrightarrow> (?T j)\<in>rely" in allE,simp) |
274 apply(case_tac k,simp,simp) |
265 apply(case_tac k,simp,simp) |
275 apply(case_tac j) |
266 apply(case_tac j) |
276 apply(erule_tac x=0 and P="\<lambda>j. (?H j) \<longrightarrow> (?J j)\<in>etran" in allE,simp) |
267 apply(erule_tac x=0 and P="\<lambda>j. (?H j) \<longrightarrow> (?J j)\<in>etran" in allE,simp) |
277 apply(erule etran.elims,simp) |
268 apply(erule etran.cases,simp) |
278 apply(erule_tac x="nata" in allE) |
269 apply(erule_tac x="nata" in allE) |
279 apply(erule_tac x="nat" and P="\<lambda>j. (?s\<le>j) \<longrightarrow> (?J j)" in allE,simp) |
270 apply(erule_tac x="nat" and P="\<lambda>j. (?s\<le>j) \<longrightarrow> (?J j)" in allE,simp) |
280 apply(subgoal_tac "(\<forall>i. i < length xs \<longrightarrow> ((Q, t) # xs) ! i -e\<rightarrow> xs ! i \<longrightarrow> (snd (((Q, t) # xs) ! i), snd (xs ! i)) \<in> rely)") |
271 apply(subgoal_tac "(\<forall>i. i < length xs \<longrightarrow> ((Q, t) # xs) ! i -e\<rightarrow> xs ! i \<longrightarrow> (snd (((Q, t) # xs) ! i), snd (xs ! i)) \<in> rely)") |
281 apply clarify |
272 apply clarify |
282 apply(erule_tac x="Suc i" and P="\<lambda>j. (?H j) \<longrightarrow> (?J j)\<in>etran" in allE,simp) |
273 apply(erule_tac x="Suc i" and P="\<lambda>j. (?H j) \<longrightarrow> (?J j)\<in>etran" in allE,simp) |
293 Suc i<length x \<longrightarrow> x!i -c\<rightarrow> x!Suc i \<longrightarrow> |
284 Suc i<length x \<longrightarrow> x!i -c\<rightarrow> x!Suc i \<longrightarrow> |
294 (\<forall>j. Suc j<length x \<longrightarrow> i\<noteq>j \<longrightarrow> x!j -e\<rightarrow> x!Suc j)" |
285 (\<forall>j. Suc j<length x \<longrightarrow> i\<noteq>j \<longrightarrow> x!j -e\<rightarrow> x!Suc j)" |
295 apply(induct x,simp) |
286 apply(induct x,simp) |
296 apply simp |
287 apply simp |
297 apply clarify |
288 apply clarify |
298 apply(erule cptn.elims,simp) |
289 apply(erule cptn.cases,simp) |
299 apply(case_tac i,simp+) |
290 apply(case_tac i,simp+) |
300 apply clarify |
291 apply clarify |
301 apply(case_tac j,simp) |
292 apply(case_tac j,simp) |
302 apply(rule Env) |
293 apply(rule Env) |
303 apply simp |
294 apply simp |
304 apply clarify |
295 apply clarify |
305 apply simp |
296 apply simp |
306 apply(case_tac i) |
297 apply(case_tac i) |
307 apply(case_tac j,simp,simp) |
298 apply(case_tac j,simp,simp) |
308 apply(erule ctran.elims,simp_all) |
299 apply(erule ctran.cases,simp_all) |
309 apply(force elim: not_ctran_None) |
300 apply(force elim: not_ctran_None) |
310 apply(ind_cases "((Some (Basic f), sa), Q, t) \<in> ctran") |
301 apply(ind_cases "((Some (Basic f), sa), Q, t) \<in> ctran" for sa Q t) |
311 apply simp |
302 apply simp |
312 apply(drule_tac i=nat in not_ctran_None,simp) |
303 apply(drule_tac i=nat in not_ctran_None,simp) |
313 apply(erule etran.elims,simp) |
304 apply(erule etranE,simp) |
314 done |
305 done |
315 |
306 |
316 lemma exists_ctran_Basic_None [rule_format]: |
307 lemma exists_ctran_Basic_None [rule_format]: |
317 "\<forall>s i. x \<in> cptn \<longrightarrow> x ! 0 = (Some (Basic f), s) |
308 "\<forall>s i. x \<in> cptn \<longrightarrow> x ! 0 = (Some (Basic f), s) |
318 \<longrightarrow> i<length x \<longrightarrow> fst(x!i)=None \<longrightarrow> (\<exists>j<i. x!j -c\<rightarrow> x!Suc j)" |
309 \<longrightarrow> i<length x \<longrightarrow> fst(x!i)=None \<longrightarrow> (\<exists>j<i. x!j -c\<rightarrow> x!Suc j)" |
319 apply(induct x,simp) |
310 apply(induct x,simp) |
320 apply simp |
311 apply simp |
321 apply clarify |
312 apply clarify |
322 apply(erule cptn.elims,simp) |
313 apply(erule cptn.cases,simp) |
323 apply(case_tac i,simp,simp) |
314 apply(case_tac i,simp,simp) |
324 apply(erule_tac x=nat in allE,simp) |
315 apply(erule_tac x=nat in allE,simp) |
325 apply clarify |
316 apply clarify |
326 apply(rule_tac x="Suc j" in exI,simp,simp) |
317 apply(rule_tac x="Suc j" in exI,simp,simp) |
327 apply clarify |
318 apply clarify |
387 "\<forall>s i. x \<in> cptn \<longrightarrow> x ! 0 = (Some (Await b c), s) \<longrightarrow> |
378 "\<forall>s i. x \<in> cptn \<longrightarrow> x ! 0 = (Some (Await b c), s) \<longrightarrow> |
388 Suc i<length x \<longrightarrow> x!i -c\<rightarrow> x!Suc i \<longrightarrow> |
379 Suc i<length x \<longrightarrow> x!i -c\<rightarrow> x!Suc i \<longrightarrow> |
389 (\<forall>j. Suc j<length x \<longrightarrow> i\<noteq>j \<longrightarrow> x!j -e\<rightarrow> x!Suc j)" |
380 (\<forall>j. Suc j<length x \<longrightarrow> i\<noteq>j \<longrightarrow> x!j -e\<rightarrow> x!Suc j)" |
390 apply(induct x,simp+) |
381 apply(induct x,simp+) |
391 apply clarify |
382 apply clarify |
392 apply(erule cptn.elims,simp) |
383 apply(erule cptn.cases,simp) |
393 apply(case_tac i,simp+) |
384 apply(case_tac i,simp+) |
394 apply clarify |
385 apply clarify |
395 apply(case_tac j,simp) |
386 apply(case_tac j,simp) |
396 apply(rule Env) |
387 apply(rule Env) |
397 apply simp |
388 apply simp |
398 apply clarify |
389 apply clarify |
399 apply simp |
390 apply simp |
400 apply(case_tac i) |
391 apply(case_tac i) |
401 apply(case_tac j,simp,simp) |
392 apply(case_tac j,simp,simp) |
402 apply(erule ctran.elims,simp_all) |
393 apply(erule ctran.cases,simp_all) |
403 apply(force elim: not_ctran_None) |
394 apply(force elim: not_ctran_None) |
404 apply(ind_cases "((Some (Await b c), sa), Q, t) \<in> ctran",simp) |
395 apply(ind_cases "((Some (Await b c), sa), Q, t) \<in> ctran" for sa Q t,simp) |
405 apply(drule_tac i=nat in not_ctran_None,simp) |
396 apply(drule_tac i=nat in not_ctran_None,simp) |
406 apply(erule etran.elims,simp) |
397 apply(erule etranE,simp) |
407 done |
398 done |
408 |
399 |
409 lemma exists_ctran_Await_None [rule_format]: |
400 lemma exists_ctran_Await_None [rule_format]: |
410 "\<forall>s i. x \<in> cptn \<longrightarrow> x ! 0 = (Some (Await b c), s) |
401 "\<forall>s i. x \<in> cptn \<longrightarrow> x ! 0 = (Some (Await b c), s) |
411 \<longrightarrow> i<length x \<longrightarrow> fst(x!i)=None \<longrightarrow> (\<exists>j<i. x!j -c\<rightarrow> x!Suc j)" |
402 \<longrightarrow> i<length x \<longrightarrow> fst(x!i)=None \<longrightarrow> (\<exists>j<i. x!j -c\<rightarrow> x!Suc j)" |
412 apply(induct x,simp+) |
403 apply(induct x,simp+) |
413 apply clarify |
404 apply clarify |
414 apply(erule cptn.elims,simp) |
405 apply(erule cptn.cases,simp) |
415 apply(case_tac i,simp+) |
406 apply(case_tac i,simp+) |
416 apply(erule_tac x=nat in allE,simp) |
407 apply(erule_tac x=nat in allE,simp) |
417 apply clarify |
408 apply clarify |
418 apply(rule_tac x="Suc j" in exI,simp,simp) |
409 apply(rule_tac x="Suc j" in exI,simp,simp) |
419 apply clarify |
410 apply clarify |
464 apply(erule_tac x=ia in allE,simp) |
455 apply(erule_tac x=ia in allE,simp) |
465 apply(subgoal_tac "x\<in> cp (Some(Await b P)) s") |
456 apply(subgoal_tac "x\<in> cp (Some(Await b P)) s") |
466 apply(erule_tac i=i in unique_ctran_Await,force,simp_all) |
457 apply(erule_tac i=i in unique_ctran_Await,force,simp_all) |
467 apply(simp add:cp_def) |
458 apply(simp add:cp_def) |
468 --{* here starts the different part. *} |
459 --{* here starts the different part. *} |
469 apply(erule ctran.elims,simp_all) |
460 apply(erule ctran.cases,simp_all) |
470 apply(drule Star_imp_cptn) |
461 apply(drule Star_imp_cptn) |
471 apply clarify |
462 apply clarify |
472 apply(erule_tac x=sa in allE) |
463 apply(erule_tac x=sa in allE) |
473 apply clarify |
464 apply clarify |
474 apply(erule_tac x=sa in allE) |
465 apply(erule_tac x=sa in allE) |
475 apply(drule_tac c=l in subsetD) |
466 apply(drule_tac c=l in subsetD) |
476 apply (simp add:cp_def) |
467 apply (simp add:cp_def) |
477 apply clarify |
468 apply clarify |
478 apply(erule_tac x=ia and P="\<lambda>i. ?H i \<longrightarrow> (?J i,?I i)\<in>ctran" in allE,simp) |
469 apply(erule_tac x=ia and P="\<lambda>i. ?H i \<longrightarrow> (?J i,?I i)\<in>ctran" in allE,simp) |
479 apply(erule etran.elims,simp) |
470 apply(erule etranE,simp) |
480 apply simp |
471 apply simp |
481 apply clarify |
472 apply clarify |
482 apply(simp add:cp_def) |
473 apply(simp add:cp_def) |
483 apply clarify |
474 apply clarify |
484 apply(frule_tac i="length x - 1" in exists_ctran_Await_None,force) |
475 apply(frule_tac i="length x - 1" in exists_ctran_Await_None,force) |
494 apply(case_tac "x!j") |
485 apply(case_tac "x!j") |
495 apply clarify |
486 apply clarify |
496 apply simp |
487 apply simp |
497 apply(drule_tac s="Some (Await b P)" in sym,simp) |
488 apply(drule_tac s="Some (Await b P)" in sym,simp) |
498 apply(case_tac "x!Suc j",simp) |
489 apply(case_tac "x!Suc j",simp) |
499 apply(rule ctran.elims,simp) |
490 apply(rule ctran.cases,simp) |
500 apply(simp_all) |
491 apply(simp_all) |
501 apply(drule Star_imp_cptn) |
492 apply(drule Star_imp_cptn) |
502 apply clarify |
493 apply clarify |
503 apply(erule_tac x=sa in allE) |
494 apply(erule_tac x=sa in allE) |
504 apply clarify |
495 apply clarify |
505 apply(erule_tac x=sa in allE) |
496 apply(erule_tac x=sa in allE) |
506 apply(drule_tac c=l in subsetD) |
497 apply(drule_tac c=l in subsetD) |
507 apply (simp add:cp_def) |
498 apply (simp add:cp_def) |
508 apply clarify |
499 apply clarify |
509 apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> (?J i,?I i)\<in>ctran" in allE,simp) |
500 apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> (?J i,?I i)\<in>ctran" in allE,simp) |
510 apply(erule etran.elims,simp) |
501 apply(erule etranE,simp) |
511 apply simp |
502 apply simp |
512 apply clarify |
503 apply clarify |
513 apply(frule_tac j="Suc j" and k="length x - 1" and p=post in stability,simp_all) |
504 apply(frule_tac j="Suc j" and k="length x - 1" and p=post in stability,simp_all) |
514 apply(case_tac x,simp+) |
505 apply(case_tac x,simp+) |
515 apply(erule_tac x=i in allE) |
506 apply(erule_tac x=i in allE) |
614 apply(rule_tac x="(Some Pa, sa) #(Some Pa, t) # zs" in exI,simp) |
605 apply(rule_tac x="(Some Pa, sa) #(Some Pa, t) # zs" in exI,simp) |
615 apply(rule conjI,erule CptnEnv) |
606 apply(rule conjI,erule CptnEnv) |
616 apply(simp (no_asm_use) add:lift_def) |
607 apply(simp (no_asm_use) add:lift_def) |
617 apply clarify |
608 apply clarify |
618 apply(erule_tac x="Suc i" in allE, simp) |
609 apply(erule_tac x="Suc i" in allE, simp) |
619 apply(ind_cases "((Some (Seq Pa Q), sa), None, t) \<in> ctran") |
610 apply(ind_cases "((Some (Seq Pa Q), sa), None, t) \<in> ctran" for Pa sa t) |
620 apply(rule_tac x="(Some P, sa) # xs" in exI, simp add:cptn_iff_cptn_mod lift_def) |
611 apply(rule_tac x="(Some P, sa) # xs" in exI, simp add:cptn_iff_cptn_mod lift_def) |
621 apply(erule_tac x="length xs" in allE, simp) |
612 apply(erule_tac x="length xs" in allE, simp) |
622 apply(simp only:Cons_lift_append) |
613 apply(simp only:Cons_lift_append) |
623 apply(subgoal_tac "length xs < length ((Some P, sa) # xs)") |
614 apply(subgoal_tac "length xs < length ((Some P, sa) # xs)") |
624 apply(simp only :nth_append length_map last_length nth_map) |
615 apply(simp only :nth_append length_map last_length nth_map) |
647 apply(case_tac xsa,simp,simp) |
638 apply(case_tac xsa,simp,simp) |
648 apply(rule_tac x="(Some Pa, sa) #(Some Pa, t) # list" in exI,simp) |
639 apply(rule_tac x="(Some Pa, sa) #(Some Pa, t) # list" in exI,simp) |
649 apply(rule conjI,erule CptnEnv) |
640 apply(rule conjI,erule CptnEnv) |
650 apply(simp (no_asm_use) add:lift_def) |
641 apply(simp (no_asm_use) add:lift_def) |
651 apply(rule_tac x=ys in exI,simp) |
642 apply(rule_tac x=ys in exI,simp) |
652 apply(ind_cases "((Some (Seq Pa Q), sa), t) \<in> ctran") |
643 apply(ind_cases "((Some (Seq Pa Q), sa), t) \<in> ctran" for Pa sa t) |
653 apply simp |
644 apply simp |
654 apply(rule_tac x="(Some Pa, sa)#[(None, ta)]" in exI,simp) |
645 apply(rule_tac x="(Some Pa, sa)#[(None, ta)]" in exI,simp) |
655 apply(rule conjI) |
646 apply(rule conjI) |
656 apply(drule_tac xs="[]" in CptnComp,force simp add:CptnOne,simp) |
647 apply(drule_tac xs="[]" in CptnComp,force simp add:CptnOne,simp) |
657 apply(case_tac i, simp+) |
648 apply(case_tac i, simp+) |
898 --{* 4 subgoals left *} |
889 --{* 4 subgoals left *} |
899 apply(rule etran_in_comm) |
890 apply(rule etran_in_comm) |
900 apply(erule mp) |
891 apply(erule mp) |
901 apply(erule tl_of_assum_in_assum,simp) |
892 apply(erule tl_of_assum_in_assum,simp) |
902 --{* While-None *} |
893 --{* While-None *} |
903 apply(ind_cases "((Some (While b P), s), None, t) \<in> ctran") |
894 apply(ind_cases "((Some (While b P), s), None, t) \<in> ctran" for s t) |
904 apply(simp add:comm_def) |
895 apply(simp add:comm_def) |
905 apply(simp add:cptn_iff_cptn_mod [THEN sym]) |
896 apply(simp add:cptn_iff_cptn_mod [THEN sym]) |
906 apply(rule conjI,clarify) |
897 apply(rule conjI,clarify) |
907 apply(force simp add:assum_def) |
898 apply(force simp add:assum_def) |
908 apply clarify |
899 apply clarify |
909 apply(rule conjI, clarify) |
900 apply(rule conjI, clarify) |
910 apply(case_tac i,simp,simp) |
901 apply(case_tac i,simp,simp) |
911 apply(force simp add:not_ctran_None2) |
902 apply(force simp add:not_ctran_None2) |
912 apply(subgoal_tac "\<forall>i. Suc i < length ((None, sa) # xs) \<longrightarrow> (((None, sa) # xs) ! i, ((None, sa) # xs) ! Suc i)\<in> etran") |
903 apply(subgoal_tac "\<forall>i. Suc i < length ((None, t) # xs) \<longrightarrow> (((None, t) # xs) ! i, ((None, t) # xs) ! Suc i)\<in> etran") |
913 prefer 2 |
904 prefer 2 |
914 apply clarify |
905 apply clarify |
915 apply(rule_tac m="length ((None, s) # xs)" in etran_or_ctran,simp+) |
906 apply(rule_tac m="length ((None, s) # xs)" in etran_or_ctran,simp+) |
916 apply(erule not_ctran_None2,simp) |
907 apply(erule not_ctran_None2,simp) |
917 apply simp+ |
908 apply simp+ |
996 apply(drule_tac c="(Some P, sa) # xs" in subsetD) |
987 apply(drule_tac c="(Some P, sa) # xs" in subsetD) |
997 apply (simp add:assum_def del:map.simps last.simps) |
988 apply (simp add:assum_def del:map.simps last.simps) |
998 apply clarify |
989 apply clarify |
999 apply(erule_tac x="Suc ia" in allE,simp add:nth_append snd_lift del:map.simps last.simps, erule mp) |
990 apply(erule_tac x="Suc ia" in allE,simp add:nth_append snd_lift del:map.simps last.simps, erule mp) |
1000 apply(case_tac "fst(((Some P, sa) # xs) ! ia)") |
991 apply(case_tac "fst(((Some P, sa) # xs) ! ia)") |
1001 apply(erule etran.elims,simp add:lift_def) |
992 apply(erule etranE,simp add:lift_def) |
1002 apply(rule Env) |
993 apply(rule Env) |
1003 apply(erule etran.elims,simp add:lift_def) |
994 apply(erule etranE,simp add:lift_def) |
1004 apply(rule Env) |
995 apply(rule Env) |
1005 apply (simp add:comm_def del:map.simps) |
996 apply (simp add:comm_def del:map.simps) |
1006 apply clarify |
997 apply clarify |
1007 apply(erule allE,erule impE,assumption) |
998 apply(erule allE,erule impE,assumption) |
1008 apply(erule mp) |
999 apply(erule mp) |
1196 apply(erule disjE) |
1187 apply(erule disjE) |
1197 prefer 2 |
1188 prefer 2 |
1198 apply(force simp add:same_state_def par_assum_def) |
1189 apply(force simp add:same_state_def par_assum_def) |
1199 apply clarify |
1190 apply clarify |
1200 apply(case_tac "i=ia",simp) |
1191 apply(case_tac "i=ia",simp) |
1201 apply(erule etran.elims,simp) |
1192 apply(erule etranE,simp) |
1202 apply(erule_tac x="ia" and P="\<lambda>i. ?H i \<longrightarrow> (?I i) \<or> (?J i)" in allE,simp) |
1193 apply(erule_tac x="ia" and P="\<lambda>i. ?H i \<longrightarrow> (?I i) \<or> (?J i)" in allE,simp) |
1203 apply(erule_tac x=j and P="\<lambda>j. \<forall>i. ?S j i \<longrightarrow> (?I j i, ?H j i)\<in> ctran \<longrightarrow> (?P i j)" in allE) |
1194 apply(erule_tac x=j and P="\<lambda>j. \<forall>i. ?S j i \<longrightarrow> (?I j i, ?H j i)\<in> ctran \<longrightarrow> (?P i j)" in allE) |
1204 apply(erule_tac x=ia and P="\<lambda>j. ?S j \<longrightarrow> (?I j, ?H j)\<in> ctran \<longrightarrow> (?P j)" in allE) |
1195 apply(erule_tac x=ia and P="\<lambda>j. ?S j \<longrightarrow> (?I j, ?H j)\<in> ctran \<longrightarrow> (?P j)" in allE) |
1205 apply(simp add:same_state_def) |
1196 apply(simp add:same_state_def) |
1206 apply(erule_tac x=i and P="\<lambda>j. (?T j) \<longrightarrow> (\<forall>i. (?H j i) \<longrightarrow> (snd (?d j i))=(snd (?e j i)))" in all_dupE) |
1197 apply(erule_tac x=i and P="\<lambda>j. (?T j) \<longrightarrow> (\<forall>i. (?H j i) \<longrightarrow> (snd (?d j i))=(snd (?e j i)))" in all_dupE) |
1235 apply assumption |
1226 apply assumption |
1236 apply(simp add:conjoin_def same_program_def) |
1227 apply(simp add:conjoin_def same_program_def) |
1237 apply clarify |
1228 apply clarify |
1238 apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> fst(?I j)=(?J j)" in all_dupE) |
1229 apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> fst(?I j)=(?J j)" in all_dupE) |
1239 apply(erule_tac x="Suc i" and P="\<lambda>j. ?H j \<longrightarrow> fst(?I j)=(?J j)" in allE) |
1230 apply(erule_tac x="Suc i" and P="\<lambda>j. ?H j \<longrightarrow> fst(?I j)=(?J j)" in allE) |
1240 apply(erule par_ctran.elims,simp) |
1231 apply(erule par_ctranE,simp) |
1241 apply(erule_tac x=i and P="\<lambda>j. \<forall>i. ?S j i \<longrightarrow> (?I j i, ?H j i)\<in> ctran \<longrightarrow> (?P i j)" in allE) |
1232 apply(erule_tac x=i and P="\<lambda>j. \<forall>i. ?S j i \<longrightarrow> (?I j i, ?H j i)\<in> ctran \<longrightarrow> (?P i j)" in allE) |
1242 apply(erule_tac x=ia and P="\<lambda>j. ?S j \<longrightarrow> (?I j, ?H j)\<in> ctran \<longrightarrow> (?P j)" in allE) |
1233 apply(erule_tac x=ia and P="\<lambda>j. ?S j \<longrightarrow> (?I j, ?H j)\<in> ctran \<longrightarrow> (?P j)" in allE) |
1243 apply(rule_tac x=ia in exI) |
1234 apply(rule_tac x=ia in exI) |
1244 apply(simp add:same_state_def) |
1235 apply(simp add:same_state_def) |
1245 apply(erule_tac x=ia and P="\<lambda>j. (?T j) \<longrightarrow> (\<forall>i. (?H j i) \<longrightarrow> (snd (?d j i))=(snd (?e j i)))" in all_dupE,simp) |
1236 apply(erule_tac x=ia and P="\<lambda>j. (?T j) \<longrightarrow> (\<forall>i. (?H j i) \<longrightarrow> (snd (?d j i))=(snd (?e j i)))" in all_dupE,simp) |