author | nipkow |
Fri, 21 Sep 2012 13:39:30 +0200 | |
changeset 49496 | 2694d1615eef |
parent 49399 | a9d9f3483b71 |
child 49547 | 78be750222cf |
permissions | -rw-r--r-- |
47613 | 1 |
(* Author: Tobias Nipkow *) |
2 |
||
3 |
theory Abs_Int3 |
|
4 |
imports Abs_Int2_ivl |
|
5 |
begin |
|
6 |
||
7 |
subsubsection "Welltypedness" |
|
8 |
||
49396 | 9 |
class Lc = |
10 |
fixes Lc :: "com \<Rightarrow> 'a set" |
|
47613 | 11 |
|
49396 | 12 |
instantiation st :: (type)Lc |
47613 | 13 |
begin |
14 |
||
49396 | 15 |
definition Lc_st :: "com \<Rightarrow> 'a st set" where |
16 |
"Lc_st c = L (vars c)" |
|
47613 | 17 |
|
18 |
instance .. |
|
19 |
||
20 |
end |
|
21 |
||
49396 | 22 |
instantiation acom :: (Lc)Lc |
47613 | 23 |
begin |
24 |
||
49396 | 25 |
definition Lc_acom :: "com \<Rightarrow> 'a acom set" where |
26 |
"Lc c = {C. strip C = c \<and> (\<forall>a\<in>set(annos C). a \<in> Lc c)}" |
|
47613 | 27 |
|
28 |
instance .. |
|
29 |
||
30 |
end |
|
31 |
||
49396 | 32 |
instantiation option :: (Lc)Lc |
47613 | 33 |
begin |
34 |
||
49396 | 35 |
definition Lc_option :: "com \<Rightarrow> 'a option set" where |
36 |
"Lc c = {None} \<union> Some ` Lc c" |
|
37 |
||
38 |
lemma Lc_option_simps[simp]: "None \<in> Lc c" "(Some x \<in> Lc c) = (x \<in> Lc c)" |
|
39 |
by(auto simp: Lc_option_def) |
|
47613 | 40 |
|
41 |
instance .. |
|
42 |
||
43 |
end |
|
44 |
||
49396 | 45 |
lemma Lc_option_iff_wt[simp]: fixes a :: "_ st option" |
46 |
shows "(a \<in> Lc c) = (a \<in> L (vars c))" |
|
47 |
by(auto simp add: L_option_def Lc_st_def split: option.splits) |
|
47613 | 48 |
|
49 |
||
50 |
context Abs_Int1 |
|
51 |
begin |
|
52 |
||
49396 | 53 |
lemma step'_in_Lc: "C \<in> Lc c \<Longrightarrow> S \<in> Lc c \<Longrightarrow> step' S C \<in> Lc c" |
54 |
apply(auto simp add: Lc_acom_def) |
|
55 |
by(metis step'_in_L[simplified L_acom_def mem_Collect_eq] order_refl) |
|
47613 | 56 |
|
57 |
end |
|
58 |
||
59 |
||
60 |
subsection "Widening and Narrowing" |
|
61 |
||
62 |
class widen = |
|
63 |
fixes widen :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infix "\<nabla>" 65) |
|
64 |
||
65 |
class narrow = |
|
66 |
fixes narrow :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infix "\<triangle>" 65) |
|
67 |
||
68 |
class WN = widen + narrow + preord + |
|
69 |
assumes widen1: "x \<sqsubseteq> x \<nabla> y" |
|
70 |
assumes widen2: "y \<sqsubseteq> x \<nabla> y" |
|
71 |
assumes narrow1: "y \<sqsubseteq> x \<Longrightarrow> y \<sqsubseteq> x \<triangle> y" |
|
72 |
assumes narrow2: "y \<sqsubseteq> x \<Longrightarrow> x \<triangle> y \<sqsubseteq> x" |
|
73 |
||
49396 | 74 |
class WN_Lc = widen + narrow + preord + Lc + |
75 |
assumes widen1: "x \<in> Lc c \<Longrightarrow> y \<in> Lc c \<Longrightarrow> x \<sqsubseteq> x \<nabla> y" |
|
76 |
assumes widen2: "x \<in> Lc c \<Longrightarrow> y \<in> Lc c \<Longrightarrow> y \<sqsubseteq> x \<nabla> y" |
|
47613 | 77 |
assumes narrow1: "y \<sqsubseteq> x \<Longrightarrow> y \<sqsubseteq> x \<triangle> y" |
78 |
assumes narrow2: "y \<sqsubseteq> x \<Longrightarrow> x \<triangle> y \<sqsubseteq> x" |
|
49396 | 79 |
assumes Lc_widen[simp]: "x \<in> Lc c \<Longrightarrow> y \<in> Lc c \<Longrightarrow> x \<nabla> y \<in> Lc c" |
80 |
assumes Lc_narrow[simp]: "x \<in> Lc c \<Longrightarrow> y \<in> Lc c \<Longrightarrow> x \<triangle> y \<in> Lc c" |
|
47613 | 81 |
|
82 |
||
83 |
instantiation ivl :: WN |
|
84 |
begin |
|
85 |
||
86 |
definition "widen_ivl ivl1 ivl2 = |
|
87 |
((*if is_empty ivl1 then ivl2 else |
|
88 |
if is_empty ivl2 then ivl1 else*) |
|
89 |
case (ivl1,ivl2) of (I l1 h1, I l2 h2) \<Rightarrow> |
|
90 |
I (if le_option False l2 l1 \<and> l2 \<noteq> l1 then None else l1) |
|
91 |
(if le_option True h1 h2 \<and> h1 \<noteq> h2 then None else h1))" |
|
92 |
||
93 |
definition "narrow_ivl ivl1 ivl2 = |
|
94 |
((*if is_empty ivl1 \<or> is_empty ivl2 then empty else*) |
|
95 |
case (ivl1,ivl2) of (I l1 h1, I l2 h2) \<Rightarrow> |
|
96 |
I (if l1 = None then l2 else l1) |
|
97 |
(if h1 = None then h2 else h1))" |
|
98 |
||
99 |
instance |
|
100 |
proof qed |
|
101 |
(auto simp add: widen_ivl_def narrow_ivl_def le_option_def le_ivl_def empty_def split: ivl.split option.split if_splits) |
|
102 |
||
103 |
end |
|
104 |
||
105 |
||
49396 | 106 |
instantiation st :: (WN)WN_Lc |
47613 | 107 |
begin |
108 |
||
109 |
definition "widen_st F1 F2 = FunDom (\<lambda>x. fun F1 x \<nabla> fun F2 x) (dom F1)" |
|
110 |
||
111 |
definition "narrow_st F1 F2 = FunDom (\<lambda>x. fun F1 x \<triangle> fun F2 x) (dom F1)" |
|
112 |
||
113 |
instance |
|
114 |
proof |
|
115 |
case goal1 thus ?case |
|
116 |
by(simp add: widen_st_def le_st_def WN_class.widen1) |
|
117 |
next |
|
118 |
case goal2 thus ?case |
|
49396 | 119 |
by(simp add: widen_st_def le_st_def WN_class.widen2 Lc_st_def L_st_def) |
47613 | 120 |
next |
121 |
case goal3 thus ?case |
|
122 |
by(auto simp: narrow_st_def le_st_def WN_class.narrow1) |
|
123 |
next |
|
124 |
case goal4 thus ?case |
|
125 |
by(auto simp: narrow_st_def le_st_def WN_class.narrow2) |
|
126 |
next |
|
49396 | 127 |
case goal5 thus ?case by(auto simp: widen_st_def Lc_st_def L_st_def) |
47613 | 128 |
next |
49396 | 129 |
case goal6 thus ?case by(auto simp: narrow_st_def Lc_st_def L_st_def) |
47613 | 130 |
qed |
131 |
||
132 |
end |
|
133 |
||
134 |
||
49396 | 135 |
instantiation option :: (WN_Lc)WN_Lc |
47613 | 136 |
begin |
137 |
||
138 |
fun widen_option where |
|
139 |
"None \<nabla> x = x" | |
|
140 |
"x \<nabla> None = x" | |
|
141 |
"(Some x) \<nabla> (Some y) = Some(x \<nabla> y)" |
|
142 |
||
143 |
fun narrow_option where |
|
144 |
"None \<triangle> x = None" | |
|
145 |
"x \<triangle> None = None" | |
|
146 |
"(Some x) \<triangle> (Some y) = Some(x \<triangle> y)" |
|
147 |
||
148 |
instance |
|
149 |
proof |
|
150 |
case goal1 thus ?case |
|
151 |
by(induct x y rule: widen_option.induct)(simp_all add: widen1) |
|
152 |
next |
|
153 |
case goal2 thus ?case |
|
154 |
by(induct x y rule: widen_option.induct)(simp_all add: widen2) |
|
155 |
next |
|
156 |
case goal3 thus ?case |
|
157 |
by(induct x y rule: narrow_option.induct) (simp_all add: narrow1) |
|
158 |
next |
|
159 |
case goal4 thus ?case |
|
160 |
by(induct x y rule: narrow_option.induct) (simp_all add: narrow2) |
|
161 |
next |
|
162 |
case goal5 thus ?case |
|
49396 | 163 |
by(induction x y rule: widen_option.induct)(auto simp: Lc_st_def) |
47613 | 164 |
next |
165 |
case goal6 thus ?case |
|
49396 | 166 |
by(induction x y rule: narrow_option.induct)(auto simp: Lc_st_def) |
47613 | 167 |
qed |
168 |
||
169 |
end |
|
170 |
||
171 |
||
172 |
fun map2_acom :: "('a \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> 'a acom \<Rightarrow> 'a acom \<Rightarrow> 'a acom" where |
|
173 |
"map2_acom f (SKIP {a1}) (SKIP {a2}) = (SKIP {f a1 a2})" | |
|
174 |
"map2_acom f (x ::= e {a1}) (x' ::= e' {a2}) = (x ::= e {f a1 a2})" | |
|
175 |
"map2_acom f (C1;C2) (D1;D2) = (map2_acom f C1 D1; map2_acom f C2 D2)" | |
|
49095 | 176 |
"map2_acom f (IF b THEN {p1} C1 ELSE {p2} C2 {a1}) (IF b' THEN {q1} D1 ELSE {q2} D2 {a2}) = |
177 |
(IF b THEN {f p1 q1} map2_acom f C1 D1 ELSE {f p2 q2} map2_acom f C2 D2 {f a1 a2})" | |
|
178 |
"map2_acom f ({a1} WHILE b DO {p} C {a2}) ({a3} WHILE b' DO {p'} C' {a4}) = |
|
179 |
({f a1 a3} WHILE b DO {f p p'} map2_acom f C C' {f a2 a4})" |
|
47613 | 180 |
|
49396 | 181 |
instantiation acom :: (WN_Lc)WN_Lc |
47613 | 182 |
begin |
183 |
||
184 |
definition "widen_acom = map2_acom (op \<nabla>)" |
|
185 |
||
186 |
definition "narrow_acom = map2_acom (op \<triangle>)" |
|
187 |
||
188 |
lemma widen_acom1: |
|
49396 | 189 |
"\<lbrakk>\<forall>a\<in>set(annos x). a \<in> Lc c; \<forall>a\<in>set (annos y). a \<in> Lc c; strip x = strip y\<rbrakk> |
47613 | 190 |
\<Longrightarrow> x \<sqsubseteq> x \<nabla> y" |
191 |
by(induct x y rule: le_acom.induct) |
|
49396 | 192 |
(auto simp: widen_acom_def widen1 Lc_acom_def) |
47613 | 193 |
|
194 |
lemma widen_acom2: |
|
49396 | 195 |
"\<lbrakk>\<forall>a\<in>set(annos x). a \<in> Lc c; \<forall>a\<in>set (annos y). a \<in> Lc c; strip x = strip y\<rbrakk> |
47613 | 196 |
\<Longrightarrow> y \<sqsubseteq> x \<nabla> y" |
197 |
by(induct x y rule: le_acom.induct) |
|
49396 | 198 |
(auto simp: widen_acom_def widen2 Lc_acom_def) |
47613 | 199 |
|
200 |
lemma strip_map2_acom[simp]: |
|
201 |
"strip C1 = strip C2 \<Longrightarrow> strip(map2_acom f C1 C2) = strip C1" |
|
202 |
by(induct f C1 C2 rule: map2_acom.induct) simp_all |
|
203 |
||
204 |
lemma strip_widen_acom[simp]: |
|
205 |
"strip C1 = strip C2 \<Longrightarrow> strip(C1 \<nabla> C2) = strip C1" |
|
206 |
by(simp add: widen_acom_def strip_map2_acom) |
|
207 |
||
208 |
lemma strip_narrow_acom[simp]: |
|
209 |
"strip C1 = strip C2 \<Longrightarrow> strip(C1 \<triangle> C2) = strip C1" |
|
210 |
by(simp add: narrow_acom_def strip_map2_acom) |
|
211 |
||
212 |
lemma annos_map2_acom[simp]: "strip C2 = strip C1 \<Longrightarrow> |
|
213 |
annos(map2_acom f C1 C2) = map (%(x,y).f x y) (zip (annos C1) (annos C2))" |
|
214 |
by(induction f C1 C2 rule: map2_acom.induct)(simp_all add: size_annos_same2) |
|
215 |
||
216 |
instance |
|
217 |
proof |
|
49396 | 218 |
case goal1 thus ?case by(auto simp: Lc_acom_def widen_acom1) |
47613 | 219 |
next |
49396 | 220 |
case goal2 thus ?case by(auto simp: Lc_acom_def widen_acom2) |
47613 | 221 |
next |
222 |
case goal3 thus ?case |
|
223 |
by(induct x y rule: le_acom.induct)(simp_all add: narrow_acom_def narrow1) |
|
224 |
next |
|
225 |
case goal4 thus ?case |
|
226 |
by(induct x y rule: le_acom.induct)(simp_all add: narrow_acom_def narrow2) |
|
227 |
next |
|
228 |
case goal5 thus ?case |
|
49396 | 229 |
by(auto simp: Lc_acom_def widen_acom_def split_conv elim!: in_set_zipE) |
47613 | 230 |
next |
231 |
case goal6 thus ?case |
|
49396 | 232 |
by(auto simp: Lc_acom_def narrow_acom_def split_conv elim!: in_set_zipE) |
47613 | 233 |
qed |
234 |
||
235 |
end |
|
236 |
||
49396 | 237 |
lemma widen_o_in_L[simp]: fixes x1 x2 :: "_ st option" |
238 |
shows "x1 \<in> L X \<Longrightarrow> x2 \<in> L X \<Longrightarrow> x1 \<nabla> x2 \<in> L X" |
|
47613 | 239 |
by(induction x1 x2 rule: widen_option.induct) |
49396 | 240 |
(simp_all add: widen_st_def L_st_def) |
47613 | 241 |
|
49396 | 242 |
lemma narrow_o_in_L[simp]: fixes x1 x2 :: "_ st option" |
243 |
shows "x1 \<in> L X \<Longrightarrow> x2 \<in> L X \<Longrightarrow> x1 \<triangle> x2 \<in> L X" |
|
47613 | 244 |
by(induction x1 x2 rule: narrow_option.induct) |
49396 | 245 |
(simp_all add: narrow_st_def L_st_def) |
47613 | 246 |
|
49396 | 247 |
lemma widen_c_in_L: fixes C1 C2 :: "_ st option acom" |
248 |
shows "strip C1 = strip C2 \<Longrightarrow> C1 \<in> L X \<Longrightarrow> C2 \<in> L X \<Longrightarrow> C1 \<nabla> C2 \<in> L X" |
|
47613 | 249 |
by(induction C1 C2 rule: le_acom.induct) |
250 |
(auto simp: widen_acom_def) |
|
251 |
||
49396 | 252 |
lemma narrow_c_in_L: fixes C1 C2 :: "_ st option acom" |
253 |
shows "strip C1 = strip C2 \<Longrightarrow> C1 \<in> L X \<Longrightarrow> C2 \<in> L X \<Longrightarrow> C1 \<triangle> C2 \<in> L X" |
|
47613 | 254 |
by(induction C1 C2 rule: le_acom.induct) |
255 |
(auto simp: narrow_acom_def) |
|
256 |
||
49396 | 257 |
lemma bot_in_Lc[simp]: "bot c \<in> Lc c" |
258 |
by(simp add: Lc_acom_def bot_def) |
|
47613 | 259 |
|
260 |
||
261 |
subsubsection "Post-fixed point computation" |
|
262 |
||
263 |
definition iter_widen :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> ('a::{preord,widen})option" |
|
264 |
where "iter_widen f = while_option (\<lambda>c. \<not> f c \<sqsubseteq> c) (\<lambda>c. c \<nabla> f c)" |
|
265 |
||
266 |
definition iter_narrow :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> ('a::{preord,narrow})option" |
|
267 |
where "iter_narrow f = while_option (\<lambda>c. \<not> c \<sqsubseteq> c \<triangle> f c) (\<lambda>c. c \<triangle> f c)" |
|
268 |
||
49396 | 269 |
definition pfp_wn :: "(('a::WN_Lc option acom) \<Rightarrow> 'a option acom) \<Rightarrow> com \<Rightarrow> 'a option acom option" |
47613 | 270 |
where "pfp_wn f c = |
271 |
(case iter_widen f (bot c) of None \<Rightarrow> None | Some c' \<Rightarrow> iter_narrow f c')" |
|
272 |
||
273 |
||
274 |
lemma iter_widen_pfp: "iter_widen f c = Some c' \<Longrightarrow> f c' \<sqsubseteq> c'" |
|
275 |
by(auto simp add: iter_widen_def dest: while_option_stop) |
|
276 |
||
277 |
lemma iter_widen_inv: |
|
278 |
assumes "!!x. P x \<Longrightarrow> P(f x)" "!!x1 x2. P x1 \<Longrightarrow> P x2 \<Longrightarrow> P(x1 \<nabla> x2)" and "P x" |
|
279 |
and "iter_widen f x = Some y" shows "P y" |
|
280 |
using while_option_rule[where P = "P", OF _ assms(4)[unfolded iter_widen_def]] |
|
281 |
by (blast intro: assms(1-3)) |
|
282 |
||
283 |
lemma strip_while: fixes f :: "'a acom \<Rightarrow> 'a acom" |
|
284 |
assumes "\<forall>C. strip (f C) = strip C" and "while_option P f C = Some C'" |
|
285 |
shows "strip C' = strip C" |
|
286 |
using while_option_rule[where P = "\<lambda>C'. strip C' = strip C", OF _ assms(2)] |
|
287 |
by (metis assms(1)) |
|
288 |
||
49396 | 289 |
lemma strip_iter_widen: fixes f :: "'a::WN_Lc acom \<Rightarrow> 'a acom" |
47613 | 290 |
assumes "\<forall>C. strip (f C) = strip C" and "iter_widen f C = Some C'" |
291 |
shows "strip C' = strip C" |
|
292 |
proof- |
|
293 |
have "\<forall>C. strip(C \<nabla> f C) = strip C" |
|
294 |
by (metis assms(1) strip_map2_acom widen_acom_def) |
|
295 |
from strip_while[OF this] assms(2) show ?thesis by(simp add: iter_widen_def) |
|
296 |
qed |
|
297 |
||
298 |
lemma iter_narrow_pfp: |
|
49396 | 299 |
assumes mono: "!!c1 c2::_::WN_Lc. P c1 \<Longrightarrow> P c2 \<Longrightarrow> c1 \<sqsubseteq> c2 \<Longrightarrow> f c1 \<sqsubseteq> f c2" |
47613 | 300 |
and Pinv: "!!c. P c \<Longrightarrow> P(f c)" "!!c1 c2. P c1 \<Longrightarrow> P c2 \<Longrightarrow> P(c1 \<triangle> c2)" and "P c0" |
301 |
and "f c0 \<sqsubseteq> c0" and "iter_narrow f c0 = Some c" |
|
302 |
shows "P c \<and> f c \<sqsubseteq> c" |
|
303 |
proof- |
|
304 |
let ?Q = "%c. P c \<and> f c \<sqsubseteq> c \<and> c \<sqsubseteq> c0" |
|
305 |
{ fix c assume "?Q c" |
|
306 |
note P = conjunct1[OF this] and 12 = conjunct2[OF this] |
|
307 |
note 1 = conjunct1[OF 12] and 2 = conjunct2[OF 12] |
|
308 |
let ?c' = "c \<triangle> f c" |
|
309 |
have "?Q ?c'" |
|
310 |
proof auto |
|
311 |
show "P ?c'" by (blast intro: P Pinv) |
|
312 |
have "f ?c' \<sqsubseteq> f c" by(rule mono[OF `P (c \<triangle> f c)` P narrow2[OF 1]]) |
|
313 |
also have "\<dots> \<sqsubseteq> ?c'" by(rule narrow1[OF 1]) |
|
314 |
finally show "f ?c' \<sqsubseteq> ?c'" . |
|
315 |
have "?c' \<sqsubseteq> c" by (rule narrow2[OF 1]) |
|
316 |
also have "c \<sqsubseteq> c0" by(rule 2) |
|
317 |
finally show "?c' \<sqsubseteq> c0" . |
|
318 |
qed |
|
319 |
} |
|
320 |
thus ?thesis |
|
321 |
using while_option_rule[where P = ?Q, OF _ assms(6)[simplified iter_narrow_def]] |
|
322 |
by (blast intro: assms(4,5) le_refl) |
|
323 |
qed |
|
324 |
||
325 |
lemma pfp_wn_pfp: |
|
49396 | 326 |
assumes mono: "!!c1 c2::_::WN_Lc option acom. P c1 \<Longrightarrow> P c2 \<Longrightarrow> c1 \<sqsubseteq> c2 \<Longrightarrow> f c1 \<sqsubseteq> f c2" |
47613 | 327 |
and Pinv: "P (bot c)" "!!c. P c \<Longrightarrow> P(f c)" |
328 |
"!!c1 c2. P c1 \<Longrightarrow> P c2 \<Longrightarrow> P(c1 \<nabla> c2)" |
|
329 |
"!!c1 c2. P c1 \<Longrightarrow> P c2 \<Longrightarrow> P(c1 \<triangle> c2)" |
|
330 |
and pfp_wn: "pfp_wn f c = Some c'" shows "P c' \<and> f c' \<sqsubseteq> c'" |
|
331 |
proof- |
|
332 |
from pfp_wn obtain p |
|
333 |
where its: "iter_widen f (bot c) = Some p" "iter_narrow f p = Some c'" |
|
334 |
by(auto simp: pfp_wn_def split: option.splits) |
|
335 |
have "P p" by (blast intro: iter_widen_inv[where P="P"] its(1) Pinv(1-3)) |
|
336 |
thus ?thesis |
|
337 |
by - (assumption | |
|
338 |
rule iter_narrow_pfp[where P=P] mono Pinv(2,4) iter_widen_pfp its)+ |
|
339 |
qed |
|
340 |
||
341 |
lemma strip_pfp_wn: |
|
342 |
"\<lbrakk> \<forall>c. strip(f c) = strip c; pfp_wn f c = Some c' \<rbrakk> \<Longrightarrow> strip c' = c" |
|
343 |
by(auto simp add: pfp_wn_def iter_narrow_def split: option.splits) |
|
344 |
(metis (no_types) narrow_acom_def strip_bot strip_iter_widen strip_map2_acom strip_while) |
|
345 |
||
346 |
||
347 |
locale Abs_Int2 = Abs_Int1_mono |
|
49396 | 348 |
where \<gamma>=\<gamma> for \<gamma> :: "'av::{WN,lattice} \<Rightarrow> val set" |
47613 | 349 |
begin |
350 |
||
351 |
definition AI_wn :: "com \<Rightarrow> 'av st option acom option" where |
|
352 |
"AI_wn c = pfp_wn (step' (top c)) c" |
|
353 |
||
354 |
lemma AI_wn_sound: "AI_wn c = Some C \<Longrightarrow> CS c \<le> \<gamma>\<^isub>c C" |
|
355 |
proof(simp add: CS_def AI_wn_def) |
|
356 |
assume 1: "pfp_wn (step' (top c)) c = Some C" |
|
49396 | 357 |
have 2: "(strip C = c & C \<in> L(vars c)) \<and> step' \<top>\<^bsub>c\<^esub> C \<sqsubseteq> C" |
47613 | 358 |
by(rule pfp_wn_pfp[where c=c]) |
49396 | 359 |
(simp_all add: 1 mono_step'_top widen_c_in_L narrow_c_in_L) |
47613 | 360 |
have 3: "strip (\<gamma>\<^isub>c (step' \<top>\<^bsub>c\<^esub> C)) = c" by(simp add: strip_pfp_wn[OF _ 1]) |
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47613
diff
changeset
|
361 |
have "lfp c (step UNIV) \<le> \<gamma>\<^isub>c (step' \<top>\<^bsub>c\<^esub> C)" |
47613 | 362 |
proof(rule lfp_lowerbound[simplified,OF 3]) |
363 |
show "step UNIV (\<gamma>\<^isub>c (step' \<top>\<^bsub>c\<^esub> C)) \<le> \<gamma>\<^isub>c (step' \<top>\<^bsub>c\<^esub> C)" |
|
49396 | 364 |
proof(rule step_preserves_le[OF _ _ _ top_in_L]) |
47613 | 365 |
show "UNIV \<subseteq> \<gamma>\<^isub>o \<top>\<^bsub>c\<^esub>" by simp |
366 |
show "\<gamma>\<^isub>c (step' \<top>\<^bsub>c\<^esub> C) \<le> \<gamma>\<^isub>c C" by(rule mono_gamma_c[OF conjunct2[OF 2]]) |
|
49396 | 367 |
show "C \<in> L(vars c)" using 2 by blast |
47613 | 368 |
qed |
369 |
qed |
|
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47613
diff
changeset
|
370 |
from this 2 show "lfp c (step UNIV) \<le> \<gamma>\<^isub>c C" |
47613 | 371 |
by (blast intro: mono_gamma_c order_trans) |
372 |
qed |
|
373 |
||
374 |
end |
|
375 |
||
376 |
interpretation Abs_Int2 |
|
377 |
where \<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = plus_ivl |
|
378 |
and test_num' = in_ivl |
|
379 |
and filter_plus' = filter_plus_ivl and filter_less' = filter_less_ivl |
|
380 |
defines AI_ivl' is AI_wn |
|
381 |
.. |
|
382 |
||
383 |
||
384 |
subsubsection "Tests" |
|
385 |
||
49399 | 386 |
(* Trick to make the code generator happy. *) |
49396 | 387 |
lemma [code]: "equal_class.equal (x::'a st) y = equal_class.equal x y" |
388 |
by(rule refl) |
|
389 |
||
47613 | 390 |
definition "step_up_ivl n = |
391 |
((\<lambda>C. C \<nabla> step_ivl (top(strip C)) C)^^n)" |
|
392 |
definition "step_down_ivl n = |
|
393 |
((\<lambda>C. C \<triangle> step_ivl (top (strip C)) C)^^n)" |
|
394 |
||
395 |
text{* For @{const test3_ivl}, @{const AI_ivl} needed as many iterations as |
|
396 |
the loop took to execute. In contrast, @{const AI_ivl'} converges in a |
|
397 |
constant number of steps: *} |
|
398 |
||
399 |
value "show_acom (step_up_ivl 1 (bot test3_ivl))" |
|
400 |
value "show_acom (step_up_ivl 2 (bot test3_ivl))" |
|
401 |
value "show_acom (step_up_ivl 3 (bot test3_ivl))" |
|
402 |
value "show_acom (step_up_ivl 4 (bot test3_ivl))" |
|
403 |
value "show_acom (step_up_ivl 5 (bot test3_ivl))" |
|
49188 | 404 |
value "show_acom (step_up_ivl 6 (bot test3_ivl))" |
405 |
value "show_acom (step_up_ivl 7 (bot test3_ivl))" |
|
406 |
value "show_acom (step_up_ivl 8 (bot test3_ivl))" |
|
407 |
value "show_acom (step_down_ivl 1 (step_up_ivl 8 (bot test3_ivl)))" |
|
408 |
value "show_acom (step_down_ivl 2 (step_up_ivl 8 (bot test3_ivl)))" |
|
409 |
value "show_acom (step_down_ivl 3 (step_up_ivl 8 (bot test3_ivl)))" |
|
410 |
value "show_acom (step_down_ivl 4 (step_up_ivl 8 (bot test3_ivl)))" |
|
47613 | 411 |
value "show_acom_opt (AI_ivl' test3_ivl)" |
412 |
||
413 |
||
414 |
text{* Now all the analyses terminate: *} |
|
415 |
||
416 |
value "show_acom_opt (AI_ivl' test4_ivl)" |
|
417 |
value "show_acom_opt (AI_ivl' test5_ivl)" |
|
418 |
value "show_acom_opt (AI_ivl' test6_ivl)" |
|
419 |
||
420 |
||
421 |
subsubsection "Generic Termination Proof" |
|
422 |
||
423 |
locale Abs_Int2_measure = Abs_Int2 |
|
49396 | 424 |
where \<gamma>=\<gamma> for \<gamma> :: "'av::{WN,lattice} \<Rightarrow> val set" + |
47613 | 425 |
fixes m :: "'av \<Rightarrow> nat" |
426 |
fixes n :: "'av \<Rightarrow> nat" |
|
427 |
fixes h :: "nat" |
|
428 |
assumes m_anti_mono: "x \<sqsubseteq> y \<Longrightarrow> m x \<ge> m y" |
|
429 |
assumes m_widen: "~ y \<sqsubseteq> x \<Longrightarrow> m(x \<nabla> y) < m x" |
|
430 |
assumes m_height: "m x \<le> h" |
|
431 |
assumes n_mono: "x \<sqsubseteq> y \<Longrightarrow> n x \<le> n y" |
|
432 |
assumes n_narrow: "~ x \<sqsubseteq> x \<triangle> y \<Longrightarrow> n(x \<triangle> y) < n x" |
|
433 |
||
434 |
begin |
|
435 |
||
436 |
definition "m_st S = (SUM x:dom S. m(fun S x))" |
|
437 |
||
49496 | 438 |
lemma m_st_h: "x \<in> L X \<Longrightarrow> finite X \<Longrightarrow> m_st x \<le> h * card X" |
439 |
by(simp add: L_st_def m_st_def) |
|
440 |
(metis nat_mult_commute of_nat_id setsum_bounded[OF m_height]) |
|
47613 | 441 |
|
442 |
lemma m_st_anti_mono: "S1 \<sqsubseteq> S2 \<Longrightarrow> m_st S1 \<ge> m_st S2" |
|
443 |
proof(auto simp add: le_st_def m_st_def) |
|
444 |
assume "\<forall>x\<in>dom S2. fun S1 x \<sqsubseteq> fun S2 x" |
|
445 |
hence "\<forall>x\<in>dom S2. m(fun S1 x) \<ge> m(fun S2 x)" by (metis m_anti_mono) |
|
446 |
thus "(\<Sum>x\<in>dom S2. m (fun S2 x)) \<le> (\<Sum>x\<in>dom S2. m (fun S1 x))" |
|
447 |
by (metis setsum_mono) |
|
448 |
qed |
|
449 |
||
49396 | 450 |
lemma m_st_widen: "S1 \<in> L X \<Longrightarrow> S2 \<in> L X \<Longrightarrow> finite X \<Longrightarrow> |
47613 | 451 |
~ S2 \<sqsubseteq> S1 \<Longrightarrow> m_st(S1 \<nabla> S2) < m_st S1" |
49396 | 452 |
proof(auto simp add: le_st_def m_st_def L_st_def widen_st_def) |
47613 | 453 |
assume "finite(dom S1)" |
454 |
have 1: "\<forall>x\<in>dom S1. m(fun S1 x) \<ge> m(fun S1 x \<nabla> fun S2 x)" |
|
455 |
by (metis m_anti_mono WN_class.widen1) |
|
456 |
fix x assume "x \<in> dom S1" "\<not> fun S2 x \<sqsubseteq> fun S1 x" |
|
457 |
hence 2: "EX x : dom S1. m(fun S1 x) > m(fun S1 x \<nabla> fun S2 x)" |
|
458 |
using m_widen by blast |
|
459 |
from setsum_strict_mono_ex1[OF `finite(dom S1)` 1 2] |
|
460 |
show "(\<Sum>x\<in>dom S1. m (fun S1 x \<nabla> fun S2 x)) < (\<Sum>x\<in>dom S1. m (fun S1 x))" . |
|
461 |
qed |
|
462 |
||
463 |
definition "n_st S = (\<Sum>x\<in>dom S. n(fun S x))" |
|
464 |
||
465 |
lemma n_st_mono: assumes "S1 \<sqsubseteq> S2" shows "n_st S1 \<le> n_st S2" |
|
466 |
proof- |
|
467 |
from assms have [simp]: "dom S1 = dom S2" "\<forall>x\<in>dom S1. fun S1 x \<sqsubseteq> fun S2 x" |
|
468 |
by(simp_all add: le_st_def) |
|
469 |
have "(\<Sum>x\<in>dom S1. n(fun S1 x)) \<le> (\<Sum>x\<in>dom S1. n(fun S2 x))" |
|
470 |
by(rule setsum_mono)(simp add: le_st_def n_mono) |
|
471 |
thus ?thesis by(simp add: n_st_def) |
|
472 |
qed |
|
473 |
||
474 |
lemma n_st_narrow: |
|
475 |
assumes "finite(dom S1)" and "S2 \<sqsubseteq> S1" "\<not> S1 \<sqsubseteq> S1 \<triangle> S2" |
|
476 |
shows "n_st (S1 \<triangle> S2) < n_st S1" |
|
477 |
proof- |
|
478 |
from `S2\<sqsubseteq>S1` have [simp]: "dom S1 = dom S2" "\<forall>x\<in>dom S1. fun S2 x \<sqsubseteq> fun S1 x" |
|
479 |
by(simp_all add: le_st_def) |
|
480 |
have 1: "\<forall>x\<in>dom S1. n(fun (S1 \<triangle> S2) x) \<le> n(fun S1 x)" |
|
481 |
by(auto simp: le_st_def narrow_st_def n_mono WN_class.narrow2) |
|
482 |
have 2: "\<exists>x\<in>dom S1. n(fun (S1 \<triangle> S2) x) < n(fun S1 x)" using `\<not> S1 \<sqsubseteq> S1 \<triangle> S2` |
|
483 |
by(auto simp: le_st_def narrow_st_def intro: n_narrow) |
|
484 |
have "(\<Sum>x\<in>dom S1. n(fun (S1 \<triangle> S2) x)) < (\<Sum>x\<in>dom S1. n(fun S1 x))" |
|
485 |
apply(rule setsum_strict_mono_ex1[OF `finite(dom S1)`]) using 1 2 by blast+ |
|
486 |
moreover have "dom (S1 \<triangle> S2) = dom S1" by(simp add: narrow_st_def) |
|
487 |
ultimately show ?thesis by(simp add: n_st_def) |
|
488 |
qed |
|
489 |
||
49496 | 490 |
definition m_o :: "nat \<Rightarrow> 'av st option \<Rightarrow> nat" where |
491 |
"m_o d opt = (case opt of None \<Rightarrow> h*d+1 | Some S \<Rightarrow> m_st S)" |
|
47613 | 492 |
|
49496 | 493 |
lemma m_o_h: "ost \<in> L X \<Longrightarrow> finite X \<Longrightarrow> m_o (card X) ost \<le> (h*card X + 1)" |
494 |
by(auto simp add: m_o_def m_st_h split: option.split dest!:m_st_h) |
|
47613 | 495 |
|
49396 | 496 |
lemma m_o_anti_mono: "S1 \<in> L X \<Longrightarrow> S2 \<in> L X \<Longrightarrow> finite X \<Longrightarrow> |
49496 | 497 |
S1 \<sqsubseteq> S2 \<Longrightarrow> m_o (card X) S2 \<le> m_o (card X) S1" |
47613 | 498 |
apply(induction S1 S2 rule: le_option.induct) |
49496 | 499 |
apply(auto simp: m_o_def m_st_anti_mono le_SucI m_st_h L_st_def |
47613 | 500 |
split: option.splits) |
501 |
done |
|
502 |
||
49396 | 503 |
lemma m_o_widen: "\<lbrakk> S1 \<in> L X; S2 \<in> L X; finite X; \<not> S2 \<sqsubseteq> S1 \<rbrakk> \<Longrightarrow> |
49496 | 504 |
m_o (card X) (S1 \<nabla> S2) < m_o (card X) S1" |
505 |
by(auto simp: m_o_def L_st_def m_st_h less_Suc_eq_le m_st_widen |
|
47613 | 506 |
split: option.split) |
507 |
||
508 |
definition "n_o opt = (case opt of None \<Rightarrow> 0 | Some x \<Rightarrow> n_st x + 1)" |
|
509 |
||
510 |
lemma n_o_mono: "S1 \<sqsubseteq> S2 \<Longrightarrow> n_o S1 \<le> n_o S2" |
|
511 |
by(induction S1 S2 rule: le_option.induct)(auto simp: n_o_def n_st_mono) |
|
512 |
||
513 |
lemma n_o_narrow: |
|
49396 | 514 |
"S1 \<in> L X \<Longrightarrow> S2 \<in> L X \<Longrightarrow> finite X |
47613 | 515 |
\<Longrightarrow> S2 \<sqsubseteq> S1 \<Longrightarrow> \<not> S1 \<sqsubseteq> S1 \<triangle> S2 \<Longrightarrow> n_o (S1 \<triangle> S2) < n_o S1" |
516 |
apply(induction S1 S2 rule: narrow_option.induct) |
|
49396 | 517 |
apply(auto simp: n_o_def L_st_def n_st_narrow) |
47613 | 518 |
done |
519 |
||
520 |
||
49396 | 521 |
lemma annos_narrow_acom[simp]: "strip C2 = strip (C1::'a::WN_Lc acom) \<Longrightarrow> |
49095 | 522 |
annos(C1 \<triangle> C2) = map (\<lambda>(x,y).x\<triangle>y) (zip (annos C1) (annos C2))" |
47613 | 523 |
by(induction "narrow::'a\<Rightarrow>'a\<Rightarrow>'a" C1 C2 rule: map2_acom.induct) |
524 |
(simp_all add: narrow_acom_def size_annos_same2) |
|
525 |
||
526 |
||
527 |
definition "m_c C = (let as = annos C in |
|
49496 | 528 |
\<Sum>i<size as. m_o (card(vars(strip C))) (as!i))" |
529 |
||
530 |
lemma m_c_h: assumes "C \<in> L(vars(strip C))" |
|
531 |
shows "m_c C \<le> size(annos C) * (h * card(vars(strip C)) + 1)" |
|
532 |
proof- |
|
533 |
let ?X = "vars(strip C)" let ?n = "card ?X" let ?a = "size(annos C)" |
|
534 |
{ fix i assume "i < ?a" |
|
535 |
hence "annos C ! i \<in> L ?X" using assms by(simp add: L_acom_def) |
|
536 |
note m_o_h[OF this finite_cvars] |
|
537 |
} note 1 = this |
|
538 |
have "m_c C = (\<Sum>i<?a. m_o ?n (annos C ! i))" by(simp add: m_c_def Let_def) |
|
539 |
also have "\<dots> \<le> (\<Sum>i<?a. h * ?n + 1)" |
|
540 |
apply(rule setsum_mono) using 1 by simp |
|
541 |
also have "\<dots> = ?a * (h * ?n + 1)" by simp |
|
542 |
finally show ?thesis . |
|
543 |
qed |
|
47613 | 544 |
|
545 |
lemma m_c_widen: |
|
49396 | 546 |
"C1 \<in> Lc c \<Longrightarrow> C2 \<in> Lc c \<Longrightarrow> \<not> C2 \<sqsubseteq> C1 \<Longrightarrow> m_c (C1 \<nabla> C2) < m_c C1" |
547 |
apply(auto simp: Lc_acom_def m_c_def Let_def widen_acom_def) |
|
47613 | 548 |
apply(subgoal_tac "length(annos C2) = length(annos C1)") |
549 |
prefer 2 apply (simp add: size_annos_same2) |
|
550 |
apply (auto) |
|
551 |
apply(rule setsum_strict_mono_ex1) |
|
552 |
apply simp |
|
553 |
apply (clarsimp) |
|
554 |
apply(simp add: m_o_anti_mono finite_cvars widen1[where c = "strip C2"]) |
|
555 |
apply(auto simp: le_iff_le_annos listrel_iff_nth) |
|
556 |
apply(rule_tac x=i in bexI) |
|
557 |
prefer 2 apply simp |
|
558 |
apply(rule m_o_widen) |
|
49396 | 559 |
apply (simp add: finite_cvars)+ |
47613 | 560 |
done |
561 |
||
562 |
definition "n_c C = (let as = annos C in \<Sum>i=0..<size as. n_o (as!i))" |
|
563 |
||
49396 | 564 |
lemma n_c_narrow: "C1 \<in> Lc c \<Longrightarrow> C2 \<in> Lc c \<Longrightarrow> |
565 |
C2 \<sqsubseteq> C1 \<Longrightarrow> \<not> C1 \<sqsubseteq> C1 \<triangle> C2 \<Longrightarrow> n_c (C1 \<triangle> C2) < n_c C1" |
|
566 |
apply(auto simp: n_c_def Let_def Lc_acom_def narrow_acom_def) |
|
47613 | 567 |
apply(subgoal_tac "length(annos C2) = length(annos C1)") |
568 |
prefer 2 apply (simp add: size_annos_same2) |
|
569 |
apply (auto) |
|
570 |
apply(rule setsum_strict_mono_ex1) |
|
571 |
apply simp |
|
572 |
apply (clarsimp) |
|
573 |
apply(rule n_o_mono) |
|
574 |
apply(rule narrow2) |
|
575 |
apply(fastforce simp: le_iff_le_annos listrel_iff_nth) |
|
49496 | 576 |
apply(auto simp: le_iff_le_annos listrel_iff_nth) |
47613 | 577 |
apply(rule_tac x=i in bexI) |
578 |
prefer 2 apply simp |
|
579 |
apply(rule n_o_narrow[where X = "vars(strip C1)"]) |
|
580 |
apply (simp add: finite_cvars)+ |
|
581 |
done |
|
582 |
||
583 |
end |
|
584 |
||
585 |
||
586 |
lemma iter_widen_termination: |
|
49396 | 587 |
fixes m :: "'a::WN_Lc \<Rightarrow> nat" |
47613 | 588 |
assumes P_f: "\<And>C. P C \<Longrightarrow> P(f C)" |
589 |
and P_widen: "\<And>C1 C2. P C1 \<Longrightarrow> P C2 \<Longrightarrow> P(C1 \<nabla> C2)" |
|
590 |
and m_widen: "\<And>C1 C2. P C1 \<Longrightarrow> P C2 \<Longrightarrow> ~ C2 \<sqsubseteq> C1 \<Longrightarrow> m(C1 \<nabla> C2) < m C1" |
|
591 |
and "P C" shows "EX C'. iter_widen f C = Some C'" |
|
592 |
proof(simp add: iter_widen_def, rule wf_while_option_Some[where P = P]) |
|
593 |
show "wf {(cc, c). (P c \<and> \<not> f c \<sqsubseteq> c) \<and> cc = c \<nabla> f c}" |
|
594 |
by(rule wf_subset[OF wf_measure[of "m"]])(auto simp: m_widen P_f) |
|
595 |
next |
|
596 |
show "P C" by(rule `P C`) |
|
597 |
next |
|
598 |
fix C assume "P C" thus "P (C \<nabla> f C)" by(simp add: P_f P_widen) |
|
599 |
qed |
|
49496 | 600 |
|
47613 | 601 |
lemma iter_narrow_termination: |
49396 | 602 |
fixes n :: "'a::WN_Lc \<Rightarrow> nat" |
47613 | 603 |
assumes P_f: "\<And>C. P C \<Longrightarrow> P(f C)" |
604 |
and P_narrow: "\<And>C1 C2. P C1 \<Longrightarrow> P C2 \<Longrightarrow> P(C1 \<triangle> C2)" |
|
605 |
and mono: "\<And>C1 C2. P C1 \<Longrightarrow> P C2 \<Longrightarrow> C1 \<sqsubseteq> C2 \<Longrightarrow> f C1 \<sqsubseteq> f C2" |
|
606 |
and n_narrow: "\<And>C1 C2. P C1 \<Longrightarrow> P C2 \<Longrightarrow> C2 \<sqsubseteq> C1 \<Longrightarrow> ~ C1 \<sqsubseteq> C1 \<triangle> C2 \<Longrightarrow> n(C1 \<triangle> C2) < n C1" |
|
607 |
and init: "P C" "f C \<sqsubseteq> C" shows "EX C'. iter_narrow f C = Some C'" |
|
608 |
proof(simp add: iter_narrow_def, rule wf_while_option_Some[where P = "%C. P C \<and> f C \<sqsubseteq> C"]) |
|
609 |
show "wf {(c', c). ((P c \<and> f c \<sqsubseteq> c) \<and> \<not> c \<sqsubseteq> c \<triangle> f c) \<and> c' = c \<triangle> f c}" |
|
610 |
by(rule wf_subset[OF wf_measure[of "n"]])(auto simp: n_narrow P_f) |
|
611 |
next |
|
612 |
show "P C \<and> f C \<sqsubseteq> C" using init by blast |
|
613 |
next |
|
614 |
fix C assume 1: "P C \<and> f C \<sqsubseteq> C" |
|
615 |
hence "P (C \<triangle> f C)" by(simp add: P_f P_narrow) |
|
616 |
moreover then have "f (C \<triangle> f C) \<sqsubseteq> C \<triangle> f C" |
|
617 |
by (metis narrow1 narrow2 1 mono preord_class.le_trans) |
|
618 |
ultimately show "P (C \<triangle> f C) \<and> f (C \<triangle> f C) \<sqsubseteq> C \<triangle> f C" .. |
|
619 |
qed |
|
620 |
||
621 |
||
622 |
subsubsection "Termination: Intervals" |
|
623 |
||
624 |
definition m_ivl :: "ivl \<Rightarrow> nat" where |
|
625 |
"m_ivl ivl = (case ivl of I l h \<Rightarrow> |
|
626 |
(case l of None \<Rightarrow> 0 | Some _ \<Rightarrow> 1) + (case h of None \<Rightarrow> 0 | Some _ \<Rightarrow> 1))" |
|
627 |
||
628 |
lemma m_ivl_height: "m_ivl ivl \<le> 2" |
|
629 |
by(simp add: m_ivl_def split: ivl.split option.split) |
|
630 |
||
631 |
lemma m_ivl_anti_mono: "(y::ivl) \<sqsubseteq> x \<Longrightarrow> m_ivl x \<le> m_ivl y" |
|
632 |
by(auto simp: m_ivl_def le_option_def le_ivl_def |
|
633 |
split: ivl.split option.split if_splits) |
|
634 |
||
635 |
lemma m_ivl_widen: |
|
636 |
"~ y \<sqsubseteq> x \<Longrightarrow> m_ivl(x \<nabla> y) < m_ivl x" |
|
637 |
by(auto simp: m_ivl_def widen_ivl_def le_option_def le_ivl_def |
|
638 |
split: ivl.splits option.splits if_splits) |
|
639 |
||
640 |
definition n_ivl :: "ivl \<Rightarrow> nat" where |
|
641 |
"n_ivl ivl = 2 - m_ivl ivl" |
|
642 |
||
643 |
lemma n_ivl_mono: "(x::ivl) \<sqsubseteq> y \<Longrightarrow> n_ivl x \<le> n_ivl y" |
|
644 |
unfolding n_ivl_def by (metis diff_le_mono2 m_ivl_anti_mono) |
|
645 |
||
646 |
lemma n_ivl_narrow: |
|
647 |
"~ x \<sqsubseteq> x \<triangle> y \<Longrightarrow> n_ivl(x \<triangle> y) < n_ivl x" |
|
648 |
by(auto simp: n_ivl_def m_ivl_def narrow_ivl_def le_option_def le_ivl_def |
|
649 |
split: ivl.splits option.splits if_splits) |
|
650 |
||
651 |
||
652 |
interpretation Abs_Int2_measure |
|
653 |
where \<gamma> = \<gamma>_ivl and num' = num_ivl and plus' = plus_ivl |
|
654 |
and test_num' = in_ivl |
|
655 |
and filter_plus' = filter_plus_ivl and filter_less' = filter_less_ivl |
|
656 |
and m = m_ivl and n = n_ivl and h = 2 |
|
657 |
proof |
|
658 |
case goal1 thus ?case by(rule m_ivl_anti_mono) |
|
659 |
next |
|
660 |
case goal2 thus ?case by(rule m_ivl_widen) |
|
661 |
next |
|
662 |
case goal3 thus ?case by(rule m_ivl_height) |
|
663 |
next |
|
664 |
case goal4 thus ?case by(rule n_ivl_mono) |
|
665 |
next |
|
666 |
case goal5 thus ?case by(rule n_ivl_narrow) |
|
667 |
qed |
|
668 |
||
669 |
||
670 |
lemma iter_winden_step_ivl_termination: |
|
671 |
"\<exists>C. iter_widen (step_ivl (top c)) (bot c) = Some C" |
|
49396 | 672 |
apply(rule iter_widen_termination[where m = "m_c" and P = "%C. C \<in> Lc c"]) |
673 |
apply (simp_all add: step'_in_Lc m_c_widen) |
|
47613 | 674 |
done |
675 |
||
676 |
lemma iter_narrow_step_ivl_termination: |
|
49396 | 677 |
"C0 \<in> Lc c \<Longrightarrow> step_ivl (top c) C0 \<sqsubseteq> C0 \<Longrightarrow> |
47613 | 678 |
\<exists>C. iter_narrow (step_ivl (top c)) C0 = Some C" |
49396 | 679 |
apply(rule iter_narrow_termination[where n = "n_c" and P = "%C. C \<in> Lc c"]) |
680 |
apply (simp add: step'_in_Lc) |
|
47613 | 681 |
apply (simp) |
682 |
apply(rule mono_step'_top) |
|
49396 | 683 |
apply(simp add: Lc_acom_def L_acom_def) |
684 |
apply(simp add: Lc_acom_def L_acom_def) |
|
47613 | 685 |
apply assumption |
686 |
apply(erule (3) n_c_narrow) |
|
687 |
apply assumption |
|
688 |
apply assumption |
|
689 |
done |
|
690 |
||
691 |
theorem AI_ivl'_termination: |
|
692 |
"\<exists>C. AI_ivl' c = Some C" |
|
693 |
apply(auto simp: AI_wn_def pfp_wn_def iter_winden_step_ivl_termination |
|
694 |
split: option.split) |
|
695 |
apply(rule iter_narrow_step_ivl_termination) |
|
49396 | 696 |
apply(blast intro: iter_widen_inv[where f = "step' \<top>\<^bsub>c\<^esub>" and P = "%C. C \<in> Lc c"] bot_in_Lc Lc_widen step'_in_Lc[where S = "\<top>\<^bsub>c\<^esub>" and c=c, simplified]) |
47613 | 697 |
apply(erule iter_widen_pfp) |
698 |
done |
|
699 |
||
700 |
(*unused_thms Abs_Int_init -*) |
|
701 |
||
702 |
end |