author | wenzelm |
Fri, 19 Jun 2020 16:12:32 +0200 | |
changeset 71960 | 6a64205b491a |
parent 69597 | ff784d5a5bfb |
child 78099 | 4d9349989d94 |
permissions | -rw-r--r-- |
12857 | 1 |
(* Title: HOL/Bali/Eval.thy |
12854 | 2 |
Author: David von Oheimb |
3 |
*) |
|
62042 | 4 |
subsection \<open>Operational evaluation (big-step) semantics of Java expressions and |
12854 | 5 |
statements |
62042 | 6 |
\<close> |
12854 | 7 |
|
16417 | 8 |
theory Eval imports State DeclConcepts begin |
12854 | 9 |
|
62042 | 10 |
text \<open> |
12854 | 11 |
|
12 |
improvements over Java Specification 1.0: |
|
13 |
\begin{itemize} |
|
14 |
\item dynamic method lookup does not need to consider the return type |
|
15 |
(cf.15.11.4.4) |
|
16 |
\item throw raises a NullPointer exception if a null reference is given, and |
|
17 |
each throw of a standard exception yield a fresh exception object |
|
18 |
(was not specified) |
|
19 |
\item if there is not enough memory even to allocate an OutOfMemory exception, |
|
20 |
evaluation/execution fails, i.e. simply stops (was not specified) |
|
21 |
\item array assignment checks lhs (and may throw exceptions) before evaluating |
|
22 |
rhs |
|
23 |
\item fixed exact positions of class initializations |
|
24 |
(immediate at first active use) |
|
25 |
\end{itemize} |
|
26 |
||
27 |
design issues: |
|
28 |
\begin{itemize} |
|
29 |
\item evaluation vs. (single-step) transition semantics |
|
30 |
evaluation semantics chosen, because: |
|
31 |
\begin{itemize} |
|
32 |
\item[++] less verbose and therefore easier to read (and to handle in proofs) |
|
33 |
\item[+] more abstract |
|
34 |
\item[+] intermediate values (appearing in recursive rules) need not be |
|
35 |
stored explicitly, e.g. no call body construct or stack of invocation |
|
36 |
frames containing local variables and return addresses for method calls |
|
37 |
needed |
|
38 |
\item[+] convenient rule induction for subject reduction theorem |
|
39 |
\item[-] no interleaving (for parallelism) can be described |
|
40 |
\item[-] stating a property of infinite executions requires the meta-level |
|
41 |
argument that this property holds for any finite prefixes of it |
|
42 |
(e.g. stopped using a counter that is decremented to zero and then |
|
43 |
throwing an exception) |
|
44 |
\end{itemize} |
|
45 |
\item unified evaluation for variables, expressions, expression lists, |
|
46 |
statements |
|
47 |
\item the value entry in statement rules is redundant |
|
48 |
\item the value entry in rules is irrelevant in case of exceptions, but its full |
|
58318 | 49 |
inclusion helps to make the rule structure independent of exception occurrence. |
12854 | 50 |
\item as irrelevant value entries are ignored, it does not matter if they are |
51 |
unique. |
|
52 |
For simplicity, (fixed) arbitrary values are preferred over "free" values. |
|
53 |
\item the rule format is such that the start state may contain an exception. |
|
54 |
\begin{itemize} |
|
55 |
\item[++] faciliates exception handling |
|
56 |
\item[+] symmetry |
|
57 |
\end{itemize} |
|
58 |
\item the rules are defined carefully in order to be applicable even in not |
|
59 |
type-correct situations (yielding undefined values), |
|
62042 | 60 |
e.g. \<open>the_Addr (Val (Bool b)) = undefined\<close>. |
12854 | 61 |
\begin{itemize} |
62 |
\item[++] fewer rules |
|
62042 | 63 |
\item[-] less readable because of auxiliary functions like \<open>the_Addr\<close> |
12854 | 64 |
\end{itemize} |
65 |
Alternative: "defensive" evaluation throwing some InternalError exception |
|
66 |
in case of (impossible, for correct programs) type mismatches |
|
67 |
\item there is exactly one rule per syntactic construct |
|
68 |
\begin{itemize} |
|
69 |
\item[+] no redundancy in case distinctions |
|
70 |
\end{itemize} |
|
71 |
\item halloc fails iff there is no free heap address. When there is |
|
72 |
only one free heap address left, it returns an OutOfMemory exception. |
|
73 |
In this way it is guaranteed that when an OutOfMemory exception is thrown for |
|
74 |
the first time, there is a free location on the heap to allocate it. |
|
75 |
\item the allocation of objects that represent standard exceptions is deferred |
|
76 |
until execution of any enclosing catch clause, which is transparent to |
|
77 |
the program. |
|
78 |
\begin{itemize} |
|
79 |
\item[-] requires an auxiliary execution relation |
|
80 |
\item[++] avoids copies of allocation code and awkward case distinctions |
|
81 |
(whether there is enough memory to allocate the exception) in |
|
82 |
evaluation rules |
|
83 |
\end{itemize} |
|
62042 | 84 |
\item unfortunately \<open>new_Addr\<close> is not directly executable because of |
12854 | 85 |
Hilbert operator. |
86 |
\end{itemize} |
|
87 |
simplifications: |
|
88 |
\begin{itemize} |
|
89 |
\item local variables are initialized with default values |
|
90 |
(no definite assignment) |
|
91 |
\item garbage collection not considered, therefore also no finalizers |
|
92 |
\item stack overflow and memory overflow during class initialization not |
|
93 |
modelled |
|
94 |
\item exceptions in initializations not replaced by ExceptionInInitializerError |
|
95 |
\end{itemize} |
|
62042 | 96 |
\<close> |
12854 | 97 |
|
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
98 |
|
41778 | 99 |
type_synonym vvar = "val \<times> (val \<Rightarrow> state \<Rightarrow> state)" |
100 |
type_synonym vals = "(val, vvar, val list) sum3" |
|
12854 | 101 |
translations |
35431 | 102 |
(type) "vvar" <= (type) "val \<times> (val \<Rightarrow> state \<Rightarrow> state)" |
103 |
(type) "vals" <= (type) "(val, vvar, val list) sum3" |
|
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
104 |
|
62042 | 105 |
text \<open>To avoid redundancy and to reduce the number of rules, there is only |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
106 |
one evaluation rule for each syntactic term. This is also true for variables |
62042 | 107 |
(e.g. see the rules below for \<open>LVar\<close>, \<open>FVar\<close> and \<open>AVar\<close>). |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
108 |
So evaluation of a variable must capture both possible further uses: |
62042 | 109 |
read (rule \<open>Acc\<close>) or write (rule \<open>Ass\<close>) to the variable. |
69597 | 110 |
Therefor a variable evaluates to a special value \<^term>\<open>vvar\<close>, which is |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
111 |
a pair, consisting of the current value (for later read access) and an update |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
112 |
function (for later write access). Because |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
113 |
during assignment to an array variable an exception may occur if the types |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
114 |
don't match, the update function is very generic: it transforms the |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
115 |
full state. This generic update function causes some technical trouble during |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
116 |
some proofs (e.g. type safety, correctness of definite assignment). There we |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
117 |
need to prove some additional invariant on this update function to prove the |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
118 |
assignment correct, since the update function could potentially alter the whole |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
119 |
state in an arbitrary manner. This invariant must be carried around through |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
120 |
the whole induction. |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
121 |
So for future approaches it may be better not to take |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
122 |
such a generic update function, but only to store the address and the kind |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
123 |
of variable (array (+ element type), local variable or field) for later |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
124 |
assignment. |
62042 | 125 |
\<close> |
12854 | 126 |
|
61989 | 127 |
abbreviation |
12854 | 128 |
dummy_res :: "vals" ("\<diamondsuit>") |
35067
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
129 |
where "\<diamondsuit> == In1 Unit" |
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
130 |
|
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
131 |
abbreviation (input) |
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
132 |
val_inj_vals ("\<lfloor>_\<rfloor>\<^sub>e" 1000) |
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
133 |
where "\<lfloor>e\<rfloor>\<^sub>e == In1 e" |
12854 | 134 |
|
35067
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
135 |
abbreviation (input) |
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
136 |
var_inj_vals ("\<lfloor>_\<rfloor>\<^sub>v" 1000) |
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
137 |
where "\<lfloor>v\<rfloor>\<^sub>v == In2 v" |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
138 |
|
35067
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
139 |
abbreviation (input) |
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
140 |
lst_inj_vals ("\<lfloor>_\<rfloor>\<^sub>l" 1000) |
af4c18c30593
modernized syntax translations, using mostly abbreviation/notation;
wenzelm
parents:
32960
diff
changeset
|
141 |
where "\<lfloor>es\<rfloor>\<^sub>l == In3 es" |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
142 |
|
35416
d8d7d1b785af
replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents:
35069
diff
changeset
|
143 |
definition undefined3 :: "('al + 'ar, 'b, 'c) sum3 \<Rightarrow> vals" where |
55417
01fbfb60c33e
adapted to 'xxx_{case,rec}' renaming, to new theorem names, and to new variable names in theorems
blanchet
parents:
55414
diff
changeset
|
144 |
"undefined3 = case_sum3 (In1 \<circ> case_sum (\<lambda>x. undefined) (\<lambda>x. Unit)) |
28524 | 145 |
(\<lambda>x. In2 undefined) (\<lambda>x. In3 undefined)" |
12854 | 146 |
|
28524 | 147 |
lemma [simp]: "undefined3 (In1l x) = In1 undefined" |
148 |
by (simp add: undefined3_def) |
|
12854 | 149 |
|
28524 | 150 |
lemma [simp]: "undefined3 (In1r x) = \<diamondsuit>" |
151 |
by (simp add: undefined3_def) |
|
12854 | 152 |
|
28524 | 153 |
lemma [simp]: "undefined3 (In2 x) = In2 undefined" |
154 |
by (simp add: undefined3_def) |
|
12854 | 155 |
|
28524 | 156 |
lemma [simp]: "undefined3 (In3 x) = In3 undefined" |
157 |
by (simp add: undefined3_def) |
|
12854 | 158 |
|
159 |
||
58887 | 160 |
subsubsection "exception throwing and catching" |
12854 | 161 |
|
37956 | 162 |
definition |
163 |
throw :: "val \<Rightarrow> abopt \<Rightarrow> abopt" where |
|
164 |
"throw a' x = abrupt_if True (Some (Xcpt (Loc (the_Addr a')))) (np a' x)" |
|
12854 | 165 |
|
166 |
lemma throw_def2: |
|
167 |
"throw a' x = abrupt_if True (Some (Xcpt (Loc (the_Addr a')))) (np a' x)" |
|
168 |
apply (unfold throw_def) |
|
169 |
apply (simp (no_asm)) |
|
170 |
done |
|
171 |
||
37956 | 172 |
definition |
173 |
fits :: "prog \<Rightarrow> st \<Rightarrow> val \<Rightarrow> ty \<Rightarrow> bool" ("_,_\<turnstile>_ fits _"[61,61,61,61]60) |
|
174 |
where "G,s\<turnstile>a' fits T = ((\<exists>rt. T=RefT rt) \<longrightarrow> a'=Null \<or> G\<turnstile>obj_ty(lookup_obj s a')\<preceq>T)" |
|
12854 | 175 |
|
176 |
lemma fits_Null [simp]: "G,s\<turnstile>Null fits T" |
|
177 |
by (simp add: fits_def) |
|
178 |
||
179 |
||
180 |
lemma fits_Addr_RefT [simp]: |
|
181 |
"G,s\<turnstile>Addr a fits RefT t = G\<turnstile>obj_ty (the (heap s a))\<preceq>RefT t" |
|
182 |
by (simp add: fits_def) |
|
183 |
||
184 |
lemma fitsD: "\<And>X. G,s\<turnstile>a' fits T \<Longrightarrow> (\<exists>pt. T = PrimT pt) \<or> |
|
185 |
(\<exists>t. T = RefT t) \<and> a' = Null \<or> |
|
186 |
(\<exists>t. T = RefT t) \<and> a' \<noteq> Null \<and> G\<turnstile>obj_ty (lookup_obj s a')\<preceq>T" |
|
187 |
apply (unfold fits_def) |
|
188 |
apply (case_tac "\<exists>pt. T = PrimT pt") |
|
189 |
apply simp_all |
|
190 |
apply (case_tac "T") |
|
191 |
defer |
|
192 |
apply (case_tac "a' = Null") |
|
193 |
apply simp_all |
|
194 |
done |
|
195 |
||
37956 | 196 |
definition |
197 |
catch :: "prog \<Rightarrow> state \<Rightarrow> qtname \<Rightarrow> bool" ("_,_\<turnstile>catch _"[61,61,61]60) where |
|
198 |
"G,s\<turnstile>catch C = (\<exists>xc. abrupt s=Some (Xcpt xc) \<and> |
|
199 |
G,store s\<turnstile>Addr (the_Loc xc) fits Class C)" |
|
12854 | 200 |
|
201 |
lemma catch_Norm [simp]: "\<not>G,Norm s\<turnstile>catch tn" |
|
202 |
apply (unfold catch_def) |
|
203 |
apply (simp (no_asm)) |
|
204 |
done |
|
205 |
||
206 |
lemma catch_XcptLoc [simp]: |
|
207 |
"G,(Some (Xcpt (Loc a)),s)\<turnstile>catch C = G,s\<turnstile>Addr a fits Class C" |
|
208 |
apply (unfold catch_def) |
|
209 |
apply (simp (no_asm)) |
|
210 |
done |
|
211 |
||
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
212 |
lemma catch_Jump [simp]: "\<not>G,(Some (Jump j),s)\<turnstile>catch tn" |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
213 |
apply (unfold catch_def) |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
214 |
apply (simp (no_asm)) |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
215 |
done |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
216 |
|
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
217 |
lemma catch_Error [simp]: "\<not>G,(Some (Error e),s)\<turnstile>catch tn" |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
218 |
apply (unfold catch_def) |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
219 |
apply (simp (no_asm)) |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
220 |
done |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
221 |
|
37956 | 222 |
definition |
223 |
new_xcpt_var :: "vname \<Rightarrow> state \<Rightarrow> state" where |
|
224 |
"new_xcpt_var vn = (\<lambda>(x,s). Norm (lupd(VName vn\<mapsto>Addr (the_Loc (the_Xcpt (the x)))) s))" |
|
12854 | 225 |
|
226 |
lemma new_xcpt_var_def2 [simp]: |
|
227 |
"new_xcpt_var vn (x,s) = |
|
228 |
Norm (lupd(VName vn\<mapsto>Addr (the_Loc (the_Xcpt (the x)))) s)" |
|
229 |
apply (unfold new_xcpt_var_def) |
|
230 |
apply (simp (no_asm)) |
|
231 |
done |
|
232 |
||
233 |
||
234 |
||
58887 | 235 |
subsubsection "misc" |
12854 | 236 |
|
37956 | 237 |
definition |
238 |
assign :: "('a \<Rightarrow> state \<Rightarrow> state) \<Rightarrow> 'a \<Rightarrow> state \<Rightarrow> state" where |
|
239 |
"assign f v = (\<lambda>(x,s). let (x',s') = (if x = None then f v else id) (x,s) |
|
240 |
in (x',if x' = None then s' else s))" |
|
12854 | 241 |
|
242 |
(* |
|
243 |
lemma assign_Norm_Norm [simp]: |
|
244 |
"f v \<lparr>abrupt=None,store=s\<rparr> = \<lparr>abrupt=None,store=s'\<rparr> |
|
245 |
\<Longrightarrow> assign f v \<lparr>abrupt=None,store=s\<rparr> = \<lparr>abrupt=None,store=s'\<rparr>" |
|
246 |
by (simp add: assign_def Let_def) |
|
247 |
*) |
|
248 |
||
249 |
lemma assign_Norm_Norm [simp]: |
|
250 |
"f v (Norm s) = Norm s' \<Longrightarrow> assign f v (Norm s) = Norm s'" |
|
251 |
by (simp add: assign_def Let_def) |
|
252 |
||
253 |
(* |
|
254 |
lemma assign_Norm_Some [simp]: |
|
255 |
"\<lbrakk>abrupt (f v \<lparr>abrupt=None,store=s\<rparr>) = Some y\<rbrakk> |
|
256 |
\<Longrightarrow> assign f v \<lparr>abrupt=None,store=s\<rparr> = \<lparr>abrupt=Some y,store =s\<rparr>" |
|
257 |
by (simp add: assign_def Let_def split_beta) |
|
258 |
*) |
|
259 |
||
260 |
lemma assign_Norm_Some [simp]: |
|
261 |
"\<lbrakk>abrupt (f v (Norm s)) = Some y\<rbrakk> |
|
262 |
\<Longrightarrow> assign f v (Norm s) = (Some y,s)" |
|
263 |
by (simp add: assign_def Let_def split_beta) |
|
264 |
||
265 |
||
266 |
lemma assign_Some [simp]: |
|
267 |
"assign f v (Some x,s) = (Some x,s)" |
|
268 |
by (simp add: assign_def Let_def split_beta) |
|
269 |
||
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
270 |
lemma assign_Some1 [simp]: "\<not> normal s \<Longrightarrow> assign f v s = s" |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
271 |
by (auto simp add: assign_def Let_def split_beta) |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
272 |
|
12854 | 273 |
lemma assign_supd [simp]: |
274 |
"assign (\<lambda>v. supd (f v)) v (x,s) |
|
275 |
= (x, if x = None then f v s else s)" |
|
276 |
apply auto |
|
277 |
done |
|
278 |
||
279 |
lemma assign_raise_if [simp]: |
|
280 |
"assign (\<lambda>v (x,s). ((raise_if (b s v) xcpt) x, f v s)) v (x, s) = |
|
281 |
(raise_if (b s v) xcpt x, if x=None \<and> \<not>b s v then f v s else s)" |
|
282 |
apply (case_tac "x = None") |
|
283 |
apply auto |
|
284 |
done |
|
285 |
||
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
286 |
|
12854 | 287 |
(* |
288 |
lemma assign_raise_if [simp]: |
|
289 |
"assign (\<lambda>v s. \<lparr>abrupt=(raise_if (b (store s) v) xcpt) (abrupt s), |
|
290 |
store = f v (store s)\<rparr>) v s = |
|
291 |
\<lparr>abrupt=raise_if (b (store s) v) xcpt (abrupt s), |
|
292 |
store= if (abrupt s)=None \<and> \<not>b (store s) v |
|
293 |
then f v (store s) else (store s)\<rparr>" |
|
294 |
apply (case_tac "abrupt s = None") |
|
295 |
apply auto |
|
296 |
done |
|
297 |
*) |
|
298 |
||
37956 | 299 |
definition |
300 |
init_comp_ty :: "ty \<Rightarrow> stmt" |
|
301 |
where "init_comp_ty T = (if (\<exists>C. T = Class C) then Init (the_Class T) else Skip)" |
|
12854 | 302 |
|
303 |
lemma init_comp_ty_PrimT [simp]: "init_comp_ty (PrimT pt) = Skip" |
|
304 |
apply (unfold init_comp_ty_def) |
|
305 |
apply (simp (no_asm)) |
|
306 |
done |
|
307 |
||
37956 | 308 |
definition |
309 |
invocation_class :: "inv_mode \<Rightarrow> st \<Rightarrow> val \<Rightarrow> ref_ty \<Rightarrow> qtname" where |
|
310 |
"invocation_class m s a' statT = |
|
311 |
(case m of |
|
312 |
Static \<Rightarrow> if (\<exists> statC. statT = ClassT statC) |
|
313 |
then the_Class (RefT statT) |
|
314 |
else Object |
|
315 |
| SuperM \<Rightarrow> the_Class (RefT statT) |
|
316 |
| IntVir \<Rightarrow> obj_class (lookup_obj s a'))" |
|
12854 | 317 |
|
37956 | 318 |
definition |
319 |
invocation_declclass :: "prog \<Rightarrow> inv_mode \<Rightarrow> st \<Rightarrow> val \<Rightarrow> ref_ty \<Rightarrow> sig \<Rightarrow> qtname" where |
|
320 |
"invocation_declclass G m s a' statT sig = |
|
321 |
declclass (the (dynlookup G statT |
|
12854 | 322 |
(invocation_class m s a' statT) |
323 |
sig))" |
|
324 |
||
325 |
lemma invocation_class_IntVir [simp]: |
|
326 |
"invocation_class IntVir s a' statT = obj_class (lookup_obj s a')" |
|
327 |
by (simp add: invocation_class_def) |
|
328 |
||
329 |
lemma dynclass_SuperM [simp]: |
|
330 |
"invocation_class SuperM s a' statT = the_Class (RefT statT)" |
|
331 |
by (simp add: invocation_class_def) |
|
332 |
||
333 |
lemma invocation_class_Static [simp]: |
|
334 |
"invocation_class Static s a' statT = (if (\<exists> statC. statT = ClassT statC) |
|
335 |
then the_Class (RefT statT) |
|
336 |
else Object)" |
|
337 |
by (simp add: invocation_class_def) |
|
338 |
||
37956 | 339 |
definition |
340 |
init_lvars :: "prog \<Rightarrow> qtname \<Rightarrow> sig \<Rightarrow> inv_mode \<Rightarrow> val \<Rightarrow> val list \<Rightarrow> state \<Rightarrow> state" |
|
341 |
where |
|
342 |
"init_lvars G C sig mode a' pvs = |
|
343 |
(\<lambda>(x,s). |
|
12854 | 344 |
let m = mthd (the (methd G C sig)); |
345 |
l = \<lambda> k. |
|
346 |
(case k of |
|
347 |
EName e |
|
348 |
\<Rightarrow> (case e of |
|
68451 | 349 |
VNam v \<Rightarrow> (Map.empty ((pars m)[\<mapsto>]pvs)) v |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
350 |
| Res \<Rightarrow> None) |
12854 | 351 |
| This |
352 |
\<Rightarrow> (if mode=Static then None else Some a')) |
|
37956 | 353 |
in set_lvars l (if mode = Static then x else np a' x,s))" |
12854 | 354 |
|
355 |
||
356 |
||
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
357 |
lemma init_lvars_def2: \<comment> \<open>better suited for simplification\<close> |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
358 |
"init_lvars G C sig mode a' pvs (x,s) = |
12854 | 359 |
set_lvars |
360 |
(\<lambda> k. |
|
361 |
(case k of |
|
362 |
EName e |
|
363 |
\<Rightarrow> (case e of |
|
364 |
VNam v |
|
68451 | 365 |
\<Rightarrow> (Map.empty ((pars (mthd (the (methd G C sig))))[\<mapsto>]pvs)) v |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
366 |
| Res \<Rightarrow> None) |
12854 | 367 |
| This |
368 |
\<Rightarrow> (if mode=Static then None else Some a'))) |
|
369 |
(if mode = Static then x else np a' x,s)" |
|
370 |
apply (unfold init_lvars_def) |
|
371 |
apply (simp (no_asm) add: Let_def) |
|
372 |
done |
|
373 |
||
37956 | 374 |
definition |
375 |
body :: "prog \<Rightarrow> qtname \<Rightarrow> sig \<Rightarrow> expr" where |
|
376 |
"body G C sig = |
|
377 |
(let m = the (methd G C sig) |
|
378 |
in Body (declclass m) (stmt (mbody (mthd m))))" |
|
12854 | 379 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
380 |
lemma body_def2: \<comment> \<open>better suited for simplification\<close> |
12854 | 381 |
"body G C sig = Body (declclass (the (methd G C sig))) |
382 |
(stmt (mbody (mthd (the (methd G C sig)))))" |
|
383 |
apply (unfold body_def Let_def) |
|
384 |
apply auto |
|
385 |
done |
|
386 |
||
58887 | 387 |
subsubsection "variables" |
12854 | 388 |
|
37956 | 389 |
definition |
390 |
lvar :: "lname \<Rightarrow> st \<Rightarrow> vvar" |
|
391 |
where "lvar vn s = (the (locals s vn), \<lambda>v. supd (lupd(vn\<mapsto>v)))" |
|
12854 | 392 |
|
37956 | 393 |
definition |
394 |
fvar :: "qtname \<Rightarrow> bool \<Rightarrow> vname \<Rightarrow> val \<Rightarrow> state \<Rightarrow> vvar \<times> state" where |
|
395 |
"fvar C stat fn a' s = |
|
396 |
(let (oref,xf) = if stat then (Stat C,id) |
|
397 |
else (Heap (the_Addr a'),np a'); |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
398 |
n = Inl (fn,C); |
12854 | 399 |
f = (\<lambda>v. supd (upd_gobj oref n v)) |
37956 | 400 |
in ((the (values (the (globs (store s) oref)) n),f),abupd xf s))" |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
401 |
|
37956 | 402 |
definition |
403 |
avar :: "prog \<Rightarrow> val \<Rightarrow> val \<Rightarrow> state \<Rightarrow> vvar \<times> state" where |
|
404 |
"avar G i' a' s = |
|
405 |
(let oref = Heap (the_Addr a'); |
|
406 |
i = the_Intg i'; |
|
407 |
n = Inr i; |
|
408 |
(T,k,cs) = the_Arr (globs (store s) oref); |
|
409 |
f = (\<lambda>v (x,s). (raise_if (\<not>G,s\<turnstile>v fits T) |
|
12854 | 410 |
ArrStore x |
411 |
,upd_gobj oref n v s)) |
|
37956 | 412 |
in ((the (cs n),f),abupd (raise_if (\<not>i in_bounds k) IndOutBound \<circ> np a') s))" |
12854 | 413 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
414 |
lemma fvar_def2: \<comment> \<open>better suited for simplification\<close> |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
415 |
"fvar C stat fn a' s = |
12854 | 416 |
((the |
417 |
(values |
|
418 |
(the (globs (store s) (if stat then Stat C else Heap (the_Addr a')))) |
|
419 |
(Inl (fn,C))) |
|
420 |
,(\<lambda>v. supd (upd_gobj (if stat then Stat C else Heap (the_Addr a')) |
|
421 |
(Inl (fn,C)) |
|
422 |
v))) |
|
423 |
,abupd (if stat then id else np a') s) |
|
424 |
" |
|
425 |
apply (unfold fvar_def) |
|
426 |
apply (simp (no_asm) add: Let_def split_beta) |
|
427 |
done |
|
428 |
||
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
429 |
lemma avar_def2: \<comment> \<open>better suited for simplification\<close> |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
430 |
"avar G i' a' s = |
12854 | 431 |
((the ((snd(snd(the_Arr (globs (store s) (Heap (the_Addr a')))))) |
432 |
(Inr (the_Intg i'))) |
|
433 |
,(\<lambda>v (x,s'). (raise_if (\<not>G,s'\<turnstile>v fits (fst(the_Arr (globs (store s) |
|
434 |
(Heap (the_Addr a')))))) |
|
435 |
ArrStore x |
|
436 |
,upd_gobj (Heap (the_Addr a')) |
|
437 |
(Inr (the_Intg i')) v s'))) |
|
438 |
,abupd (raise_if (\<not>(the_Intg i') in_bounds (fst(snd(the_Arr (globs (store s) |
|
439 |
(Heap (the_Addr a'))))))) IndOutBound \<circ> np a') |
|
440 |
s)" |
|
441 |
apply (unfold avar_def) |
|
442 |
apply (simp (no_asm) add: Let_def split_beta) |
|
443 |
done |
|
444 |
||
37956 | 445 |
definition |
446 |
check_field_access :: "prog \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> vname \<Rightarrow> bool \<Rightarrow> val \<Rightarrow> state \<Rightarrow> state" where |
|
447 |
"check_field_access G accC statDeclC fn stat a' s = |
|
448 |
(let oref = if stat then Stat statDeclC |
|
449 |
else Heap (the_Addr a'); |
|
450 |
dynC = case oref of |
|
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
451 |
Heap a \<Rightarrow> obj_class (the (globs (store s) oref)) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
452 |
| Stat C \<Rightarrow> C; |
37956 | 453 |
f = (the (table_of (DeclConcepts.fields G dynC) (fn,statDeclC))) |
454 |
in abupd |
|
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
455 |
(error_if (\<not> G\<turnstile>Field fn (statDeclC,f) in dynC dyn_accessible_from accC) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
456 |
AccessViolation) |
37956 | 457 |
s)" |
12854 | 458 |
|
37956 | 459 |
definition |
460 |
check_method_access :: "prog \<Rightarrow> qtname \<Rightarrow> ref_ty \<Rightarrow> inv_mode \<Rightarrow> sig \<Rightarrow> val \<Rightarrow> state \<Rightarrow> state" where |
|
461 |
"check_method_access G accC statT mode sig a' s = |
|
462 |
(let invC = invocation_class mode (store s) a' statT; |
|
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
463 |
dynM = the (dynlookup G statT invC sig) |
37956 | 464 |
in abupd |
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
465 |
(error_if (\<not> G\<turnstile>Methd sig dynM in invC dyn_accessible_from accC) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
466 |
AccessViolation) |
37956 | 467 |
s)" |
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
468 |
|
58887 | 469 |
subsubsection "evaluation judgments" |
12854 | 470 |
|
23747 | 471 |
inductive |
21765 | 472 |
halloc :: "[prog,state,obj_tag,loc,state]\<Rightarrow>bool" ("_\<turnstile>_ \<midarrow>halloc _\<succ>_\<rightarrow> _"[61,61,61,61,61]60) for G::prog |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
473 |
where \<comment> \<open>allocating objects on the heap, cf. 12.5\<close> |
12854 | 474 |
|
475 |
Abrupt: |
|
28524 | 476 |
"G\<turnstile>(Some x,s) \<midarrow>halloc oi\<succ>undefined\<rightarrow> (Some x,s)" |
12854 | 477 |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
478 |
| New: "\<lbrakk>new_Addr (heap s) = Some a; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
479 |
(x,oi') = (if atleast_free (heap s) (Suc (Suc 0)) then (None,oi) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
480 |
else (Some (Xcpt (Loc a)),CInst (SXcpt OutOfMemory)))\<rbrakk> |
12854 | 481 |
\<Longrightarrow> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
482 |
G\<turnstile>Norm s \<midarrow>halloc oi\<succ>a\<rightarrow> (x,init_obj G oi' (Heap a) s)" |
12854 | 483 |
|
23747 | 484 |
inductive sxalloc :: "[prog,state,state]\<Rightarrow>bool" ("_\<turnstile>_ \<midarrow>sxalloc\<rightarrow> _"[61,61,61]60) for G::prog |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
485 |
where \<comment> \<open>allocating exception objects for |
62042 | 486 |
standard exceptions (other than OutOfMemory)\<close> |
12854 | 487 |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
488 |
Norm: "G\<turnstile> Norm s \<midarrow>sxalloc\<rightarrow> Norm s" |
12854 | 489 |
|
21765 | 490 |
| Jmp: "G\<turnstile>(Some (Jump j), s) \<midarrow>sxalloc\<rightarrow> (Some (Jump j), s)" |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
491 |
|
21765 | 492 |
| Error: "G\<turnstile>(Some (Error e), s) \<midarrow>sxalloc\<rightarrow> (Some (Error e), s)" |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
493 |
|
21765 | 494 |
| XcptL: "G\<turnstile>(Some (Xcpt (Loc a) ),s) \<midarrow>sxalloc\<rightarrow> (Some (Xcpt (Loc a)),s)" |
12854 | 495 |
|
21765 | 496 |
| SXcpt: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>halloc (CInst (SXcpt xn))\<succ>a\<rightarrow> (x,s1)\<rbrakk> \<Longrightarrow> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
497 |
G\<turnstile>(Some (Xcpt (Std xn)),s0) \<midarrow>sxalloc\<rightarrow> (Some (Xcpt (Loc a)),s1)" |
12854 | 498 |
|
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
499 |
|
23747 | 500 |
inductive |
21765 | 501 |
eval :: "[prog,state,term,vals,state]\<Rightarrow>bool" ("_\<turnstile>_ \<midarrow>_\<succ>\<rightarrow> '(_, _')" [61,61,80,0,0]60) |
502 |
and exec ::"[prog,state,stmt ,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_\<rightarrow> _" [61,61,65, 61]60) |
|
503 |
and evar ::"[prog,state,var ,vvar,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_=\<succ>_\<rightarrow> _"[61,61,90,61,61]60) |
|
504 |
and eval'::"[prog,state,expr ,val ,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_-\<succ>_\<rightarrow> _"[61,61,80,61,61]60) |
|
505 |
and evals::"[prog,state,expr list , |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
506 |
val list ,state]\<Rightarrow>bool"("_\<turnstile>_ \<midarrow>_\<doteq>\<succ>_\<rightarrow> _"[61,61,61,61,61]60) |
21765 | 507 |
for G::prog |
508 |
where |
|
509 |
||
510 |
"G\<turnstile>s \<midarrow>c \<rightarrow> s' \<equiv> G\<turnstile>s \<midarrow>In1r c\<succ>\<rightarrow> (\<diamondsuit>, s')" |
|
511 |
| "G\<turnstile>s \<midarrow>e-\<succ>v \<rightarrow> s' \<equiv> G\<turnstile>s \<midarrow>In1l e\<succ>\<rightarrow> (In1 v, s')" |
|
512 |
| "G\<turnstile>s \<midarrow>e=\<succ>vf\<rightarrow> s' \<equiv> G\<turnstile>s \<midarrow>In2 e\<succ>\<rightarrow> (In2 vf, s')" |
|
513 |
| "G\<turnstile>s \<midarrow>e\<doteq>\<succ>v \<rightarrow> s' \<equiv> G\<turnstile>s \<midarrow>In3 e\<succ>\<rightarrow> (In3 v, s')" |
|
12854 | 514 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
515 |
\<comment> \<open>propagation of abrupt completion\<close> |
12854 | 516 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
517 |
\<comment> \<open>cf. 14.1, 15.5\<close> |
21765 | 518 |
| Abrupt: |
28524 | 519 |
"G\<turnstile>(Some xc,s) \<midarrow>t\<succ>\<rightarrow> (undefined3 t, (Some xc, s))" |
12854 | 520 |
|
521 |
||
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
522 |
\<comment> \<open>execution of statements\<close> |
12854 | 523 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
524 |
\<comment> \<open>cf. 14.5\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
525 |
| Skip: "G\<turnstile>Norm s \<midarrow>Skip\<rightarrow> Norm s" |
12854 | 526 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
527 |
\<comment> \<open>cf. 14.7\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
528 |
| Expr: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
529 |
G\<turnstile>Norm s0 \<midarrow>Expr e\<rightarrow> s1" |
12854 | 530 |
|
21765 | 531 |
| Lab: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c \<rightarrow> s1\<rbrakk> \<Longrightarrow> |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
532 |
G\<turnstile>Norm s0 \<midarrow>l\<bullet> c\<rightarrow> abupd (absorb l) s1" |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
533 |
\<comment> \<open>cf. 14.2\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
534 |
| Comp: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c1 \<rightarrow> s1; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
535 |
G\<turnstile> s1 \<midarrow>c2 \<rightarrow> s2\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
536 |
G\<turnstile>Norm s0 \<midarrow>c1;; c2\<rightarrow> s2" |
12854 | 537 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
538 |
\<comment> \<open>cf. 14.8.2\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
539 |
| If: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>b\<rightarrow> s1; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
540 |
G\<turnstile> s1\<midarrow>(if the_Bool b then c1 else c2)\<rightarrow> s2\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
541 |
G\<turnstile>Norm s0 \<midarrow>If(e) c1 Else c2 \<rightarrow> s2" |
12854 | 542 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
543 |
\<comment> \<open>cf. 14.10, 14.10.1\<close> |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
544 |
|
69597 | 545 |
\<comment> \<open>A continue jump from the while body \<^term>\<open>c\<close> is handled by |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
546 |
this rule. If a continue jump with the proper label was invoked inside |
69597 | 547 |
\<^term>\<open>c\<close> this label (Cont l) is deleted out of the abrupt component of |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
548 |
the state before the iterative evaluation of the while statement. |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
549 |
A break jump is handled by the Lab Statement \<open>Lab l (while\<dots>)\<close>.\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
550 |
| Loop: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>b\<rightarrow> s1; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
551 |
if the_Bool b |
12854 | 552 |
then (G\<turnstile>s1 \<midarrow>c\<rightarrow> s2 \<and> |
553 |
G\<turnstile>(abupd (absorb (Cont l)) s2) \<midarrow>l\<bullet> While(e) c\<rightarrow> s3) |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
554 |
else s3 = s1\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
555 |
G\<turnstile>Norm s0 \<midarrow>l\<bullet> While(e) c\<rightarrow> s3" |
12854 | 556 |
|
21765 | 557 |
| Jmp: "G\<turnstile>Norm s \<midarrow>Jmp j\<rightarrow> (Some (Jump j), s)" |
12854 | 558 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
559 |
\<comment> \<open>cf. 14.16\<close> |
21765 | 560 |
| Throw: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>a'\<rightarrow> s1\<rbrakk> \<Longrightarrow> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
561 |
G\<turnstile>Norm s0 \<midarrow>Throw e\<rightarrow> abupd (throw a') s1" |
12854 | 562 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
563 |
\<comment> \<open>cf. 14.18.1\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
564 |
| Try: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c1\<rightarrow> s1; G\<turnstile>s1 \<midarrow>sxalloc\<rightarrow> s2; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
565 |
if G,s2\<turnstile>catch C then G\<turnstile>new_xcpt_var vn s2 \<midarrow>c2\<rightarrow> s3 else s3 = s2\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
566 |
G\<turnstile>Norm s0 \<midarrow>Try c1 Catch(C vn) c2\<rightarrow> s3" |
12854 | 567 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
568 |
\<comment> \<open>cf. 14.18.2\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
569 |
| Fin: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>c1\<rightarrow> (x1,s1); |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
570 |
G\<turnstile>Norm s1 \<midarrow>c2\<rightarrow> s2; |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
571 |
s3=(if (\<exists> err. x1=Some (Error err)) |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
572 |
then (x1,s1) |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
573 |
else abupd (abrupt_if (x1\<noteq>None) x1) s2) \<rbrakk> |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
574 |
\<Longrightarrow> |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
575 |
G\<turnstile>Norm s0 \<midarrow>c1 Finally c2\<rightarrow> s3" |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
576 |
\<comment> \<open>cf. 12.4.2, 8.5\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
577 |
| Init: "\<lbrakk>the (class G C) = c; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
578 |
if inited C (globs s0) then s3 = Norm s0 |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
579 |
else (G\<turnstile>Norm (init_class_obj G C s0) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
580 |
\<midarrow>(if C = Object then Skip else Init (super c))\<rightarrow> s1 \<and> |
68451 | 581 |
G\<turnstile>set_lvars Map.empty s1 \<midarrow>init c\<rightarrow> s2 \<and> s3 = restore_lvars s1 s2)\<rbrakk> |
12854 | 582 |
\<Longrightarrow> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
583 |
G\<turnstile>Norm s0 \<midarrow>Init C\<rightarrow> s3" |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
584 |
\<comment> \<open>This class initialisation rule is a little bit inaccurate. Look at the |
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
585 |
exact sequence: |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
586 |
(1) The current class object (the static fields) are initialised |
62042 | 587 |
(\<open>init_class_obj\<close>), |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
588 |
(2) the superclasses are initialised, |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
589 |
(3) the static initialiser of the current class is invoked. |
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
590 |
More precisely we should expect another ordering, namely 2 1 3. |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
591 |
But we can't just naively toggle 1 and 2. By calling |
62042 | 592 |
\<open>init_class_obj\<close> |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
593 |
before initialising the superclasses, we also implicitly record that |
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
594 |
we have started to initialise the current class (by setting an |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
595 |
value for the class object). This becomes |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
596 |
crucial for the completeness proof of the axiomatic semantics |
62042 | 597 |
\<open>AxCompl.thy\<close>. Static initialisation requires an induction on |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
598 |
the number of classes not yet initialised (or to be more precise, |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
599 |
classes were the initialisation has not yet begun). |
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
600 |
So we could first assign a dummy value to the class before |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
601 |
superclass initialisation and afterwards set the correct values. |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
602 |
But as long as we don't take memory overflow into account |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
603 |
when allocating class objects, we can leave things as they are for |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
604 |
convenience.\<close> |
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
605 |
\<comment> \<open>evaluation of expressions\<close> |
12854 | 606 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
607 |
\<comment> \<open>cf. 15.8.1, 12.4.1\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
608 |
| NewC: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init C\<rightarrow> s1; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
609 |
G\<turnstile> s1 \<midarrow>halloc (CInst C)\<succ>a\<rightarrow> s2\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
610 |
G\<turnstile>Norm s0 \<midarrow>NewC C-\<succ>Addr a\<rightarrow> s2" |
12854 | 611 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
612 |
\<comment> \<open>cf. 15.9.1, 12.4.1\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
613 |
| NewA: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>init_comp_ty T\<rightarrow> s1; G\<turnstile>s1 \<midarrow>e-\<succ>i'\<rightarrow> s2; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
614 |
G\<turnstile>abupd (check_neg i') s2 \<midarrow>halloc (Arr T (the_Intg i'))\<succ>a\<rightarrow> s3\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
615 |
G\<turnstile>Norm s0 \<midarrow>New T[e]-\<succ>Addr a\<rightarrow> s3" |
12854 | 616 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
617 |
\<comment> \<open>cf. 15.15\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
618 |
| Cast: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
619 |
s2 = abupd (raise_if (\<not>G,store s1\<turnstile>v fits T) ClassCast) s1\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
620 |
G\<turnstile>Norm s0 \<midarrow>Cast T e-\<succ>v\<rightarrow> s2" |
12854 | 621 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
622 |
\<comment> \<open>cf. 15.19.2\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
623 |
| Inst: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
624 |
b = (v\<noteq>Null \<and> G,store s1\<turnstile>v fits RefT T)\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
625 |
G\<turnstile>Norm s0 \<midarrow>e InstOf T-\<succ>Bool b\<rightarrow> s1" |
12854 | 626 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
627 |
\<comment> \<open>cf. 15.7.1\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
628 |
| Lit: "G\<turnstile>Norm s \<midarrow>Lit v-\<succ>v\<rightarrow> Norm s" |
12854 | 629 |
|
21765 | 630 |
| UnOp: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>v\<rightarrow> s1\<rbrakk> |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
631 |
\<Longrightarrow> G\<turnstile>Norm s0 \<midarrow>UnOp unop e-\<succ>(eval_unop unop v)\<rightarrow> s1" |
13384 | 632 |
|
21765 | 633 |
| BinOp: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e1-\<succ>v1\<rightarrow> s1; |
13384 | 634 |
G\<turnstile>s1 \<midarrow>(if need_second_arg binop v1 then (In1l e2) else (In1r Skip)) |
21765 | 635 |
\<succ>\<rightarrow> (In1 v2, s2) |
13384 | 636 |
\<rbrakk> |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
637 |
\<Longrightarrow> G\<turnstile>Norm s0 \<midarrow>BinOp binop e1 e2-\<succ>(eval_binop binop v1 v2)\<rightarrow> s2" |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
638 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
639 |
\<comment> \<open>cf. 15.10.2\<close> |
21765 | 640 |
| Super: "G\<turnstile>Norm s \<midarrow>Super-\<succ>val_this s\<rightarrow> Norm s" |
12854 | 641 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
642 |
\<comment> \<open>cf. 15.2\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
643 |
| Acc: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>va=\<succ>(v,f)\<rightarrow> s1\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
644 |
G\<turnstile>Norm s0 \<midarrow>Acc va-\<succ>v\<rightarrow> s1" |
12854 | 645 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
646 |
\<comment> \<open>cf. 15.25.1\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
647 |
| Ass: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>va=\<succ>(w,f)\<rightarrow> s1; |
12854 | 648 |
G\<turnstile> s1 \<midarrow>e-\<succ>v \<rightarrow> s2\<rbrakk> \<Longrightarrow> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
649 |
G\<turnstile>Norm s0 \<midarrow>va:=e-\<succ>v\<rightarrow> assign f v s2" |
12854 | 650 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
651 |
\<comment> \<open>cf. 15.24\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
652 |
| Cond: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e0-\<succ>b\<rightarrow> s1; |
12854 | 653 |
G\<turnstile> s1 \<midarrow>(if the_Bool b then e1 else e2)-\<succ>v\<rightarrow> s2\<rbrakk> \<Longrightarrow> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
654 |
G\<turnstile>Norm s0 \<midarrow>e0 ? e1 : e2-\<succ>v\<rightarrow> s2" |
12854 | 655 |
|
656 |
||
69597 | 657 |
\<comment> \<open>The interplay of \<^term>\<open>Call\<close>, \<^term>\<open>Methd\<close> and \<^term>\<open>Body\<close>: |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
658 |
Method invocation is split up into these three rules: |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
659 |
\begin{itemize} |
69597 | 660 |
\item [\<^term>\<open>Call\<close>] Calculates the target address and evaluates the |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
661 |
arguments of the method, and then performs dynamic |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
662 |
or static lookup of the method, corresponding to the |
69597 | 663 |
call mode. Then the \<^term>\<open>Methd\<close> rule is evaluated |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
664 |
on the calculated declaration class of the method |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
665 |
invocation. |
69597 | 666 |
\item [\<^term>\<open>Methd\<close>] A syntactic bridge for the folded method body. |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
667 |
It is used by the axiomatic semantics to add the |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
668 |
proper hypothesis for recursive calls of the method. |
69597 | 669 |
\item [\<^term>\<open>Body\<close>] An extra syntactic entity for the unfolded method |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
670 |
body was introduced to properly trigger class |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
671 |
initialisation. Without class initialisation we |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
672 |
could just evaluate the body statement. |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
673 |
\end{itemize}\<close> |
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
674 |
\<comment> \<open>cf. 15.11.4.1, 15.11.4.2, 15.11.4.4, 15.11.4.5\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
675 |
| Call: |
12854 | 676 |
"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>a'\<rightarrow> s1; G\<turnstile>s1 \<midarrow>args\<doteq>\<succ>vs\<rightarrow> s2; |
677 |
D = invocation_declclass G mode (store s2) a' statT \<lparr>name=mn,parTs=pTs\<rparr>; |
|
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
678 |
s3=init_lvars G D \<lparr>name=mn,parTs=pTs\<rparr> mode a' vs s2; |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
679 |
s3' = check_method_access G accC statT mode \<lparr>name=mn,parTs=pTs\<rparr> a' s3; |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
680 |
G\<turnstile>s3' \<midarrow>Methd D \<lparr>name=mn,parTs=pTs\<rparr>-\<succ>v\<rightarrow> s4\<rbrakk> |
12854 | 681 |
\<Longrightarrow> |
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
682 |
G\<turnstile>Norm s0 \<midarrow>{accC,statT,mode}e\<cdot>mn({pTs}args)-\<succ>v\<rightarrow> (restore_lvars s2 s4)" |
69597 | 683 |
\<comment> \<open>The accessibility check is after \<^term>\<open>init_lvars\<close>, to keep it simple. |
684 |
\<^term>\<open>init_lvars\<close> already tests for the absence of a null-pointer |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
685 |
reference in case of an instance method invocation.\<close> |
12854 | 686 |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
687 |
| Methd: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>body G D sig-\<succ>v\<rightarrow> s1\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
688 |
G\<turnstile>Norm s0 \<midarrow>Methd D sig-\<succ>v\<rightarrow> s1" |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
689 |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
690 |
| Body: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init D\<rightarrow> s1; G\<turnstile>s1 \<midarrow>c\<rightarrow> s2; |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
691 |
s3 = (if (\<exists> l. abrupt s2 = Some (Jump (Break l)) \<or> |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
692 |
abrupt s2 = Some (Jump (Cont l))) |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
693 |
then abupd (\<lambda> x. Some (Error CrossMethodJump)) s2 |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
694 |
else s2)\<rbrakk> \<Longrightarrow> |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
695 |
G\<turnstile>Norm s0 \<midarrow>Body D c-\<succ>the (locals (store s2) Result) |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
696 |
\<rightarrow>abupd (absorb Ret) s3" |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
697 |
\<comment> \<open>cf. 14.15, 12.4.1\<close> |
69597 | 698 |
\<comment> \<open>We filter out a break/continue in \<^term>\<open>s2\<close>, so that we can proof |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
699 |
definite assignment |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
700 |
correct, without the need of conformance of the state. By this the |
62042 | 701 |
different parts of the typesafety proof can be disentangled a little.\<close> |
12854 | 702 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
703 |
\<comment> \<open>evaluation of variables\<close> |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
704 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
705 |
\<comment> \<open>cf. 15.13.1, 15.7.2\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
706 |
| LVar: "G\<turnstile>Norm s \<midarrow>LVar vn=\<succ>lvar vn s\<rightarrow> Norm s" |
12854 | 707 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
708 |
\<comment> \<open>cf. 15.10.1, 12.4.1\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
709 |
| FVar: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init statDeclC\<rightarrow> s1; G\<turnstile>s1 \<midarrow>e-\<succ>a\<rightarrow> s2; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
710 |
(v,s2') = fvar statDeclC stat fn a s2; |
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
711 |
s3 = check_field_access G accC statDeclC fn stat a s2' \<rbrakk> \<Longrightarrow> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
712 |
G\<turnstile>Norm s0 \<midarrow>{accC,statDeclC,stat}e..fn=\<succ>v\<rightarrow> s3" |
69597 | 713 |
\<comment> \<open>The accessibility check is after \<^term>\<open>fvar\<close>, to keep it simple. |
714 |
\<^term>\<open>fvar\<close> already tests for the absence of a null-pointer reference |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
715 |
in case of an instance field\<close> |
12854 | 716 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
717 |
\<comment> \<open>cf. 15.12.1, 15.25.1\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
718 |
| AVar: "\<lbrakk>G\<turnstile> Norm s0 \<midarrow>e1-\<succ>a\<rightarrow> s1; G\<turnstile>s1 \<midarrow>e2-\<succ>i\<rightarrow> s2; |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
719 |
(v,s2') = avar G i a s2\<rbrakk> \<Longrightarrow> |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
720 |
G\<turnstile>Norm s0 \<midarrow>e1.[e2]=\<succ>v\<rightarrow> s2'" |
12854 | 721 |
|
722 |
||
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
723 |
\<comment> \<open>evaluation of expression lists\<close> |
12854 | 724 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
725 |
\<comment> \<open>cf. 15.11.4.2\<close> |
21765 | 726 |
| Nil: |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
727 |
"G\<turnstile>Norm s0 \<midarrow>[]\<doteq>\<succ>[]\<rightarrow> Norm s0" |
12854 | 728 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
66110
diff
changeset
|
729 |
\<comment> \<open>cf. 15.6.4\<close> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
730 |
| Cons: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e -\<succ> v \<rightarrow> s1; |
12854 | 731 |
G\<turnstile> s1 \<midarrow>es\<doteq>\<succ>vs\<rightarrow> s2\<rbrakk> \<Longrightarrow> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
732 |
G\<turnstile>Norm s0 \<midarrow>e#es\<doteq>\<succ>v#vs\<rightarrow> s2" |
12854 | 733 |
|
734 |
(* Rearrangement of premisses: |
|
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
735 |
[0,1(Abrupt),2(Skip),8(Jmp),4(Lab),30(Nil),31(Cons),27(LVar),17(Cast),18(Inst), |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
736 |
17(Lit),18(UnOp),19(BinOp),20(Super),21(Acc),3(Expr),5(Comp),25(Methd),26(Body),23(Cond),6(If), |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
737 |
7(Loop),11(Fin),9(Throw),13(NewC),14(NewA),12(Init),22(Ass),10(Try),28(FVar), |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
738 |
29(AVar),24(Call)] |
12854 | 739 |
*) |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
740 |
|
62042 | 741 |
ML \<open> |
56199 | 742 |
ML_Thms.bind_thm ("eval_induct", rearrange_prems |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
743 |
[0,1,2,8,4,30,31,27,15,16, |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
744 |
17,18,19,20,21,3,5,25,26,23,6, |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
745 |
7,11,9,13,14,12,22,10,28, |
24019 | 746 |
29,24] @{thm eval.induct}) |
62042 | 747 |
\<close> |
12854 | 748 |
|
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
749 |
|
62390 | 750 |
declare if_split [split del] if_split_asm [split del] |
12854 | 751 |
option.split [split del] option.split_asm [split del] |
23747 | 752 |
inductive_cases halloc_elim_cases: |
12854 | 753 |
"G\<turnstile>(Some xc,s) \<midarrow>halloc oi\<succ>a\<rightarrow> s'" |
754 |
"G\<turnstile>(Norm s) \<midarrow>halloc oi\<succ>a\<rightarrow> s'" |
|
755 |
||
23747 | 756 |
inductive_cases sxalloc_elim_cases: |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
757 |
"G\<turnstile> Norm s \<midarrow>sxalloc\<rightarrow> s'" |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
758 |
"G\<turnstile>(Some (Jump j),s) \<midarrow>sxalloc\<rightarrow> s'" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
759 |
"G\<turnstile>(Some (Error e),s) \<midarrow>sxalloc\<rightarrow> s'" |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
760 |
"G\<turnstile>(Some (Xcpt (Loc a )),s) \<midarrow>sxalloc\<rightarrow> s'" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
761 |
"G\<turnstile>(Some (Xcpt (Std xn)),s) \<midarrow>sxalloc\<rightarrow> s'" |
23747 | 762 |
inductive_cases sxalloc_cases: "G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s'" |
12854 | 763 |
|
764 |
lemma sxalloc_elim_cases2: "\<lbrakk>G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s'; |
|
765 |
\<And>s. \<lbrakk>s' = Norm s\<rbrakk> \<Longrightarrow> P; |
|
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
766 |
\<And>j s. \<lbrakk>s' = (Some (Jump j),s)\<rbrakk> \<Longrightarrow> P; |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
767 |
\<And>e s. \<lbrakk>s' = (Some (Error e),s)\<rbrakk> \<Longrightarrow> P; |
12854 | 768 |
\<And>a s. \<lbrakk>s' = (Some (Xcpt (Loc a)),s)\<rbrakk> \<Longrightarrow> P |
769 |
\<rbrakk> \<Longrightarrow> P" |
|
770 |
apply cut_tac |
|
771 |
apply (erule sxalloc_cases) |
|
772 |
apply blast+ |
|
773 |
done |
|
774 |
||
775 |
declare not_None_eq [simp del] (* IntDef.Zero_def [simp del] *) |
|
776 |
declare split_paired_All [simp del] split_paired_Ex [simp del] |
|
62042 | 777 |
setup \<open>map_theory_simpset (fn ctxt => ctxt delloop "split_all_tac")\<close> |
24019 | 778 |
|
23747 | 779 |
inductive_cases eval_cases: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v, s')" |
12854 | 780 |
|
23747 | 781 |
inductive_cases eval_elim_cases [cases set]: |
21765 | 782 |
"G\<turnstile>(Some xc,s) \<midarrow>t \<succ>\<rightarrow> (v, s')" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
783 |
"G\<turnstile>Norm s \<midarrow>In1r Skip \<succ>\<rightarrow> (x, s')" |
21765 | 784 |
"G\<turnstile>Norm s \<midarrow>In1r (Jmp j) \<succ>\<rightarrow> (x, s')" |
785 |
"G\<turnstile>Norm s \<midarrow>In1r (l\<bullet> c) \<succ>\<rightarrow> (x, s')" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
786 |
"G\<turnstile>Norm s \<midarrow>In3 ([]) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
787 |
"G\<turnstile>Norm s \<midarrow>In3 (e#es) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
788 |
"G\<turnstile>Norm s \<midarrow>In1l (Lit w) \<succ>\<rightarrow> (v, s')" |
21765 | 789 |
"G\<turnstile>Norm s \<midarrow>In1l (UnOp unop e) \<succ>\<rightarrow> (v, s')" |
790 |
"G\<turnstile>Norm s \<midarrow>In1l (BinOp binop e1 e2) \<succ>\<rightarrow> (v, s')" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
791 |
"G\<turnstile>Norm s \<midarrow>In2 (LVar vn) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
792 |
"G\<turnstile>Norm s \<midarrow>In1l (Cast T e) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
793 |
"G\<turnstile>Norm s \<midarrow>In1l (e InstOf T) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
794 |
"G\<turnstile>Norm s \<midarrow>In1l (Super) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
795 |
"G\<turnstile>Norm s \<midarrow>In1l (Acc va) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
796 |
"G\<turnstile>Norm s \<midarrow>In1r (Expr e) \<succ>\<rightarrow> (x, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
797 |
"G\<turnstile>Norm s \<midarrow>In1r (c1;; c2) \<succ>\<rightarrow> (x, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
798 |
"G\<turnstile>Norm s \<midarrow>In1l (Methd C sig) \<succ>\<rightarrow> (x, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
799 |
"G\<turnstile>Norm s \<midarrow>In1l (Body D c) \<succ>\<rightarrow> (x, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
800 |
"G\<turnstile>Norm s \<midarrow>In1l (e0 ? e1 : e2) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
801 |
"G\<turnstile>Norm s \<midarrow>In1r (If(e) c1 Else c2) \<succ>\<rightarrow> (x, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
802 |
"G\<turnstile>Norm s \<midarrow>In1r (l\<bullet> While(e) c) \<succ>\<rightarrow> (x, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
803 |
"G\<turnstile>Norm s \<midarrow>In1r (c1 Finally c2) \<succ>\<rightarrow> (x, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
804 |
"G\<turnstile>Norm s \<midarrow>In1r (Throw e) \<succ>\<rightarrow> (x, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
805 |
"G\<turnstile>Norm s \<midarrow>In1l (NewC C) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
806 |
"G\<turnstile>Norm s \<midarrow>In1l (New T[e]) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
807 |
"G\<turnstile>Norm s \<midarrow>In1l (Ass va e) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
808 |
"G\<turnstile>Norm s \<midarrow>In1r (Try c1 Catch(tn vn) c2) \<succ>\<rightarrow> (x, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
809 |
"G\<turnstile>Norm s \<midarrow>In2 ({accC,statDeclC,stat}e..fn) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
810 |
"G\<turnstile>Norm s \<midarrow>In2 (e1.[e2]) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
811 |
"G\<turnstile>Norm s \<midarrow>In1l ({accC,statT,mode}e\<cdot>mn({pT}p)) \<succ>\<rightarrow> (v, s')" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
28524
diff
changeset
|
812 |
"G\<turnstile>Norm s \<midarrow>In1r (Init C) \<succ>\<rightarrow> (x, s')" |
12854 | 813 |
declare not_None_eq [simp] (* IntDef.Zero_def [simp] *) |
814 |
declare split_paired_All [simp] split_paired_Ex [simp] |
|
62042 | 815 |
declaration \<open>K (Simplifier.map_ss (fn ss => ss addloop ("split_all_tac", split_all_tac)))\<close> |
62390 | 816 |
declare if_split [split] if_split_asm [split] |
12854 | 817 |
option.split [split] option.split_asm [split] |
818 |
||
819 |
lemma eval_Inj_elim: |
|
820 |
"G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (w,s') |
|
821 |
\<Longrightarrow> case t of |
|
822 |
In1 ec \<Rightarrow> (case ec of |
|
823 |
Inl e \<Rightarrow> (\<exists>v. w = In1 v) |
|
824 |
| Inr c \<Rightarrow> w = \<diamondsuit>) |
|
825 |
| In2 e \<Rightarrow> (\<exists>v. w = In2 v) |
|
826 |
| In3 e \<Rightarrow> (\<exists>v. w = In3 v)" |
|
827 |
apply (erule eval_cases) |
|
828 |
apply auto |
|
829 |
apply (induct_tac "t") |
|
58251 | 830 |
apply (rename_tac a, induct_tac "a") |
12854 | 831 |
apply auto |
832 |
done |
|
833 |
||
62042 | 834 |
text \<open>The following simplification procedures set up the proper injections of |
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
835 |
terms and their corresponding values in the evaluation relation: |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
836 |
E.g. an expression |
69597 | 837 |
(injection \<^term>\<open>In1l\<close> into terms) always evaluates to ordinary values |
838 |
(injection \<^term>\<open>In1\<close> into generalised values \<^term>\<open>vals\<close>). |
|
62042 | 839 |
\<close> |
21765 | 840 |
|
841 |
lemma eval_expr_eq: "G\<turnstile>s \<midarrow>In1l t\<succ>\<rightarrow> (w, s') = (\<exists>v. w=In1 v \<and> G\<turnstile>s \<midarrow>t-\<succ>v \<rightarrow> s')" |
|
842 |
by (auto, frule eval_Inj_elim, auto) |
|
843 |
||
844 |
lemma eval_var_eq: "G\<turnstile>s \<midarrow>In2 t\<succ>\<rightarrow> (w, s') = (\<exists>vf. w=In2 vf \<and> G\<turnstile>s \<midarrow>t=\<succ>vf\<rightarrow> s')" |
|
845 |
by (auto, frule eval_Inj_elim, auto) |
|
846 |
||
847 |
lemma eval_exprs_eq: "G\<turnstile>s \<midarrow>In3 t\<succ>\<rightarrow> (w, s') = (\<exists>vs. w=In3 vs \<and> G\<turnstile>s \<midarrow>t\<doteq>\<succ>vs\<rightarrow> s')" |
|
848 |
by (auto, frule eval_Inj_elim, auto) |
|
849 |
||
850 |
lemma eval_stmt_eq: "G\<turnstile>s \<midarrow>In1r t\<succ>\<rightarrow> (w, s') = (w=\<diamondsuit> \<and> G\<turnstile>s \<midarrow>t \<rightarrow> s')" |
|
851 |
by (auto, frule eval_Inj_elim, auto, frule eval_Inj_elim, auto) |
|
852 |
||
62042 | 853 |
simproc_setup eval_expr ("G\<turnstile>s \<midarrow>In1l t\<succ>\<rightarrow> (w, s')") = \<open> |
24019 | 854 |
fn _ => fn _ => fn ct => |
855 |
(case Thm.term_of ct of |
|
856 |
(_ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE |
|
62042 | 857 |
| _ => SOME (mk_meta_eq @{thm eval_expr_eq}))\<close> |
24019 | 858 |
|
62042 | 859 |
simproc_setup eval_var ("G\<turnstile>s \<midarrow>In2 t\<succ>\<rightarrow> (w, s')") = \<open> |
24019 | 860 |
fn _ => fn _ => fn ct => |
861 |
(case Thm.term_of ct of |
|
862 |
(_ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE |
|
62042 | 863 |
| _ => SOME (mk_meta_eq @{thm eval_var_eq}))\<close> |
24019 | 864 |
|
62042 | 865 |
simproc_setup eval_exprs ("G\<turnstile>s \<midarrow>In3 t\<succ>\<rightarrow> (w, s')") = \<open> |
24019 | 866 |
fn _ => fn _ => fn ct => |
867 |
(case Thm.term_of ct of |
|
868 |
(_ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE |
|
62042 | 869 |
| _ => SOME (mk_meta_eq @{thm eval_exprs_eq}))\<close> |
24019 | 870 |
|
62042 | 871 |
simproc_setup eval_stmt ("G\<turnstile>s \<midarrow>In1r t\<succ>\<rightarrow> (w, s')") = \<open> |
24019 | 872 |
fn _ => fn _ => fn ct => |
873 |
(case Thm.term_of ct of |
|
874 |
(_ $ _ $ _ $ _ $ (Const _ $ _) $ _) => NONE |
|
62042 | 875 |
| _ => SOME (mk_meta_eq @{thm eval_stmt_eq}))\<close> |
24019 | 876 |
|
62042 | 877 |
ML \<open> |
69597 | 878 |
ML_Thms.bind_thms ("AbruptIs", sum3_instantiate \<^context> @{thm eval.Abrupt}) |
62042 | 879 |
\<close> |
12854 | 880 |
|
24019 | 881 |
declare halloc.Abrupt [intro!] eval.Abrupt [intro!] AbruptIs [intro!] |
12854 | 882 |
|
62042 | 883 |
text\<open>\<open>Callee\<close>,\<open>InsInitE\<close>, \<open>InsInitV\<close>, \<open>FinA\<close> are only |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
884 |
used in smallstep semantics, not in the bigstep semantics. So their is no |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
885 |
valid evaluation of these terms |
62042 | 886 |
\<close> |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
887 |
|
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
888 |
|
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
889 |
lemma eval_Callee: "G\<turnstile>Norm s\<midarrow>Callee l e-\<succ>v\<rightarrow> s' = False" |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
890 |
proof - |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
891 |
{ fix s t v s' |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
892 |
assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
893 |
normal: "normal s" and |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
894 |
callee: "t=In1l (Callee l e)" |
21765 | 895 |
then have "False" by induct auto |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
896 |
} |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
897 |
then show ?thesis |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41778
diff
changeset
|
898 |
by (cases s') fastforce |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
899 |
qed |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
900 |
|
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
901 |
|
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
902 |
lemma eval_InsInitE: "G\<turnstile>Norm s\<midarrow>InsInitE c e-\<succ>v\<rightarrow> s' = False" |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
903 |
proof - |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
904 |
{ fix s t v s' |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
905 |
assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
906 |
normal: "normal s" and |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
907 |
callee: "t=In1l (InsInitE c e)" |
21765 | 908 |
then have "False" by induct auto |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
909 |
} |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
910 |
then show ?thesis |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41778
diff
changeset
|
911 |
by (cases s') fastforce |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
912 |
qed |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
913 |
|
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
914 |
lemma eval_InsInitV: "G\<turnstile>Norm s\<midarrow>InsInitV c w=\<succ>v\<rightarrow> s' = False" |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
915 |
proof - |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
916 |
{ fix s t v s' |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
917 |
assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
918 |
normal: "normal s" and |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
919 |
callee: "t=In2 (InsInitV c w)" |
21765 | 920 |
then have "False" by induct auto |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
921 |
} |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
922 |
then show ?thesis |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41778
diff
changeset
|
923 |
by (cases s') fastforce |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
924 |
qed |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
925 |
|
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
926 |
lemma eval_FinA: "G\<turnstile>Norm s\<midarrow>FinA a c\<rightarrow> s' = False" |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
927 |
proof - |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
928 |
{ fix s t v s' |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
929 |
assume eval: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s')" and |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
930 |
normal: "normal s" and |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
931 |
callee: "t=In1r (FinA a c)" |
21765 | 932 |
then have "False" by induct auto |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
933 |
} |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
934 |
then show ?thesis |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
41778
diff
changeset
|
935 |
by (cases s') fastforce |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
936 |
qed |
12854 | 937 |
|
938 |
lemma eval_no_abrupt_lemma: |
|
939 |
"\<And>s s'. G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (w,s') \<Longrightarrow> normal s' \<longrightarrow> normal s" |
|
940 |
by (erule eval_cases, auto) |
|
941 |
||
942 |
lemma eval_no_abrupt: |
|
943 |
"G\<turnstile>(x,s) \<midarrow>t\<succ>\<rightarrow> (w,Norm s') = |
|
944 |
(x = None \<and> G\<turnstile>Norm s \<midarrow>t\<succ>\<rightarrow> (w,Norm s'))" |
|
945 |
apply auto |
|
946 |
apply (frule eval_no_abrupt_lemma, auto)+ |
|
947 |
done |
|
948 |
||
62042 | 949 |
simproc_setup eval_no_abrupt ("G\<turnstile>(x,s) \<midarrow>e\<succ>\<rightarrow> (w,Norm s')") = \<open> |
24019 | 950 |
fn _ => fn _ => fn ct => |
951 |
(case Thm.term_of ct of |
|
69597 | 952 |
(_ $ _ $ (Const (\<^const_name>\<open>Pair\<close>, _) $ (Const (\<^const_name>\<open>None\<close>, _)) $ _) $ _ $ _ $ _) => NONE |
24019 | 953 |
| _ => SOME (mk_meta_eq @{thm eval_no_abrupt})) |
62042 | 954 |
\<close> |
12854 | 955 |
|
956 |
||
957 |
lemma eval_abrupt_lemma: |
|
28524 | 958 |
"G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v,s') \<Longrightarrow> abrupt s=Some xc \<longrightarrow> s'= s \<and> v = undefined3 t" |
12854 | 959 |
by (erule eval_cases, auto) |
960 |
||
961 |
lemma eval_abrupt: |
|
962 |
" G\<turnstile>(Some xc,s) \<midarrow>t\<succ>\<rightarrow> (w,s') = |
|
28524 | 963 |
(s'=(Some xc,s) \<and> w=undefined3 t \<and> |
964 |
G\<turnstile>(Some xc,s) \<midarrow>t\<succ>\<rightarrow> (undefined3 t,(Some xc,s)))" |
|
12854 | 965 |
apply auto |
966 |
apply (frule eval_abrupt_lemma, auto)+ |
|
967 |
done |
|
968 |
||
62042 | 969 |
simproc_setup eval_abrupt ("G\<turnstile>(Some xc,s) \<midarrow>e\<succ>\<rightarrow> (w,s')") = \<open> |
24019 | 970 |
fn _ => fn _ => fn ct => |
971 |
(case Thm.term_of ct of |
|
69597 | 972 |
(_ $ _ $ _ $ _ $ _ $ (Const (\<^const_name>\<open>Pair\<close>, _) $ (Const (\<^const_name>\<open>Some\<close>, _) $ _)$ _)) => NONE |
24019 | 973 |
| _ => SOME (mk_meta_eq @{thm eval_abrupt})) |
62042 | 974 |
\<close> |
12854 | 975 |
|
28524 | 976 |
lemma LitI: "G\<turnstile>s \<midarrow>Lit v-\<succ>(if normal s then v else undefined)\<rightarrow> s" |
12854 | 977 |
apply (case_tac "s", case_tac "a = None") |
978 |
by (auto intro!: eval.Lit) |
|
979 |
||
980 |
lemma SkipI [intro!]: "G\<turnstile>s \<midarrow>Skip\<rightarrow> s" |
|
981 |
apply (case_tac "s", case_tac "a = None") |
|
982 |
by (auto intro!: eval.Skip) |
|
983 |
||
984 |
lemma ExprI: "G\<turnstile>s \<midarrow>e-\<succ>v\<rightarrow> s' \<Longrightarrow> G\<turnstile>s \<midarrow>Expr e\<rightarrow> s'" |
|
985 |
apply (case_tac "s", case_tac "a = None") |
|
986 |
by (auto intro!: eval.Expr) |
|
987 |
||
988 |
lemma CompI: "\<lbrakk>G\<turnstile>s \<midarrow>c1\<rightarrow> s1; G\<turnstile>s1 \<midarrow>c2\<rightarrow> s2\<rbrakk> \<Longrightarrow> G\<turnstile>s \<midarrow>c1;; c2\<rightarrow> s2" |
|
989 |
apply (case_tac "s", case_tac "a = None") |
|
990 |
by (auto intro!: eval.Comp) |
|
991 |
||
992 |
lemma CondI: |
|
993 |
"\<And>s1. \<lbrakk>G\<turnstile>s \<midarrow>e-\<succ>b\<rightarrow> s1; G\<turnstile>s1 \<midarrow>(if the_Bool b then e1 else e2)-\<succ>v\<rightarrow> s2\<rbrakk> \<Longrightarrow> |
|
28524 | 994 |
G\<turnstile>s \<midarrow>e ? e1 : e2-\<succ>(if normal s1 then v else undefined)\<rightarrow> s2" |
12854 | 995 |
apply (case_tac "s", case_tac "a = None") |
996 |
by (auto intro!: eval.Cond) |
|
997 |
||
998 |
lemma IfI: "\<lbrakk>G\<turnstile>s \<midarrow>e-\<succ>v\<rightarrow> s1; G\<turnstile>s1 \<midarrow>(if the_Bool v then c1 else c2)\<rightarrow> s2\<rbrakk> |
|
999 |
\<Longrightarrow> G\<turnstile>s \<midarrow>If(e) c1 Else c2\<rightarrow> s2" |
|
1000 |
apply (case_tac "s", case_tac "a = None") |
|
1001 |
by (auto intro!: eval.If) |
|
1002 |
||
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1003 |
lemma MethdI: "G\<turnstile>s \<midarrow>body G C sig-\<succ>v\<rightarrow> s' |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1004 |
\<Longrightarrow> G\<turnstile>s \<midarrow>Methd C sig-\<succ>v\<rightarrow> s'" |
12854 | 1005 |
apply (case_tac "s", case_tac "a = None") |
1006 |
by (auto intro!: eval.Methd) |
|
1007 |
||
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
1008 |
lemma eval_Call: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
1009 |
"\<lbrakk>G\<turnstile>Norm s0 \<midarrow>e-\<succ>a'\<rightarrow> s1; G\<turnstile>s1 \<midarrow>ps\<doteq>\<succ>pvs\<rightarrow> s2; |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
1010 |
D = invocation_declclass G mode (store s2) a' statT \<lparr>name=mn,parTs=pTs\<rparr>; |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
1011 |
s3 = init_lvars G D \<lparr>name=mn,parTs=pTs\<rparr> mode a' pvs s2; |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
1012 |
s3' = check_method_access G accC statT mode \<lparr>name=mn,parTs=pTs\<rparr> a' s3; |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
1013 |
G\<turnstile>s3'\<midarrow>Methd D \<lparr>name=mn,parTs=pTs\<rparr>-\<succ> v\<rightarrow> s4; |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
1014 |
s4' = restore_lvars s2 s4\<rbrakk> \<Longrightarrow> |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12919
diff
changeset
|
1015 |
G\<turnstile>Norm s0 \<midarrow>{accC,statT,mode}e\<cdot>mn({pTs}ps)-\<succ>v\<rightarrow> s4'" |
12854 | 1016 |
apply (drule eval.Call, assumption) |
1017 |
apply (rule HOL.refl) |
|
1018 |
apply simp+ |
|
1019 |
done |
|
1020 |
||
1021 |
lemma eval_Init: |
|
1022 |
"\<lbrakk>if inited C (globs s0) then s3 = Norm s0 |
|
1023 |
else G\<turnstile>Norm (init_class_obj G C s0) |
|
1024 |
\<midarrow>(if C = Object then Skip else Init (super (the (class G C))))\<rightarrow> s1 \<and> |
|
68451 | 1025 |
G\<turnstile>set_lvars Map.empty s1 \<midarrow>(init (the (class G C)))\<rightarrow> s2 \<and> |
12854 | 1026 |
s3 = restore_lvars s1 s2\<rbrakk> \<Longrightarrow> |
1027 |
G\<turnstile>Norm s0 \<midarrow>Init C\<rightarrow> s3" |
|
1028 |
apply (rule eval.Init) |
|
1029 |
apply auto |
|
1030 |
done |
|
1031 |
||
1032 |
lemma init_done: "initd C s \<Longrightarrow> G\<turnstile>s \<midarrow>Init C\<rightarrow> s" |
|
1033 |
apply (case_tac "s", simp) |
|
1034 |
apply (case_tac "a") |
|
1035 |
apply safe |
|
1036 |
apply (rule eval_Init) |
|
1037 |
apply auto |
|
1038 |
done |
|
1039 |
||
1040 |
lemma eval_StatRef: |
|
28524 | 1041 |
"G\<turnstile>s \<midarrow>StatRef rt-\<succ>(if abrupt s=None then Null else undefined)\<rightarrow> s" |
12854 | 1042 |
apply (case_tac "s", simp) |
1043 |
apply (case_tac "a = None") |
|
1044 |
apply (auto del: eval.Abrupt intro!: eval.intros) |
|
1045 |
done |
|
1046 |
||
1047 |
||
1048 |
lemma SkipD [dest!]: "G\<turnstile>s \<midarrow>Skip\<rightarrow> s' \<Longrightarrow> s' = s" |
|
1049 |
apply (erule eval_cases) |
|
1050 |
by auto |
|
1051 |
||
1052 |
lemma Skip_eq [simp]: "G\<turnstile>s \<midarrow>Skip\<rightarrow> s' = (s = s')" |
|
1053 |
by auto |
|
1054 |
||
1055 |
(*unused*) |
|
1056 |
lemma init_retains_locals [rule_format (no_asm)]: "G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (w,s') \<Longrightarrow> |
|
1057 |
(\<forall>C. t=In1r (Init C) \<longrightarrow> locals (store s) = locals (store s'))" |
|
1058 |
apply (erule eval.induct) |
|
62390 | 1059 |
apply (simp (no_asm_use) split del: if_split_asm option.split_asm)+ |
12854 | 1060 |
apply auto |
1061 |
done |
|
1062 |
||
1063 |
lemma halloc_xcpt [dest!]: |
|
1064 |
"\<And>s'. G\<turnstile>(Some xc,s) \<midarrow>halloc oi\<succ>a\<rightarrow> s' \<Longrightarrow> s'=(Some xc,s)" |
|
1065 |
apply (erule_tac halloc_elim_cases) |
|
1066 |
by auto |
|
1067 |
||
1068 |
(* |
|
1069 |
G\<turnstile>(x,(h,l)) \<midarrow>e\<succ>v\<rightarrow> (x',(h',l'))) \<Longrightarrow> l This = l' This" |
|
1070 |
G\<turnstile>(x,(h,l)) \<midarrow>s \<rightarrow> (x',(h',l'))) \<Longrightarrow> l This = l' This" |
|
1071 |
*) |
|
1072 |
||
1073 |
lemma eval_Methd: |
|
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1074 |
"G\<turnstile>s \<midarrow>In1l(body G C sig)\<succ>\<rightarrow> (w,s') |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1075 |
\<Longrightarrow> G\<turnstile>s \<midarrow>In1l(Methd C sig)\<succ>\<rightarrow> (w,s')" |
12854 | 1076 |
apply (case_tac "s") |
1077 |
apply (case_tac "a") |
|
1078 |
apply clarsimp+ |
|
1079 |
apply (erule eval.Methd) |
|
1080 |
apply (drule eval_abrupt_lemma) |
|
1081 |
apply force |
|
1082 |
done |
|
1083 |
||
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1084 |
lemma eval_Body: "\<lbrakk>G\<turnstile>Norm s0 \<midarrow>Init D\<rightarrow> s1; G\<turnstile>s1 \<midarrow>c\<rightarrow> s2; |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1085 |
res=the (locals (store s2) Result); |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1086 |
s3 = (if (\<exists> l. abrupt s2 = Some (Jump (Break l)) \<or> |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1087 |
abrupt s2 = Some (Jump (Cont l))) |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1088 |
then abupd (\<lambda> x. Some (Error CrossMethodJump)) s2 |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1089 |
else s2); |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1090 |
s4=abupd (absorb Ret) s3\<rbrakk> \<Longrightarrow> |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1091 |
G\<turnstile>Norm s0 \<midarrow>Body D c-\<succ>res\<rightarrow>s4" |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1092 |
by (auto elim: eval.Body) |
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1093 |
|
13384 | 1094 |
lemma eval_binop_arg2_indep: |
1095 |
"\<not> need_second_arg binop v1 \<Longrightarrow> eval_binop binop v1 x = eval_binop binop v1 y" |
|
1096 |
by (cases binop) |
|
1097 |
(simp_all add: need_second_arg_def) |
|
1098 |
||
1099 |
||
1100 |
lemma eval_BinOp_arg2_indepI: |
|
1101 |
assumes eval_e1: "G\<turnstile>Norm s0 \<midarrow>e1-\<succ>v1\<rightarrow> s1" and |
|
1102 |
no_need: "\<not> need_second_arg binop v1" |
|
1103 |
shows "G\<turnstile>Norm s0 \<midarrow>BinOp binop e1 e2-\<succ>(eval_binop binop v1 v2)\<rightarrow> s1" |
|
1104 |
(is "?EvalBinOp v2") |
|
1105 |
proof - |
|
1106 |
from eval_e1 |
|
1107 |
have "?EvalBinOp Unit" |
|
1108 |
by (rule eval.BinOp) |
|
1109 |
(simp add: no_need) |
|
1110 |
moreover |
|
1111 |
from no_need |
|
1112 |
have "eval_binop binop v1 Unit = eval_binop binop v1 v2" |
|
1113 |
by (simp add: eval_binop_arg2_indep) |
|
1114 |
ultimately |
|
1115 |
show ?thesis |
|
1116 |
by simp |
|
1117 |
qed |
|
1118 |
||
12854 | 1119 |
|
58887 | 1120 |
subsubsection "single valued" |
12854 | 1121 |
|
1122 |
lemma unique_halloc [rule_format (no_asm)]: |
|
21765 | 1123 |
"G\<turnstile>s \<midarrow>halloc oi\<succ>a \<rightarrow> s' \<Longrightarrow> G\<turnstile>s \<midarrow>halloc oi\<succ>a' \<rightarrow> s'' \<longrightarrow> a' = a \<and> s'' = s'" |
12854 | 1124 |
apply (erule halloc.induct) |
62390 | 1125 |
apply (auto elim!: halloc_elim_cases split del: if_split if_split_asm) |
12854 | 1126 |
apply (drule trans [THEN sym], erule sym) |
1127 |
defer |
|
1128 |
apply (drule trans [THEN sym], erule sym) |
|
1129 |
apply auto |
|
1130 |
done |
|
1131 |
||
1132 |
||
1133 |
lemma single_valued_halloc: |
|
1134 |
"single_valued {((s,oi),(a,s')). G\<turnstile>s \<midarrow>halloc oi\<succ>a \<rightarrow> s'}" |
|
1135 |
apply (unfold single_valued_def) |
|
1136 |
by (clarsimp, drule (1) unique_halloc, auto) |
|
1137 |
||
1138 |
||
1139 |
lemma unique_sxalloc [rule_format (no_asm)]: |
|
21765 | 1140 |
"G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s' \<Longrightarrow> G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s'' \<longrightarrow> s'' = s'" |
12854 | 1141 |
apply (erule sxalloc.induct) |
1142 |
apply (auto dest: unique_halloc elim!: sxalloc_elim_cases |
|
62390 | 1143 |
split del: if_split if_split_asm) |
12854 | 1144 |
done |
1145 |
||
1146 |
lemma single_valued_sxalloc: "single_valued {(s,s'). G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s'}" |
|
1147 |
apply (unfold single_valued_def) |
|
1148 |
apply (blast dest: unique_sxalloc) |
|
1149 |
done |
|
1150 |
||
1151 |
lemma split_pairD: "(x,y) = p \<Longrightarrow> x = fst p & y = snd p" |
|
1152 |
by auto |
|
1153 |
||
13688
a0b16d42d489
"Definite Assignment Analysis" included, with proof of correctness. Large adjustments of type safety proof and soundness proof of the axiomatic semantics were necessary. Completeness proof of the loop rule of the axiomatic semantic was altered. So the additional polymorphic variants of some rules could be removed.
schirmer
parents:
13601
diff
changeset
|
1154 |
|
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1155 |
|
12854 | 1156 |
lemma unique_eval [rule_format (no_asm)]: |
21765 | 1157 |
"G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (w, s') \<Longrightarrow> (\<forall>w' s''. G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (w', s'') \<longrightarrow> w' = w \<and> s'' = s')" |
12854 | 1158 |
apply (erule eval_induct) |
62042 | 1159 |
apply (tactic \<open>ALLGOALS (EVERY' |
69597 | 1160 |
[strip_tac \<^context>, rotate_tac ~1, eresolve_tac \<^context> @{thms eval_elim_cases}])\<close>) |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1161 |
(* 31 subgoals *) |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1162 |
prefer 28 (* Try *) |
63648 | 1163 |
apply (simp (no_asm_use) only: split: if_split_asm) |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1164 |
(* 34 subgoals *) |
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1165 |
prefer 30 (* Init *) |
21765 | 1166 |
apply (case_tac "inited C (globs s0)", (simp only: if_True if_False simp_thms)+) |
13337
f75dfc606ac7
Added unary and binary operations like (+,-,<, ...); Added smallstep semantics (no proofs about it yet).
schirmer
parents:
12925
diff
changeset
|
1167 |
prefer 26 (* While *) |
63648 | 1168 |
apply (simp (no_asm_use) only: split: if_split_asm, blast) |
21765 | 1169 |
(* 36 subgoals *) |
12854 | 1170 |
apply (blast dest: unique_sxalloc unique_halloc split_pairD)+ |
1171 |
done |
|
1172 |
||
1173 |
(* unused *) |
|
1174 |
lemma single_valued_eval: |
|
21765 | 1175 |
"single_valued {((s, t), (v, s')). G\<turnstile>s \<midarrow>t\<succ>\<rightarrow> (v, s')}" |
12854 | 1176 |
apply (unfold single_valued_def) |
1177 |
by (clarify, drule (1) unique_eval, auto) |
|
1178 |
||
1179 |
end |