author | nipkow |
Sun, 01 Jan 2012 18:12:11 +0100 | |
changeset 46067 | a03bf644cb27 |
parent 46066 | e81411bfa7ef |
child 46068 | b9d4ec0f79ac |
permissions | -rw-r--r-- |
45111 | 1 |
(* Author: Tobias Nipkow *) |
2 |
||
3 |
theory Abs_Int1 |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
4 |
imports Abs_Int0 |
45111 | 5 |
begin |
6 |
||
7 |
instantiation prod :: (preord,preord) preord |
|
8 |
begin |
|
9 |
||
10 |
definition "le_prod p1 p2 = (fst p1 \<sqsubseteq> fst p2 \<and> snd p1 \<sqsubseteq> snd p2)" |
|
11 |
||
12 |
instance |
|
13 |
proof |
|
14 |
case goal1 show ?case by(simp add: le_prod_def) |
|
15 |
next |
|
16 |
case goal2 thus ?case unfolding le_prod_def by(metis le_trans) |
|
17 |
qed |
|
18 |
||
19 |
end |
|
20 |
||
21 |
||
22 |
subsection "Backward Analysis of Expressions" |
|
23 |
||
24 |
hide_const bot |
|
25 |
||
26 |
class L_top_bot = SL_top + |
|
27 |
fixes meet :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<sqinter>" 65) |
|
28 |
and bot :: "'a" ("\<bottom>") |
|
29 |
assumes meet_le1 [simp]: "x \<sqinter> y \<sqsubseteq> x" |
|
30 |
and meet_le2 [simp]: "x \<sqinter> y \<sqsubseteq> y" |
|
31 |
and meet_greatest: "x \<sqsubseteq> y \<Longrightarrow> x \<sqsubseteq> z \<Longrightarrow> x \<sqsubseteq> y \<sqinter> z" |
|
32 |
assumes bot[simp]: "\<bottom> \<sqsubseteq> x" |
|
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
33 |
begin |
45111 | 34 |
|
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
35 |
lemma mono_meet: "x \<sqsubseteq> x' \<Longrightarrow> y \<sqsubseteq> y' \<Longrightarrow> x \<sqinter> y \<sqsubseteq> x' \<sqinter> y'" |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
36 |
by (metis meet_greatest meet_le1 meet_le2 le_trans) |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
37 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
38 |
end |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
39 |
|
46039 | 40 |
locale Val_abs1_gamma = |
46063 | 41 |
Val_abs where \<gamma> = \<gamma> for \<gamma> :: "'av::L_top_bot \<Rightarrow> val set" + |
46039 | 42 |
assumes inter_gamma_subset_gamma_meet: |
43 |
"\<gamma> a1 \<inter> \<gamma> a2 \<subseteq> \<gamma>(a1 \<sqinter> a2)" |
|
44 |
and gamma_Bot[simp]: "\<gamma> \<bottom> = {}" |
|
45111 | 45 |
begin |
46 |
||
46039 | 47 |
lemma in_gamma_meet: "x : \<gamma> a1 \<Longrightarrow> x : \<gamma> a2 \<Longrightarrow> x : \<gamma>(a1 \<sqinter> a2)" |
48 |
by (metis IntI inter_gamma_subset_gamma_meet set_mp) |
|
45111 | 49 |
|
46039 | 50 |
lemma gamma_meet[simp]: "\<gamma>(a1 \<sqinter> a2) = \<gamma> a1 \<inter> \<gamma> a2" |
51 |
by (metis equalityI inter_gamma_subset_gamma_meet le_inf_iff mono_gamma meet_le1 meet_le2) |
|
45111 | 52 |
|
53 |
end |
|
54 |
||
55 |
||
46063 | 56 |
locale Val_abs1 = |
57 |
Val_abs1_gamma where \<gamma> = \<gamma> |
|
58 |
for \<gamma> :: "'av::L_top_bot \<Rightarrow> val set" + |
|
59 |
fixes filter_plus' :: "'av \<Rightarrow> 'av \<Rightarrow> 'av \<Rightarrow> 'av * 'av" |
|
60 |
and filter_less' :: "bool \<Rightarrow> 'av \<Rightarrow> 'av \<Rightarrow> 'av * 'av" |
|
45111 | 61 |
assumes filter_plus': "filter_plus' a a1 a2 = (a1',a2') \<Longrightarrow> |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
62 |
n1 : \<gamma> a1 \<Longrightarrow> n2 : \<gamma> a2 \<Longrightarrow> n1+n2 : \<gamma> a \<Longrightarrow> n1 : \<gamma> a1' \<and> n2 : \<gamma> a2'" |
45111 | 63 |
and filter_less': "filter_less' (n1<n2) a1 a2 = (a1',a2') \<Longrightarrow> |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
64 |
n1 : \<gamma> a1 \<Longrightarrow> n2 : \<gamma> a2 \<Longrightarrow> n1 : \<gamma> a1' \<and> n2 : \<gamma> a2'" |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
65 |
|
45111 | 66 |
|
46063 | 67 |
locale Abs_Int1 = |
68 |
Val_abs1 where \<gamma> = \<gamma> for \<gamma> :: "'av::L_top_bot \<Rightarrow> val set" |
|
45111 | 69 |
begin |
70 |
||
46039 | 71 |
lemma in_gamma_join_UpI: "s : \<gamma>\<^isub>o S1 \<or> s : \<gamma>\<^isub>o S2 \<Longrightarrow> s : \<gamma>\<^isub>o(S1 \<squnion> S2)" |
72 |
by (metis (no_types) join_ge1 join_ge2 mono_gamma_o set_rev_mp) |
|
45111 | 73 |
|
46063 | 74 |
fun aval'' :: "aexp \<Rightarrow> 'av st option \<Rightarrow> 'av" where |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
75 |
"aval'' e None = \<bottom>" | |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
76 |
"aval'' e (Some sa) = aval' e sa" |
45111 | 77 |
|
46039 | 78 |
lemma aval''_sound: "s : \<gamma>\<^isub>o S \<Longrightarrow> aval a s : \<gamma>(aval'' a S)" |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
79 |
by(cases S)(simp add: aval'_sound)+ |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
80 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
81 |
subsubsection "Backward analysis" |
45111 | 82 |
|
46063 | 83 |
fun afilter :: "aexp \<Rightarrow> 'av \<Rightarrow> 'av st option \<Rightarrow> 'av st option" where |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
84 |
"afilter (N n) a S = (if n : \<gamma> a then S else None)" | |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
85 |
"afilter (V x) a S = (case S of None \<Rightarrow> None | Some S \<Rightarrow> |
45111 | 86 |
let a' = lookup S x \<sqinter> a in |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
87 |
if a' \<sqsubseteq> \<bottom> then None else Some(update S x a'))" | |
45111 | 88 |
"afilter (Plus e1 e2) a S = |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
89 |
(let (a1,a2) = filter_plus' a (aval'' e1 S) (aval'' e2 S) |
45111 | 90 |
in afilter e1 a1 (afilter e2 a2 S))" |
91 |
||
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
92 |
text{* The test for @{const bot} in the @{const V}-case is important: @{const |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
93 |
bot} indicates that a variable has no possible values, i.e.\ that the current |
45111 | 94 |
program point is unreachable. But then the abstract state should collapse to |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
95 |
@{const None}. Put differently, we maintain the invariant that in an abstract |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
96 |
state of the form @{term"Some s"}, all variables are mapped to non-@{const |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
97 |
bot} values. Otherwise the (pointwise) join of two abstract states, one of |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
98 |
which contains @{const bot} values, may produce too large a result, thus |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
99 |
making the analysis less precise. *} |
45111 | 100 |
|
101 |
||
46063 | 102 |
fun bfilter :: "bexp \<Rightarrow> bool \<Rightarrow> 'av st option \<Rightarrow> 'av st option" where |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
103 |
"bfilter (Bc v) res S = (if v=res then S else None)" | |
45111 | 104 |
"bfilter (Not b) res S = bfilter b (\<not> res) S" | |
105 |
"bfilter (And b1 b2) res S = |
|
106 |
(if res then bfilter b1 True (bfilter b2 True S) |
|
107 |
else bfilter b1 False S \<squnion> bfilter b2 False S)" | |
|
108 |
"bfilter (Less e1 e2) res S = |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
109 |
(let (res1,res2) = filter_less' res (aval'' e1 S) (aval'' e2 S) |
45111 | 110 |
in afilter e1 res1 (afilter e2 res2 S))" |
111 |
||
46039 | 112 |
lemma afilter_sound: "s : \<gamma>\<^isub>o S \<Longrightarrow> aval e s : \<gamma> a \<Longrightarrow> s : \<gamma>\<^isub>o (afilter e a S)" |
45111 | 113 |
proof(induction e arbitrary: a S) |
114 |
case N thus ?case by simp |
|
115 |
next |
|
116 |
case (V x) |
|
46039 | 117 |
obtain S' where "S = Some S'" and "s : \<gamma>\<^isub>f S'" using `s : \<gamma>\<^isub>o S` |
118 |
by(auto simp: in_gamma_option_iff) |
|
119 |
moreover hence "s x : \<gamma> (lookup S' x)" by(simp add: \<gamma>_st_def) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
120 |
moreover have "s x : \<gamma> a" using V by simp |
45111 | 121 |
ultimately show ?case using V(1) |
46039 | 122 |
by(simp add: lookup_update Let_def \<gamma>_st_def) |
123 |
(metis mono_gamma emptyE in_gamma_meet gamma_Bot subset_empty) |
|
45111 | 124 |
next |
125 |
case (Plus e1 e2) thus ?case |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
126 |
using filter_plus'[OF _ aval''_sound[OF Plus(3)] aval''_sound[OF Plus(3)]] |
45111 | 127 |
by (auto split: prod.split) |
128 |
qed |
|
129 |
||
46039 | 130 |
lemma bfilter_sound: "s : \<gamma>\<^isub>o S \<Longrightarrow> bv = bval b s \<Longrightarrow> s : \<gamma>\<^isub>o(bfilter b bv S)" |
45111 | 131 |
proof(induction b arbitrary: S bv) |
45200 | 132 |
case Bc thus ?case by simp |
45111 | 133 |
next |
134 |
case (Not b) thus ?case by simp |
|
135 |
next |
|
46039 | 136 |
case (And b1 b2) thus ?case by(fastforce simp: in_gamma_join_UpI) |
45111 | 137 |
next |
138 |
case (Less e1 e2) thus ?case |
|
139 |
by (auto split: prod.split) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
140 |
(metis afilter_sound filter_less' aval''_sound Less) |
45111 | 141 |
qed |
142 |
||
143 |
||
46063 | 144 |
fun step' :: "'av st option \<Rightarrow> 'av st option acom \<Rightarrow> 'av st option acom" |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
145 |
where |
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
146 |
"step' S (SKIP {P}) = (SKIP {S})" | |
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
147 |
"step' S (x ::= e {P}) = |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
148 |
x ::= e {case S of None \<Rightarrow> None | Some S \<Rightarrow> Some(update S x (aval' e S))}" | |
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
149 |
"step' S (c1; c2) = step' S c1; step' (post c1) c2" | |
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
150 |
"step' S (IF b THEN c1 ELSE c2 {P}) = |
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
151 |
(let c1' = step' (bfilter b True S) c1; c2' = step' (bfilter b False S) c2 |
45111 | 152 |
in IF b THEN c1' ELSE c2' {post c1 \<squnion> post c2})" | |
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
153 |
"step' S ({Inv} WHILE b DO c {P}) = |
45111 | 154 |
{S \<squnion> post c} |
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
155 |
WHILE b DO step' (bfilter b True Inv) c |
45111 | 156 |
{bfilter b False Inv}" |
157 |
||
46063 | 158 |
definition AI :: "com \<Rightarrow> 'av st option acom option" where |
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
159 |
"AI = lpfp\<^isub>c (step' \<top>)" |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
160 |
|
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
161 |
lemma strip_step'[simp]: "strip(step' S c) = strip c" |
45111 | 162 |
by(induct c arbitrary: S) (simp_all add: Let_def) |
163 |
||
164 |
||
165 |
subsubsection "Soundness" |
|
166 |
||
46039 | 167 |
lemma in_gamma_update: |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
168 |
"\<lbrakk> s : \<gamma>\<^isub>f S; i : \<gamma> a \<rbrakk> \<Longrightarrow> s(x := i) : \<gamma>\<^isub>f(update S x a)" |
46039 | 169 |
by(simp add: \<gamma>_st_def lookup_update) |
45111 | 170 |
|
171 |
||
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
172 |
lemma step_preserves_le2: |
46067 | 173 |
"\<lbrakk> S \<subseteq> \<gamma>\<^isub>o S'; cs \<le> \<gamma>\<^isub>c ca; strip cs = c; strip ca = c \<rbrakk> |
174 |
\<Longrightarrow> step S cs \<le> \<gamma>\<^isub>c (step' S' ca)" |
|
175 |
proof(induction c arbitrary: cs ca S S') |
|
45111 | 176 |
case SKIP thus ?case |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
177 |
by(auto simp:strip_eq_SKIP) |
45111 | 178 |
next |
179 |
case Assign thus ?case |
|
46039 | 180 |
by (fastforce simp: strip_eq_Assign intro: aval'_sound in_gamma_update |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
181 |
split: option.splits del:subsetD) |
45111 | 182 |
next |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
183 |
case Semi thus ?case apply (auto simp: strip_eq_Semi) |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
184 |
by (metis le_post post_map_acom) |
45111 | 185 |
next |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
186 |
case (If b c1 c2) |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
187 |
then obtain cs1 cs2 ca1 ca2 P Pa where |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
188 |
"cs= IF b THEN cs1 ELSE cs2 {P}" "ca= IF b THEN ca1 ELSE ca2 {Pa}" |
46039 | 189 |
"P \<subseteq> \<gamma>\<^isub>o Pa" "cs1 \<le> \<gamma>\<^isub>c ca1" "cs2 \<le> \<gamma>\<^isub>c ca2" |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
190 |
"strip cs1 = c1" "strip ca1 = c1" "strip cs2 = c2" "strip ca2 = c2" |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
191 |
by (fastforce simp: strip_eq_If) |
46039 | 192 |
moreover have "post cs1 \<subseteq> \<gamma>\<^isub>o(post ca1 \<squnion> post ca2)" |
193 |
by (metis (no_types) `cs1 \<le> \<gamma>\<^isub>c ca1` join_ge1 le_post mono_gamma_o order_trans post_map_acom) |
|
194 |
moreover have "post cs2 \<subseteq> \<gamma>\<^isub>o(post ca1 \<squnion> post ca2)" |
|
195 |
by (metis (no_types) `cs2 \<le> \<gamma>\<^isub>c ca2` join_ge2 le_post mono_gamma_o order_trans post_map_acom) |
|
46067 | 196 |
ultimately show ?case using `S \<subseteq> \<gamma>\<^isub>o S'` |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
197 |
by (simp add: If.IH subset_iff bfilter_sound) |
45111 | 198 |
next |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
199 |
case (While b c1) |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
200 |
then obtain cs1 ca1 I P Ia Pa where |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
201 |
"cs = {I} WHILE b DO cs1 {P}" "ca = {Ia} WHILE b DO ca1 {Pa}" |
46039 | 202 |
"I \<subseteq> \<gamma>\<^isub>o Ia" "P \<subseteq> \<gamma>\<^isub>o Pa" "cs1 \<le> \<gamma>\<^isub>c ca1" |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
203 |
"strip cs1 = c1" "strip ca1 = c1" |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
204 |
by (fastforce simp: strip_eq_While) |
46067 | 205 |
moreover have "S \<union> post cs1 \<subseteq> \<gamma>\<^isub>o (S' \<squnion> post ca1)" |
206 |
using `S \<subseteq> \<gamma>\<^isub>o S'` le_post[OF `cs1 \<le> \<gamma>\<^isub>c ca1`, simplified] |
|
46039 | 207 |
by (metis (no_types) join_ge1 join_ge2 le_sup_iff mono_gamma_o order_trans) |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
208 |
ultimately show ?case by (simp add: While.IH subset_iff bfilter_sound) |
45111 | 209 |
qed |
210 |
||
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
211 |
lemma step_preserves_le: |
46067 | 212 |
"\<lbrakk> S \<subseteq> \<gamma>\<^isub>o S'; cs \<le> \<gamma>\<^isub>c ca; strip cs = c \<rbrakk> |
213 |
\<Longrightarrow> step S cs \<le> \<gamma>\<^isub>c(step' S' ca)" |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
214 |
by (metis le_strip step_preserves_le2 strip_acom) |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
215 |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
216 |
lemma AI_sound: "AI c = Some c' \<Longrightarrow> CS UNIV c \<le> \<gamma>\<^isub>c c'" |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
217 |
proof(simp add: CS_def AI_def) |
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
218 |
assume 1: "lpfp\<^isub>c (step' \<top>) c = Some c'" |
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
219 |
have 2: "step' \<top> c' \<sqsubseteq> c'" by(rule lpfpc_pfp[OF 1]) |
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
220 |
have 3: "strip (\<gamma>\<^isub>c (step' \<top> c')) = c" |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
221 |
by(simp add: strip_lpfpc[OF _ 1]) |
46066 | 222 |
have "lfp (step UNIV) c \<le> \<gamma>\<^isub>c (step' \<top> c')" |
45903 | 223 |
proof(rule lfp_lowerbound[simplified,OF 3]) |
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
224 |
show "step UNIV (\<gamma>\<^isub>c (step' \<top> c')) \<le> \<gamma>\<^isub>c (step' \<top> c')" |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
225 |
proof(rule step_preserves_le[OF _ _ 3]) |
46039 | 226 |
show "UNIV \<subseteq> \<gamma>\<^isub>o \<top>" by simp |
227 |
show "\<gamma>\<^isub>c (step' \<top> c') \<le> \<gamma>\<^isub>c c'" by(rule mono_gamma_c[OF 2]) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
228 |
qed |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
229 |
qed |
46066 | 230 |
from this 2 show "lfp (step UNIV) c \<le> \<gamma>\<^isub>c c'" |
46039 | 231 |
by (blast intro: mono_gamma_c order_trans) |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
232 |
qed |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
233 |
|
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
234 |
end |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
235 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
236 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
237 |
subsubsection "Monotonicity" |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
238 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
239 |
locale Abs_Int1_mono = Abs_Int1 + |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
240 |
assumes mono_plus': "a1 \<sqsubseteq> b1 \<Longrightarrow> a2 \<sqsubseteq> b2 \<Longrightarrow> plus' a1 a2 \<sqsubseteq> plus' b1 b2" |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
241 |
and mono_filter_plus': "a1 \<sqsubseteq> b1 \<Longrightarrow> a2 \<sqsubseteq> b2 \<Longrightarrow> r \<sqsubseteq> r' \<Longrightarrow> |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
242 |
filter_plus' r a1 a2 \<sqsubseteq> filter_plus' r' b1 b2" |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
243 |
and mono_filter_less': "a1 \<sqsubseteq> b1 \<Longrightarrow> a2 \<sqsubseteq> b2 \<Longrightarrow> |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
244 |
filter_less' bv a1 a2 \<sqsubseteq> filter_less' bv b1 b2" |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
245 |
begin |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
246 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
247 |
lemma mono_aval': "S \<sqsubseteq> S' \<Longrightarrow> aval' e S \<sqsubseteq> aval' e S'" |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
248 |
by(induction e) (auto simp: le_st_def lookup_def mono_plus') |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
249 |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
250 |
lemma mono_aval'': "S \<sqsubseteq> S' \<Longrightarrow> aval'' e S \<sqsubseteq> aval'' e S'" |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
251 |
apply(cases S) |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
252 |
apply simp |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
253 |
apply(cases S') |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
254 |
apply simp |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
255 |
by (simp add: mono_aval') |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
256 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
257 |
lemma mono_afilter: "r \<sqsubseteq> r' \<Longrightarrow> S \<sqsubseteq> S' \<Longrightarrow> afilter e r S \<sqsubseteq> afilter e r' S'" |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
258 |
apply(induction e arbitrary: r r' S S') |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
259 |
apply(auto simp: Let_def split: option.splits prod.splits) |
46039 | 260 |
apply (metis mono_gamma subsetD) |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
261 |
apply(drule_tac x = "list" in mono_lookup) |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
262 |
apply (metis mono_meet le_trans) |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
263 |
apply (metis mono_meet mono_lookup mono_update) |
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
264 |
apply(metis mono_aval'' mono_filter_plus'[simplified le_prod_def] fst_conv snd_conv) |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
265 |
done |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
266 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
267 |
lemma mono_bfilter: "S \<sqsubseteq> S' \<Longrightarrow> bfilter b r S \<sqsubseteq> bfilter b r S'" |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
268 |
apply(induction b arbitrary: r S S') |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
269 |
apply(auto simp: le_trans[OF _ join_ge1] le_trans[OF _ join_ge2] split: prod.splits) |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
270 |
apply(metis mono_aval'' mono_afilter mono_filter_less'[simplified le_prod_def] fst_conv snd_conv) |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
271 |
done |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
272 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
273 |
|
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
274 |
lemma post_le_post: "c \<sqsubseteq> c' \<Longrightarrow> post c \<sqsubseteq> post c'" |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
275 |
by (induction c c' rule: le_acom.induct) simp_all |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
276 |
|
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
277 |
lemma mono_step'_aux: "S \<sqsubseteq> S' \<Longrightarrow> c \<sqsubseteq> c' \<Longrightarrow> step' S c \<sqsubseteq> step' S' c'" |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
278 |
apply(induction c c' arbitrary: S S' rule: le_acom.induct) |
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
279 |
apply (auto simp: post_le_post Let_def mono_bfilter mono_update mono_aval' le_join_disj |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
280 |
split: option.split) |
45127
d2eb07a1e01b
separated monotonicity reasoning and defined narrowing with while_option
nipkow
parents:
45111
diff
changeset
|
281 |
done |
45111 | 282 |
|
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
283 |
lemma mono_step': "mono (step' S)" |
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
284 |
by(simp add: mono_def mono_step'_aux[OF le_refl]) |
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
45200
diff
changeset
|
285 |
|
45111 | 286 |
end |
287 |
||
288 |
end |