author | haftmann |
Fri, 03 Nov 2006 14:22:44 +0100 | |
changeset 21158 | b379fdc3a3bd |
parent 19763 | ec18656a2c10 |
child 26304 | 02fbd0e7954a |
permissions | -rw-r--r-- |
17293 | 1 |
(* Title: HOLCF/FOCUS/Buffer_adm.thy |
11355 | 2 |
ID: $Id$ |
17293 | 3 |
Author: David von Oheimb, TU Muenchen |
11350
4c55b020d6ee
added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff
changeset
|
4 |
*) |
4c55b020d6ee
added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff
changeset
|
5 |
|
17293 | 6 |
header {* One-element buffer, proof of Buf_Eq_imp_AC by induction + admissibility *} |
11350
4c55b020d6ee
added FOCUS including the One-Element Buffer by Manfred Broy
oheimb
parents:
diff
changeset
|
7 |
|
17293 | 8 |
theory Buffer_adm |
9 |
imports Buffer Stream_adm |
|
10 |
begin |
|
11 |
||
19759 | 12 |
declare Fin_0 [simp] |
13 |
||
14 |
lemma BufAC_Asm_d2: "a\<leadsto>s:BufAC_Asm ==> ? d. a=Md d" |
|
15 |
by (drule BufAC_Asm_unfold [THEN iffD1], auto) |
|
16 |
||
17 |
lemma BufAC_Asm_d3: |
|
18 |
"a\<leadsto>b\<leadsto>s:BufAC_Asm ==> ? d. a=Md d & b=\<bullet> & s:BufAC_Asm" |
|
19 |
by (drule BufAC_Asm_unfold [THEN iffD1], auto) |
|
20 |
||
21 |
lemma BufAC_Asm_F_def3: |
|
22 |
"(s:BufAC_Asm_F A) = (s=<> | |
|
23 |
(? d. ft\<cdot>s=Def(Md d)) & (rt\<cdot>s=<> | ft\<cdot>(rt\<cdot>s)=Def \<bullet> & rt\<cdot>(rt\<cdot>s):A))" |
|
24 |
by (unfold BufAC_Asm_F_def, auto) |
|
25 |
||
26 |
lemma cont_BufAC_Asm_F: "down_cont BufAC_Asm_F" |
|
27 |
by (auto simp add: down_cont_def BufAC_Asm_F_def3) |
|
28 |
||
29 |
lemma BufAC_Cmt_F_def3: |
|
30 |
"((s,t):BufAC_Cmt_F C) = (!d x. |
|
31 |
(s = <> --> t = <> ) & |
|
32 |
(s = Md d\<leadsto><> --> t = <> ) & |
|
33 |
(s = Md d\<leadsto>\<bullet>\<leadsto>x --> ft\<cdot>t = Def d & (x,rt\<cdot>t):C))" |
|
34 |
apply (unfold BufAC_Cmt_F_def) |
|
35 |
apply (subgoal_tac "!d x. (s = Md d\<leadsto>\<bullet>\<leadsto>x --> (? y. t = d\<leadsto>y & (x,y):C)) = |
|
36 |
(s = Md d\<leadsto>\<bullet>\<leadsto>x --> ft\<cdot>t = Def d & (x,rt\<cdot>t):C)") |
|
37 |
apply (simp) |
|
38 |
apply (auto intro: surjectiv_scons [symmetric]) |
|
39 |
done |
|
40 |
||
41 |
lemma cont_BufAC_Cmt_F: "down_cont BufAC_Cmt_F" |
|
42 |
by (auto simp add: down_cont_def BufAC_Cmt_F_def3) |
|
43 |
||
44 |
||
45 |
(**** adm_BufAC_Asm ***********************************************************) |
|
46 |
||
47 |
lemma BufAC_Asm_F_stream_monoP: "stream_monoP BufAC_Asm_F" |
|
48 |
apply (unfold BufAC_Asm_F_def stream_monoP_def) |
|
49 |
apply (rule_tac x="{x. (? d. x = Md d\<leadsto>\<bullet>\<leadsto><>)}" in exI) |
|
50 |
apply (rule_tac x="Suc (Suc 0)" in exI) |
|
51 |
apply (clarsimp) |
|
52 |
done |
|
53 |
||
54 |
lemma adm_BufAC_Asm: "adm (%x. x:BufAC_Asm)" |
|
55 |
apply (unfold BufAC_Asm_def) |
|
56 |
apply (rule cont_BufAC_Asm_F [THEN BufAC_Asm_F_stream_monoP [THEN fstream_gfp_admI]]) |
|
57 |
done |
|
58 |
||
59 |
||
60 |
(**** adm_non_BufAC_Asm *******************************************************) |
|
61 |
||
62 |
lemma BufAC_Asm_F_stream_antiP: "stream_antiP BufAC_Asm_F" |
|
63 |
apply (unfold stream_antiP_def BufAC_Asm_F_def) |
|
64 |
apply (intro strip) |
|
65 |
apply (rule_tac x="{x. (? d. x = Md d\<leadsto>\<bullet>\<leadsto><>)}" in exI) |
|
66 |
apply (rule_tac x="Suc (Suc 0)" in exI) |
|
67 |
apply (rule conjI) |
|
68 |
prefer 2 |
|
69 |
apply ( intro strip) |
|
70 |
apply ( drule slen_mono) |
|
71 |
apply ( drule (1) ile_trans) |
|
72 |
apply (force)+ |
|
73 |
done |
|
74 |
||
75 |
lemma adm_non_BufAC_Asm: "adm (%u. u~:BufAC_Asm)" |
|
76 |
apply (unfold BufAC_Asm_def) |
|
77 |
apply (rule cont_BufAC_Asm_F [THEN BufAC_Asm_F_stream_antiP [THEN fstream_non_gfp_admI]]) |
|
78 |
done |
|
79 |
||
80 |
(**** adm_BufAC ***************************************************************) |
|
81 |
||
82 |
(*adm_non_BufAC_Asm*) |
|
83 |
lemma BufAC_Asm_cong [rule_format]: "!f ff. f:BufEq --> ff:BufEq --> s:BufAC_Asm --> f\<cdot>s = ff\<cdot>s" |
|
84 |
apply (rule fstream_ind2) |
|
85 |
apply (simp add: adm_non_BufAC_Asm) |
|
86 |
apply (force dest: Buf_f_empty) |
|
87 |
apply (force dest!: BufAC_Asm_d2 |
|
88 |
dest: Buf_f_d elim: ssubst) |
|
89 |
apply (safe dest!: BufAC_Asm_d3) |
|
90 |
apply (drule Buf_f_d_req)+ |
|
91 |
apply (fast elim: ssubst) |
|
92 |
done |
|
93 |
||
94 |
(*adm_non_BufAC_Asm,BufAC_Asm_cong*) |
|
95 |
lemma BufAC_Cmt_d_req: |
|
96 |
"!!X. [|f:BufEq; s:BufAC_Asm; (s, f\<cdot>s):BufAC_Cmt|] ==> (a\<leadsto>b\<leadsto>s, f\<cdot>(a\<leadsto>b\<leadsto>s)):BufAC_Cmt" |
|
97 |
apply (rule BufAC_Cmt_unfold [THEN iffD2]) |
|
98 |
apply (intro strip) |
|
99 |
apply (frule Buf_f_d_req) |
|
100 |
apply (auto elim: BufAC_Asm_cong [THEN subst]) |
|
101 |
done |
|
102 |
||
103 |
(*adm_BufAC_Asm*) |
|
104 |
lemma BufAC_Asm_antiton: "antitonP BufAC_Asm" |
|
105 |
apply (rule antitonPI) |
|
106 |
apply (rule allI) |
|
107 |
apply (rule fstream_ind2) |
|
108 |
apply ( rule adm_lemmas)+ |
|
109 |
apply ( rule cont_id) |
|
110 |
apply ( rule adm_BufAC_Asm) |
|
111 |
apply ( safe) |
|
112 |
apply ( rule BufAC_Asm_empty) |
|
113 |
apply ( force dest!: fstream_prefix |
|
114 |
dest: BufAC_Asm_d2 intro: BufAC_Asm_d) |
|
115 |
apply ( force dest!: fstream_prefix |
|
116 |
dest: BufAC_Asm_d3 intro!: BufAC_Asm_d_req) |
|
117 |
done |
|
118 |
||
119 |
(*adm_BufAC_Asm,BufAC_Asm_antiton,adm_non_BufAC_Asm,BufAC_Asm_cong*) |
|
120 |
lemma BufAC_Cmt_2stream_monoP: "f:BufEq ==> ? l. !i x s. s:BufAC_Asm --> x << s --> Fin (l i) < #x --> |
|
121 |
(x,f\<cdot>x):down_iterate BufAC_Cmt_F i --> |
|
122 |
(s,f\<cdot>s):down_iterate BufAC_Cmt_F i" |
|
123 |
apply (rule_tac x="%i. 2*i" in exI) |
|
124 |
apply (rule allI) |
|
125 |
apply (induct_tac "i") |
|
126 |
apply ( simp) |
|
127 |
apply (simp add: add_commute) |
|
128 |
apply (intro strip) |
|
129 |
apply (subst BufAC_Cmt_F_def3) |
|
130 |
apply (drule_tac P="%x. x" in BufAC_Cmt_F_def3 [THEN subst]) |
|
131 |
apply safe |
|
132 |
apply ( erule Buf_f_empty) |
|
133 |
apply ( erule Buf_f_d) |
|
134 |
apply ( drule Buf_f_d_req) |
|
135 |
apply ( safe, erule ssubst, simp) |
|
136 |
apply clarsimp |
|
137 |
apply (rename_tac i d xa ya t) |
|
138 |
(* |
|
139 |
1. \<And>i d xa ya t. |
|
140 |
\<lbrakk>f \<in> BufEq; |
|
141 |
\<forall>x s. s \<in> BufAC_Asm \<longrightarrow> |
|
142 |
x \<sqsubseteq> s \<longrightarrow> |
|
143 |
Fin (2 * i) < #x \<longrightarrow> |
|
144 |
(x, f\<cdot>x) \<in> down_iterate BufAC_Cmt_F i \<longrightarrow> |
|
145 |
(s, f\<cdot>s) \<in> down_iterate BufAC_Cmt_F i; |
|
146 |
Md d\<leadsto>\<bullet>\<leadsto>xa \<in> BufAC_Asm; Fin (2 * i) < #ya; f\<cdot>(Md d\<leadsto>\<bullet>\<leadsto>ya) = d\<leadsto>t; |
|
147 |
(ya, t) \<in> down_iterate BufAC_Cmt_F i; ya \<sqsubseteq> xa\<rbrakk> |
|
148 |
\<Longrightarrow> (xa, rt\<cdot>(f\<cdot>(Md d\<leadsto>\<bullet>\<leadsto>xa))) \<in> down_iterate BufAC_Cmt_F i |
|
149 |
*) |
|
150 |
apply (rotate_tac 2) |
|
151 |
apply (drule BufAC_Asm_prefix2) |
|
152 |
apply (frule Buf_f_d_req, erule exE, erule conjE, rotate_tac -1, erule ssubst) |
|
153 |
apply (frule Buf_f_d_req, erule exE, erule conjE) |
|
154 |
apply ( subgoal_tac "f\<cdot>(Md d\<leadsto>\<bullet>\<leadsto>ya) = d\<leadsto>ffa\<cdot>ya") |
|
155 |
prefer 2 |
|
156 |
apply ( assumption) |
|
157 |
apply ( rotate_tac -1) |
|
158 |
apply ( simp) |
|
159 |
apply (erule subst) |
|
160 |
(* |
|
161 |
1. \<And>i d xa ya t ff ffa. |
|
162 |
\<lbrakk>f\<cdot>(Md d\<leadsto>\<bullet>\<leadsto>ya) = d\<leadsto>ffa\<cdot>ya; Fin (2 * i) < #ya; |
|
163 |
(ya, ffa\<cdot>ya) \<in> down_iterate BufAC_Cmt_F i; ya \<sqsubseteq> xa; f \<in> BufEq; |
|
164 |
\<forall>x s. s \<in> BufAC_Asm \<longrightarrow> |
|
165 |
x \<sqsubseteq> s \<longrightarrow> |
|
166 |
Fin (2 * i) < #x \<longrightarrow> |
|
167 |
(x, f\<cdot>x) \<in> down_iterate BufAC_Cmt_F i \<longrightarrow> |
|
168 |
(s, f\<cdot>s) \<in> down_iterate BufAC_Cmt_F i; |
|
169 |
xa \<in> BufAC_Asm; ff \<in> BufEq; ffa \<in> BufEq\<rbrakk> |
|
170 |
\<Longrightarrow> (xa, ff\<cdot>xa) \<in> down_iterate BufAC_Cmt_F i |
|
171 |
*) |
|
172 |
apply (drule spec, drule spec, drule (1) mp) |
|
173 |
apply (drule (1) mp) |
|
174 |
apply (drule (1) mp) |
|
175 |
apply (erule impE) |
|
176 |
apply ( subst BufAC_Asm_cong, assumption) |
|
177 |
prefer 3 apply assumption |
|
178 |
apply assumption |
|
179 |
apply ( erule (1) BufAC_Asm_antiton [THEN antitonPD]) |
|
180 |
apply (subst BufAC_Asm_cong, assumption) |
|
181 |
prefer 3 apply assumption |
|
182 |
apply assumption |
|
183 |
apply assumption |
|
184 |
done |
|
185 |
||
186 |
lemma BufAC_Cmt_iterate_all: "(x\<in>BufAC_Cmt) = (\<forall>n. x\<in>down_iterate BufAC_Cmt_F n)" |
|
187 |
apply (unfold BufAC_Cmt_def) |
|
188 |
apply (subst cont_BufAC_Cmt_F [THEN INTER_down_iterate_is_gfp]) |
|
189 |
apply (fast) |
|
190 |
done |
|
191 |
||
192 |
(*adm_BufAC_Asm,BufAC_Asm_antiton,adm_non_BufAC_Asm,BufAC_Asm_cong, |
|
193 |
BufAC_Cmt_2stream_monoP*) |
|
194 |
lemma adm_BufAC: "f:BufEq ==> adm (%s. s:BufAC_Asm --> (s, f\<cdot>s):BufAC_Cmt)" |
|
195 |
apply (rule flatstream_admI) |
|
196 |
apply (subst BufAC_Cmt_iterate_all) |
|
197 |
apply (drule BufAC_Cmt_2stream_monoP) |
|
198 |
apply safe |
|
199 |
apply (drule spec, erule exE) |
|
200 |
apply (drule spec, erule impE) |
|
201 |
apply (erule BufAC_Asm_antiton [THEN antitonPD]) |
|
202 |
apply (erule is_ub_thelub) |
|
203 |
apply (tactic "smp_tac 3 1") |
|
204 |
apply (drule is_ub_thelub) |
|
205 |
apply (drule (1) mp) |
|
206 |
apply (drule (1) mp) |
|
207 |
apply (erule mp) |
|
208 |
apply (drule BufAC_Cmt_iterate_all [THEN iffD1]) |
|
209 |
apply (erule spec) |
|
210 |
done |
|
211 |
||
212 |
||
213 |
||
214 |
(**** Buf_Eq_imp_AC by induction **********************************************) |
|
215 |
||
216 |
(*adm_BufAC_Asm,BufAC_Asm_antiton,adm_non_BufAC_Asm,BufAC_Asm_cong, |
|
217 |
BufAC_Cmt_2stream_monoP,adm_BufAC,BufAC_Cmt_d_req*) |
|
218 |
lemma Buf_Eq_imp_AC: "BufEq <= BufAC" |
|
219 |
apply (unfold BufAC_def) |
|
220 |
apply (rule subsetI) |
|
221 |
apply (simp) |
|
222 |
apply (rule allI) |
|
223 |
apply (rule fstream_ind2) |
|
224 |
back |
|
225 |
apply ( erule adm_BufAC) |
|
226 |
apply ( safe) |
|
227 |
apply ( erule BufAC_Cmt_empty) |
|
228 |
apply ( erule BufAC_Cmt_d) |
|
229 |
apply ( drule BufAC_Asm_prefix2) |
|
230 |
apply ( simp) |
|
231 |
apply (fast intro: BufAC_Cmt_d_req BufAC_Asm_prefix2) |
|
232 |
done |
|
233 |
||
234 |
(**** new approach for admissibility, reduces itself to absurdity *************) |
|
235 |
||
236 |
lemma adm_BufAC_Asm: "adm (\<lambda>x. x\<in>BufAC_Asm)" |
|
237 |
apply (rule def_gfp_admI) |
|
19763 | 238 |
apply (rule BufAC_Asm_def [THEN eq_reflection]) |
19759 | 239 |
apply (safe) |
240 |
apply (unfold BufAC_Asm_F_def) |
|
241 |
apply (safe) |
|
242 |
apply (erule contrapos_np) |
|
243 |
apply (drule fstream_exhaust_eq [THEN iffD1]) |
|
244 |
apply (clarsimp) |
|
245 |
apply (drule (1) fstream_lub_lemma) |
|
246 |
apply (clarify) |
|
247 |
apply (erule_tac x="j" in all_dupE) |
|
248 |
apply (simp) |
|
249 |
apply (drule BufAC_Asm_d2) |
|
250 |
apply (clarify) |
|
251 |
apply (simp) |
|
252 |
apply (rule disjCI) |
|
253 |
apply (erule contrapos_np) |
|
254 |
apply (drule fstream_exhaust_eq [THEN iffD1]) |
|
255 |
apply (clarsimp) |
|
256 |
apply (drule (1) fstream_lub_lemma) |
|
257 |
apply (clarsimp) |
|
258 |
apply (tactic "simp_tac (HOL_basic_ss addsimps (ex_simps@all_simps RL[sym])) 1") |
|
259 |
apply (rule_tac x="Xa" in exI) |
|
260 |
apply (rule allI) |
|
261 |
apply (rotate_tac -1) |
|
262 |
apply (erule_tac x="i" in allE) |
|
263 |
apply (clarsimp) |
|
264 |
apply (erule_tac x="jb" in allE) |
|
265 |
apply (clarsimp) |
|
266 |
apply (erule_tac x="jc" in allE) |
|
267 |
apply (clarsimp dest!: BufAC_Asm_d3) |
|
268 |
done |
|
269 |
||
270 |
lemma adm_non_BufAC_Asm': "adm (\<lambda>u. u \<notin> BufAC_Asm)" (* uses antitonP *) |
|
271 |
apply (rule def_gfp_adm_nonP) |
|
19763 | 272 |
apply (rule BufAC_Asm_def [THEN eq_reflection]) |
19759 | 273 |
apply (unfold BufAC_Asm_F_def) |
274 |
apply (safe) |
|
275 |
apply (erule contrapos_np) |
|
276 |
apply (drule fstream_exhaust_eq [THEN iffD1]) |
|
277 |
apply (clarsimp) |
|
278 |
apply (frule fstream_prefix) |
|
279 |
apply (clarsimp) |
|
280 |
apply (frule BufAC_Asm_d2) |
|
281 |
apply (clarsimp) |
|
282 |
apply (rotate_tac -1) |
|
283 |
apply (erule contrapos_pp) |
|
284 |
apply (drule fstream_exhaust_eq [THEN iffD1]) |
|
285 |
apply (clarsimp) |
|
286 |
apply (frule fstream_prefix) |
|
287 |
apply (clarsimp) |
|
288 |
apply (frule BufAC_Asm_d3) |
|
289 |
apply (force) |
|
290 |
done |
|
291 |
||
292 |
lemma adm_BufAC': "f \<in> BufEq \<Longrightarrow> adm (\<lambda>u. u \<in> BufAC_Asm \<longrightarrow> (u, f\<cdot>u) \<in> BufAC_Cmt)" |
|
293 |
apply (rule triv_admI) |
|
294 |
apply (clarify) |
|
295 |
apply (erule (1) Buf_Eq_imp_AC_lemma) |
|
296 |
(* this is what we originally aimed to show, using admissibilty :-( *) |
|
297 |
done |
|
298 |
||
17293 | 299 |
end |
300 |
||
301 |