8245
|
1 |
(* Title: HOL/MicroJava/BV/BVLightSpec.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Gerwin Klein
|
|
4 |
Copyright 1999 Technische Universitaet Muenchen
|
9054
|
5 |
*)
|
8245
|
6 |
|
9054
|
7 |
header {* Specification of the LBV *}
|
|
8 |
|
8245
|
9 |
|
9183
|
10 |
theory LBVSpec = BVSpec:
|
8245
|
11 |
|
|
12 |
types
|
|
13 |
certificate = "state_type option list"
|
|
14 |
class_certificate = "sig \\<Rightarrow> certificate"
|
9183
|
15 |
prog_certificate = "cname \\<Rightarrow> class_certificate"
|
8245
|
16 |
|
|
17 |
consts
|
9183
|
18 |
wtl_LS :: "[load_and_store,state_type,state_type,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
19 |
primrec
|
|
20 |
"wtl_LS (Load idx) s s' max_pc pc =
|
|
21 |
(let (ST,LT) = s
|
|
22 |
in
|
|
23 |
pc+1 < max_pc \\<and>
|
|
24 |
idx < length LT \\<and>
|
|
25 |
(\\<exists>ts. (LT ! idx) = Some ts \\<and>
|
|
26 |
(ts # ST , LT) = s'))"
|
|
27 |
|
|
28 |
"wtl_LS (Store idx) s s' max_pc pc =
|
|
29 |
(let (ST,LT) = s
|
|
30 |
in
|
|
31 |
pc+1 < max_pc \\<and>
|
|
32 |
idx < length LT \\<and>
|
|
33 |
(\\<exists>ts ST'. ST = ts # ST' \\<and>
|
|
34 |
(ST' , LT[idx:=Some ts]) = s'))"
|
|
35 |
|
|
36 |
"wtl_LS (Bipush i) s s' max_pc pc =
|
|
37 |
(let (ST,LT) = s
|
|
38 |
in
|
|
39 |
pc+1 < max_pc \\<and>
|
|
40 |
((PrimT Integer) # ST , LT) = s')"
|
|
41 |
|
|
42 |
"wtl_LS (Aconst_null) s s' max_pc pc =
|
|
43 |
(let (ST,LT) = s
|
|
44 |
in
|
|
45 |
pc+1 < max_pc \\<and>
|
9183
|
46 |
(NT # ST , LT) = s')"
|
8245
|
47 |
|
|
48 |
consts
|
9183
|
49 |
wtl_MO :: "[manipulate_object,jvm_prog,state_type,state_type,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
50 |
primrec
|
|
51 |
"wtl_MO (Getfield F C) G s s' max_pc pc =
|
|
52 |
(let (ST,LT) = s
|
|
53 |
in
|
|
54 |
pc+1 < max_pc \\<and>
|
|
55 |
is_class G C \\<and>
|
|
56 |
(\\<exists>T oT ST'. field (G,C) F = Some(C,T) \\<and>
|
8390
|
57 |
ST = oT # ST' \\<and>
|
|
58 |
G \\<turnstile> oT \\<preceq> (Class C) \\<and>
|
|
59 |
(T # ST' , LT) = s'))"
|
8245
|
60 |
|
|
61 |
"wtl_MO (Putfield F C) G s s' max_pc pc =
|
|
62 |
(let (ST,LT) = s
|
|
63 |
in
|
|
64 |
pc+1 < max_pc \\<and>
|
|
65 |
is_class G C \\<and>
|
|
66 |
(\\<exists>T vT oT ST'.
|
|
67 |
field (G,C) F = Some(C,T) \\<and>
|
|
68 |
ST = vT # oT # ST' \\<and>
|
|
69 |
G \\<turnstile> oT \\<preceq> (Class C) \\<and>
|
8390
|
70 |
G \\<turnstile> vT \\<preceq> T \\<and>
|
9183
|
71 |
(ST' , LT) = s'))"
|
8245
|
72 |
|
|
73 |
|
|
74 |
consts
|
9183
|
75 |
wtl_CO :: "[create_object,jvm_prog,state_type,state_type,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
76 |
primrec
|
|
77 |
"wtl_CO (New C) G s s' max_pc pc =
|
|
78 |
(let (ST,LT) = s
|
|
79 |
in
|
|
80 |
pc+1 < max_pc \\<and>
|
|
81 |
is_class G C \\<and>
|
9183
|
82 |
((Class C) # ST , LT) = s')"
|
8245
|
83 |
|
|
84 |
consts
|
9183
|
85 |
wtl_CH :: "[check_object,jvm_prog,state_type,state_type,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
86 |
primrec
|
|
87 |
"wtl_CH (Checkcast C) G s s' max_pc pc =
|
9054
|
88 |
(let (ST,LT) = s
|
8245
|
89 |
in
|
|
90 |
pc+1 < max_pc \\<and>
|
|
91 |
is_class G C \\<and>
|
|
92 |
(\\<exists>rt ST'. ST = RefT rt # ST' \\<and>
|
9183
|
93 |
(Class C # ST' , LT) = s'))"
|
8245
|
94 |
|
|
95 |
consts
|
9183
|
96 |
wtl_OS :: "[op_stack,state_type,state_type,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
97 |
primrec
|
|
98 |
"wtl_OS Pop s s' max_pc pc =
|
|
99 |
(let (ST,LT) = s
|
|
100 |
in
|
|
101 |
\\<exists>ts ST'. pc+1 < max_pc \\<and>
|
|
102 |
ST = ts # ST' \\<and>
|
|
103 |
(ST' , LT) = s')"
|
|
104 |
|
|
105 |
"wtl_OS Dup s s' max_pc pc =
|
|
106 |
(let (ST,LT) = s
|
|
107 |
in
|
|
108 |
pc+1 < max_pc \\<and>
|
|
109 |
(\\<exists>ts ST'. ST = ts # ST' \\<and>
|
|
110 |
(ts # ts # ST' , LT) = s'))"
|
|
111 |
|
|
112 |
"wtl_OS Dup_x1 s s' max_pc pc =
|
|
113 |
(let (ST,LT) = s
|
|
114 |
in
|
|
115 |
pc+1 < max_pc \\<and>
|
|
116 |
(\\<exists>ts1 ts2 ST'. ST = ts1 # ts2 # ST' \\<and>
|
|
117 |
(ts1 # ts2 # ts1 # ST' , LT) = s'))"
|
|
118 |
|
|
119 |
"wtl_OS Dup_x2 s s' max_pc pc =
|
|
120 |
(let (ST,LT) = s
|
|
121 |
in
|
|
122 |
pc+1 < max_pc \\<and>
|
|
123 |
(\\<exists>ts1 ts2 ts3 ST'. ST = ts1 # ts2 # ts3 # ST' \\<and>
|
|
124 |
(ts1 # ts2 # ts3 # ts1 # ST' , LT) = s'))"
|
|
125 |
|
|
126 |
"wtl_OS Swap s s' max_pc pc =
|
|
127 |
(let (ST,LT) = s
|
|
128 |
in
|
|
129 |
pc+1 < max_pc \\<and>
|
|
130 |
(\\<exists>ts ts' ST'. ST = ts' # ts # ST' \\<and>
|
9183
|
131 |
(ts # ts' # ST' , LT) = s'))"
|
8245
|
132 |
|
|
133 |
consts
|
9183
|
134 |
wtl_BR :: "[branch,jvm_prog,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
135 |
primrec
|
|
136 |
"wtl_BR (Ifcmpeq branch) G s s' cert max_pc pc =
|
|
137 |
(let (ST,LT) = s
|
|
138 |
in
|
|
139 |
pc+1 < max_pc \\<and> (nat(int pc+branch)) < max_pc \\<and>
|
8390
|
140 |
(\\<exists>ts ts' ST'. ST = ts # ts' # ST' \\<and>
|
|
141 |
((\\<exists>p. ts = PrimT p \\<and> ts' = PrimT p) \\<or>
|
|
142 |
(\\<exists>r r'. ts = RefT r \\<and> ts' = RefT r')) \\<and>
|
8245
|
143 |
((ST' , LT) = s') \\<and>
|
|
144 |
cert ! (nat(int pc+branch)) \\<noteq> None \\<and>
|
|
145 |
G \\<turnstile> (ST' , LT) <=s the (cert ! (nat(int pc+branch)))))"
|
|
146 |
|
|
147 |
"wtl_BR (Goto branch) G s s' cert max_pc pc =
|
|
148 |
((let (ST,LT) = s
|
|
149 |
in
|
|
150 |
(nat(int pc+branch)) < max_pc \\<and> cert ! (nat(int pc+branch)) \\<noteq> None \\<and>
|
|
151 |
G \\<turnstile> (ST , LT) <=s the (cert ! (nat(int pc+branch)))) \\<and>
|
9183
|
152 |
(cert ! (pc+1) = Some s'))"
|
8245
|
153 |
|
|
154 |
consts
|
9183
|
155 |
wtl_MI :: "[meth_inv,jvm_prog,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
156 |
primrec
|
8390
|
157 |
"wtl_MI (Invoke mn fpTs) G s s' cert max_pc pc =
|
8245
|
158 |
(let (ST,LT) = s
|
|
159 |
in
|
|
160 |
pc+1 < max_pc \\<and>
|
8390
|
161 |
(\\<exists>apTs X ST'. ST = (rev apTs) @ (X # ST') \\<and>
|
8245
|
162 |
length apTs = length fpTs \\<and>
|
8390
|
163 |
(\\<exists>s''. cert ! (pc+1) = Some s'' \\<and>
|
|
164 |
((s'' = s' \\<and> X = NT) \\<or>
|
|
165 |
((G \\<turnstile> s' <=s s'') \\<and> (\\<exists>C. X = Class C \\<and>
|
|
166 |
(\\<forall>(aT,fT)\\<in>set(zip apTs fpTs). G \\<turnstile> aT \\<preceq> fT) \\<and>
|
|
167 |
(\\<exists>D rT b. method (G,C) (mn,fpTs) = Some(D,rT,b) \\<and>
|
9183
|
168 |
(rT # ST' , LT) = s')))))))"
|
8245
|
169 |
|
|
170 |
consts
|
9183
|
171 |
wtl_MR :: "[meth_ret,jvm_prog,ty,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
172 |
primrec
|
|
173 |
"wtl_MR Return G rT s s' cert max_pc pc =
|
|
174 |
((let (ST,LT) = s
|
|
175 |
in
|
|
176 |
(\\<exists>T ST'. ST = T # ST' \\<and> G \\<turnstile> T \\<preceq> rT)) \\<and>
|
9183
|
177 |
(cert ! (pc+1) = Some s'))"
|
8245
|
178 |
|
|
179 |
|
|
180 |
consts
|
9183
|
181 |
wtl_inst :: "[instr,jvm_prog,ty,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
182 |
primrec
|
|
183 |
"wtl_inst (LS ins) G rT s s' cert max_pc pc = wtl_LS ins s s' max_pc pc"
|
|
184 |
"wtl_inst (CO ins) G rT s s' cert max_pc pc = wtl_CO ins G s s' max_pc pc"
|
|
185 |
"wtl_inst (MO ins) G rT s s' cert max_pc pc = wtl_MO ins G s s' max_pc pc"
|
|
186 |
"wtl_inst (CH ins) G rT s s' cert max_pc pc = wtl_CH ins G s s' max_pc pc"
|
8390
|
187 |
"wtl_inst (MI ins) G rT s s' cert max_pc pc = wtl_MI ins G s s' cert max_pc pc"
|
8245
|
188 |
"wtl_inst (MR ins) G rT s s' cert max_pc pc = wtl_MR ins G rT s s' cert max_pc pc"
|
|
189 |
"wtl_inst (OS ins) G rT s s' cert max_pc pc = wtl_OS ins s s' max_pc pc"
|
9183
|
190 |
"wtl_inst (BR ins) G rT s s' cert max_pc pc = wtl_BR ins G s s' cert max_pc pc"
|
8245
|
191 |
|
|
192 |
|
|
193 |
constdefs
|
|
194 |
wtl_inst_option :: "[instr,jvm_prog,ty,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
|
|
195 |
"wtl_inst_option i G rT s0 s1 cert max_pc pc \\<equiv>
|
|
196 |
(case cert!pc of
|
|
197 |
None \\<Rightarrow> wtl_inst i G rT s0 s1 cert max_pc pc
|
|
198 |
| Some s0' \\<Rightarrow> (G \\<turnstile> s0 <=s s0') \\<and>
|
9183
|
199 |
wtl_inst i G rT s0' s1 cert max_pc pc)"
|
8245
|
200 |
|
|
201 |
consts
|
9183
|
202 |
wtl_inst_list :: "[instr list,jvm_prog,ty,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
|
8245
|
203 |
primrec
|
|
204 |
"wtl_inst_list [] G rT s0 s2 cert max_pc pc = (s0 = s2)"
|
|
205 |
|
|
206 |
"wtl_inst_list (instr#is) G rT s0 s2 cert max_pc pc =
|
|
207 |
(\\<exists>s1. wtl_inst_option instr G rT s0 s1 cert max_pc pc \\<and>
|
9183
|
208 |
wtl_inst_list is G rT s1 s2 cert max_pc (pc+1))"
|
8245
|
209 |
|
|
210 |
constdefs
|
|
211 |
wtl_method :: "[jvm_prog,cname,ty list,ty,nat,instr list,certificate] \\<Rightarrow> bool"
|
|
212 |
"wtl_method G C pTs rT mxl ins cert \\<equiv>
|
|
213 |
let max_pc = length ins
|
|
214 |
in
|
|
215 |
0 < max_pc \\<and>
|
|
216 |
(\\<exists>s2. wtl_inst_list ins G rT
|
|
217 |
([],(Some(Class C))#((map Some pTs))@(replicate mxl None))
|
|
218 |
s2 cert max_pc 0)"
|
|
219 |
|
9012
|
220 |
wtl_jvm_prog :: "[jvm_prog,prog_certificate] \\<Rightarrow> bool"
|
8245
|
221 |
"wtl_jvm_prog G cert \\<equiv>
|
|
222 |
wf_prog (\\<lambda>G C (sig,rT,maxl,b).
|
9183
|
223 |
wtl_method G C (snd sig) rT maxl b (cert C sig)) G"
|
9012
|
224 |
|
9054
|
225 |
text {* \medskip *}
|
|
226 |
|
9183
|
227 |
lemma rev_eq: "\\<lbrakk>length a = n; length x = n; rev a @ b # c = rev x @ y # z\\<rbrakk> \\<Longrightarrow> a = x \\<and> b = y \\<and> c = z"
|
|
228 |
by auto
|
9012
|
229 |
|
|
230 |
lemma wtl_inst_unique:
|
|
231 |
"wtl_inst i G rT s0 s1 cert max_pc pc \\<longrightarrow>
|
9183
|
232 |
wtl_inst i G rT s0 s1' cert max_pc pc \\<longrightarrow> s1 = s1'" (is "?P i")
|
|
233 |
proof (induct i)
|
|
234 |
case LS
|
|
235 |
show "?P (LS load_and_store)" by (induct load_and_store) auto
|
|
236 |
case CO
|
|
237 |
show "?P (CO create_object)" by (induct create_object) auto
|
|
238 |
case MO
|
|
239 |
show "?P (MO manipulate_object)" by (induct manipulate_object) auto
|
|
240 |
case CH
|
|
241 |
show "?P (CH check_object)" by (induct check_object) auto
|
|
242 |
case MI
|
|
243 |
show "?P (MI meth_inv)" proof (induct meth_inv)
|
|
244 |
case Invoke
|
|
245 |
have "\\<exists>x y. s0 = (x,y)" by (simp)
|
9012
|
246 |
thus "wtl_inst (MI (Invoke mname list)) G rT s0 s1 cert max_pc pc \\<longrightarrow>
|
|
247 |
wtl_inst (MI (Invoke mname list)) G rT s0 s1' cert max_pc pc \\<longrightarrow>
|
9183
|
248 |
s1 = s1'"
|
|
249 |
proof elim
|
|
250 |
apply_end(clarsimp_tac, drule rev_eq, assumption+)
|
|
251 |
qed auto
|
|
252 |
qed
|
|
253 |
case MR
|
|
254 |
show "?P (MR meth_ret)" by (induct meth_ret) auto
|
|
255 |
case OS
|
|
256 |
show "?P (OS op_stack)" by (induct op_stack) auto
|
|
257 |
case BR
|
|
258 |
show "?P (BR branch)" by (induct branch) auto
|
|
259 |
qed
|
9012
|
260 |
|
|
261 |
lemma wtl_inst_option_unique:
|
|
262 |
"\\<lbrakk>wtl_inst_option i G rT s0 s1 cert max_pc pc;
|
9183
|
263 |
wtl_inst_option i G rT s0 s1' cert max_pc pc\\<rbrakk> \\<Longrightarrow> s1 = s1'"
|
|
264 |
by (cases "cert!pc") (auto simp add: wtl_inst_unique wtl_inst_option_def)
|
9012
|
265 |
|
|
266 |
|
|
267 |
lemma wtl_inst_list_unique:
|
|
268 |
"\\<forall> s0 pc. wtl_inst_list is G rT s0 s1 cert max_pc pc \\<longrightarrow>
|
9183
|
269 |
wtl_inst_list is G rT s0 s1' cert max_pc pc \\<longrightarrow> s1=s1'" (is "?P is")
|
|
270 |
proof (induct "?P" "is")
|
|
271 |
case Nil
|
|
272 |
show "?P []" by simp
|
8245
|
273 |
|
9183
|
274 |
case Cons
|
|
275 |
show "?P (a # list)"
|
|
276 |
proof intro
|
|
277 |
fix s0 fix pc
|
|
278 |
let "?o s0 s1" = "wtl_inst_option a G rT s0 s1 cert max_pc pc"
|
|
279 |
let "?l l s1 s2 pc" = "wtl_inst_list l G rT s1 s2 cert max_pc pc"
|
|
280 |
assume a: "?l (a#list) s0 s1 pc"
|
|
281 |
assume b: "?l (a#list) s0 s1' pc"
|
|
282 |
with a
|
|
283 |
show "s1 = s1'"
|
9012
|
284 |
obtain s s' where "?o s0 s" "?o s0 s'"
|
|
285 |
and l: "?l list s s1 (Suc pc)"
|
9183
|
286 |
and l': "?l list s' s1' (Suc pc)" by auto
|
|
287 |
have "s=s'" by(rule wtl_inst_option_unique)
|
|
288 |
with l l' Cons
|
|
289 |
show ?thesis by blast
|
|
290 |
qed
|
|
291 |
qed
|
|
292 |
qed
|
9012
|
293 |
|
|
294 |
lemma wtl_partial:
|
|
295 |
"\\<forall> pc' pc s.
|
|
296 |
wtl_inst_list is G rT s s' cert mpc pc \\<longrightarrow> \
|
|
297 |
pc' < length is \\<longrightarrow> \
|
|
298 |
(\\<exists> a b s1. a @ b = is \\<and> length a = pc' \\<and> \
|
|
299 |
wtl_inst_list a G rT s s1 cert mpc pc \\<and> \
|
9183
|
300 |
wtl_inst_list b G rT s1 s' cert mpc (pc+length a))" (is "?P is")
|
|
301 |
proof (induct "?P" "is")
|
|
302 |
case Nil
|
|
303 |
show "?P []" by auto
|
9012
|
304 |
|
9183
|
305 |
case Cons
|
|
306 |
show "?P (a#list)"
|
|
307 |
proof (intro allI impI)
|
|
308 |
fix pc' pc s
|
|
309 |
assume length: "pc' < length (a # list)"
|
|
310 |
assume wtl: "wtl_inst_list (a # list) G rT s s' cert mpc pc"
|
9012
|
311 |
show "\\<exists> a' b s1.
|
|
312 |
a' @ b = a#list \\<and> length a' = pc' \\<and> \
|
|
313 |
wtl_inst_list a' G rT s s1 cert mpc pc \\<and> \
|
|
314 |
wtl_inst_list b G rT s1 s' cert mpc (pc+length a')"
|
9183
|
315 |
(is "\\<exists> a b s1. ?E a b s1")
|
|
316 |
proof (cases "pc'")
|
|
317 |
case 0
|
|
318 |
with wtl
|
|
319 |
have "?E [] (a#list) s" by simp
|
|
320 |
thus ?thesis by blast
|
|
321 |
next
|
|
322 |
case Suc
|
|
323 |
with wtl
|
|
324 |
show ?thesis
|
9012
|
325 |
obtain s0 where wtlSuc: "wtl_inst_list list G rT s0 s' cert mpc (Suc pc)"
|
9183
|
326 |
and wtlOpt: "wtl_inst_option a G rT s s0 cert mpc pc" by auto
|
|
327 |
from Cons
|
|
328 |
show ?thesis
|
9012
|
329 |
obtain a' b s1'
|
|
330 |
where "a' @ b = list" "length a' = nat"
|
|
331 |
and w:"wtl_inst_list a' G rT s0 s1' cert mpc (Suc pc)"
|
9183
|
332 |
and "wtl_inst_list b G rT s1' s' cert mpc (Suc pc + length a')"
|
|
333 |
proof (elim allE impE)
|
|
334 |
from length Suc show "nat < length list" by simp
|
|
335 |
from wtlSuc show "wtl_inst_list list G rT s0 s' cert mpc (Suc pc)" .
|
|
336 |
qed (elim exE conjE, auto)
|
|
337 |
with Suc wtlOpt
|
|
338 |
have "?E (a#a') b s1'" by (auto simp del: split_paired_Ex)
|
|
339 |
thus ?thesis by blast
|
|
340 |
qed
|
|
341 |
qed
|
|
342 |
qed
|
|
343 |
qed
|
|
344 |
qed
|
9012
|
345 |
|
|
346 |
lemma "wtl_append1":
|
|
347 |
"\\<lbrakk>wtl_inst_list x G rT s0 s1 cert (length (x@y)) 0;
|
|
348 |
wtl_inst_list y G rT s1 s2 cert (length (x@y)) (length x)\\<rbrakk> \\<Longrightarrow>
|
9183
|
349 |
wtl_inst_list (x@y) G rT s0 s2 cert (length (x@y)) 0"
|
|
350 |
proof -
|
9012
|
351 |
assume w:
|
|
352 |
"wtl_inst_list x G rT s0 s1 cert (length (x@y)) 0"
|
9183
|
353 |
"wtl_inst_list y G rT s1 s2 cert (length (x@y)) (length x)"
|
9012
|
354 |
|
|
355 |
have
|
|
356 |
"\\<forall> pc s0.
|
|
357 |
wtl_inst_list x G rT s0 s1 cert (pc+length (x@y)) pc \\<longrightarrow>
|
|
358 |
wtl_inst_list y G rT s1 s2 cert (pc+length (x@y)) (pc+length x) \\<longrightarrow>
|
9183
|
359 |
wtl_inst_list (x@y) G rT s0 s2 cert (pc+length (x@y)) pc" (is "?P x")
|
|
360 |
proof (induct "?P" "x")
|
|
361 |
case Nil
|
|
362 |
show "?P []" by simp
|
|
363 |
next
|
|
364 |
case Cons
|
|
365 |
show "?P (a#list)"
|
|
366 |
proof intro
|
|
367 |
fix pc s0
|
9012
|
368 |
assume y:
|
9183
|
369 |
"wtl_inst_list y G rT s1 s2 cert (pc + length ((a # list) @ y)) (pc + length (a # list))"
|
9012
|
370 |
assume al:
|
9183
|
371 |
"wtl_inst_list (a # list) G rT s0 s1 cert (pc + length ((a # list) @ y)) pc"
|
|
372 |
thus "wtl_inst_list ((a # list) @ y) G rT s0 s2 cert (pc + length ((a # list) @ y)) pc"
|
9012
|
373 |
obtain s' where
|
|
374 |
a: "wtl_inst_option a G rT s0 s' cert (Suc pc + length (list@y)) pc" and
|
9183
|
375 |
l: "wtl_inst_list list G rT s' s1 cert (Suc pc + length (list@y)) (Suc pc)" by auto
|
|
376 |
with y Cons
|
|
377 |
have "wtl_inst_list (list @ y) G rT s' s2 cert (Suc pc + length (list @ y)) (Suc pc)"
|
|
378 |
by (elim allE impE) (assumption, simp+)
|
|
379 |
with a
|
|
380 |
show ?thesis by (auto simp del: split_paired_Ex)
|
|
381 |
qed
|
|
382 |
qed
|
|
383 |
qed
|
9012
|
384 |
|
9183
|
385 |
with w
|
|
386 |
show ?thesis
|
|
387 |
proof (elim allE impE)
|
|
388 |
from w show "wtl_inst_list x G rT s0 s1 cert (0+length (x @ y)) 0" by simp
|
|
389 |
qed simp+
|
|
390 |
qed
|
9012
|
391 |
|
|
392 |
lemma wtl_cons_appendl:
|
|
393 |
"\\<lbrakk>wtl_inst_list a G rT s0 s1 cert (length (a@i#b)) 0;
|
|
394 |
wtl_inst_option i G rT s1 s2 cert (length (a@i#b)) (length a);
|
|
395 |
wtl_inst_list b G rT s2 s3 cert (length (a@i#b)) (Suc (length a))\\<rbrakk> \\<Longrightarrow>
|
9183
|
396 |
wtl_inst_list (a@i#b) G rT s0 s3 cert (length (a@i#b)) 0"
|
|
397 |
proof -
|
|
398 |
assume a: "wtl_inst_list a G rT s0 s1 cert (length (a@i#b)) 0"
|
9012
|
399 |
|
|
400 |
assume "wtl_inst_option i G rT s1 s2 cert (length (a@i#b)) (length a)"
|
9183
|
401 |
"wtl_inst_list b G rT s2 s3 cert (length (a@i#b)) (Suc (length a))"
|
9012
|
402 |
|
9183
|
403 |
hence "wtl_inst_list (i#b) G rT s1 s3 cert (length (a@i#b)) (length a)"
|
|
404 |
by (auto simp del: split_paired_Ex)
|
9012
|
405 |
|
9183
|
406 |
with a
|
|
407 |
show ?thesis by (rule wtl_append1)
|
|
408 |
qed
|
9012
|
409 |
|
|
410 |
lemma "wtl_append":
|
|
411 |
"\\<lbrakk>wtl_inst_list a G rT s0 s1 cert (length (a@i#b)) 0;
|
|
412 |
wtl_inst_option i G rT s1 s2 cert (length (a@i#b)) (length a);
|
|
413 |
wtl_inst_list b G rT s2 s3 cert (length (a@i#b)) (Suc (length a))\\<rbrakk> \\<Longrightarrow>
|
9183
|
414 |
wtl_inst_list (a@[i]) G rT s0 s2 cert (length (a@i#b)) 0"
|
|
415 |
proof -
|
|
416 |
assume a: "wtl_inst_list a G rT s0 s1 cert (length (a@i#b)) 0"
|
|
417 |
assume i: "wtl_inst_option i G rT s1 s2 cert (length (a@i#b)) (length a)"
|
|
418 |
assume b: "wtl_inst_list b G rT s2 s3 cert (length (a@i#b)) (Suc (length a))"
|
9012
|
419 |
|
|
420 |
have "\\<forall> s0 pc. wtl_inst_list a G rT s0 s1 cert (pc+length (a@i#b)) pc \\<longrightarrow>
|
|
421 |
wtl_inst_option i G rT s1 s2 cert (pc+length (a@i#b)) (pc + length a) \\<longrightarrow>
|
|
422 |
wtl_inst_list b G rT s2 s3 cert (pc+length (a@i#b)) (Suc pc + length a) \\<longrightarrow>
|
9183
|
423 |
wtl_inst_list (a@[i]) G rT s0 s2 cert (pc+length (a@i#b)) pc" (is "?P a")
|
|
424 |
proof (induct "?P" "a")
|
|
425 |
case Nil
|
|
426 |
show "?P []" by (simp del: split_paired_Ex)
|
|
427 |
case Cons
|
|
428 |
show "?P (a#list)" (is "\\<forall>s0 pc. ?x s0 pc \\<longrightarrow> ?y s0 pc \\<longrightarrow> ?z s0 pc \\<longrightarrow> ?p s0 pc")
|
|
429 |
proof intro
|
|
430 |
fix s0 pc
|
|
431 |
assume y: "?y s0 pc"
|
|
432 |
assume z: "?z s0 pc"
|
|
433 |
assume "?x s0 pc"
|
|
434 |
thus "?p s0 pc"
|
9012
|
435 |
obtain s0' where opt: "wtl_inst_option a G rT s0 s0' cert (pc + length ((a # list) @ i # b)) pc"
|
9183
|
436 |
and list: "wtl_inst_list list G rT s0' s1 cert (Suc pc + length (list @ i # b)) (Suc pc)"
|
|
437 |
by (auto simp del: split_paired_Ex)
|
|
438 |
with y z Cons
|
|
439 |
have "wtl_inst_list (list @ [i]) G rT s0' s2 cert (Suc pc + length (list @ i # b)) (Suc pc)"
|
|
440 |
proof (elim allE impE)
|
|
441 |
from list show "wtl_inst_list list G rT s0' s1 cert (Suc pc + length (list @ i # b)) (Suc pc)" .
|
|
442 |
qed auto
|
|
443 |
with opt
|
|
444 |
show ?thesis by (auto simp del: split_paired_Ex)
|
|
445 |
qed
|
|
446 |
qed
|
|
447 |
qed
|
|
448 |
with a i b
|
|
449 |
show ?thesis
|
|
450 |
proof (elim allE impE)
|
|
451 |
from a show "wtl_inst_list a G rT s0 s1 cert (0+length (a@i#b)) 0" by simp
|
|
452 |
qed auto
|
|
453 |
qed
|
9012
|
454 |
|
9183
|
455 |
end
|