| author | nipkow |
| Mon, 01 Apr 2013 17:42:29 +0200 | |
| changeset 51593 | d40aec502416 |
| parent 51390 | 1dff81cf425b |
| child 51610 | d1e192124cd6 |
| permissions | -rw-r--r-- |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
1 |
theory Collecting |
| 49487 | 2 |
imports Complete_Lattice Big_Step ACom |
| 51389 | 3 |
"~~/src/HOL/ex/Interpretation_with_Defs" |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
4 |
begin |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
5 |
|
| 51389 | 6 |
subsection "The generic Step function" |
7 |
||
8 |
notation |
|
9 |
sup (infixl "\<squnion>" 65) and |
|
10 |
inf (infixl "\<sqinter>" 70) and |
|
11 |
bot ("\<bottom>") and
|
|
12 |
top ("\<top>")
|
|
13 |
||
| 51390 | 14 |
fun Step :: "(vname \<Rightarrow> aexp \<Rightarrow> 'a \<Rightarrow> 'a::sup) \<Rightarrow> (bexp \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'a acom \<Rightarrow> 'a acom" where |
15 |
"Step f g S (SKIP {Q}) = (SKIP {S})" |
|
|
16 |
"Step f g S (x ::= e {Q}) =
|
|
17 |
x ::= e {f x e S}" |
|
|
18 |
"Step f g S (C1; C2) = Step f g S C1; Step f g (post C1) C2" | |
|
19 |
"Step f g S (IF b THEN {P1} C1 ELSE {P2} C2 {Q}) =
|
|
20 |
IF b THEN {g b S} Step f g P1 C1 ELSE {g (Not b) S} Step f g P2 C2
|
|
21 |
{post C1 \<squnion> post C2}" |
|
|
22 |
"Step f g S ({I} WHILE b DO {P} C {Q}) =
|
|
23 |
{S \<squnion> post C} WHILE b DO {g b I} Step f g P C {g (Not b) I}"
|
|
| 51389 | 24 |
|
| 51390 | 25 |
(* Could hide f and g like this: |
26 |
consts fa :: "vname \<Rightarrow> aexp \<Rightarrow> 'a \<Rightarrow> 'a::sup" |
|
27 |
fb :: "bexp \<Rightarrow> 'a \<Rightarrow> 'a::sup" |
|
28 |
abbreviation "STEP == Step fa fb" |
|
29 |
thm Step.simps[where f = fa and g = fb] |
|
30 |
*) |
|
| 51389 | 31 |
|
| 51390 | 32 |
lemma strip_Step[simp]: "strip(Step f g S C) = strip C" |
33 |
by(induct C arbitrary: S) auto |
|
| 51389 | 34 |
|
35 |
||
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
36 |
subsection "Collecting Semantics of Commands" |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
37 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
38 |
subsubsection "Annotated commands as a complete lattice" |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
39 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
40 |
(* Orderings could also be lifted generically (thus subsuming the |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
41 |
instantiation for preord and order), but then less_eq_acom would need to |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
42 |
become a definition, eg less_eq_acom = lift2 less_eq, and then proofs would |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
43 |
need to unfold this defn first. *) |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
44 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
45 |
instantiation acom :: (order) order |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
46 |
begin |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
47 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
48 |
fun less_eq_acom :: "('a::order)acom \<Rightarrow> 'a acom \<Rightarrow> bool" where
|
| 49344 | 49 |
"(SKIP {P}) \<le> (SKIP {P'}) = (P \<le> P')" |
|
50 |
"(x ::= e {P}) \<le> (x' ::= e' {P'}) = (x=x' \<and> e=e' \<and> P \<le> P')" |
|
|
51 |
"(C1;C2) \<le> (C1';C2') = (C1 \<le> C1' \<and> C2 \<le> C2')" | |
|
52 |
"(IF b THEN {P1} C1 ELSE {P2} C2 {Q}) \<le> (IF b' THEN {P1'} C1' ELSE {P2'} C2' {Q'}) =
|
|
53 |
(b=b' \<and> P1 \<le> P1' \<and> C1 \<le> C1' \<and> P2 \<le> P2' \<and> C2 \<le> C2' \<and> Q \<le> Q')" | |
|
54 |
"({I} WHILE b DO {P} C {Q}) \<le> ({I'} WHILE b' DO {P'} C' {Q'}) =
|
|
55 |
(b=b' \<and> C \<le> C' \<and> I \<le> I' \<and> P \<le> P' \<and> Q \<le> Q')" | |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
56 |
"less_eq_acom _ _ = False" |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
57 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
58 |
lemma SKIP_le: "SKIP {S} \<le> c \<longleftrightarrow> (\<exists>S'. c = SKIP {S'} \<and> S \<le> S')"
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
59 |
by (cases c) auto |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
60 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
61 |
lemma Assign_le: "x ::= e {S} \<le> c \<longleftrightarrow> (\<exists>S'. c = x ::= e {S'} \<and> S \<le> S')"
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
62 |
by (cases c) auto |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
63 |
|
| 49095 | 64 |
lemma Seq_le: "C1;C2 \<le> C \<longleftrightarrow> (\<exists>C1' C2'. C = C1';C2' \<and> C1 \<le> C1' \<and> C2 \<le> C2')" |
65 |
by (cases C) auto |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
66 |
|
| 49095 | 67 |
lemma If_le: "IF b THEN {p1} C1 ELSE {p2} C2 {S} \<le> C \<longleftrightarrow>
|
68 |
(\<exists>p1' p2' C1' C2' S'. C = IF b THEN {p1'} C1' ELSE {p2'} C2' {S'} \<and>
|
|
69 |
p1 \<le> p1' \<and> p2 \<le> p2' \<and> C1 \<le> C1' \<and> C2 \<le> C2' \<and> S \<le> S')" |
|
70 |
by (cases C) auto |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
71 |
|
| 49095 | 72 |
lemma While_le: "{I} WHILE b DO {p} C {P} \<le> W \<longleftrightarrow>
|
73 |
(\<exists>I' p' C' P'. W = {I'} WHILE b DO {p'} C' {P'} \<and> C \<le> C' \<and> p \<le> p' \<and> I \<le> I' \<and> P \<le> P')"
|
|
74 |
by (cases W) auto |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
75 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
76 |
definition less_acom :: "'a acom \<Rightarrow> 'a acom \<Rightarrow> bool" where |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
77 |
"less_acom x y = (x \<le> y \<and> \<not> y \<le> x)" |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
78 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
79 |
instance |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
80 |
proof |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
81 |
case goal1 show ?case by(simp add: less_acom_def) |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
82 |
next |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
83 |
case goal2 thus ?case by (induct x) auto |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
84 |
next |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
85 |
case goal3 thus ?case |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
86 |
apply(induct x y arbitrary: z rule: less_eq_acom.induct) |
| 47818 | 87 |
apply (auto intro: le_trans simp: SKIP_le Assign_le Seq_le If_le While_le) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
88 |
done |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
89 |
next |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
90 |
case goal4 thus ?case |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
91 |
apply(induct x y rule: less_eq_acom.induct) |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
92 |
apply (auto intro: le_antisym) |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
93 |
done |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
94 |
qed |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
95 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
96 |
end |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
97 |
|
| 45919 | 98 |
fun sub\<^isub>1 :: "'a acom \<Rightarrow> 'a acom" where |
| 49095 | 99 |
"sub\<^isub>1(C1;C2) = C1" | |
| 49344 | 100 |
"sub\<^isub>1(IF b THEN {P1} C1 ELSE {P2} C2 {Q}) = C1" |
|
101 |
"sub\<^isub>1({I} WHILE b DO {P} C {Q}) = C"
|
|
| 45903 | 102 |
|
| 45919 | 103 |
fun sub\<^isub>2 :: "'a acom \<Rightarrow> 'a acom" where |
| 49095 | 104 |
"sub\<^isub>2(C1;C2) = C2" | |
| 49344 | 105 |
"sub\<^isub>2(IF b THEN {P1} C1 ELSE {P2} C2 {Q}) = C2"
|
| 45903 | 106 |
|
| 49095 | 107 |
fun anno\<^isub>1 :: "'a acom \<Rightarrow> 'a" where |
| 49344 | 108 |
"anno\<^isub>1(IF b THEN {P1} C1 ELSE {P2} C2 {Q}) = P1" |
|
109 |
"anno\<^isub>1({I} WHILE b DO {P} C {Q}) = I"
|
|
| 49095 | 110 |
|
111 |
fun anno\<^isub>2 :: "'a acom \<Rightarrow> 'a" where |
|
| 49344 | 112 |
"anno\<^isub>2(IF b THEN {P1} C1 ELSE {P2} C2 {Q}) = P2" |
|
113 |
"anno\<^isub>2({I} WHILE b DO {P} C {Q}) = P"
|
|
| 49095 | 114 |
|
| 45903 | 115 |
|
| 49397 | 116 |
fun Union_acom :: "com \<Rightarrow> 'a acom set \<Rightarrow> 'a set acom" where |
117 |
"Union_acom com.SKIP M = (SKIP {post ` M})" |
|
|
118 |
"Union_acom (x ::= a) M = (x ::= a {post ` M})" |
|
|
119 |
"Union_acom (c1;c2) M = |
|
120 |
Union_acom c1 (sub\<^isub>1 ` M); Union_acom c2 (sub\<^isub>2 ` M)" | |
|
121 |
"Union_acom (IF b THEN c1 ELSE c2) M = |
|
122 |
IF b THEN {anno\<^isub>1 ` M} Union_acom c1 (sub\<^isub>1 ` M) ELSE {anno\<^isub>2 ` M} Union_acom c2 (sub\<^isub>2 ` M)
|
|
123 |
{post ` M}" |
|
|
124 |
"Union_acom (WHILE b DO c) M = |
|
125 |
{anno\<^isub>1 ` M}
|
|
126 |
WHILE b DO {anno\<^isub>2 ` M} Union_acom c (sub\<^isub>1 ` M)
|
|
127 |
{post ` M}"
|
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
128 |
|
| 49397 | 129 |
interpretation |
130 |
Complete_Lattice "{C. strip C = c}" "map_acom Inter o (Union_acom c)" for c
|
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
131 |
proof |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
132 |
case goal1 |
| 49397 | 133 |
have "a:A \<Longrightarrow> map_acom Inter (Union_acom (strip a) A) \<le> a" |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
134 |
proof(induction a arbitrary: A) |
| 47818 | 135 |
case Seq from Seq.prems show ?case by(force intro!: Seq.IH) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
136 |
next |
| 45903 | 137 |
case If from If.prems show ?case by(force intro!: If.IH) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
138 |
next |
| 45903 | 139 |
case While from While.prems show ?case by(force intro!: While.IH) |
140 |
qed force+ |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
141 |
with goal1 show ?case by auto |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
142 |
next |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
143 |
case goal2 |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
144 |
thus ?case |
|
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47818
diff
changeset
|
145 |
proof(simp, induction b arbitrary: c A) |
| 45903 | 146 |
case SKIP thus ?case by (force simp:SKIP_le) |
147 |
next |
|
148 |
case Assign thus ?case by (force simp:Assign_le) |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
149 |
next |
|
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47818
diff
changeset
|
150 |
case Seq from Seq.prems show ?case by(force intro!: Seq.IH simp:Seq_le) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
151 |
next |
| 45903 | 152 |
case If from If.prems show ?case by (force simp: If_le intro!: If.IH) |
153 |
next |
|
|
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47818
diff
changeset
|
154 |
case While from While.prems show ?case by(fastforce simp: While_le intro: While.IH) |
| 45903 | 155 |
qed |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
156 |
next |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
157 |
case goal3 |
| 49397 | 158 |
have "strip(Union_acom c A) = c" |
|
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47818
diff
changeset
|
159 |
proof(induction c arbitrary: A) |
|
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47818
diff
changeset
|
160 |
case Seq from Seq.prems show ?case by (fastforce simp: strip_eq_Seq subset_iff intro!: Seq.IH) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
161 |
next |
|
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47818
diff
changeset
|
162 |
case If from If.prems show ?case by (fastforce intro!: If.IH simp: strip_eq_If) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
163 |
next |
|
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47818
diff
changeset
|
164 |
case While from While.prems show ?case by(fastforce intro: While.IH simp: strip_eq_While) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
165 |
qed auto |
| 45903 | 166 |
thus ?case by auto |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
167 |
qed |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
168 |
|
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
169 |
lemma le_post: "c \<le> d \<Longrightarrow> post c \<le> post d" |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
170 |
by(induction c d rule: less_eq_acom.induct) auto |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
171 |
|
| 49487 | 172 |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
173 |
subsubsection "Collecting semantics" |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
174 |
|
| 51390 | 175 |
definition "step = Step (\<lambda>x e S. {s(x := aval e s) |s. s : S}) (\<lambda>b S. {s:S. bval b s})"
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
176 |
|
| 46070 | 177 |
definition CS :: "com \<Rightarrow> state set acom" where |
|
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47818
diff
changeset
|
178 |
"CS c = lfp c (step UNIV)" |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
179 |
|
| 51390 | 180 |
lemma mono2_Step: fixes C1 C2 :: "'a::semilattice_sup acom" |
181 |
assumes "!!x e S1 S2. S1 \<le> S2 \<Longrightarrow> f x e S1 \<le> f x e S2" |
|
182 |
"!!b S1 S2. S1 \<le> S2 \<Longrightarrow> g b S1 \<le> g b S2" |
|
183 |
shows "C1 \<le> C2 \<Longrightarrow> S1 \<le> S2 \<Longrightarrow> Step f g S1 C1 \<le> Step f g S2 C2" |
|
184 |
proof(induction C1 C2 arbitrary: S1 S2 rule: less_eq_acom.induct) |
|
185 |
case 2 thus ?case by (fastforce simp: assms(1)) |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
186 |
next |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
187 |
case 3 thus ?case by(simp add: le_post) |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
188 |
next |
| 51390 | 189 |
case 4 thus ?case |
190 |
by(simp add: subset_iff assms(2)) (metis le_post le_supI1 le_supI2) |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
191 |
next |
| 51390 | 192 |
case 5 thus ?case |
193 |
by(simp add: subset_iff assms(2)) (metis le_post le_supI1 le_supI2) |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
194 |
qed auto |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
195 |
|
| 51390 | 196 |
lemma mono2_step: "C1 \<le> C2 \<Longrightarrow> S1 \<subseteq> S2 \<Longrightarrow> step S1 C1 \<le> step S2 C2" |
197 |
unfolding step_def by(rule mono2_Step) auto |
|
198 |
||
|
45655
a49f9428aba4
simplified Collecting1 and renamed: step -> step', step_cs -> step
nipkow
parents:
45623
diff
changeset
|
199 |
lemma mono_step: "mono (step S)" |
| 46334 | 200 |
by(blast intro: monoI mono2_step) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
201 |
|
| 49095 | 202 |
lemma strip_step: "strip(step S C) = strip C" |
| 51390 | 203 |
by (induction C arbitrary: S) (auto simp: step_def) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
204 |
|
|
48759
ff570720ba1c
Improved complete lattice formalisation - no more index set.
nipkow
parents:
47818
diff
changeset
|
205 |
lemma lfp_cs_unfold: "lfp c (step S) = step S (lfp c (step S))" |
| 45903 | 206 |
apply(rule lfp_unfold[OF _ mono_step]) |
207 |
apply(simp add: strip_step) |
|
208 |
done |
|
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
209 |
|
| 46070 | 210 |
lemma CS_unfold: "CS c = step UNIV (CS c)" |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
211 |
by (metis CS_def lfp_cs_unfold) |
|
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
212 |
|
| 46070 | 213 |
lemma strip_CS[simp]: "strip(CS c) = c" |
| 45903 | 214 |
by(simp add: CS_def index_lfp[simplified]) |
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
215 |
|
| 49487 | 216 |
|
217 |
subsubsection "Relation to big-step semantics" |
|
218 |
||
219 |
lemma post_Union_acom: "\<forall> c' \<in> M. strip c' = c \<Longrightarrow> post (Union_acom c M) = post ` M" |
|
220 |
proof(induction c arbitrary: M) |
|
221 |
case (Seq c1 c2) |
|
222 |
have "post ` M = post ` sub\<^isub>2 ` M" using Seq.prems by (force simp: strip_eq_Seq) |
|
223 |
moreover have "\<forall> c' \<in> sub\<^isub>2 ` M. strip c' = c2" using Seq.prems by (auto simp: strip_eq_Seq) |
|
224 |
ultimately show ?case using Seq.IH(2)[of "sub\<^isub>2 ` M"] by simp |
|
225 |
qed simp_all |
|
226 |
||
227 |
||
228 |
lemma post_lfp: "post(lfp c f) = (\<Inter>{post C|C. strip C = c \<and> f C \<le> C})"
|
|
229 |
by(auto simp add: lfp_def post_Union_acom) |
|
230 |
||
231 |
lemma big_step_post_step: |
|
232 |
"\<lbrakk> (c, s) \<Rightarrow> t; strip C = c; s \<in> S; step S C \<le> C \<rbrakk> \<Longrightarrow> t \<in> post C" |
|
233 |
proof(induction arbitrary: C S rule: big_step_induct) |
|
| 51390 | 234 |
case Skip thus ?case by(auto simp: strip_eq_SKIP step_def) |
| 49487 | 235 |
next |
| 51390 | 236 |
case Assign thus ?case by(fastforce simp: strip_eq_Assign step_def) |
| 49487 | 237 |
next |
| 51390 | 238 |
case Seq thus ?case by(fastforce simp: strip_eq_Seq step_def) |
| 49487 | 239 |
next |
| 51390 | 240 |
case IfTrue thus ?case apply(auto simp: strip_eq_If step_def) |
241 |
by (metis (lifting,full_types) mem_Collect_eq set_mp) |
|
| 49487 | 242 |
next |
| 51390 | 243 |
case IfFalse thus ?case apply(auto simp: strip_eq_If step_def) |
244 |
by (metis (lifting,full_types) mem_Collect_eq set_mp) |
|
| 49487 | 245 |
next |
246 |
case (WhileTrue b s1 c' s2 s3) |
|
247 |
from WhileTrue.prems(1) obtain I P C' Q where "C = {I} WHILE b DO {P} C' {Q}" "strip C' = c'"
|
|
248 |
by(auto simp: strip_eq_While) |
|
249 |
from WhileTrue.prems(3) `C = _` |
|
| 51390 | 250 |
have "step P C' \<le> C'" "{s \<in> I. bval b s} \<le> P" "S \<le> I" "step (post C') C \<le> C"
|
251 |
by (auto simp: step_def) |
|
| 49487 | 252 |
have "step {s \<in> I. bval b s} C' \<le> C'"
|
253 |
by (rule order_trans[OF mono2_step[OF order_refl `{s \<in> I. bval b s} \<le> P`] `step P C' \<le> C'`])
|
|
254 |
have "s1: {s:I. bval b s}" using `s1 \<in> S` `S \<subseteq> I` `bval b s1` by auto
|
|
255 |
note s2_in_post_C' = WhileTrue.IH(1)[OF `strip C' = c'` this `step {s \<in> I. bval b s} C' \<le> C'`]
|
|
256 |
from WhileTrue.IH(2)[OF WhileTrue.prems(1) s2_in_post_C' `step (post C') C \<le> C`] |
|
257 |
show ?case . |
|
258 |
next |
|
| 51390 | 259 |
case (WhileFalse b s1 c') thus ?case by (force simp: strip_eq_While step_def) |
| 49487 | 260 |
qed |
261 |
||
262 |
lemma big_step_lfp: "\<lbrakk> (c,s) \<Rightarrow> t; s \<in> S \<rbrakk> \<Longrightarrow> t \<in> post(lfp c (step S))" |
|
263 |
by(auto simp add: post_lfp intro: big_step_post_step) |
|
264 |
||
265 |
lemma big_step_CS: "(c,s) \<Rightarrow> t \<Longrightarrow> t : post(CS c)" |
|
266 |
by(simp add: CS_def big_step_lfp) |
|
267 |
||
|
45623
f682f3f7b726
Abstract interpretation is now based uniformly on annotated programs,
nipkow
parents:
diff
changeset
|
268 |
end |