12516
|
1 |
(* Title: HOL/MicroJava/BV/Kildall_Lift.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Gerwin Klein
|
|
4 |
Copyright 2001 TUM
|
|
5 |
*)
|
|
6 |
|
|
7 |
theory Kildall_Lift = Kildall + Typing_Framework_err:
|
|
8 |
|
|
9 |
constdefs
|
|
10 |
app_mono :: "'s ord \<Rightarrow> (nat \<Rightarrow> 's \<Rightarrow> bool) \<Rightarrow> nat \<Rightarrow> 's set \<Rightarrow> bool"
|
|
11 |
"app_mono r app n A ==
|
|
12 |
\<forall>s p t. s \<in> A \<and> p < n \<and> s <=_r t \<longrightarrow> app p t \<longrightarrow> app p s"
|
|
13 |
|
|
14 |
succs_stable :: "'s ord \<Rightarrow> 's step_type \<Rightarrow> bool"
|
|
15 |
"succs_stable r step == \<forall>p t t'. map fst (step p t') = map fst (step p t)"
|
|
16 |
|
|
17 |
lemma succs_stableD:
|
|
18 |
"succs_stable r step \<Longrightarrow> map fst (step p t) = map fst (step p t')"
|
|
19 |
by (unfold succs_stable_def) blast
|
|
20 |
|
|
21 |
lemma eqsub_def [simp]: "a <=_(op =) b = (a = b)" by (simp add: lesub_def)
|
|
22 |
|
|
23 |
lemma list_le_eq [simp]: "\<And>b. a <=[op =] b = (a = b)"
|
|
24 |
apply (induct a)
|
|
25 |
apply simp
|
|
26 |
apply rule
|
|
27 |
apply simp
|
|
28 |
apply simp
|
|
29 |
apply (case_tac b)
|
|
30 |
apply simp
|
|
31 |
apply simp
|
|
32 |
done
|
|
33 |
|
|
34 |
lemma map_err: "map_err a = zip (map fst a) (map (\<lambda>x. Err) (map snd a))"
|
|
35 |
apply (induct a)
|
|
36 |
apply (auto simp add: map_err_def map_snd_def)
|
|
37 |
done
|
|
38 |
|
|
39 |
lemma map_snd: "map_snd f a = zip (map fst a) (map f (map snd a))"
|
|
40 |
apply (induct a)
|
|
41 |
apply (auto simp add: map_snd_def)
|
|
42 |
done
|
|
43 |
|
|
44 |
lemma zipI:
|
|
45 |
"\<And>b c d. a <=[r1] c \<Longrightarrow> b <=[r2] d \<Longrightarrow> zip a b <=[Product.le r1 r2] zip c d"
|
|
46 |
apply (induct a)
|
|
47 |
apply simp
|
|
48 |
apply (case_tac c)
|
|
49 |
apply simp
|
|
50 |
apply (case_tac b)
|
|
51 |
apply simp
|
|
52 |
apply (case_tac d)
|
|
53 |
apply simp
|
|
54 |
apply simp
|
|
55 |
done
|
|
56 |
|
|
57 |
lemma step_type_ord:
|
|
58 |
"\<And>b. a <=|r| b \<Longrightarrow> map snd a <=[r] map snd b \<and> map fst a = map fst b"
|
|
59 |
apply (induct a)
|
|
60 |
apply simp
|
|
61 |
apply (case_tac b)
|
|
62 |
apply simp
|
|
63 |
apply simp
|
|
64 |
apply (auto simp add: Product.le_def lesub_def)
|
|
65 |
done
|
|
66 |
|
|
67 |
lemma map_OK_Err:
|
|
68 |
"\<And>y. length y = length x \<Longrightarrow> map OK x <=[Err.le r] map (\<lambda>x. Err) y"
|
|
69 |
apply (induct x)
|
|
70 |
apply simp
|
|
71 |
apply simp
|
|
72 |
apply (case_tac y)
|
|
73 |
apply auto
|
|
74 |
done
|
|
75 |
|
|
76 |
lemma map_Err_Err:
|
|
77 |
"\<And>b. length a = length b \<Longrightarrow> map (\<lambda>x. Err) a <=[Err.le r] map (\<lambda>x. Err) b"
|
|
78 |
apply (induct a)
|
|
79 |
apply simp
|
|
80 |
apply (case_tac b)
|
|
81 |
apply auto
|
|
82 |
done
|
|
83 |
|
|
84 |
lemma succs_stable_length:
|
|
85 |
"succs_stable r step \<Longrightarrow> length (step p t) = length (step p t')"
|
|
86 |
proof -
|
|
87 |
assume "succs_stable r step"
|
|
88 |
hence "map fst (step p t) = map fst (step p t')" by (rule succs_stableD)
|
|
89 |
hence "length (map fst (step p t)) = length (map fst (step p t'))" by simp
|
|
90 |
thus ?thesis by simp
|
|
91 |
qed
|
|
92 |
|
|
93 |
lemma le_list_map_OK [simp]:
|
|
94 |
"\<And>b. map OK a <=[Err.le r] map OK b = (a <=[r] b)"
|
|
95 |
apply (induct a)
|
|
96 |
apply simp
|
|
97 |
apply simp
|
|
98 |
apply (case_tac b)
|
|
99 |
apply simp
|
|
100 |
apply simp
|
|
101 |
done
|
|
102 |
|
|
103 |
lemma mono_lift:
|
|
104 |
"order r \<Longrightarrow> succs_stable r step \<Longrightarrow> app_mono r app n A \<Longrightarrow>
|
|
105 |
\<forall>s p t. s \<in> A \<and> p < n \<and> s <=_r t \<longrightarrow> app p t \<longrightarrow> step p s <=|r| step p t \<Longrightarrow>
|
|
106 |
mono (Err.le r) (err_step app step) n (err A)"
|
|
107 |
apply (unfold app_mono_def mono_def err_step_def)
|
|
108 |
apply clarify
|
|
109 |
apply (case_tac s)
|
|
110 |
apply simp
|
|
111 |
apply (rule le_list_refl)
|
|
112 |
apply simp
|
|
113 |
apply simp
|
|
114 |
apply (subgoal_tac "map fst (step p arbitrary) = map fst (step p a)")
|
|
115 |
prefer 2
|
|
116 |
apply (erule succs_stableD)
|
|
117 |
apply (case_tac t)
|
|
118 |
apply simp
|
|
119 |
apply (rule conjI)
|
|
120 |
apply clarify
|
|
121 |
apply (simp add: map_err map_snd)
|
|
122 |
apply (rule zipI)
|
|
123 |
apply simp
|
|
124 |
apply (rule map_OK_Err)
|
|
125 |
apply (subgoal_tac "length (step p arbitrary) = length (step p a)")
|
|
126 |
prefer 2
|
|
127 |
apply (erule succs_stable_length)
|
|
128 |
apply simp
|
|
129 |
apply clarify
|
|
130 |
apply (simp add: map_err)
|
|
131 |
apply (rule zipI)
|
|
132 |
apply simp
|
|
133 |
apply (rule map_Err_Err)
|
|
134 |
apply simp
|
|
135 |
apply (erule succs_stable_length)
|
|
136 |
apply simp
|
|
137 |
apply (elim allE)
|
|
138 |
apply (erule impE, blast)+
|
|
139 |
apply (rule conjI)
|
|
140 |
apply clarify
|
|
141 |
apply (simp add: map_snd)
|
|
142 |
apply (rule zipI)
|
|
143 |
apply simp
|
|
144 |
apply (erule succs_stableD)
|
|
145 |
apply (simp add: step_type_ord)
|
|
146 |
apply clarify
|
|
147 |
apply (rule conjI)
|
|
148 |
apply clarify
|
|
149 |
apply (simp add: map_snd map_err)
|
|
150 |
apply (rule zipI)
|
|
151 |
apply simp
|
|
152 |
apply (erule succs_stableD)
|
|
153 |
apply (rule map_OK_Err)
|
|
154 |
apply (simp add: succs_stable_length)
|
|
155 |
apply clarify
|
|
156 |
apply (simp add: map_err)
|
|
157 |
apply (rule zipI)
|
|
158 |
apply simp
|
|
159 |
apply (erule succs_stableD)
|
|
160 |
apply (rule map_Err_Err)
|
|
161 |
apply (simp add: succs_stable_length)
|
|
162 |
done
|
|
163 |
|
|
164 |
lemma in_map_sndD: "(a,b) \<in> set (map_snd f xs) \<Longrightarrow> \<exists>b'. (a,b') \<in> set xs"
|
|
165 |
apply (induct xs)
|
|
166 |
apply (auto simp add: map_snd_def)
|
|
167 |
done
|
|
168 |
|
|
169 |
lemma bounded_lift:
|
|
170 |
"bounded (err_step app step) n = bounded step n"
|
|
171 |
apply (unfold bounded_def err_step_def)
|
|
172 |
apply rule
|
|
173 |
apply clarify
|
|
174 |
apply (erule allE, erule impE, assumption)
|
|
175 |
apply (erule_tac x = "OK s" in allE)
|
|
176 |
apply simp
|
|
177 |
apply (case_tac "app p s")
|
|
178 |
apply (simp add: map_snd_def)
|
|
179 |
apply (drule bspec, assumption)
|
|
180 |
apply simp
|
|
181 |
apply (simp add: map_err_def map_snd_def)
|
|
182 |
apply (drule bspec, assumption)
|
|
183 |
apply simp
|
|
184 |
apply clarify
|
|
185 |
apply (case_tac s)
|
|
186 |
apply simp
|
|
187 |
apply (simp add: map_err_def)
|
|
188 |
apply (blast dest: in_map_sndD)
|
|
189 |
apply (simp split: split_if_asm)
|
|
190 |
apply (blast dest: in_map_sndD)
|
|
191 |
apply (simp add: map_err_def)
|
|
192 |
apply (blast dest: in_map_sndD)
|
|
193 |
done
|
|
194 |
|
|
195 |
lemma set_zipD: "\<And>y. (a,b) \<in> set (zip x y) \<Longrightarrow> (a \<in> set x \<and> b \<in> set y)"
|
|
196 |
apply (induct x)
|
|
197 |
apply simp
|
|
198 |
apply (case_tac y)
|
|
199 |
apply simp
|
|
200 |
apply simp
|
|
201 |
apply blast
|
|
202 |
done
|
|
203 |
|
|
204 |
lemma pres_type_lift:
|
|
205 |
"\<forall>s\<in>A. \<forall>p. p < n \<longrightarrow> app p s \<longrightarrow> (\<forall>(q, s')\<in>set (step p s). s' \<in> A)
|
|
206 |
\<Longrightarrow> pres_type (err_step app step) n (err A)"
|
|
207 |
apply (unfold pres_type_def err_step_def)
|
|
208 |
apply clarify
|
|
209 |
apply (case_tac b)
|
|
210 |
apply simp
|
|
211 |
apply (case_tac s)
|
|
212 |
apply (simp add: map_err)
|
|
213 |
apply (drule set_zipD)
|
|
214 |
apply clarify
|
|
215 |
apply simp
|
|
216 |
apply blast
|
|
217 |
apply (simp add: map_err split: split_if_asm)
|
|
218 |
apply (simp add: map_snd_def)
|
|
219 |
apply fastsimp
|
|
220 |
apply (drule set_zipD)
|
|
221 |
apply simp
|
|
222 |
apply blast
|
|
223 |
done
|
|
224 |
|
|
225 |
end
|