author | haftmann |
Tue, 05 Jun 2007 19:19:30 +0200 | |
changeset 23261 | 85f27f79232f |
parent 20432 | 07ec57376051 |
child 23746 | a455e69c31cc |
permissions | -rw-r--r-- |
13020 | 1 |
header {* \section{The Proof System} *} |
2 |
||
16417 | 3 |
theory RG_Hoare imports RG_Tran begin |
13020 | 4 |
|
5 |
subsection {* Proof System for Component Programs *} |
|
6 |
||
15102 | 7 |
declare Un_subset_iff [iff del] |
18447 | 8 |
declare Cons_eq_map_conv[iff] |
15102 | 9 |
|
13020 | 10 |
constdefs |
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)" |
|
13 |
||
14 |
consts rghoare :: "('a rgformula) set" |
|
15 |
syntax |
|
16 |
"_rghoare" :: "['a com, 'a set, ('a \<times> 'a) set, ('a \<times> 'a) set, 'a set] \<Rightarrow> bool" |
|
17 |
("\<turnstile> _ sat [_, _, _, _]" [60,0,0,0,0] 45) |
|
18 |
translations |
|
19 |
"\<turnstile> P sat [pre, rely, guar, post]" \<rightleftharpoons> "(P, pre, rely, guar, post) \<in> rghoare" |
|
20 |
||
21 |
inductive rghoare |
|
22 |
intros |
|
13099 | 23 |
Basic: "\<lbrakk> pre \<subseteq> {s. f s \<in> post}; {(s,t). s \<in> pre \<and> (t=f s \<or> t=s)} \<subseteq> guar; |
13020 | 24 |
stable pre rely; stable post rely \<rbrakk> |
25 |
\<Longrightarrow> \<turnstile> Basic f sat [pre, rely, guar, post]" |
|
26 |
||
27 |
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]" |
|
29 |
||
30 |
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> |
|
32 |
\<Longrightarrow> \<turnstile> Cond b P1 P2 sat [pre, rely, guar, post]" |
|
33 |
||
34 |
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> |
|
36 |
\<Longrightarrow> \<turnstile> While b P sat [pre, rely, guar, post]" |
|
37 |
||
38 |
Await: "\<lbrakk> stable pre rely; stable post rely; |
|
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
|
39 |
\<forall>V. \<turnstile> P sat [pre \<inter> b \<inter> {V}, {(s, t). s = t}, |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
40 |
UNIV, {s. (V, s) \<in> guar} \<inter> post] \<rbrakk> |
13020 | 41 |
\<Longrightarrow> \<turnstile> Await b P sat [pre, rely, guar, post]" |
42 |
||
43 |
Conseq: "\<lbrakk> pre \<subseteq> pre'; rely \<subseteq> rely'; guar' \<subseteq> guar; post' \<subseteq> post; |
|
44 |
\<turnstile> P sat [pre', rely', guar', post'] \<rbrakk> |
|
45 |
\<Longrightarrow> \<turnstile> P sat [pre, rely, guar, post]" |
|
46 |
||
47 |
constdefs |
|
48 |
Pre :: "'a rgformula \<Rightarrow> 'a set" |
|
49 |
"Pre x \<equiv> fst(snd x)" |
|
50 |
Post :: "'a rgformula \<Rightarrow> 'a set" |
|
51 |
"Post x \<equiv> snd(snd(snd(snd x)))" |
|
52 |
Rely :: "'a rgformula \<Rightarrow> ('a \<times> 'a) set" |
|
53 |
"Rely x \<equiv> fst(snd(snd x))" |
|
54 |
Guar :: "'a rgformula \<Rightarrow> ('a \<times> 'a) set" |
|
55 |
"Guar x \<equiv> fst(snd(snd(snd x)))" |
|
56 |
Com :: "'a rgformula \<Rightarrow> 'a com" |
|
57 |
"Com x \<equiv> fst x" |
|
58 |
||
59 |
subsection {* Proof System for Parallel Programs *} |
|
60 |
||
61 |
types 'a par_rgformula = "('a rgformula) list \<times> 'a set \<times> ('a \<times> 'a) set \<times> ('a \<times> 'a) set \<times> 'a set" |
|
62 |
||
63 |
consts par_rghoare :: "('a par_rgformula) set" |
|
64 |
syntax |
|
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
|
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) |
13020 | 66 |
translations |
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: |
|
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); |
|
73 |
(\<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)); |
|
75 |
(\<Inter>i\<in>{i. i<length xs}. Post(xs!i)) \<subseteq> post; |
|
76 |
\<forall>i<length xs. \<turnstile> Com(xs!i) sat [Pre(xs!i),Rely(xs!i),Guar(xs!i),Post(xs!i)] \<rbrakk> |
|
77 |
\<Longrightarrow> \<turnstile> xs SAT [pre, rely, guar, post]" |
|
78 |
||
79 |
section {* Soundness*} |
|
80 |
||
81 |
subsubsection {* Some previous lemmas *} |
|
82 |
||
83 |
lemma tl_of_assum_in_assum: |
|
84 |
"(P, s) # (P, t) # xs \<in> assum (pre, rely) \<Longrightarrow> stable pre rely |
|
85 |
\<Longrightarrow> (P, t) # xs \<in> assum (pre, rely)" |
|
86 |
apply(simp add:assum_def) |
|
87 |
apply clarify |
|
88 |
apply(rule conjI) |
|
89 |
apply(erule_tac x=0 in allE) |
|
90 |
apply(simp (no_asm_use)only:stable_def) |
|
91 |
apply(erule allE,erule allE,erule impE,assumption,erule mp) |
|
92 |
apply(simp add:Env) |
|
93 |
apply clarify |
|
94 |
apply(erule_tac x="Suc i" in allE) |
|
95 |
apply simp |
|
96 |
done |
|
97 |
||
98 |
lemma etran_in_comm: |
|
99 |
"(P, t) # xs \<in> comm(guar, post) \<Longrightarrow> (P, s) # (P, t) # xs \<in> comm(guar, post)" |
|
100 |
apply(simp add:comm_def) |
|
101 |
apply clarify |
|
102 |
apply(case_tac i,simp+) |
|
103 |
done |
|
104 |
||
105 |
lemma ctran_in_comm: |
|
106 |
"\<lbrakk>(s, s) \<in> guar; (Q, s) # xs \<in> comm(guar, post)\<rbrakk> |
|
107 |
\<Longrightarrow> (P, s) # (Q, s) # xs \<in> comm(guar, post)" |
|
108 |
apply(simp add:comm_def) |
|
109 |
apply clarify |
|
110 |
apply(case_tac i,simp+) |
|
111 |
done |
|
112 |
||
113 |
lemma takecptn_is_cptn [rule_format, elim!]: |
|
114 |
"\<forall>j. c \<in> cptn \<longrightarrow> take (Suc j) c \<in> cptn" |
|
115 |
apply(induct "c") |
|
116 |
apply(force elim: cptn.elims) |
|
117 |
apply clarify |
|
118 |
apply(case_tac j) |
|
119 |
apply simp |
|
120 |
apply(rule CptnOne) |
|
121 |
apply simp |
|
122 |
apply(force intro:cptn.intros elim:cptn.elims) |
|
123 |
done |
|
124 |
||
125 |
lemma dropcptn_is_cptn [rule_format,elim!]: |
|
126 |
"\<forall>j<length c. c \<in> cptn \<longrightarrow> drop j c \<in> cptn" |
|
127 |
apply(induct "c") |
|
128 |
apply(force elim: cptn.elims) |
|
129 |
apply clarify |
|
130 |
apply(case_tac j,simp+) |
|
131 |
apply(erule cptn.elims) |
|
132 |
apply simp |
|
133 |
apply force |
|
134 |
apply force |
|
135 |
done |
|
136 |
||
137 |
lemma takepar_cptn_is_par_cptn [rule_format,elim]: |
|
138 |
"\<forall>j. c \<in> par_cptn \<longrightarrow> take (Suc j) c \<in> par_cptn" |
|
139 |
apply(induct "c") |
|
140 |
apply(force elim: cptn.elims) |
|
141 |
apply clarify |
|
142 |
apply(case_tac j,simp) |
|
143 |
apply(rule ParCptnOne) |
|
144 |
apply(force intro:par_cptn.intros elim:par_cptn.elims) |
|
145 |
done |
|
146 |
||
147 |
lemma droppar_cptn_is_par_cptn [rule_format]: |
|
148 |
"\<forall>j<length c. c \<in> par_cptn \<longrightarrow> drop j c \<in> par_cptn" |
|
149 |
apply(induct "c") |
|
150 |
apply(force elim: par_cptn.elims) |
|
151 |
apply clarify |
|
152 |
apply(case_tac j,simp+) |
|
153 |
apply(erule par_cptn.elims) |
|
154 |
apply simp |
|
155 |
apply force |
|
156 |
apply force |
|
157 |
done |
|
158 |
||
159 |
lemma tl_of_cptn_is_cptn: "\<lbrakk>x # xs \<in> cptn; xs \<noteq> []\<rbrakk> \<Longrightarrow> xs \<in> cptn" |
|
160 |
apply(subgoal_tac "1 < length (x # xs)") |
|
161 |
apply(drule dropcptn_is_cptn,simp+) |
|
162 |
done |
|
163 |
||
164 |
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)" |
|
166 |
apply(induct xs,simp+) |
|
167 |
apply clarify |
|
168 |
apply(erule cptn.elims,simp) |
|
169 |
apply simp |
|
170 |
apply(case_tac i,simp) |
|
171 |
apply(rule Env) |
|
172 |
apply simp |
|
173 |
apply(force elim:ctran.elims) |
|
174 |
done |
|
175 |
||
176 |
lemma cptn_not_empty [simp]:"[] \<notin> cptn" |
|
177 |
apply(force elim:cptn.elims) |
|
178 |
done |
|
179 |
||
180 |
lemma etran_or_ctran [rule_format]: |
|
181 |
"\<forall>m i. x\<in>cptn \<longrightarrow> m \<le> length x |
|
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
|
182 |
\<longrightarrow> (\<forall>i. Suc i < m \<longrightarrow> \<not> x!i -c\<rightarrow> x!Suc i) \<longrightarrow> Suc i < m |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
183 |
\<longrightarrow> x!i -e\<rightarrow> x!Suc i" |
13020 | 184 |
apply(induct x,simp) |
185 |
apply clarify |
|
186 |
apply(erule cptn.elims,simp) |
|
187 |
apply(case_tac i,simp) |
|
188 |
apply(rule Env) |
|
189 |
apply simp |
|
190 |
apply(erule_tac x="m - 1" in allE) |
|
191 |
apply(case_tac m,simp,simp) |
|
192 |
apply(subgoal_tac "(\<forall>i. Suc i < nata \<longrightarrow> (((P, t) # xs) ! i, xs ! i) \<notin> ctran)") |
|
193 |
apply force |
|
194 |
apply clarify |
|
195 |
apply(erule_tac x="Suc ia" in allE,simp) |
|
196 |
apply(erule_tac x="0" and P="\<lambda>j. ?H j \<longrightarrow> (?J j) \<notin> ctran" in allE,simp) |
|
197 |
done |
|
198 |
||
199 |
lemma etran_or_ctran2 [rule_format]: |
|
200 |
"\<forall>i. Suc i<length x \<longrightarrow> x\<in>cptn \<longrightarrow> (x!i -c\<rightarrow> x!Suc i \<longrightarrow> \<not> x!i -e\<rightarrow> x!Suc i) |
|
201 |
\<or> (x!i -e\<rightarrow> x!Suc i \<longrightarrow> \<not> x!i -c\<rightarrow> x!Suc i)" |
|
202 |
apply(induct x) |
|
203 |
apply simp |
|
204 |
apply clarify |
|
205 |
apply(erule cptn.elims,simp) |
|
206 |
apply(case_tac i,simp+) |
|
207 |
apply(case_tac i,simp) |
|
208 |
apply(force elim:etran.elims) |
|
209 |
apply simp |
|
210 |
done |
|
211 |
||
212 |
lemma etran_or_ctran2_disjI1: |
|
213 |
"\<lbrakk> x\<in>cptn; Suc i<length x; x!i -c\<rightarrow> x!Suc i\<rbrakk> \<Longrightarrow> \<not> x!i -e\<rightarrow> x!Suc i" |
|
214 |
by(drule etran_or_ctran2,simp_all) |
|
215 |
||
216 |
lemma etran_or_ctran2_disjI2: |
|
217 |
"\<lbrakk> x\<in>cptn; Suc i<length x; x!i -e\<rightarrow> x!Suc i\<rbrakk> \<Longrightarrow> \<not> x!i -c\<rightarrow> x!Suc i" |
|
218 |
by(drule etran_or_ctran2,simp_all) |
|
219 |
||
220 |
lemma not_ctran_None2 [rule_format]: |
|
221 |
"\<lbrakk> (None, s) # xs \<in>cptn; i<length xs\<rbrakk> \<Longrightarrow> \<not> ((None, s) # xs) ! i -c\<rightarrow> xs ! i" |
|
222 |
apply(frule not_ctran_None,simp) |
|
223 |
apply(case_tac i,simp) |
|
224 |
apply(force elim:etran.elims) |
|
225 |
apply simp |
|
226 |
apply(rule etran_or_ctran2_disjI2,simp_all) |
|
227 |
apply(force intro:tl_of_cptn_is_cptn) |
|
228 |
done |
|
229 |
||
230 |
lemma Ex_first_occurrence [rule_format]: "P (n::nat) \<longrightarrow> (\<exists>m. P m \<and> (\<forall>i<m. \<not> P i))"; |
|
231 |
apply(rule nat_less_induct) |
|
232 |
apply clarify |
|
233 |
apply(case_tac "\<forall>m. m<n \<longrightarrow> \<not> P m") |
|
234 |
apply auto |
|
235 |
done |
|
236 |
||
237 |
lemma stability [rule_format]: |
|
238 |
"\<forall>j k. x \<in> cptn \<longrightarrow> stable p rely \<longrightarrow> j\<le>k \<longrightarrow> k<length x \<longrightarrow> snd(x!j)\<in>p \<longrightarrow> |
|
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
|
239 |
(\<forall>i. (Suc i)<length x \<longrightarrow> |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
240 |
(x!i -e\<rightarrow> x!(Suc i)) \<longrightarrow> (snd(x!i), snd(x!(Suc i))) \<in> rely) \<longrightarrow> |
13020 | 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)" |
242 |
apply(induct x) |
|
243 |
apply clarify |
|
244 |
apply(force elim:cptn.elims) |
|
245 |
apply clarify |
|
246 |
apply(erule cptn.elims,simp) |
|
247 |
apply simp |
|
248 |
apply(case_tac k,simp,simp) |
|
249 |
apply(case_tac j,simp) |
|
250 |
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) |
|
252 |
apply(subgoal_tac "t\<in>p") |
|
253 |
apply(subgoal_tac "(\<forall>i. i < length xs \<longrightarrow> ((P, t) # xs) ! i -e\<rightarrow> xs ! i \<longrightarrow> (snd (((P, t) # xs) ! i), snd (xs ! i)) \<in> rely)") |
|
254 |
apply clarify |
|
255 |
apply(erule_tac x="Suc i" and P="\<lambda>j. (?H j) \<longrightarrow> (?J j)\<in>etran" in allE,simp) |
|
256 |
apply clarify |
|
257 |
apply(erule_tac x="Suc i" and P="\<lambda>j. (?H j) \<longrightarrow> (?J j) \<longrightarrow> (?T j)\<in>rely" in allE,simp) |
|
258 |
apply(erule_tac x=0 and P="\<lambda>j. (?H j) \<longrightarrow> (?J j)\<in>etran \<longrightarrow> ?T j" in allE,simp) |
|
259 |
apply(simp(no_asm_use) only:stable_def) |
|
260 |
apply(erule_tac x=s in allE) |
|
261 |
apply(erule_tac x=t in allE) |
|
262 |
apply simp |
|
263 |
apply(erule mp) |
|
264 |
apply(erule mp) |
|
265 |
apply(rule Env) |
|
266 |
apply simp |
|
267 |
apply(erule_tac x="nata" in allE) |
|
268 |
apply(erule_tac x="nat" and P="\<lambda>j. (?s\<le>j) \<longrightarrow> (?J j)" in allE,simp) |
|
269 |
apply(subgoal_tac "(\<forall>i. i < length xs \<longrightarrow> ((P, t) # xs) ! i -e\<rightarrow> xs ! i \<longrightarrow> (snd (((P, t) # xs) ! i), snd (xs ! i)) \<in> rely)") |
|
270 |
apply clarify |
|
271 |
apply(erule_tac x="Suc i" and P="\<lambda>j. (?H j) \<longrightarrow> (?J j)\<in>etran" in allE,simp) |
|
272 |
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) |
|
274 |
apply(case_tac k,simp,simp) |
|
275 |
apply(case_tac j) |
|
276 |
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) |
|
278 |
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) |
|
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)") |
|
281 |
apply clarify |
|
282 |
apply(erule_tac x="Suc i" and P="\<lambda>j. (?H j) \<longrightarrow> (?J j)\<in>etran" in allE,simp) |
|
283 |
apply clarify |
|
284 |
apply(erule_tac x="Suc i" and P="\<lambda>j. (?H j) \<longrightarrow> (?J j) \<longrightarrow> (?T j)\<in>rely" in allE,simp) |
|
285 |
done |
|
286 |
||
287 |
subsection {* Soundness of the System for Component Programs *} |
|
288 |
||
289 |
subsubsection {* Soundness of the Basic rule *} |
|
290 |
||
291 |
lemma unique_ctran_Basic [rule_format]: |
|
292 |
"\<forall>s i. x \<in> cptn \<longrightarrow> x ! 0 = (Some (Basic f), s) \<longrightarrow> |
|
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
|
293 |
Suc i<length x \<longrightarrow> x!i -c\<rightarrow> x!Suc i \<longrightarrow> |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
294 |
(\<forall>j. Suc j<length x \<longrightarrow> i\<noteq>j \<longrightarrow> x!j -e\<rightarrow> x!Suc j)" |
13020 | 295 |
apply(induct x,simp) |
296 |
apply simp |
|
297 |
apply clarify |
|
298 |
apply(erule cptn.elims,simp) |
|
299 |
apply(case_tac i,simp+) |
|
300 |
apply clarify |
|
301 |
apply(case_tac j,simp) |
|
302 |
apply(rule Env) |
|
303 |
apply simp |
|
304 |
apply clarify |
|
305 |
apply simp |
|
306 |
apply(case_tac i) |
|
307 |
apply(case_tac j,simp,simp) |
|
308 |
apply(erule ctran.elims,simp_all) |
|
309 |
apply(force elim: not_ctran_None) |
|
310 |
apply(ind_cases "((Some (Basic f), sa), Q, t) \<in> ctran") |
|
311 |
apply simp |
|
312 |
apply(drule_tac i=nat in not_ctran_None,simp) |
|
313 |
apply(erule etran.elims,simp) |
|
314 |
done |
|
315 |
||
316 |
lemma exists_ctran_Basic_None [rule_format]: |
|
317 |
"\<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)" |
|
319 |
apply(induct x,simp) |
|
320 |
apply simp |
|
321 |
apply clarify |
|
322 |
apply(erule cptn.elims,simp) |
|
323 |
apply(case_tac i,simp,simp) |
|
324 |
apply(erule_tac x=nat in allE,simp) |
|
325 |
apply clarify |
|
326 |
apply(rule_tac x="Suc j" in exI,simp,simp) |
|
327 |
apply clarify |
|
328 |
apply(case_tac i,simp,simp) |
|
329 |
apply(rule_tac x=0 in exI,simp) |
|
330 |
done |
|
331 |
||
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
332 |
lemma Basic_sound: |
13020 | 333 |
" \<lbrakk>pre \<subseteq> {s. f s \<in> post}; {(s, t). s \<in> pre \<and> t = f s} \<subseteq> guar; |
334 |
stable pre rely; stable post rely\<rbrakk> |
|
335 |
\<Longrightarrow> \<Turnstile> Basic f sat [pre, rely, guar, post]" |
|
336 |
apply(unfold com_validity_def) |
|
337 |
apply clarify |
|
338 |
apply(simp add:comm_def) |
|
339 |
apply(rule conjI) |
|
340 |
apply clarify |
|
341 |
apply(simp add:cp_def assum_def) |
|
342 |
apply clarify |
|
343 |
apply(frule_tac j=0 and k=i and p=pre in stability) |
|
344 |
apply simp_all |
|
345 |
apply(erule_tac x=ia in allE,simp) |
|
346 |
apply(erule_tac i=i and f=f in unique_ctran_Basic,simp_all) |
|
347 |
apply(erule subsetD,simp) |
|
348 |
apply(case_tac "x!i") |
|
349 |
apply clarify |
|
350 |
apply(drule_tac s="Some (Basic f)" in sym,simp) |
|
351 |
apply(thin_tac "\<forall>j. ?H j") |
|
352 |
apply(force elim:ctran.elims) |
|
353 |
apply clarify |
|
354 |
apply(simp add:cp_def) |
|
355 |
apply clarify |
|
356 |
apply(frule_tac i="length x - 1" and f=f in exists_ctran_Basic_None,simp+) |
|
357 |
apply(case_tac x,simp+) |
|
358 |
apply(rule last_fst_esp,simp add:last_length) |
|
359 |
apply (case_tac x,simp+) |
|
360 |
apply(simp add:assum_def) |
|
361 |
apply clarify |
|
362 |
apply(frule_tac j=0 and k="j" and p=pre in stability) |
|
363 |
apply simp_all |
|
364 |
apply(erule_tac x=i in allE,simp) |
|
365 |
apply(erule_tac i=j and f=f in unique_ctran_Basic,simp_all) |
|
366 |
apply(case_tac "x!j") |
|
367 |
apply clarify |
|
368 |
apply simp |
|
369 |
apply(drule_tac s="Some (Basic f)" in sym,simp) |
|
370 |
apply(case_tac "x!Suc j",simp) |
|
371 |
apply(rule ctran.elims,simp) |
|
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
372 |
apply(simp_all) |
13020 | 373 |
apply(drule_tac c=sa in subsetD,simp) |
374 |
apply clarify |
|
375 |
apply(frule_tac j="Suc j" and k="length x - 1" and p=post in stability,simp_all) |
|
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
376 |
apply(case_tac x,simp+) |
13020 | 377 |
apply(erule_tac x=i in allE) |
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
378 |
apply(erule_tac i=j and f=f in unique_ctran_Basic,simp_all) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
379 |
apply arith+ |
13020 | 380 |
apply(case_tac x) |
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
381 |
apply(simp add:last_length)+ |
13020 | 382 |
done |
383 |
||
384 |
subsubsection{* Soundness of the Await rule *} |
|
385 |
||
386 |
lemma unique_ctran_Await [rule_format]: |
|
387 |
"\<forall>s i. x \<in> cptn \<longrightarrow> x ! 0 = (Some (Await b c), s) \<longrightarrow> |
|
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
|
388 |
Suc i<length x \<longrightarrow> x!i -c\<rightarrow> x!Suc i \<longrightarrow> |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
389 |
(\<forall>j. Suc j<length x \<longrightarrow> i\<noteq>j \<longrightarrow> x!j -e\<rightarrow> x!Suc j)" |
13020 | 390 |
apply(induct x,simp+) |
391 |
apply clarify |
|
392 |
apply(erule cptn.elims,simp) |
|
393 |
apply(case_tac i,simp+) |
|
394 |
apply clarify |
|
395 |
apply(case_tac j,simp) |
|
396 |
apply(rule Env) |
|
397 |
apply simp |
|
398 |
apply clarify |
|
399 |
apply simp |
|
400 |
apply(case_tac i) |
|
401 |
apply(case_tac j,simp,simp) |
|
402 |
apply(erule ctran.elims,simp_all) |
|
403 |
apply(force elim: not_ctran_None) |
|
404 |
apply(ind_cases "((Some (Await b c), sa), Q, t) \<in> ctran",simp) |
|
405 |
apply(drule_tac i=nat in not_ctran_None,simp) |
|
406 |
apply(erule etran.elims,simp) |
|
407 |
done |
|
408 |
||
409 |
lemma exists_ctran_Await_None [rule_format]: |
|
410 |
"\<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)" |
|
412 |
apply(induct x,simp+) |
|
413 |
apply clarify |
|
414 |
apply(erule cptn.elims,simp) |
|
415 |
apply(case_tac i,simp+) |
|
416 |
apply(erule_tac x=nat in allE,simp) |
|
417 |
apply clarify |
|
418 |
apply(rule_tac x="Suc j" in exI,simp,simp) |
|
419 |
apply clarify |
|
420 |
apply(case_tac i,simp,simp) |
|
421 |
apply(rule_tac x=0 in exI,simp) |
|
422 |
done |
|
423 |
||
424 |
lemma Star_imp_cptn: |
|
425 |
"(P, s) -c*\<rightarrow> (R, t) \<Longrightarrow> \<exists>l \<in> cp P s. (last l)=(R, t) |
|
426 |
\<and> (\<forall>i. Suc i<length l \<longrightarrow> l!i -c\<rightarrow> l!Suc i)" |
|
427 |
apply (erule converse_rtrancl_induct2) |
|
428 |
apply(rule_tac x="[(R,t)]" in bexI) |
|
429 |
apply simp |
|
430 |
apply(simp add:cp_def) |
|
431 |
apply(rule CptnOne) |
|
432 |
apply clarify |
|
433 |
apply(rule_tac x="(a, b)#l" in bexI) |
|
434 |
apply (rule conjI) |
|
435 |
apply(case_tac l,simp add:cp_def) |
|
436 |
apply(simp add:last_length) |
|
437 |
apply clarify |
|
438 |
apply(case_tac i,simp) |
|
439 |
apply(simp add:cp_def) |
|
440 |
apply force |
|
441 |
apply(simp add:cp_def) |
|
442 |
apply(case_tac l) |
|
443 |
apply(force elim:cptn.elims) |
|
444 |
apply simp |
|
445 |
apply(erule CptnComp) |
|
446 |
apply clarify |
|
447 |
done |
|
448 |
||
449 |
lemma Await_sound: |
|
450 |
"\<lbrakk>stable pre rely; stable post rely; |
|
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
|
451 |
\<forall>V. \<turnstile> P sat [pre \<inter> b \<inter> {s. s = V}, {(s, t). s = t}, |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
452 |
UNIV, {s. (V, s) \<in> guar} \<inter> post] \<and> |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
453 |
\<Turnstile> P sat [pre \<inter> b \<inter> {s. s = V}, {(s, t). s = t}, |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
454 |
UNIV, {s. (V, s) \<in> guar} \<inter> post] \<rbrakk> |
13020 | 455 |
\<Longrightarrow> \<Turnstile> Await b P sat [pre, rely, guar, post]" |
456 |
apply(unfold com_validity_def) |
|
457 |
apply clarify |
|
458 |
apply(simp add:comm_def) |
|
459 |
apply(rule conjI) |
|
460 |
apply clarify |
|
461 |
apply(simp add:cp_def assum_def) |
|
462 |
apply clarify |
|
463 |
apply(frule_tac j=0 and k=i and p=pre in stability,simp_all) |
|
464 |
apply(erule_tac x=ia in allE,simp) |
|
465 |
apply(subgoal_tac "x\<in> cp (Some(Await b P)) s") |
|
466 |
apply(erule_tac i=i in unique_ctran_Await,force,simp_all) |
|
467 |
apply(simp add:cp_def) |
|
468 |
--{* here starts the different part. *} |
|
469 |
apply(erule ctran.elims,simp_all) |
|
470 |
apply(drule Star_imp_cptn) |
|
471 |
apply clarify |
|
472 |
apply(erule_tac x=sa in allE) |
|
473 |
apply clarify |
|
474 |
apply(erule_tac x=sa in allE) |
|
475 |
apply(drule_tac c=l in subsetD) |
|
476 |
apply (simp add:cp_def) |
|
477 |
apply clarify |
|
478 |
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) |
|
480 |
apply simp |
|
481 |
apply clarify |
|
482 |
apply(simp add:cp_def) |
|
483 |
apply clarify |
|
484 |
apply(frule_tac i="length x - 1" in exists_ctran_Await_None,force) |
|
485 |
apply (case_tac x,simp+) |
|
486 |
apply(rule last_fst_esp,simp add:last_length) |
|
487 |
apply(case_tac x, (simp add:cptn_not_empty)+) |
|
488 |
apply clarify |
|
489 |
apply(simp add:assum_def) |
|
490 |
apply clarify |
|
491 |
apply(frule_tac j=0 and k="j" and p=pre in stability,simp_all) |
|
492 |
apply(erule_tac x=i in allE,simp) |
|
493 |
apply(erule_tac i=j in unique_ctran_Await,force,simp_all) |
|
494 |
apply(case_tac "x!j") |
|
495 |
apply clarify |
|
496 |
apply simp |
|
497 |
apply(drule_tac s="Some (Await b P)" in sym,simp) |
|
498 |
apply(case_tac "x!Suc j",simp) |
|
499 |
apply(rule ctran.elims,simp) |
|
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
500 |
apply(simp_all) |
13020 | 501 |
apply(drule Star_imp_cptn) |
502 |
apply clarify |
|
503 |
apply(erule_tac x=sa in allE) |
|
504 |
apply clarify |
|
505 |
apply(erule_tac x=sa in allE) |
|
506 |
apply(drule_tac c=l in subsetD) |
|
507 |
apply (simp add:cp_def) |
|
508 |
apply clarify |
|
509 |
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) |
|
511 |
apply simp |
|
512 |
apply clarify |
|
513 |
apply(frule_tac j="Suc j" and k="length x - 1" and p=post in stability,simp_all) |
|
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
514 |
apply(case_tac x,simp+) |
13020 | 515 |
apply(erule_tac x=i in allE) |
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
516 |
apply(erule_tac i=j in unique_ctran_Await,force,simp_all) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
517 |
apply arith+ |
13020 | 518 |
apply(case_tac x) |
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
519 |
apply(simp add:last_length)+ |
13020 | 520 |
done |
521 |
||
522 |
subsubsection{* Soundness of the Conditional rule *} |
|
523 |
||
524 |
lemma Cond_sound: |
|
525 |
"\<lbrakk> stable pre rely; \<Turnstile> P1 sat [pre \<inter> b, rely, guar, post]; |
|
526 |
\<Turnstile> P2 sat [pre \<inter> - b, rely, guar, post]; \<forall>s. (s,s)\<in>guar\<rbrakk> |
|
527 |
\<Longrightarrow> \<Turnstile> (Cond b P1 P2) sat [pre, rely, guar, post]" |
|
528 |
apply(unfold com_validity_def) |
|
529 |
apply clarify |
|
530 |
apply(simp add:cp_def comm_def) |
|
531 |
apply(case_tac "\<exists>i. Suc i<length x \<and> x!i -c\<rightarrow> x!Suc i") |
|
532 |
prefer 2 |
|
533 |
apply simp |
|
534 |
apply clarify |
|
535 |
apply(frule_tac j="0" and k="length x - 1" and p=pre in stability,simp+) |
|
536 |
apply(case_tac x,simp+) |
|
537 |
apply(simp add:assum_def) |
|
538 |
apply(simp add:assum_def) |
|
539 |
apply(erule_tac m="length x" in etran_or_ctran,simp+) |
|
540 |
apply(case_tac x, (simp add:last_length)+) |
|
541 |
apply(erule exE) |
|
542 |
apply(drule_tac n=i and P="\<lambda>i. ?H i \<and> (?J i,?I i)\<in> ctran" in Ex_first_occurrence) |
|
543 |
apply clarify |
|
544 |
apply (simp add:assum_def) |
|
545 |
apply(frule_tac j=0 and k="m" and p=pre in stability,simp+) |
|
546 |
apply(erule_tac m="Suc m" in etran_or_ctran,simp+) |
|
547 |
apply(erule ctran.elims,simp_all) |
|
548 |
apply(erule_tac x="sa" in allE) |
|
549 |
apply(drule_tac c="drop (Suc m) x" in subsetD) |
|
550 |
apply simp |
|
551 |
apply clarify |
|
552 |
apply simp |
|
17528
2a602a8462d5
fixed proof script of lemma Cond_sound (Why did it stop working anyway?);
wenzelm
parents:
16417
diff
changeset
|
553 |
apply clarify |
2a602a8462d5
fixed proof script of lemma Cond_sound (Why did it stop working anyway?);
wenzelm
parents:
16417
diff
changeset
|
554 |
apply(case_tac "i\<le>m") |
2a602a8462d5
fixed proof script of lemma Cond_sound (Why did it stop working anyway?);
wenzelm
parents:
16417
diff
changeset
|
555 |
apply(drule le_imp_less_or_eq) |
2a602a8462d5
fixed proof script of lemma Cond_sound (Why did it stop working anyway?);
wenzelm
parents:
16417
diff
changeset
|
556 |
apply(erule disjE) |
2a602a8462d5
fixed proof script of lemma Cond_sound (Why did it stop working anyway?);
wenzelm
parents:
16417
diff
changeset
|
557 |
apply(erule_tac x=i in allE, erule impE, assumption) |
2a602a8462d5
fixed proof script of lemma Cond_sound (Why did it stop working anyway?);
wenzelm
parents:
16417
diff
changeset
|
558 |
apply simp+ |
2a602a8462d5
fixed proof script of lemma Cond_sound (Why did it stop working anyway?);
wenzelm
parents:
16417
diff
changeset
|
559 |
apply(erule_tac x="i - (Suc m)" and P="\<lambda>j. ?H j \<longrightarrow> ?J j \<longrightarrow> (?I j)\<in>guar" in allE) |
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
560 |
apply(subgoal_tac "(Suc m)+(i - Suc m) \<le> length x") |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
561 |
apply(subgoal_tac "(Suc m)+Suc (i - Suc m) \<le> length x") |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
562 |
apply(rotate_tac -2) |
13020 | 563 |
apply simp |
564 |
apply arith |
|
565 |
apply arith |
|
20432
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
566 |
apply(case_tac "length (drop (Suc m) x)",simp) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
567 |
apply(erule_tac x="sa" in allE) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
568 |
back |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
569 |
apply(drule_tac c="drop (Suc m) x" in subsetD,simp) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
570 |
apply clarify |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
571 |
apply simp |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
572 |
apply clarify |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
573 |
apply(case_tac "i\<le>m") |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
574 |
apply(drule le_imp_less_or_eq) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
575 |
apply(erule disjE) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
576 |
apply(erule_tac x=i in allE, erule impE, assumption) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
577 |
apply simp |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
578 |
apply simp |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
579 |
apply(erule_tac x="i - (Suc m)" and P="\<lambda>j. ?H j \<longrightarrow> ?J j \<longrightarrow> (?I j)\<in>guar" in allE) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
580 |
apply(subgoal_tac "(Suc m)+(i - Suc m) \<le> length x") |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
581 |
apply(subgoal_tac "(Suc m)+Suc (i - Suc m) \<le> length x") |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
582 |
apply(rotate_tac -2) |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
583 |
apply simp |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
584 |
apply arith |
07ec57376051
lin_arith_prover: splitting reverted because of performance loss
webertj
parents:
20272
diff
changeset
|
585 |
apply arith |
20217
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents:
18576
diff
changeset
|
586 |
done |
13020 | 587 |
|
588 |
subsubsection{* Soundness of the Sequential rule *} |
|
589 |
||
590 |
inductive_cases Seq_cases [elim!]: "(Some (Seq P Q), s) -c\<rightarrow> t" |
|
591 |
||
592 |
lemma last_lift_not_None: "fst ((lift Q) ((x#xs)!(length xs))) \<noteq> None" |
|
593 |
apply(subgoal_tac "length xs<length (x # xs)") |
|
594 |
apply(drule_tac Q=Q in lift_nth) |
|
595 |
apply(erule ssubst) |
|
596 |
apply (simp add:lift_def) |
|
597 |
apply(case_tac "(x # xs) ! length xs",simp) |
|
598 |
apply simp |
|
599 |
done |
|
600 |
||
14025 | 601 |
declare map_eq_Cons_conv [simp del] Cons_eq_map_conv [simp del] |
13020 | 602 |
lemma Seq_sound1 [rule_format]: |
603 |
"x\<in> cptn_mod \<Longrightarrow> \<forall>s P. x !0=(Some (Seq P Q), s) \<longrightarrow> |
|
604 |
(\<forall>i<length x. fst(x!i)\<noteq>Some Q) \<longrightarrow> |
|
605 |
(\<exists>xs\<in> cp (Some P) s. x=map (lift Q) xs)" |
|
606 |
apply(erule cptn_mod.induct) |
|
607 |
apply(unfold cp_def) |
|
608 |
apply safe |
|
609 |
apply simp_all |
|
610 |
apply(simp add:lift_def) |
|
611 |
apply(rule_tac x="[(Some Pa, sa)]" in exI,simp add:CptnOne) |
|
612 |
apply(subgoal_tac "(\<forall>i < Suc (length xs). fst (((Some (Seq Pa Q), t) # xs) ! i) \<noteq> Some Q)") |
|
613 |
apply clarify |
|
14025 | 614 |
apply(rule_tac x="(Some Pa, sa) #(Some Pa, t) # zs" in exI,simp) |
13020 | 615 |
apply(rule conjI,erule CptnEnv) |
13601 | 616 |
apply(simp (no_asm_use) add:lift_def) |
13020 | 617 |
apply clarify |
618 |
apply(erule_tac x="Suc i" in allE, simp) |
|
619 |
apply(ind_cases "((Some (Seq Pa Q), sa), None, t) \<in> ctran") |
|
620 |
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) |
|
622 |
apply(simp only:Cons_lift_append) |
|
623 |
apply(subgoal_tac "length xs < length ((Some P, sa) # xs)") |
|
624 |
apply(simp only :nth_append length_map last_length nth_map) |
|
625 |
apply(case_tac "last((Some P, sa) # xs)") |
|
626 |
apply(simp add:lift_def) |
|
627 |
apply simp |
|
628 |
done |
|
14025 | 629 |
declare map_eq_Cons_conv [simp del] Cons_eq_map_conv [simp del] |
13020 | 630 |
|
631 |
lemma Seq_sound2 [rule_format]: |
|
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
|
632 |
"x \<in> cptn \<Longrightarrow> \<forall>s P i. x!0=(Some (Seq P Q), s) \<longrightarrow> i<length x |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
633 |
\<longrightarrow> fst(x!i)=Some Q \<longrightarrow> |
13020 | 634 |
(\<forall>j<i. fst(x!j)\<noteq>(Some Q)) \<longrightarrow> |
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
|
635 |
(\<exists>xs ys. xs \<in> cp (Some P) s \<and> length xs=Suc i |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
636 |
\<and> ys \<in> cp (Some Q) (snd(xs !i)) \<and> x=(map (lift Q) xs)@tl ys)" |
13020 | 637 |
apply(erule cptn.induct) |
638 |
apply(unfold cp_def) |
|
639 |
apply safe |
|
640 |
apply simp_all |
|
641 |
apply(case_tac i,simp+) |
|
642 |
apply(erule allE,erule impE,assumption,simp) |
|
643 |
apply clarify |
|
644 |
apply(subgoal_tac "(\<forall>j < nat. fst (((Some (Seq Pa Q), t) # xs) ! j) \<noteq> Some Q)",clarify) |
|
645 |
prefer 2 |
|
646 |
apply force |
|
647 |
apply(case_tac xsa,simp,simp) |
|
648 |
apply(rule_tac x="(Some Pa, sa) #(Some Pa, t) # list" in exI,simp) |
|
649 |
apply(rule conjI,erule CptnEnv) |
|
13601 | 650 |
apply(simp (no_asm_use) add:lift_def) |
13020 | 651 |
apply(rule_tac x=ys in exI,simp) |
652 |
apply(ind_cases "((Some (Seq Pa Q), sa), t) \<in> ctran") |
|
653 |
apply simp |
|
654 |
apply(rule_tac x="(Some Pa, sa)#[(None, ta)]" in exI,simp) |
|
655 |
apply(rule conjI) |
|
656 |
apply(drule_tac xs="[]" in CptnComp,force simp add:CptnOne,simp) |
|
657 |
apply(case_tac i, simp+) |
|
658 |
apply(case_tac nat,simp+) |
|
659 |
apply(rule_tac x="(Some Q,ta)#xs" in exI,simp add:lift_def) |
|
660 |
apply(case_tac nat,simp+) |
|
661 |
apply(force) |
|
662 |
apply(case_tac i, simp+) |
|
663 |
apply(case_tac nat,simp+) |
|
664 |
apply(erule_tac x="Suc nata" in allE,simp) |
|
665 |
apply clarify |
|
666 |
apply(subgoal_tac "(\<forall>j<Suc nata. fst (((Some (Seq P2 Q), ta) # xs) ! j) \<noteq> Some Q)",clarify) |
|
667 |
prefer 2 |
|
668 |
apply clarify |
|
669 |
apply force |
|
670 |
apply(rule_tac x="(Some Pa, sa)#(Some P2, ta)#(tl xsa)" in exI,simp) |
|
671 |
apply(rule conjI,erule CptnComp) |
|
672 |
apply(rule nth_tl_if,force,simp+) |
|
673 |
apply(rule_tac x=ys in exI,simp) |
|
674 |
apply(rule conjI) |
|
675 |
apply(rule nth_tl_if,force,simp+) |
|
676 |
apply(rule tl_zero,simp+) |
|
677 |
apply force |
|
678 |
apply(rule conjI,simp add:lift_def) |
|
679 |
apply(subgoal_tac "lift Q (Some P2, ta) =(Some (Seq P2 Q), ta)") |
|
680 |
apply(simp add:Cons_lift del:map.simps) |
|
681 |
apply(rule nth_tl_if) |
|
682 |
apply force |
|
683 |
apply simp+ |
|
684 |
apply(simp add:lift_def) |
|
685 |
done |
|
686 |
(* |
|
687 |
lemma last_lift_not_None3: "fst (last (map (lift Q) (x#xs))) \<noteq> None" |
|
688 |
apply(simp only:last_length [THEN sym]) |
|
689 |
apply(subgoal_tac "length xs<length (x # xs)") |
|
690 |
apply(drule_tac Q=Q in lift_nth) |
|
691 |
apply(erule ssubst) |
|
692 |
apply (simp add:lift_def) |
|
693 |
apply(case_tac "(x # xs) ! length xs",simp) |
|
694 |
apply simp |
|
695 |
done |
|
696 |
*) |
|
697 |
||
698 |
lemma last_lift_not_None2: "fst ((lift Q) (last (x#xs))) \<noteq> None" |
|
699 |
apply(simp only:last_length [THEN sym]) |
|
700 |
apply(subgoal_tac "length xs<length (x # xs)") |
|
701 |
apply(drule_tac Q=Q in lift_nth) |
|
702 |
apply(erule ssubst) |
|
703 |
apply (simp add:lift_def) |
|
704 |
apply(case_tac "(x # xs) ! length xs",simp) |
|
705 |
apply simp |
|
706 |
done |
|
707 |
||
708 |
lemma Seq_sound: |
|
709 |
"\<lbrakk>\<Turnstile> P sat [pre, rely, guar, mid]; \<Turnstile> Q sat [mid, rely, guar, post]\<rbrakk> |
|
710 |
\<Longrightarrow> \<Turnstile> Seq P Q sat [pre, rely, guar, post]" |
|
711 |
apply(unfold com_validity_def) |
|
712 |
apply clarify |
|
713 |
apply(case_tac "\<exists>i<length x. fst(x!i)=Some Q") |
|
714 |
prefer 2 |
|
715 |
apply (simp add:cp_def cptn_iff_cptn_mod) |
|
716 |
apply clarify |
|
717 |
apply(frule_tac Seq_sound1,force) |
|
718 |
apply force |
|
719 |
apply clarify |
|
720 |
apply(erule_tac x=s in allE,simp) |
|
721 |
apply(drule_tac c=xs in subsetD,simp add:cp_def cptn_iff_cptn_mod) |
|
722 |
apply(simp add:assum_def) |
|
723 |
apply clarify |
|
724 |
apply(erule_tac P="\<lambda>j. ?H j \<longrightarrow> ?J j \<longrightarrow> ?I j" in allE,erule impE, assumption) |
|
725 |
apply(simp add:snd_lift) |
|
726 |
apply(erule mp) |
|
727 |
apply(force elim:etran.elims intro:Env simp add:lift_def) |
|
728 |
apply(simp add:comm_def) |
|
729 |
apply(rule conjI) |
|
730 |
apply clarify |
|
731 |
apply(erule_tac P="\<lambda>j. ?H j \<longrightarrow> ?J j \<longrightarrow> ?I j" in allE,erule impE, assumption) |
|
732 |
apply(simp add:snd_lift) |
|
733 |
apply(erule mp) |
|
734 |
apply(case_tac "(xs!i)") |
|
735 |
apply(case_tac "(xs! Suc i)") |
|
736 |
apply(case_tac "fst(xs!i)") |
|
737 |
apply(erule_tac x=i in allE, simp add:lift_def) |
|
738 |
apply(case_tac "fst(xs!Suc i)") |
|
739 |
apply(force simp add:lift_def) |
|
740 |
apply(force simp add:lift_def) |
|
741 |
apply clarify |
|
742 |
apply(case_tac xs,simp add:cp_def) |
|
743 |
apply clarify |
|
744 |
apply (simp del:map.simps) |
|
745 |
apply(subgoal_tac "(map (lift Q) ((a, b) # list))\<noteq>[]") |
|
17588 | 746 |
apply(drule last_conv_nth) |
13020 | 747 |
apply (simp del:map.simps) |
748 |
apply(simp only:last_lift_not_None) |
|
749 |
apply simp |
|
750 |
--{* @{text "\<exists>i<length x. fst (x ! i) = Some Q"} *} |
|
751 |
apply(erule exE) |
|
752 |
apply(drule_tac n=i and P="\<lambda>i. i < length x \<and> fst (x ! i) = Some Q" in Ex_first_occurrence) |
|
753 |
apply clarify |
|
754 |
apply (simp add:cp_def) |
|
755 |
apply clarify |
|
756 |
apply(frule_tac i=m in Seq_sound2,force) |
|
757 |
apply simp+ |
|
758 |
apply clarify |
|
759 |
apply(simp add:comm_def) |
|
760 |
apply(erule_tac x=s in allE) |
|
761 |
apply(drule_tac c=xs in subsetD,simp) |
|
762 |
apply(case_tac "xs=[]",simp) |
|
763 |
apply(simp add:cp_def assum_def nth_append) |
|
764 |
apply clarify |
|
765 |
apply(erule_tac x=i in allE) |
|
766 |
back |
|
767 |
apply(simp add:snd_lift) |
|
768 |
apply(erule mp) |
|
769 |
apply(force elim:etran.elims intro:Env simp add:lift_def) |
|
770 |
apply simp |
|
771 |
apply clarify |
|
772 |
apply(erule_tac x="snd(xs!m)" in allE) |
|
773 |
apply(drule_tac c=ys in subsetD,simp add:cp_def assum_def) |
|
774 |
apply(case_tac "xs\<noteq>[]") |
|
17588 | 775 |
apply(drule last_conv_nth,simp) |
13020 | 776 |
apply(rule conjI) |
777 |
apply(erule mp) |
|
778 |
apply(case_tac "xs!m") |
|
779 |
apply(case_tac "fst(xs!m)",simp) |
|
780 |
apply(simp add:lift_def nth_append) |
|
781 |
apply clarify |
|
782 |
apply(erule_tac x="m+i" in allE) |
|
783 |
back |
|
784 |
back |
|
785 |
apply(case_tac ys,(simp add:nth_append)+) |
|
786 |
apply (case_tac i, (simp add:snd_lift)+) |
|
787 |
apply(erule mp) |
|
788 |
apply(case_tac "xs!m") |
|
789 |
apply(force elim:etran.elims intro:Env simp add:lift_def) |
|
790 |
apply simp |
|
791 |
apply simp |
|
792 |
apply clarify |
|
793 |
apply(rule conjI,clarify) |
|
794 |
apply(case_tac "i<m",simp add:nth_append) |
|
795 |
apply(simp add:snd_lift) |
|
796 |
apply(erule allE, erule impE, assumption, erule mp) |
|
797 |
apply(case_tac "(xs ! i)") |
|
798 |
apply(case_tac "(xs ! Suc i)") |
|
799 |
apply(case_tac "fst(xs ! i)",force simp add:lift_def) |
|
800 |
apply(case_tac "fst(xs ! Suc i)") |
|
801 |
apply (force simp add:lift_def) |
|
802 |
apply (force simp add:lift_def) |
|
803 |
apply(erule_tac x="i-m" in allE) |
|
804 |
back |
|
805 |
back |
|
806 |
apply(subgoal_tac "Suc (i - m) < length ys",simp) |
|
807 |
prefer 2 |
|
808 |
apply arith |
|
809 |
apply(simp add:nth_append snd_lift) |
|
810 |
apply(rule conjI,clarify) |
|
811 |
apply(subgoal_tac "i=m") |
|
812 |
prefer 2 |
|
813 |
apply arith |
|
814 |
apply clarify |
|
815 |
apply(simp add:cp_def) |
|
816 |
apply(rule tl_zero) |
|
817 |
apply(erule mp) |
|
818 |
apply(case_tac "lift Q (xs!m)",simp add:snd_lift) |
|
819 |
apply(case_tac "xs!m",case_tac "fst(xs!m)",simp add:lift_def snd_lift) |
|
820 |
apply(case_tac ys,simp+) |
|
821 |
apply(simp add:lift_def) |
|
822 |
apply simp |
|
823 |
apply force |
|
824 |
apply clarify |
|
825 |
apply(rule tl_zero) |
|
826 |
apply(rule tl_zero) |
|
827 |
apply (subgoal_tac "i-m=Suc(i-Suc m)") |
|
828 |
apply simp |
|
829 |
apply(erule mp) |
|
830 |
apply(case_tac ys,simp+) |
|
831 |
apply force |
|
832 |
apply arith |
|
833 |
apply force |
|
834 |
apply clarify |
|
835 |
apply(case_tac "(map (lift Q) xs @ tl ys)\<noteq>[]") |
|
17588 | 836 |
apply(drule last_conv_nth) |
13020 | 837 |
apply(simp add: snd_lift nth_append) |
838 |
apply(rule conjI,clarify) |
|
839 |
apply(case_tac ys,simp+) |
|
840 |
apply clarify |
|
841 |
apply(case_tac ys,simp+) |
|
842 |
done |
|
843 |
||
844 |
subsubsection{* Soundness of the While rule *} |
|
845 |
||
846 |
lemma last_append[rule_format]: |
|
847 |
"\<forall>xs. ys\<noteq>[] \<longrightarrow> ((xs@ys)!(length (xs@ys) - (Suc 0)))=(ys!(length ys - (Suc 0)))" |
|
848 |
apply(induct ys) |
|
849 |
apply simp |
|
850 |
apply clarify |
|
851 |
apply (simp add:nth_append length_append) |
|
852 |
done |
|
853 |
||
854 |
lemma assum_after_body: |
|
855 |
"\<lbrakk> \<Turnstile> P sat [pre \<inter> b, rely, guar, pre]; |
|
856 |
(Some P, s) # xs \<in> cptn_mod; fst (last ((Some P, s) # xs)) = None; s \<in> b; |
|
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
|
857 |
(Some (While b P), s) # (Some (Seq P (While b P)), s) # |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
858 |
map (lift (While b P)) xs @ ys \<in> assum (pre, rely)\<rbrakk> |
13020 | 859 |
\<Longrightarrow> (Some (While b P), snd (last ((Some P, s) # xs))) # ys \<in> assum (pre, rely)" |
860 |
apply(simp add:assum_def com_validity_def cp_def cptn_iff_cptn_mod) |
|
861 |
apply clarify |
|
862 |
apply(erule_tac x=s in allE) |
|
863 |
apply(drule_tac c="(Some P, s) # xs" in subsetD,simp) |
|
864 |
apply clarify |
|
865 |
apply(erule_tac x="Suc i" in allE) |
|
866 |
apply simp |
|
867 |
apply(simp add:Cons_lift_append nth_append snd_lift del:map.simps) |
|
868 |
apply(erule mp) |
|
869 |
apply(erule etran.elims,simp) |
|
870 |
apply(case_tac "fst(((Some P, s) # xs) ! i)") |
|
871 |
apply(force intro:Env simp add:lift_def) |
|
872 |
apply(force intro:Env simp add:lift_def) |
|
873 |
apply(rule conjI) |
|
874 |
apply clarify |
|
875 |
apply(simp add:comm_def last_length) |
|
876 |
apply clarify |
|
877 |
apply(rule conjI) |
|
878 |
apply(simp add:comm_def) |
|
879 |
apply clarify |
|
880 |
apply(erule_tac x="Suc(length xs + i)" in allE,simp) |
|
881 |
apply(case_tac i, simp add:nth_append Cons_lift_append snd_lift del:map.simps) |
|
882 |
apply(simp add:last_length) |
|
883 |
apply(erule mp) |
|
884 |
apply(case_tac "last xs") |
|
885 |
apply(simp add:lift_def) |
|
886 |
apply(simp add:Cons_lift_append nth_append snd_lift del:map.simps) |
|
887 |
done |
|
888 |
||
889 |
lemma While_sound_aux [rule_format]: |
|
890 |
"\<lbrakk> pre \<inter> - b \<subseteq> post; \<Turnstile> P sat [pre \<inter> b, rely, guar, pre]; \<forall>s. (s, s) \<in> guar; |
|
891 |
stable pre rely; stable post rely; x \<in> cptn_mod \<rbrakk> |
|
892 |
\<Longrightarrow> \<forall>s xs. x=(Some(While b P),s)#xs \<longrightarrow> x\<in>assum(pre, rely) \<longrightarrow> x \<in> comm (guar, post)" |
|
893 |
apply(erule cptn_mod.induct) |
|
894 |
apply safe |
|
895 |
apply (simp_all del:last.simps) |
|
896 |
--{* 5 subgoals left *} |
|
897 |
apply(simp add:comm_def) |
|
898 |
--{* 4 subgoals left *} |
|
899 |
apply(rule etran_in_comm) |
|
900 |
apply(erule mp) |
|
901 |
apply(erule tl_of_assum_in_assum,simp) |
|
902 |
--{* While-None *} |
|
903 |
apply(ind_cases "((Some (While b P), s), None, t) \<in> ctran") |
|
904 |
apply(simp add:comm_def) |
|
905 |
apply(simp add:cptn_iff_cptn_mod [THEN sym]) |
|
906 |
apply(rule conjI,clarify) |
|
907 |
apply(force simp add:assum_def) |
|
908 |
apply clarify |
|
909 |
apply(rule conjI, clarify) |
|
910 |
apply(case_tac i,simp,simp) |
|
911 |
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") |
|
913 |
prefer 2 |
|
914 |
apply clarify |
|
915 |
apply(rule_tac m="length ((None, s) # xs)" in etran_or_ctran,simp+) |
|
916 |
apply(erule not_ctran_None2,simp) |
|
917 |
apply simp+ |
|
918 |
apply(frule_tac j="0" and k="length ((None, s) # xs) - 1" and p=post in stability,simp+) |
|
919 |
apply(force simp add:assum_def subsetD) |
|
920 |
apply(simp add:assum_def) |
|
921 |
apply clarify |
|
922 |
apply(erule_tac x="i" in allE,simp) |
|
923 |
apply(erule_tac x="Suc i" in allE,simp) |
|
924 |
apply simp |
|
925 |
apply clarify |
|
926 |
apply (simp add:last_length) |
|
927 |
--{* WhileOne *} |
|
928 |
apply(thin_tac "P = While b P \<longrightarrow> ?Q") |
|
929 |
apply(rule ctran_in_comm,simp) |
|
930 |
apply(simp add:Cons_lift del:map.simps) |
|
931 |
apply(simp add:comm_def del:map.simps) |
|
932 |
apply(rule conjI) |
|
933 |
apply clarify |
|
934 |
apply(case_tac "fst(((Some P, sa) # xs) ! i)") |
|
935 |
apply(case_tac "((Some P, sa) # xs) ! i") |
|
936 |
apply (simp add:lift_def) |
|
937 |
apply(ind_cases "(Some (While b P), ba) -c\<rightarrow> t") |
|
938 |
apply simp |
|
939 |
apply simp |
|
940 |
apply(simp add:snd_lift del:map.simps) |
|
941 |
apply(simp only:com_validity_def cp_def cptn_iff_cptn_mod) |
|
942 |
apply(erule_tac x=sa in allE) |
|
943 |
apply(drule_tac c="(Some P, sa) # xs" in subsetD) |
|
944 |
apply (simp add:assum_def del:map.simps) |
|
945 |
apply clarify |
|
946 |
apply(erule_tac x="Suc ia" in allE,simp add:snd_lift del:map.simps) |
|
947 |
apply(erule mp) |
|
948 |
apply(case_tac "fst(((Some P, sa) # xs) ! ia)") |
|
949 |
apply(erule etran.elims,simp add:lift_def) |
|
950 |
apply(rule Env) |
|
951 |
apply(erule etran.elims,simp add:lift_def) |
|
952 |
apply(rule Env) |
|
953 |
apply (simp add:comm_def del:map.simps) |
|
954 |
apply clarify |
|
955 |
apply(erule allE,erule impE,assumption) |
|
956 |
apply(erule mp) |
|
957 |
apply(case_tac "((Some P, sa) # xs) ! i") |
|
958 |
apply(case_tac "xs!i") |
|
959 |
apply(simp add:lift_def) |
|
960 |
apply(case_tac "fst(xs!i)") |
|
961 |
apply force |
|
962 |
apply force |
|
963 |
--{* last=None *} |
|
964 |
apply clarify |
|
965 |
apply(subgoal_tac "(map (lift (While b P)) ((Some P, sa) # xs))\<noteq>[]") |
|
17588 | 966 |
apply(drule last_conv_nth) |
13020 | 967 |
apply (simp del:map.simps) |
968 |
apply(simp only:last_lift_not_None) |
|
969 |
apply simp |
|
970 |
--{* WhileMore *} |
|
971 |
apply(thin_tac "P = While b P \<longrightarrow> ?Q") |
|
972 |
apply(rule ctran_in_comm,simp del:last.simps) |
|
973 |
--{* metiendo la hipotesis antes de dividir la conclusion. *} |
|
974 |
apply(subgoal_tac "(Some (While b P), snd (last ((Some P, sa) # xs))) # ys \<in> assum (pre, rely)") |
|
975 |
apply (simp del:last.simps) |
|
976 |
prefer 2 |
|
977 |
apply(erule assum_after_body) |
|
978 |
apply (simp del:last.simps)+ |
|
979 |
--{* lo de antes. *} |
|
980 |
apply(simp add:comm_def del:map.simps last.simps) |
|
981 |
apply(rule conjI) |
|
982 |
apply clarify |
|
983 |
apply(simp only:Cons_lift_append) |
|
984 |
apply(case_tac "i<length xs") |
|
985 |
apply(simp add:nth_append del:map.simps last.simps) |
|
986 |
apply(case_tac "fst(((Some P, sa) # xs) ! i)") |
|
987 |
apply(case_tac "((Some P, sa) # xs) ! i") |
|
988 |
apply (simp add:lift_def del:last.simps) |
|
989 |
apply(ind_cases "(Some (While b P), ba) -c\<rightarrow> t") |
|
990 |
apply simp |
|
991 |
apply simp |
|
992 |
apply(simp add:snd_lift del:map.simps last.simps) |
|
993 |
apply(thin_tac " \<forall>i. i < length ys \<longrightarrow> ?P i") |
|
994 |
apply(simp only:com_validity_def cp_def cptn_iff_cptn_mod) |
|
995 |
apply(erule_tac x=sa in allE) |
|
996 |
apply(drule_tac c="(Some P, sa) # xs" in subsetD) |
|
997 |
apply (simp add:assum_def del:map.simps last.simps) |
|
998 |
apply clarify |
|
999 |
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)") |
|
1001 |
apply(erule etran.elims,simp add:lift_def) |
|
1002 |
apply(rule Env) |
|
1003 |
apply(erule etran.elims,simp add:lift_def) |
|
1004 |
apply(rule Env) |
|
1005 |
apply (simp add:comm_def del:map.simps) |
|
1006 |
apply clarify |
|
1007 |
apply(erule allE,erule impE,assumption) |
|
1008 |
apply(erule mp) |
|
1009 |
apply(case_tac "((Some P, sa) # xs) ! i") |
|
1010 |
apply(case_tac "xs!i") |
|
1011 |
apply(simp add:lift_def) |
|
1012 |
apply(case_tac "fst(xs!i)") |
|
1013 |
apply force |
|
1014 |
apply force |
|
1015 |
--{* @{text "i \<ge> length xs"} *} |
|
1016 |
apply(subgoal_tac "i-length xs <length ys") |
|
1017 |
prefer 2 |
|
1018 |
apply arith |
|
1019 |
apply(erule_tac x="i-length xs" in allE,clarify) |
|
1020 |
apply(case_tac "i=length xs") |
|
1021 |
apply (simp add:nth_append snd_lift del:map.simps last.simps) |
|
1022 |
apply(simp add:last_length del:last.simps) |
|
1023 |
apply(erule mp) |
|
1024 |
apply(case_tac "last((Some P, sa) # xs)") |
|
1025 |
apply(simp add:lift_def del:last.simps) |
|
1026 |
--{* @{text "i>length xs"} *} |
|
1027 |
apply(case_tac "i-length xs") |
|
1028 |
apply arith |
|
1029 |
apply(simp add:nth_append del:map.simps last.simps) |
|
13187 | 1030 |
apply(rotate_tac -3) |
13020 | 1031 |
apply(subgoal_tac "i- Suc (length xs)=nat") |
1032 |
prefer 2 |
|
1033 |
apply arith |
|
1034 |
apply simp |
|
1035 |
--{* last=None *} |
|
1036 |
apply clarify |
|
1037 |
apply(case_tac ys) |
|
1038 |
apply(simp add:Cons_lift del:map.simps last.simps) |
|
1039 |
apply(subgoal_tac "(map (lift (While b P)) ((Some P, sa) # xs))\<noteq>[]") |
|
17588 | 1040 |
apply(drule last_conv_nth) |
13020 | 1041 |
apply (simp del:map.simps) |
1042 |
apply(simp only:last_lift_not_None) |
|
1043 |
apply simp |
|
1044 |
apply(subgoal_tac "((Some (Seq P (While b P)), sa) # map (lift (While b P)) xs @ ys)\<noteq>[]") |
|
17588 | 1045 |
apply(drule last_conv_nth) |
13020 | 1046 |
apply (simp del:map.simps last.simps) |
1047 |
apply(simp add:nth_append del:last.simps) |
|
1048 |
apply(subgoal_tac "((Some (While b P), snd (last ((Some P, sa) # xs))) # a # list)\<noteq>[]") |
|
17588 | 1049 |
apply(drule last_conv_nth) |
13020 | 1050 |
apply (simp del:map.simps last.simps) |
1051 |
apply simp |
|
1052 |
apply simp |
|
1053 |
done |
|
1054 |
||
1055 |
lemma While_sound: |
|
1056 |
"\<lbrakk>stable pre rely; pre \<inter> - b \<subseteq> post; stable post rely; |
|
1057 |
\<Turnstile> P sat [pre \<inter> b, rely, guar, pre]; \<forall>s. (s,s)\<in>guar\<rbrakk> |
|
1058 |
\<Longrightarrow> \<Turnstile> While b P sat [pre, rely, guar, post]" |
|
1059 |
apply(unfold com_validity_def) |
|
1060 |
apply clarify |
|
1061 |
apply(erule_tac xs="tl x" in While_sound_aux) |
|
1062 |
apply(simp add:com_validity_def) |
|
1063 |
apply force |
|
1064 |
apply simp_all |
|
1065 |
apply(simp add:cptn_iff_cptn_mod cp_def) |
|
1066 |
apply(simp add:cp_def) |
|
1067 |
apply clarify |
|
1068 |
apply(rule nth_equalityI) |
|
1069 |
apply simp_all |
|
1070 |
apply(case_tac x,simp+) |
|
1071 |
apply clarify |
|
1072 |
apply(case_tac i,simp+) |
|
1073 |
apply(case_tac x,simp+) |
|
1074 |
done |
|
1075 |
||
1076 |
subsubsection{* Soundness of the Rule of Consequence *} |
|
1077 |
||
1078 |
lemma Conseq_sound: |
|
1079 |
"\<lbrakk>pre \<subseteq> pre'; rely \<subseteq> rely'; guar' \<subseteq> guar; post' \<subseteq> post; |
|
1080 |
\<Turnstile> P sat [pre', rely', guar', post']\<rbrakk> |
|
1081 |
\<Longrightarrow> \<Turnstile> P sat [pre, rely, guar, post]" |
|
1082 |
apply(simp add:com_validity_def assum_def comm_def) |
|
1083 |
apply clarify |
|
1084 |
apply(erule_tac x=s in allE) |
|
1085 |
apply(drule_tac c=x in subsetD) |
|
1086 |
apply force |
|
1087 |
apply force |
|
1088 |
done |
|
1089 |
||
1090 |
subsubsection {* Soundness of the system for sequential component programs *} |
|
1091 |
||
1092 |
theorem rgsound: |
|
1093 |
"\<turnstile> P sat [pre, rely, guar, post] \<Longrightarrow> \<Turnstile> P sat [pre, rely, guar, post]" |
|
1094 |
apply(erule rghoare.induct) |
|
1095 |
apply(force elim:Basic_sound) |
|
1096 |
apply(force elim:Seq_sound) |
|
1097 |
apply(force elim:Cond_sound) |
|
1098 |
apply(force elim:While_sound) |
|
1099 |
apply(force elim:Await_sound) |
|
1100 |
apply(erule Conseq_sound,simp+) |
|
1101 |
done |
|
1102 |
||
1103 |
subsection {* Soundness of the System for Parallel Programs *} |
|
1104 |
||
1105 |
constdefs |
|
1106 |
ParallelCom :: "('a rgformula) list \<Rightarrow> 'a par_com" |
|
1107 |
"ParallelCom Ps \<equiv> map (Some \<circ> fst) Ps" |
|
1108 |
||
1109 |
lemma two: |
|
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
|
1110 |
"\<lbrakk> \<forall>i<length xs. rely \<union> (\<Union>j\<in>{j. j < length xs \<and> j \<noteq> i}. Guar (xs ! j)) |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1111 |
\<subseteq> Rely (xs ! i); |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1112 |
pre \<subseteq> (\<Inter>i\<in>{i. i < length xs}. Pre (xs ! i)); |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1113 |
\<forall>i<length xs. |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1114 |
\<Turnstile> Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1115 |
length xs=length clist; x \<in> par_cp (ParallelCom xs) s; x\<in>par_assum(pre, rely); |
13020 | 1116 |
\<forall>i<length clist. clist!i\<in>cp (Some(Com(xs!i))) s; x \<propto> clist \<rbrakk> |
1117 |
\<Longrightarrow> \<forall>j i. i<length clist \<and> Suc j<length x \<longrightarrow> (clist!i!j) -c\<rightarrow> (clist!i!Suc j) |
|
1118 |
\<longrightarrow> (snd(clist!i!j), snd(clist!i!Suc j)) \<in> Guar(xs!i)" |
|
1119 |
apply(unfold par_cp_def) |
|
15102 | 1120 |
apply (rule ccontr) |
13020 | 1121 |
--{* By contradiction: *} |
15102 | 1122 |
apply (simp del: Un_subset_iff) |
13020 | 1123 |
apply(erule exE) |
1124 |
--{* the first c-tran that does not satisfy the guarantee-condition is from @{text "\<sigma>_i"} at step @{text "m"}. *} |
|
1125 |
apply(drule_tac n=j and P="\<lambda>j. \<exists>i. ?H i j" in Ex_first_occurrence) |
|
1126 |
apply(erule exE) |
|
1127 |
apply clarify |
|
1128 |
--{* @{text "\<sigma>_i \<in> A(pre, rely_1)"} *} |
|
1129 |
apply(subgoal_tac "take (Suc (Suc m)) (clist!i) \<in> assum(Pre(xs!i), Rely(xs!i))") |
|
1130 |
--{* but this contradicts @{text "\<Turnstile> \<sigma>_i sat [pre_i,rely_i,guar_i,post_i]"} *} |
|
1131 |
apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> \<Turnstile> (?J i) sat [?I i,?K i,?M i,?N i]" in allE,erule impE,assumption) |
|
1132 |
apply(simp add:com_validity_def) |
|
1133 |
apply(erule_tac x=s in allE) |
|
1134 |
apply(simp add:cp_def comm_def) |
|
1135 |
apply(drule_tac c="take (Suc (Suc m)) (clist ! i)" in subsetD) |
|
1136 |
apply simp |
|
15102 | 1137 |
apply (blast intro: takecptn_is_cptn) |
13020 | 1138 |
apply simp |
1139 |
apply clarify |
|
1140 |
apply(erule_tac x=m and P="\<lambda>j. ?I j \<and> ?J j \<longrightarrow> ?H j" in allE) |
|
1141 |
apply (simp add:conjoin_def same_length_def) |
|
15102 | 1142 |
apply(simp add:assum_def del: Un_subset_iff) |
13020 | 1143 |
apply(rule conjI) |
1144 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> ?I j \<in>cp (?K j) (?J j)" in allE) |
|
1145 |
apply(simp add:cp_def par_assum_def) |
|
1146 |
apply(drule_tac c="s" in subsetD,simp) |
|
1147 |
apply simp |
|
1148 |
apply clarify |
|
1149 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> ?M \<union> UNION (?S j) (?T j) \<subseteq> (?L j)" in allE) |
|
15102 | 1150 |
apply(simp del: Un_subset_iff) |
13020 | 1151 |
apply(erule subsetD) |
1152 |
apply simp |
|
1153 |
apply(simp add:conjoin_def compat_label_def) |
|
1154 |
apply clarify |
|
1155 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (?P j) \<or> ?Q j" in allE,simp) |
|
1156 |
--{* each etran in @{text "\<sigma>_1[0\<dots>m]"} corresponds to *} |
|
1157 |
apply(erule disjE) |
|
1158 |
--{* a c-tran in some @{text "\<sigma>_{ib}"} *} |
|
1159 |
apply clarify |
|
1160 |
apply(case_tac "i=ib",simp) |
|
1161 |
apply(erule etran.elims,simp) |
|
13601 | 1162 |
apply(erule_tac x="ib" and P="\<lambda>i. ?H i \<longrightarrow> (?I i) \<or> (?J i)" in allE) |
1163 |
apply (erule etran.elims) |
|
13020 | 1164 |
apply(case_tac "ia=m",simp) |
13601 | 1165 |
apply simp |
13020 | 1166 |
apply(erule_tac x=ia and P="\<lambda>j. ?H j \<longrightarrow> (\<forall> i. ?P i j)" in allE) |
1167 |
apply(subgoal_tac "ia<m",simp) |
|
1168 |
prefer 2 |
|
1169 |
apply arith |
|
1170 |
apply(erule_tac x=ib and P="\<lambda>j. (?I j, ?H j)\<in> ctran \<longrightarrow> (?P i j)" in allE,simp) |
|
1171 |
apply(simp add:same_state_def) |
|
13601 | 1172 |
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) |
13020 | 1173 |
apply(erule_tac x=ib and P="\<lambda>j. (?T j) \<longrightarrow> (\<forall>i. (?H j i) \<longrightarrow> (snd (?d j i))=(snd (?e j i)))" in allE,simp) |
1174 |
--{* or an e-tran in @{text "\<sigma>"}, |
|
1175 |
therefore it satisfies @{text "rely \<or> guar_{ib}"} *} |
|
1176 |
apply (force simp add:par_assum_def same_state_def) |
|
1177 |
done |
|
1178 |
||
15102 | 1179 |
|
13020 | 1180 |
lemma three [rule_format]: |
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
|
1181 |
"\<lbrakk> xs\<noteq>[]; \<forall>i<length xs. rely \<union> (\<Union>j\<in>{j. j < length xs \<and> j \<noteq> i}. Guar (xs ! j)) |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1182 |
\<subseteq> Rely (xs ! i); |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1183 |
pre \<subseteq> (\<Inter>i\<in>{i. i < length xs}. Pre (xs ! i)); |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1184 |
\<forall>i<length xs. |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1185 |
\<Turnstile> Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1186 |
length xs=length clist; x \<in> par_cp (ParallelCom xs) s; x \<in> par_assum(pre, rely); |
13020 | 1187 |
\<forall>i<length clist. clist!i\<in>cp (Some(Com(xs!i))) s; x \<propto> clist \<rbrakk> |
1188 |
\<Longrightarrow> \<forall>j i. i<length clist \<and> Suc j<length x \<longrightarrow> (clist!i!j) -e\<rightarrow> (clist!i!Suc j) |
|
1189 |
\<longrightarrow> (snd(clist!i!j), snd(clist!i!Suc j)) \<in> rely \<union> (\<Union>j\<in>{j. j < length xs \<and> j \<noteq> i}. Guar (xs ! j))" |
|
1190 |
apply(drule two) |
|
1191 |
apply simp_all |
|
1192 |
apply clarify |
|
1193 |
apply(simp add:conjoin_def compat_label_def) |
|
1194 |
apply clarify |
|
1195 |
apply(erule_tac x=j and P="\<lambda>j. ?H j \<longrightarrow> (?J j \<and> (\<exists>i. ?P i j)) \<or> ?I j" in allE,simp) |
|
1196 |
apply(erule disjE) |
|
1197 |
prefer 2 |
|
1198 |
apply(force simp add:same_state_def par_assum_def) |
|
1199 |
apply clarify |
|
1200 |
apply(case_tac "i=ia",simp) |
|
1201 |
apply(erule etran.elims,simp) |
|
1202 |
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) |
|
1204 |
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) |
|
13601 | 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) |
13020 | 1207 |
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 allE,simp) |
1208 |
done |
|
1209 |
||
1210 |
lemma four: |
|
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
|
1211 |
"\<lbrakk>xs\<noteq>[]; \<forall>i < length xs. rely \<union> (\<Union>j\<in>{j. j < length xs \<and> j \<noteq> i}. Guar (xs ! j)) |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1212 |
\<subseteq> Rely (xs ! i); |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1213 |
(\<Union>j\<in>{j. j < length xs}. Guar (xs ! j)) \<subseteq> guar; |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1214 |
pre \<subseteq> (\<Inter>i\<in>{i. i < length xs}. Pre (xs ! i)); |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1215 |
\<forall>i < length xs. |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1216 |
\<Turnstile> Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1217 |
x \<in> par_cp (ParallelCom xs) s; x \<in> par_assum (pre, rely); Suc i < length x; |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1218 |
x ! i -pc\<rightarrow> x ! Suc i\<rbrakk> |
13020 | 1219 |
\<Longrightarrow> (snd (x ! i), snd (x ! Suc i)) \<in> guar" |
15102 | 1220 |
apply(simp add: ParallelCom_def del: Un_subset_iff) |
13020 | 1221 |
apply(subgoal_tac "(map (Some \<circ> fst) xs)\<noteq>[]") |
1222 |
prefer 2 |
|
1223 |
apply simp |
|
1224 |
apply(frule rev_subsetD) |
|
1225 |
apply(erule one [THEN equalityD1]) |
|
1226 |
apply(erule subsetD) |
|
15102 | 1227 |
apply (simp del: Un_subset_iff) |
13020 | 1228 |
apply clarify |
1229 |
apply(drule_tac pre=pre and rely=rely and x=x and s=s and xs=xs and clist=clist in two) |
|
1230 |
apply(assumption+) |
|
1231 |
apply(erule sym) |
|
1232 |
apply(simp add:ParallelCom_def) |
|
1233 |
apply assumption |
|
1234 |
apply(simp add:Com_def) |
|
1235 |
apply assumption |
|
1236 |
apply(simp add:conjoin_def same_program_def) |
|
1237 |
apply clarify |
|
1238 |
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) |
|
1240 |
apply(erule par_ctran.elims,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) |
|
1242 |
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) |
|
1244 |
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) |
|
1246 |
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 allE,simp) |
|
1247 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in all_dupE) |
|
1248 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in all_dupE,simp) |
|
1249 |
apply(erule_tac x="Suc i" and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE,simp) |
|
1250 |
apply(erule mp) |
|
1251 |
apply(subgoal_tac "r=fst(clist ! ia ! Suc i)",simp) |
|
1252 |
apply(drule_tac i=ia in list_eq_if) |
|
1253 |
back |
|
1254 |
apply simp_all |
|
1255 |
done |
|
1256 |
||
1257 |
lemma parcptn_not_empty [simp]:"[] \<notin> par_cptn" |
|
1258 |
apply(force elim:par_cptn.elims) |
|
1259 |
done |
|
1260 |
||
1261 |
lemma five: |
|
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
|
1262 |
"\<lbrakk>xs\<noteq>[]; \<forall>i<length xs. rely \<union> (\<Union>j\<in>{j. j < length xs \<and> j \<noteq> i}. Guar (xs ! j)) |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1263 |
\<subseteq> Rely (xs ! i); |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1264 |
pre \<subseteq> (\<Inter>i\<in>{i. i < length xs}. Pre (xs ! i)); |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1265 |
(\<Inter>i\<in>{i. i < length xs}. Post (xs ! i)) \<subseteq> post; |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1266 |
\<forall>i < length xs. |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1267 |
\<Turnstile> Com (xs ! i) sat [Pre (xs ! i), Rely (xs ! i), Guar (xs ! i), Post (xs ! i)]; |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1268 |
x \<in> par_cp (ParallelCom xs) s; x \<in> par_assum (pre, rely); |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1269 |
All_None (fst (last x)) \<rbrakk> \<Longrightarrow> snd (last x) \<in> post" |
15102 | 1270 |
apply(simp add: ParallelCom_def del: Un_subset_iff) |
13020 | 1271 |
apply(subgoal_tac "(map (Some \<circ> fst) xs)\<noteq>[]") |
1272 |
prefer 2 |
|
1273 |
apply simp |
|
1274 |
apply(frule rev_subsetD) |
|
1275 |
apply(erule one [THEN equalityD1]) |
|
1276 |
apply(erule subsetD) |
|
15102 | 1277 |
apply(simp del: Un_subset_iff) |
13020 | 1278 |
apply clarify |
1279 |
apply(subgoal_tac "\<forall>i<length clist. clist!i\<in>assum(Pre(xs!i), Rely(xs!i))") |
|
1280 |
apply(erule_tac x=i and P="\<lambda>i. ?H i \<longrightarrow> \<Turnstile> (?J i) sat [?I i,?K i,?M i,?N i]" in allE,erule impE,assumption) |
|
1281 |
apply(simp add:com_validity_def) |
|
1282 |
apply(erule_tac x=s in allE) |
|
1283 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> (?I j) \<in> cp (?J j) s" in allE,simp) |
|
1284 |
apply(drule_tac c="clist!i" in subsetD) |
|
1285 |
apply (force simp add:Com_def) |
|
1286 |
apply(simp add:comm_def conjoin_def same_program_def del:last.simps) |
|
1287 |
apply clarify |
|
1288 |
apply(erule_tac x="length x - 1" and P="\<lambda>j. ?H j \<longrightarrow> fst(?I j)=(?J j)" in allE) |
|
1289 |
apply (simp add:All_None_def same_length_def) |
|
1290 |
apply(erule_tac x=i and P="\<lambda>j. ?H j \<longrightarrow> length(?J j)=(?K j)" in allE) |
|
1291 |
apply(subgoal_tac "length x - 1 < length x",simp) |
|
1292 |
apply(case_tac "x\<noteq>[]") |
|
17588 | 1293 |
apply(simp add: last_conv_nth) |
13020 | 1294 |
apply(erule_tac x="clist!i" in ballE) |
1295 |
apply(simp add:same_state_def) |
|
1296 |
apply(subgoal_tac "clist!i\<noteq>[]") |
|
17588 | 1297 |
apply(simp add: last_conv_nth) |
13020 | 1298 |
apply(case_tac x) |
1299 |
apply (force simp add:par_cp_def) |
|
1300 |
apply (force simp add:par_cp_def) |
|
1301 |
apply force |
|
1302 |
apply (force simp add:par_cp_def) |
|
1303 |
apply(case_tac x) |
|
1304 |
apply (force simp add:par_cp_def) |
|
1305 |
apply (force simp add:par_cp_def) |
|
1306 |
apply clarify |
|
1307 |
apply(simp add:assum_def) |
|
1308 |
apply(rule conjI) |
|
1309 |
apply(simp add:conjoin_def same_state_def par_cp_def) |
|
1310 |
apply clarify |
|
1311 |
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 allE,simp) |
|
1312 |
apply(erule_tac x=0 and P="\<lambda>j. ?H j \<longrightarrow> (snd (?d j))=(snd (?e j))" in allE) |
|
1313 |
apply(case_tac x,simp+) |
|
1314 |
apply (simp add:par_assum_def) |
|
1315 |
apply clarify |
|
1316 |
apply(drule_tac c="snd (clist ! ia ! 0)" in subsetD) |
|
1317 |
apply assumption |
|
1318 |
apply simp |
|
1319 |
apply clarify |
|
1320 |
apply(erule_tac x=ia in all_dupE) |
|
13601 | 1321 |
apply(rule subsetD, erule mp, assumption) |
13020 | 1322 |
apply(erule_tac pre=pre and rely=rely and x=x and s=s in three) |
1323 |
apply(erule_tac x=ic in allE,erule mp) |
|
1324 |
apply simp_all |
|
1325 |
apply(simp add:ParallelCom_def) |
|
1326 |
apply(force simp add:Com_def) |
|
1327 |
apply(simp add:conjoin_def same_length_def) |
|
1328 |
done |
|
1329 |
||
1330 |
lemma ParallelEmpty [rule_format]: |
|
1331 |
"\<forall>i s. x \<in> par_cp (ParallelCom []) s \<longrightarrow> |
|
1332 |
Suc i < length x \<longrightarrow> (x ! i, x ! Suc i) \<notin> par_ctran" |
|
1333 |
apply(induct_tac x) |
|
1334 |
apply(simp add:par_cp_def ParallelCom_def) |
|
1335 |
apply clarify |
|
1336 |
apply(case_tac list,simp,simp) |
|
1337 |
apply(case_tac i) |
|
1338 |
apply(simp add:par_cp_def ParallelCom_def) |
|
1339 |
apply(erule par_ctran.elims,simp) |
|
1340 |
apply(simp add:par_cp_def ParallelCom_def) |
|
1341 |
apply clarify |
|
1342 |
apply(erule par_cptn.elims,simp) |
|
1343 |
apply simp |
|
1344 |
apply(erule par_ctran.elims) |
|
1345 |
back |
|
1346 |
apply simp |
|
1347 |
done |
|
1348 |
||
1349 |
theorem par_rgsound: |
|
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
|
1350 |
"\<turnstile> c SAT [pre, rely, guar, post] \<Longrightarrow> |
b115b305612f
New order in the loading of theories (Quote-antiquote right before the OG_Syntax and RG_Syntax respectively)
prensani
parents:
13020
diff
changeset
|
1351 |
\<Turnstile> (ParallelCom c) SAT [pre, rely, guar, post]" |
13020 | 1352 |
apply(erule par_rghoare.induct) |
1353 |
apply(case_tac xs,simp) |
|
1354 |
apply(simp add:par_com_validity_def par_comm_def) |
|
1355 |
apply clarify |
|
1356 |
apply(case_tac "post=UNIV",simp) |
|
1357 |
apply clarify |
|
1358 |
apply(drule ParallelEmpty) |
|
1359 |
apply assumption |
|
1360 |
apply simp |
|
1361 |
apply clarify |
|
1362 |
apply simp |
|
1363 |
apply(subgoal_tac "xs\<noteq>[]") |
|
1364 |
prefer 2 |
|
1365 |
apply simp |
|
1366 |
apply(thin_tac "xs = a # list") |
|
1367 |
apply(simp add:par_com_validity_def par_comm_def) |
|
1368 |
apply clarify |
|
1369 |
apply(rule conjI) |
|
1370 |
apply clarify |
|
1371 |
apply(erule_tac pre=pre and rely=rely and guar=guar and x=x and s=s and xs=xs in four) |
|
1372 |
apply(assumption+) |
|
1373 |
apply clarify |
|
1374 |
apply (erule allE, erule impE, assumption,erule rgsound) |
|
1375 |
apply(assumption+) |
|
1376 |
apply clarify |
|
1377 |
apply(erule_tac pre=pre and rely=rely and post=post and x=x and s=s and xs=xs in five) |
|
1378 |
apply(assumption+) |
|
1379 |
apply clarify |
|
1380 |
apply (erule allE, erule impE, assumption,erule rgsound) |
|
1381 |
apply(assumption+) |
|
1382 |
done |
|
1383 |
||
13187 | 1384 |
end |