author | wenzelm |
Thu, 12 May 2011 22:35:15 +0200 | |
changeset 42772 | 2acb503fd857 |
parent 42771 | b6037ae5027d |
child 42786 | 06a38b936342 |
permissions | -rw-r--r-- |
41589 | 1 |
(* Title: HOL/TLA/Memory/MemoryImplementation.thy |
2 |
Author: Stephan Merz, University of Munich |
|
21624 | 3 |
*) |
3807 | 4 |
|
21624 | 5 |
header {* RPC-Memory example: Memory implementation *} |
3807 | 6 |
|
17309 | 7 |
theory MemoryImplementation |
8 |
imports Memory RPC MemClerk |
|
9 |
begin |
|
6255 | 10 |
|
17309 | 11 |
datatype histState = histA | histB |
3807 | 12 |
|
42018 | 13 |
type_synonym histType = "(PrIds => histState) stfun" (* the type of the history variable *) |
3807 | 14 |
|
15 |
consts |
|
16 |
(* the specification *) |
|
17 |
(* channel (external) *) |
|
18 |
memCh :: "memChType" |
|
19 |
(* internal variables *) |
|
6255 | 20 |
mm :: "memType" |
17309 | 21 |
|
3807 | 22 |
(* the state variables of the implementation *) |
23 |
(* channels *) |
|
24 |
(* same interface channel memCh *) |
|
25 |
crCh :: "rpcSndChType" |
|
26 |
rmCh :: "rpcRcvChType" |
|
27 |
(* internal variables *) |
|
6255 | 28 |
(* identity refinement mapping for mm -- simply reused *) |
3807 | 29 |
rst :: "rpcStType" |
30 |
cst :: "mClkStType" |
|
31 |
ires :: "resType" |
|
32 |
||
36866 | 33 |
definition |
6255 | 34 |
(* auxiliary predicates *) |
35 |
MVOKBARF :: "Vals => bool" |
|
36866 | 36 |
where "MVOKBARF v <-> (v : MemVal) | (v = OK) | (v = BadArg) | (v = RPCFailure)" |
37 |
||
38 |
definition |
|
6255 | 39 |
MVOKBA :: "Vals => bool" |
36866 | 40 |
where "MVOKBA v <-> (v : MemVal) | (v = OK) | (v = BadArg)" |
41 |
||
42 |
definition |
|
6255 | 43 |
MVNROKBA :: "Vals => bool" |
36866 | 44 |
where "MVNROKBA v <-> (v : MemVal) | (v = NotAResult) | (v = OK) | (v = BadArg)" |
6255 | 45 |
|
36866 | 46 |
definition |
6255 | 47 |
(* tuples of state functions changed by the various components *) |
48 |
e :: "PrIds => (bit * memOp) stfun" |
|
36866 | 49 |
where "e p = PRED (caller memCh!p)" |
50 |
||
51 |
definition |
|
6255 | 52 |
c :: "PrIds => (mClkState * (bit * Vals) * (bit * rpcOp)) stfun" |
36866 | 53 |
where "c p = PRED (cst!p, rtrner memCh!p, caller crCh!p)" |
54 |
||
55 |
definition |
|
6255 | 56 |
r :: "PrIds => (rpcState * (bit * Vals) * (bit * memOp)) stfun" |
36866 | 57 |
where "r p = PRED (rst!p, rtrner crCh!p, caller rmCh!p)" |
58 |
||
59 |
definition |
|
6255 | 60 |
m :: "PrIds => ((bit * Vals) * Vals) stfun" |
36866 | 61 |
where "m p = PRED (rtrner rmCh!p, ires!p)" |
6255 | 62 |
|
36866 | 63 |
definition |
3807 | 64 |
(* the environment action *) |
65 |
ENext :: "PrIds => action" |
|
36866 | 66 |
where "ENext p = ACT (? l. #l : #MemLoc & Call memCh p #(read l))" |
6255 | 67 |
|
3807 | 68 |
|
36866 | 69 |
definition |
3807 | 70 |
(* specification of the history variable *) |
71 |
HInit :: "histType => PrIds => stpred" |
|
36866 | 72 |
where "HInit rmhist p = PRED rmhist!p = #histA" |
6255 | 73 |
|
36866 | 74 |
definition |
3807 | 75 |
HNext :: "histType => PrIds => action" |
36866 | 76 |
where "HNext rmhist p = ACT (rmhist!p)$ = |
6255 | 77 |
(if (MemReturn rmCh ires p | RPCFail crCh rmCh rst p) |
78 |
then #histB |
|
79 |
else if (MClkReply memCh crCh cst p) |
|
80 |
then #histA |
|
81 |
else $(rmhist!p))" |
|
82 |
||
36866 | 83 |
definition |
3807 | 84 |
HistP :: "histType => PrIds => temporal" |
36866 | 85 |
where "HistP rmhist p = (TEMP Init HInit rmhist p |
86 |
& [][HNext rmhist p]_(c p,r p,m p, rmhist!p))" |
|
6255 | 87 |
|
36866 | 88 |
definition |
3807 | 89 |
Hist :: "histType => temporal" |
36866 | 90 |
where "Hist rmhist = TEMP (ALL p. HistP rmhist p)" |
3807 | 91 |
|
36866 | 92 |
definition |
3807 | 93 |
(* the implementation *) |
6255 | 94 |
IPImp :: "PrIds => temporal" |
36866 | 95 |
where "IPImp p = (TEMP ( Init ~Calling memCh p & [][ENext p]_(e p) |
17309 | 96 |
& MClkIPSpec memCh crCh cst p |
97 |
& RPCIPSpec crCh rmCh rst p |
|
98 |
& RPSpec rmCh mm ires p |
|
36866 | 99 |
& (ALL l. #l : #MemLoc --> MSpec rmCh mm ires l)))" |
6255 | 100 |
|
36866 | 101 |
definition |
3807 | 102 |
ImpInit :: "PrIds => stpred" |
36866 | 103 |
where "ImpInit p = PRED ( ~Calling memCh p |
6255 | 104 |
& MClkInit crCh cst p |
17309 | 105 |
& RPCInit rmCh rst p |
106 |
& PInit ires p)" |
|
6255 | 107 |
|
36866 | 108 |
definition |
3807 | 109 |
ImpNext :: "PrIds => action" |
36866 | 110 |
where "ImpNext p = (ACT [ENext p]_(e p) |
6255 | 111 |
& [MClkNext memCh crCh cst p]_(c p) |
17309 | 112 |
& [RPCNext crCh rmCh rst p]_(r p) |
36866 | 113 |
& [RNext rmCh mm ires p]_(m p))" |
6255 | 114 |
|
36866 | 115 |
definition |
3807 | 116 |
ImpLive :: "PrIds => temporal" |
36866 | 117 |
where "ImpLive p = (TEMP WF(MClkFwd memCh crCh cst p)_(c p) |
17309 | 118 |
& SF(MClkReply memCh crCh cst p)_(c p) |
119 |
& WF(RPCNext crCh rmCh rst p)_(r p) |
|
120 |
& WF(RNext rmCh mm ires p)_(m p) |
|
36866 | 121 |
& WF(MemReturn rmCh ires p)_(m p))" |
6255 | 122 |
|
36866 | 123 |
definition |
3807 | 124 |
Implementation :: "temporal" |
36866 | 125 |
where "Implementation = (TEMP ( (ALL p. Init (~Calling memCh p) & [][ENext p]_(e p)) |
6255 | 126 |
& MClkISpec memCh crCh cst |
127 |
& RPCISpec crCh rmCh rst |
|
36866 | 128 |
& IRSpec rmCh mm ires))" |
3807 | 129 |
|
36866 | 130 |
definition |
3807 | 131 |
(* the predicate S describes the states of the implementation. |
6255 | 132 |
slight simplification: two "histState" parameters instead of a |
133 |
(one- or two-element) set. |
|
134 |
NB: The second conjunct of the definition in the paper is taken care of by |
|
135 |
the type definitions. The last conjunct is asserted separately as the memory |
|
24180 | 136 |
invariant MemInv, proved in Memory.thy. *) |
6255 | 137 |
S :: "histType => bool => bool => bool => mClkState => rpcState => histState => histState => PrIds => stpred" |
36866 | 138 |
where "S rmhist ecalling ccalling rcalling cs rs hs1 hs2 p = (PRED |
6255 | 139 |
Calling memCh p = #ecalling |
140 |
& Calling crCh p = #ccalling |
|
141 |
& (#ccalling --> arg<crCh!p> = MClkRelayArg<arg<memCh!p>>) |
|
142 |
& (~ #ccalling & cst!p = #clkB --> MVOKBARF<res<crCh!p>>) |
|
143 |
& Calling rmCh p = #rcalling |
|
144 |
& (#rcalling --> arg<rmCh!p> = RPCRelayArg<arg<crCh!p>>) |
|
145 |
& (~ #rcalling --> ires!p = #NotAResult) |
|
146 |
& (~ #rcalling & rst!p = #rpcB --> MVOKBA<res<rmCh!p>>) |
|
147 |
& cst!p = #cs |
|
148 |
& rst!p = #rs |
|
149 |
& (rmhist!p = #hs1 | rmhist!p = #hs2) |
|
36866 | 150 |
& MVNROKBA<ires!p>)" |
3807 | 151 |
|
36866 | 152 |
definition |
3807 | 153 |
(* predicates S1 -- S6 define special instances of S *) |
154 |
S1 :: "histType => PrIds => stpred" |
|
36866 | 155 |
where "S1 rmhist p = S rmhist False False False clkA rpcA histA histA p" |
156 |
||
157 |
definition |
|
3807 | 158 |
S2 :: "histType => PrIds => stpred" |
36866 | 159 |
where "S2 rmhist p = S rmhist True False False clkA rpcA histA histA p" |
160 |
||
161 |
definition |
|
3807 | 162 |
S3 :: "histType => PrIds => stpred" |
36866 | 163 |
where "S3 rmhist p = S rmhist True True False clkB rpcA histA histB p" |
164 |
||
165 |
definition |
|
3807 | 166 |
S4 :: "histType => PrIds => stpred" |
36866 | 167 |
where "S4 rmhist p = S rmhist True True True clkB rpcB histA histB p" |
168 |
||
169 |
definition |
|
3807 | 170 |
S5 :: "histType => PrIds => stpred" |
36866 | 171 |
where "S5 rmhist p = S rmhist True True False clkB rpcB histB histB p" |
172 |
||
173 |
definition |
|
3807 | 174 |
S6 :: "histType => PrIds => stpred" |
36866 | 175 |
where "S6 rmhist p = S rmhist True False False clkB rpcA histB histB p" |
3807 | 176 |
|
36866 | 177 |
definition |
6255 | 178 |
(* The invariant asserts that the system is always in one of S1 - S6, for every p *) |
179 |
ImpInv :: "histType => PrIds => stpred" |
|
36866 | 180 |
where "ImpInv rmhist p = (PRED (S1 rmhist p | S2 rmhist p | S3 rmhist p |
181 |
| S4 rmhist p | S5 rmhist p | S6 rmhist p))" |
|
6255 | 182 |
|
36866 | 183 |
definition |
6255 | 184 |
resbar :: "histType => resType" (* refinement mapping *) |
36866 | 185 |
where"resbar rmhist s p = |
6255 | 186 |
(if (S1 rmhist p s | S2 rmhist p s) |
187 |
then ires s p |
|
188 |
else if S3 rmhist p s |
|
17309 | 189 |
then if rmhist s p = histA |
6255 | 190 |
then ires s p else MemFailure |
191 |
else if S4 rmhist p s |
|
192 |
then if (rmhist s p = histB & ires s p = NotAResult) |
|
193 |
then MemFailure else ires s p |
|
194 |
else if S5 rmhist p s |
|
195 |
then res (rmCh s p) |
|
196 |
else if S6 rmhist p s |
|
197 |
then if res (crCh s p) = RPCFailure |
|
198 |
then MemFailure else res (crCh s p) |
|
199 |
else NotAResult)" (* dummy value *) |
|
3807 | 200 |
|
36866 | 201 |
axiomatization where |
3807 | 202 |
(* the "base" variables: everything except resbar and hist (for any index) *) |
17309 | 203 |
MI_base: "basevars (caller memCh!p, |
204 |
(rtrner memCh!p, caller crCh!p, cst!p), |
|
205 |
(rtrner crCh!p, caller rmCh!p, rst!p), |
|
206 |
(mm!l, rtrner rmCh!p, ires!p))" |
|
207 |
||
21624 | 208 |
(* |
209 |
The main theorem is theorem "Implementation" at the end of this file, |
|
210 |
which shows that the composition of a reliable memory, an RPC component, and |
|
24180 | 211 |
a memory clerk implements an unreliable memory. The files "MIsafe.thy" and |
212 |
"MIlive.thy" contain lower-level lemmas for the safety and liveness parts. |
|
21624 | 213 |
|
214 |
Steps are (roughly) numbered as in the hand proof. |
|
215 |
*) |
|
216 |
||
217 |
(* --------------------------- automatic prover --------------------------- *) |
|
218 |
||
219 |
declare if_weak_cong [cong del] |
|
220 |
||
221 |
(* A more aggressive variant that tries to solve subgoals by assumption |
|
222 |
or contradiction during the simplification. |
|
223 |
THIS IS UNSAFE, BECAUSE IT DOESN'T RECORD THE CHOICES!! |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
224 |
(but it can be a lot faster than the default setup) |
21624 | 225 |
*) |
226 |
ML {* |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
227 |
val config_fast_solver = Attrib.setup_config_bool @{binding fast_solver} (K false); |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
228 |
val fast_solver = mk_solver' "fast_solver" (fn ss => |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
229 |
if Config.get (Simplifier.the_context ss) config_fast_solver |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
230 |
then assume_tac ORELSE' (etac notE) |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
231 |
else K no_tac); |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
232 |
*} |
21624 | 233 |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
234 |
declaration {* K (Simplifier.map_ss (fn ss => ss addSSolver fast_solver)) *} |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
235 |
|
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
236 |
ML {* val temp_elim = make_elim o temp_use *} |
21624 | 237 |
|
238 |
||
239 |
||
240 |
(****************************** The history variable ******************************) |
|
241 |
||
242 |
section "History variable" |
|
243 |
||
244 |
lemma HistoryLemma: "|- Init(ALL p. ImpInit p) & [](ALL p. ImpNext p) |
|
245 |
--> (EEX rmhist. Init(ALL p. HInit rmhist p) |
|
246 |
& [](ALL p. [HNext rmhist p]_(c p, r p, m p, rmhist!p)))" |
|
247 |
apply clarsimp |
|
248 |
apply (rule historyI) |
|
249 |
apply assumption+ |
|
250 |
apply (rule MI_base) |
|
39159 | 251 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm HInit_def}]) [] [] 1 *}) |
21624 | 252 |
apply (erule fun_cong) |
39159 | 253 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm HNext_def}]) |
254 |
[@{thm busy_squareI}] [] 1 *}) |
|
21624 | 255 |
apply (erule fun_cong) |
256 |
done |
|
257 |
||
258 |
lemma History: "|- Implementation --> (EEX rmhist. Hist rmhist)" |
|
259 |
apply clarsimp |
|
260 |
apply (rule HistoryLemma [temp_use, THEN eex_mono]) |
|
261 |
prefer 3 |
|
262 |
apply (force simp: Hist_def HistP_def Init_def all_box [try_rewrite] |
|
263 |
split_box_conj [try_rewrite]) |
|
264 |
apply (auto simp: Implementation_def MClkISpec_def RPCISpec_def |
|
265 |
IRSpec_def MClkIPSpec_def RPCIPSpec_def RPSpec_def ImpInit_def |
|
266 |
Init_def ImpNext_def c_def r_def m_def all_box [temp_use] split_box_conj [temp_use]) |
|
267 |
done |
|
268 |
||
269 |
(******************************** The safety part *********************************) |
|
270 |
||
271 |
section "The safety part" |
|
272 |
||
273 |
(* ------------------------- Include lower-level lemmas ------------------------- *) |
|
274 |
||
275 |
(* RPCFailure notin MemVals U {OK,BadArg} *) |
|
276 |
||
277 |
lemma MVOKBAnotRF: "MVOKBA x ==> x ~= RPCFailure" |
|
278 |
apply (unfold MVOKBA_def) |
|
279 |
apply auto |
|
280 |
done |
|
281 |
||
282 |
(* NotAResult notin MemVals U {OK,BadArg,RPCFailure} *) |
|
283 |
||
284 |
lemma MVOKBARFnotNR: "MVOKBARF x ==> x ~= NotAResult" |
|
285 |
apply (unfold MVOKBARF_def) |
|
286 |
apply auto |
|
287 |
done |
|
288 |
||
289 |
(* ================ Si's are mutually exclusive ================================ *) |
|
290 |
(* Si and Sj are mutually exclusive for i # j. This helps to simplify the big |
|
291 |
conditional in the definition of resbar when doing the step-simulation proof. |
|
292 |
We prove a weaker result, which suffices for our purposes: |
|
293 |
Si implies (not Sj), for j<i. |
|
294 |
*) |
|
295 |
||
296 |
(* --- not used --- |
|
42772 | 297 |
lemma S1_excl: "|- S1 rmhist p --> S1 rmhist p & ~S2 rmhist p & ~S3 rmhist p & |
298 |
~S4 rmhist p & ~S5 rmhist p & ~S6 rmhist p" |
|
299 |
by (auto simp: S_def S1_def S2_def S3_def S4_def S5_def S6_def) |
|
21624 | 300 |
*) |
301 |
||
302 |
lemma S2_excl: "|- S2 rmhist p --> S2 rmhist p & ~S1 rmhist p" |
|
303 |
by (auto simp: S_def S1_def S2_def) |
|
304 |
||
305 |
lemma S3_excl: "|- S3 rmhist p --> S3 rmhist p & ~S1 rmhist p & ~S2 rmhist p" |
|
306 |
by (auto simp: S_def S1_def S2_def S3_def) |
|
307 |
||
308 |
lemma S4_excl: "|- S4 rmhist p --> S4 rmhist p & ~S1 rmhist p & ~S2 rmhist p & ~S3 rmhist p" |
|
309 |
by (auto simp: S_def S1_def S2_def S3_def S4_def) |
|
310 |
||
311 |
lemma S5_excl: "|- S5 rmhist p --> S5 rmhist p & ~S1 rmhist p & ~S2 rmhist p |
|
312 |
& ~S3 rmhist p & ~S4 rmhist p" |
|
313 |
by (auto simp: S_def S1_def S2_def S3_def S4_def S5_def) |
|
314 |
||
315 |
lemma S6_excl: "|- S6 rmhist p --> S6 rmhist p & ~S1 rmhist p & ~S2 rmhist p |
|
316 |
& ~S3 rmhist p & ~S4 rmhist p & ~S5 rmhist p" |
|
317 |
by (auto simp: S_def S1_def S2_def S3_def S4_def S5_def S6_def) |
|
318 |
||
319 |
||
320 |
(* ==================== Lemmas about the environment ============================== *) |
|
321 |
||
322 |
lemma Envbusy: "|- $(Calling memCh p) --> ~ENext p" |
|
323 |
by (auto simp: ENext_def Call_def) |
|
324 |
||
325 |
(* ==================== Lemmas about the implementation's states ==================== *) |
|
326 |
||
327 |
(* The following series of lemmas are used in establishing the implementation's |
|
328 |
next-state relation (Step 1.2 of the proof in the paper). For each state Si, we |
|
329 |
determine which component actions are possible and what state they result in. |
|
330 |
*) |
|
331 |
||
332 |
(* ------------------------------ State S1 ---------------------------------------- *) |
|
333 |
||
334 |
lemma S1Env: "|- ENext p & $(S1 rmhist p) & unchanged (c p, r p, m p, rmhist!p) |
|
335 |
--> (S2 rmhist p)$" |
|
336 |
by (force simp: ENext_def Call_def c_def r_def m_def |
|
337 |
caller_def rtrner_def MVNROKBA_def S_def S1_def S2_def Calling_def) |
|
338 |
||
339 |
lemma S1ClerkUnch: "|- [MClkNext memCh crCh cst p]_(c p) & $(S1 rmhist p) --> unchanged (c p)" |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
340 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
341 |
by (auto elim!: squareE [temp_use] dest!: MClkidle [temp_use] simp: S_def S1_def) |
21624 | 342 |
|
343 |
lemma S1RPCUnch: "|- [RPCNext crCh rmCh rst p]_(r p) & $(S1 rmhist p) --> unchanged (r p)" |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
344 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
345 |
by (auto elim!: squareE [temp_use] dest!: RPCidle [temp_use] simp: S_def S1_def) |
21624 | 346 |
|
347 |
lemma S1MemUnch: "|- [RNext rmCh mm ires p]_(m p) & $(S1 rmhist p) --> unchanged (m p)" |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
348 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
349 |
by (auto elim!: squareE [temp_use] dest!: Memoryidle [temp_use] simp: S_def S1_def) |
21624 | 350 |
|
351 |
lemma S1Hist: "|- [HNext rmhist p]_(c p,r p,m p,rmhist!p) & $(S1 rmhist p) |
|
352 |
--> unchanged (rmhist!p)" |
|
39159 | 353 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm HNext_def}, @{thm S_def}, |
354 |
@{thm S1_def}, @{thm MemReturn_def}, @{thm RPCFail_def}, @{thm MClkReply_def}, |
|
355 |
@{thm Return_def}]) [] [temp_use @{thm squareE}] 1 *}) |
|
21624 | 356 |
|
357 |
||
358 |
(* ------------------------------ State S2 ---------------------------------------- *) |
|
359 |
||
360 |
lemma S2EnvUnch: "|- [ENext p]_(e p) & $(S2 rmhist p) --> unchanged (e p)" |
|
361 |
by (auto dest!: Envbusy [temp_use] simp: S_def S2_def) |
|
362 |
||
363 |
lemma S2Clerk: "|- MClkNext memCh crCh cst p & $(S2 rmhist p) --> MClkFwd memCh crCh cst p" |
|
364 |
by (auto simp: MClkNext_def MClkRetry_def MClkReply_def S_def S2_def) |
|
365 |
||
366 |
lemma S2Forward: "|- $(S2 rmhist p) & MClkFwd memCh crCh cst p |
|
367 |
& unchanged (e p, r p, m p, rmhist!p) |
|
368 |
--> (S3 rmhist p)$" |
|
39159 | 369 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm MClkFwd_def}, |
370 |
@{thm Call_def}, @{thm e_def}, @{thm r_def}, @{thm m_def}, @{thm caller_def}, |
|
371 |
@{thm rtrner_def}, @{thm S_def}, @{thm S2_def}, @{thm S3_def}, @{thm Calling_def}]) [] [] 1 *}) |
|
21624 | 372 |
|
373 |
lemma S2RPCUnch: "|- [RPCNext crCh rmCh rst p]_(r p) & $(S2 rmhist p) --> unchanged (r p)" |
|
374 |
by (auto simp: S_def S2_def dest!: RPCidle [temp_use]) |
|
375 |
||
376 |
lemma S2MemUnch: "|- [RNext rmCh mm ires p]_(m p) & $(S2 rmhist p) --> unchanged (m p)" |
|
377 |
by (auto simp: S_def S2_def dest!: Memoryidle [temp_use]) |
|
378 |
||
379 |
lemma S2Hist: "|- [HNext rmhist p]_(c p,r p,m p,rmhist!p) & $(S2 rmhist p) |
|
380 |
--> unchanged (rmhist!p)" |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
381 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
382 |
by (auto elim!: squareE [temp_use] simp: HNext_def MemReturn_def RPCFail_def |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
383 |
MClkReply_def Return_def S_def S2_def) |
21624 | 384 |
|
385 |
(* ------------------------------ State S3 ---------------------------------------- *) |
|
386 |
||
387 |
lemma S3EnvUnch: "|- [ENext p]_(e p) & $(S3 rmhist p) --> unchanged (e p)" |
|
388 |
by (auto dest!: Envbusy [temp_use] simp: S_def S3_def) |
|
389 |
||
390 |
lemma S3ClerkUnch: "|- [MClkNext memCh crCh cst p]_(c p) & $(S3 rmhist p) --> unchanged (c p)" |
|
391 |
by (auto dest!: MClkbusy [temp_use] simp: square_def S_def S3_def) |
|
392 |
||
393 |
lemma S3LegalRcvArg: "|- S3 rmhist p --> IsLegalRcvArg<arg<crCh!p>>" |
|
394 |
by (auto simp: IsLegalRcvArg_def MClkRelayArg_def S_def S3_def) |
|
395 |
||
396 |
lemma S3RPC: "|- RPCNext crCh rmCh rst p & $(S3 rmhist p) |
|
397 |
--> RPCFwd crCh rmCh rst p | RPCFail crCh rmCh rst p" |
|
398 |
apply clarsimp |
|
399 |
apply (frule S3LegalRcvArg [action_use]) |
|
400 |
apply (auto simp: RPCNext_def RPCReject_def RPCReply_def S_def S3_def) |
|
401 |
done |
|
402 |
||
403 |
lemma S3Forward: "|- RPCFwd crCh rmCh rst p & HNext rmhist p & $(S3 rmhist p) |
|
404 |
& unchanged (e p, c p, m p) |
|
405 |
--> (S4 rmhist p)$ & unchanged (rmhist!p)" |
|
39159 | 406 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm RPCFwd_def}, |
407 |
@{thm HNext_def}, @{thm MemReturn_def}, @{thm RPCFail_def}, |
|
408 |
@{thm MClkReply_def}, @{thm Return_def}, @{thm Call_def}, @{thm e_def}, |
|
409 |
@{thm c_def}, @{thm m_def}, @{thm caller_def}, @{thm rtrner_def}, @{thm S_def}, |
|
410 |
@{thm S3_def}, @{thm S4_def}, @{thm Calling_def}]) [] [] 1 *}) |
|
21624 | 411 |
|
412 |
lemma S3Fail: "|- RPCFail crCh rmCh rst p & $(S3 rmhist p) & HNext rmhist p |
|
413 |
& unchanged (e p, c p, m p) |
|
414 |
--> (S6 rmhist p)$" |
|
39159 | 415 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm HNext_def}, |
416 |
@{thm RPCFail_def}, @{thm Return_def}, @{thm e_def}, @{thm c_def}, |
|
417 |
@{thm m_def}, @{thm caller_def}, @{thm rtrner_def}, @{thm MVOKBARF_def}, |
|
418 |
@{thm S_def}, @{thm S3_def}, @{thm S6_def}, @{thm Calling_def}]) [] [] 1 *}) |
|
21624 | 419 |
|
420 |
lemma S3MemUnch: "|- [RNext rmCh mm ires p]_(m p) & $(S3 rmhist p) --> unchanged (m p)" |
|
421 |
by (auto simp: S_def S3_def dest!: Memoryidle [temp_use]) |
|
422 |
||
423 |
lemma S3Hist: "|- HNext rmhist p & $(S3 rmhist p) & unchanged (r p) --> unchanged (rmhist!p)" |
|
424 |
by (auto simp: HNext_def MemReturn_def RPCFail_def MClkReply_def |
|
425 |
Return_def r_def rtrner_def S_def S3_def Calling_def) |
|
426 |
||
427 |
(* ------------------------------ State S4 ---------------------------------------- *) |
|
428 |
||
429 |
lemma S4EnvUnch: "|- [ENext p]_(e p) & $(S4 rmhist p) --> unchanged (e p)" |
|
430 |
by (auto simp: S_def S4_def dest!: Envbusy [temp_use]) |
|
431 |
||
432 |
lemma S4ClerkUnch: "|- [MClkNext memCh crCh cst p]_(c p) & $(S4 rmhist p) --> unchanged (c p)" |
|
433 |
by (auto simp: S_def S4_def dest!: MClkbusy [temp_use]) |
|
434 |
||
435 |
lemma S4RPCUnch: "|- [RPCNext crCh rmCh rst p]_(r p) & $(S4 rmhist p) --> unchanged (r p)" |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
436 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
437 |
by (auto elim!: squareE [temp_use] dest!: RPCbusy [temp_use] simp: S_def S4_def) |
21624 | 438 |
|
439 |
lemma S4ReadInner: "|- ReadInner rmCh mm ires p l & $(S4 rmhist p) & unchanged (e p, c p, r p) |
|
440 |
& HNext rmhist p & $(MemInv mm l) |
|
441 |
--> (S4 rmhist p)$ & unchanged (rmhist!p)" |
|
39159 | 442 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm ReadInner_def}, |
443 |
@{thm GoodRead_def}, @{thm BadRead_def}, @{thm HNext_def}, @{thm MemReturn_def}, |
|
444 |
@{thm RPCFail_def}, @{thm MClkReply_def}, @{thm Return_def}, @{thm e_def}, |
|
445 |
@{thm c_def}, @{thm r_def}, @{thm rtrner_def}, @{thm caller_def}, |
|
446 |
@{thm MVNROKBA_def}, @{thm S_def}, @{thm S4_def}, @{thm RdRequest_def}, |
|
447 |
@{thm Calling_def}, @{thm MemInv_def}]) [] [] 1 *}) |
|
21624 | 448 |
|
449 |
lemma S4Read: "|- Read rmCh mm ires p & $(S4 rmhist p) & unchanged (e p, c p, r p) |
|
450 |
& HNext rmhist p & (!l. $MemInv mm l) |
|
451 |
--> (S4 rmhist p)$ & unchanged (rmhist!p)" |
|
452 |
by (auto simp: Read_def dest!: S4ReadInner [temp_use]) |
|
453 |
||
454 |
lemma S4WriteInner: "|- WriteInner rmCh mm ires p l v & $(S4 rmhist p) & unchanged (e p, c p, r p) & HNext rmhist p |
|
455 |
--> (S4 rmhist p)$ & unchanged (rmhist!p)" |
|
39159 | 456 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm WriteInner_def}, |
457 |
@{thm GoodWrite_def}, @{thm BadWrite_def}, @{thm HNext_def}, @{thm MemReturn_def}, |
|
458 |
@{thm RPCFail_def}, @{thm MClkReply_def}, @{thm Return_def}, @{thm e_def}, |
|
459 |
@{thm c_def}, @{thm r_def}, @{thm rtrner_def}, @{thm caller_def}, @{thm MVNROKBA_def}, |
|
460 |
@{thm S_def}, @{thm S4_def}, @{thm WrRequest_def}, @{thm Calling_def}]) [] [] 1 *}) |
|
21624 | 461 |
|
462 |
lemma S4Write: "|- Write rmCh mm ires p l & $(S4 rmhist p) & unchanged (e p, c p, r p) |
|
463 |
& (HNext rmhist p) |
|
464 |
--> (S4 rmhist p)$ & unchanged (rmhist!p)" |
|
465 |
by (auto simp: Write_def dest!: S4WriteInner [temp_use]) |
|
466 |
||
467 |
lemma WriteS4: "|- $ImpInv rmhist p & Write rmCh mm ires p l --> $S4 rmhist p" |
|
468 |
by (auto simp: Write_def WriteInner_def ImpInv_def |
|
469 |
WrRequest_def S_def S1_def S2_def S3_def S4_def S5_def S6_def) |
|
470 |
||
471 |
lemma S4Return: "|- MemReturn rmCh ires p & $S4 rmhist p & unchanged (e p, c p, r p) |
|
472 |
& HNext rmhist p |
|
473 |
--> (S5 rmhist p)$" |
|
474 |
by (auto simp: HNext_def MemReturn_def Return_def e_def c_def r_def |
|
475 |
rtrner_def caller_def MVNROKBA_def MVOKBA_def S_def S4_def S5_def Calling_def) |
|
476 |
||
477 |
lemma S4Hist: "|- HNext rmhist p & $S4 rmhist p & (m p)$ = $(m p) --> (rmhist!p)$ = $(rmhist!p)" |
|
478 |
by (auto simp: HNext_def MemReturn_def RPCFail_def MClkReply_def |
|
479 |
Return_def m_def rtrner_def S_def S4_def Calling_def) |
|
480 |
||
481 |
(* ------------------------------ State S5 ---------------------------------------- *) |
|
482 |
||
483 |
lemma S5EnvUnch: "|- [ENext p]_(e p) & $(S5 rmhist p) --> unchanged (e p)" |
|
484 |
by (auto simp: S_def S5_def dest!: Envbusy [temp_use]) |
|
485 |
||
486 |
lemma S5ClerkUnch: "|- [MClkNext memCh crCh cst p]_(c p) & $(S5 rmhist p) --> unchanged (c p)" |
|
487 |
by (auto simp: S_def S5_def dest!: MClkbusy [temp_use]) |
|
488 |
||
489 |
lemma S5RPC: "|- RPCNext crCh rmCh rst p & $(S5 rmhist p) |
|
490 |
--> RPCReply crCh rmCh rst p | RPCFail crCh rmCh rst p" |
|
491 |
by (auto simp: RPCNext_def RPCReject_def RPCFwd_def S_def S5_def) |
|
492 |
||
493 |
lemma S5Reply: "|- RPCReply crCh rmCh rst p & $(S5 rmhist p) & unchanged (e p, c p, m p,rmhist!p) |
|
494 |
--> (S6 rmhist p)$" |
|
39159 | 495 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm RPCReply_def}, |
496 |
@{thm Return_def}, @{thm e_def}, @{thm c_def}, @{thm m_def}, @{thm MVOKBA_def}, |
|
497 |
@{thm MVOKBARF_def}, @{thm caller_def}, @{thm rtrner_def}, @{thm S_def}, |
|
498 |
@{thm S5_def}, @{thm S6_def}, @{thm Calling_def}]) [] [] 1 *}) |
|
21624 | 499 |
|
500 |
lemma S5Fail: "|- RPCFail crCh rmCh rst p & $(S5 rmhist p) & unchanged (e p, c p, m p,rmhist!p) |
|
501 |
--> (S6 rmhist p)$" |
|
39159 | 502 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm RPCFail_def}, |
503 |
@{thm Return_def}, @{thm e_def}, @{thm c_def}, @{thm m_def}, |
|
504 |
@{thm MVOKBARF_def}, @{thm caller_def}, @{thm rtrner_def}, |
|
505 |
@{thm S_def}, @{thm S5_def}, @{thm S6_def}, @{thm Calling_def}]) [] [] 1 *}) |
|
21624 | 506 |
|
507 |
lemma S5MemUnch: "|- [RNext rmCh mm ires p]_(m p) & $(S5 rmhist p) --> unchanged (m p)" |
|
508 |
by (auto simp: S_def S5_def dest!: Memoryidle [temp_use]) |
|
509 |
||
510 |
lemma S5Hist: "|- [HNext rmhist p]_(c p, r p, m p, rmhist!p) & $(S5 rmhist p) |
|
511 |
--> (rmhist!p)$ = $(rmhist!p)" |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
512 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
513 |
by (auto elim!: squareE [temp_use] simp: HNext_def MemReturn_def RPCFail_def |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
514 |
MClkReply_def Return_def S_def S5_def) |
21624 | 515 |
|
516 |
(* ------------------------------ State S6 ---------------------------------------- *) |
|
517 |
||
518 |
lemma S6EnvUnch: "|- [ENext p]_(e p) & $(S6 rmhist p) --> unchanged (e p)" |
|
519 |
by (auto simp: S_def S6_def dest!: Envbusy [temp_use]) |
|
520 |
||
521 |
lemma S6Clerk: "|- MClkNext memCh crCh cst p & $(S6 rmhist p) |
|
522 |
--> MClkRetry memCh crCh cst p | MClkReply memCh crCh cst p" |
|
523 |
by (auto simp: MClkNext_def MClkFwd_def S_def S6_def) |
|
524 |
||
525 |
lemma S6Retry: "|- MClkRetry memCh crCh cst p & HNext rmhist p & $S6 rmhist p |
|
526 |
& unchanged (e p,r p,m p) |
|
527 |
--> (S3 rmhist p)$ & unchanged (rmhist!p)" |
|
39159 | 528 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm HNext_def}, |
529 |
@{thm MClkReply_def}, @{thm MClkRetry_def}, @{thm Call_def}, @{thm Return_def}, |
|
530 |
@{thm e_def}, @{thm r_def}, @{thm m_def}, @{thm caller_def}, @{thm rtrner_def}, |
|
531 |
@{thm S_def}, @{thm S6_def}, @{thm S3_def}, @{thm Calling_def}]) [] [] 1 *}) |
|
21624 | 532 |
|
533 |
lemma S6Reply: "|- MClkReply memCh crCh cst p & HNext rmhist p & $S6 rmhist p |
|
534 |
& unchanged (e p,r p,m p) |
|
535 |
--> (S1 rmhist p)$" |
|
39159 | 536 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm HNext_def}, |
537 |
@{thm MemReturn_def}, @{thm RPCFail_def}, @{thm Return_def}, @{thm MClkReply_def}, |
|
538 |
@{thm e_def}, @{thm r_def}, @{thm m_def}, @{thm caller_def}, @{thm rtrner_def}, |
|
539 |
@{thm S_def}, @{thm S6_def}, @{thm S1_def}, @{thm Calling_def}]) [] [] 1 *}) |
|
21624 | 540 |
|
541 |
lemma S6RPCUnch: "|- [RPCNext crCh rmCh rst p]_(r p) & $S6 rmhist p --> unchanged (r p)" |
|
542 |
by (auto simp: S_def S6_def dest!: RPCidle [temp_use]) |
|
543 |
||
544 |
lemma S6MemUnch: "|- [RNext rmCh mm ires p]_(m p) & $(S6 rmhist p) --> unchanged (m p)" |
|
545 |
by (auto simp: S_def S6_def dest!: Memoryidle [temp_use]) |
|
546 |
||
547 |
lemma S6Hist: "|- HNext rmhist p & $S6 rmhist p & (c p)$ = $(c p) --> (rmhist!p)$ = $(rmhist!p)" |
|
548 |
by (auto simp: HNext_def MClkReply_def Return_def c_def rtrner_def S_def S6_def Calling_def) |
|
549 |
||
550 |
||
551 |
section "Correctness of predicate-action diagram" |
|
552 |
||
553 |
||
554 |
(* ========== Step 1.1 ================================================= *) |
|
555 |
(* The implementation's initial condition implies the state predicate S1 *) |
|
556 |
||
557 |
lemma Step1_1: "|- ImpInit p & HInit rmhist p --> S1 rmhist p" |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
558 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
559 |
by (auto elim!: squareE [temp_use] simp: MVNROKBA_def |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
560 |
MClkInit_def RPCInit_def PInit_def HInit_def ImpInit_def S_def S1_def) |
21624 | 561 |
|
562 |
(* ========== Step 1.2 ================================================== *) |
|
563 |
(* Figure 16 is a predicate-action diagram for the implementation. *) |
|
564 |
||
565 |
lemma Step1_2_1: "|- [HNext rmhist p]_(c p,r p,m p, rmhist!p) & ImpNext p |
|
566 |
& ~unchanged (e p, c p, r p, m p, rmhist!p) & $S1 rmhist p |
|
567 |
--> (S2 rmhist p)$ & ENext p & unchanged (c p, r p, m p)" |
|
39159 | 568 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm ImpNext_def}]) [] |
569 |
(map temp_elim [@{thm S1ClerkUnch}, @{thm S1RPCUnch}, @{thm S1MemUnch}, @{thm S1Hist}]) 1 *}) |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
570 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
571 |
apply (auto elim!: squareE [temp_use] intro!: S1Env [temp_use]) |
21624 | 572 |
done |
573 |
||
574 |
lemma Step1_2_2: "|- [HNext rmhist p]_(c p,r p,m p, rmhist!p) & ImpNext p |
|
575 |
& ~unchanged (e p, c p, r p, m p, rmhist!p) & $S2 rmhist p |
|
576 |
--> (S3 rmhist p)$ & MClkFwd memCh crCh cst p |
|
577 |
& unchanged (e p, r p, m p, rmhist!p)" |
|
39159 | 578 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm ImpNext_def}]) [] |
579 |
(map temp_elim [@{thm S2EnvUnch}, @{thm S2RPCUnch}, @{thm S2MemUnch}, @{thm S2Hist}]) 1 *}) |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
580 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
581 |
apply (auto elim!: squareE [temp_use] intro!: S2Clerk [temp_use] S2Forward [temp_use]) |
21624 | 582 |
done |
583 |
||
584 |
lemma Step1_2_3: "|- [HNext rmhist p]_(c p,r p,m p, rmhist!p) & ImpNext p |
|
585 |
& ~unchanged (e p, c p, r p, m p, rmhist!p) & $S3 rmhist p |
|
586 |
--> ((S4 rmhist p)$ & RPCFwd crCh rmCh rst p & unchanged (e p, c p, m p, rmhist!p)) |
|
587 |
| ((S6 rmhist p)$ & RPCFail crCh rmCh rst p & unchanged (e p, c p, m p))" |
|
39159 | 588 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm ImpNext_def}]) [] |
589 |
(map temp_elim [@{thm S3EnvUnch}, @{thm S3ClerkUnch}, @{thm S3MemUnch}]) 1 *}) |
|
26342 | 590 |
apply (tactic {* action_simp_tac @{simpset} [] |
39159 | 591 |
(@{thm squareE} :: map temp_elim [@{thm S3RPC}, @{thm S3Forward}, @{thm S3Fail}]) 1 *}) |
21624 | 592 |
apply (auto dest!: S3Hist [temp_use]) |
593 |
done |
|
594 |
||
595 |
lemma Step1_2_4: "|- [HNext rmhist p]_(c p,r p,m p, rmhist!p) & ImpNext p |
|
596 |
& ~unchanged (e p, c p, r p, m p, rmhist!p) |
|
597 |
& $S4 rmhist p & (!l. $(MemInv mm l)) |
|
598 |
--> ((S4 rmhist p)$ & Read rmCh mm ires p & unchanged (e p, c p, r p, rmhist!p)) |
|
599 |
| ((S4 rmhist p)$ & (? l. Write rmCh mm ires p l) & unchanged (e p, c p, r p, rmhist!p)) |
|
600 |
| ((S5 rmhist p)$ & MemReturn rmCh ires p & unchanged (e p, c p, r p))" |
|
39159 | 601 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm ImpNext_def}]) [] |
602 |
(map temp_elim [@{thm S4EnvUnch}, @{thm S4ClerkUnch}, @{thm S4RPCUnch}]) 1 *}) |
|
603 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm RNext_def}]) [] |
|
604 |
(@{thm squareE} :: map temp_elim [@{thm S4Read}, @{thm S4Write}, @{thm S4Return}]) 1 *}) |
|
21624 | 605 |
apply (auto dest!: S4Hist [temp_use]) |
606 |
done |
|
607 |
||
608 |
lemma Step1_2_5: "|- [HNext rmhist p]_(c p,r p,m p, rmhist!p) & ImpNext p |
|
609 |
& ~unchanged (e p, c p, r p, m p, rmhist!p) & $S5 rmhist p |
|
610 |
--> ((S6 rmhist p)$ & RPCReply crCh rmCh rst p & unchanged (e p, c p, m p)) |
|
611 |
| ((S6 rmhist p)$ & RPCFail crCh rmCh rst p & unchanged (e p, c p, m p))" |
|
39159 | 612 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm ImpNext_def}]) [] |
613 |
(map temp_elim [@{thm S5EnvUnch}, @{thm S5ClerkUnch}, @{thm S5MemUnch}, @{thm S5Hist}]) 1 *}) |
|
614 |
apply (tactic {* action_simp_tac @{simpset} [] [@{thm squareE}, temp_elim @{thm S5RPC}] 1 *}) |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
615 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
616 |
apply (auto elim!: squareE [temp_use] dest!: S5Reply [temp_use] S5Fail [temp_use]) |
21624 | 617 |
done |
618 |
||
619 |
lemma Step1_2_6: "|- [HNext rmhist p]_(c p,r p,m p, rmhist!p) & ImpNext p |
|
620 |
& ~unchanged (e p, c p, r p, m p, rmhist!p) & $S6 rmhist p |
|
621 |
--> ((S1 rmhist p)$ & MClkReply memCh crCh cst p & unchanged (e p, r p, m p)) |
|
622 |
| ((S3 rmhist p)$ & MClkRetry memCh crCh cst p & unchanged (e p,r p,m p,rmhist!p))" |
|
39159 | 623 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm ImpNext_def}]) [] |
624 |
(map temp_elim [@{thm S6EnvUnch}, @{thm S6RPCUnch}, @{thm S6MemUnch}]) 1 *}) |
|
26342 | 625 |
apply (tactic {* action_simp_tac @{simpset} [] |
39159 | 626 |
(@{thm squareE} :: map temp_elim [@{thm S6Clerk}, @{thm S6Retry}, @{thm S6Reply}]) 1 *}) |
21624 | 627 |
apply (auto dest: S6Hist [temp_use]) |
628 |
done |
|
629 |
||
630 |
(* -------------------------------------------------------------------------- |
|
631 |
Step 1.3: S1 implies the barred initial condition. |
|
632 |
*) |
|
633 |
||
634 |
section "Initialization (Step 1.3)" |
|
635 |
||
636 |
lemma Step1_3: "|- S1 rmhist p --> PInit (resbar rmhist) p" |
|
39159 | 637 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm resbar_def}, |
638 |
@{thm PInit_def}, @{thm S_def}, @{thm S1_def}]) [] [] 1 *}) |
|
21624 | 639 |
|
640 |
(* ---------------------------------------------------------------------- |
|
641 |
Step 1.4: Implementation's next-state relation simulates specification's |
|
642 |
next-state relation (with appropriate substitutions) |
|
643 |
*) |
|
644 |
||
645 |
section "Step simulation (Step 1.4)" |
|
646 |
||
647 |
lemma Step1_4_1: "|- ENext p & $S1 rmhist p & (S2 rmhist p)$ & unchanged (c p, r p, m p) |
|
648 |
--> unchanged (rtrner memCh!p, resbar rmhist!p)" |
|
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
649 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
650 |
by (auto elim!: squareE [temp_use] simp: c_def r_def m_def resbar_def) |
21624 | 651 |
|
652 |
lemma Step1_4_2: "|- MClkFwd memCh crCh cst p & $S2 rmhist p & (S3 rmhist p)$ |
|
653 |
& unchanged (e p, r p, m p, rmhist!p) |
|
654 |
--> unchanged (rtrner memCh!p, resbar rmhist!p)" |
|
655 |
by (tactic {* action_simp_tac |
|
39159 | 656 |
(@{simpset} addsimps [@{thm MClkFwd_def}, @{thm e_def}, @{thm r_def}, @{thm m_def}, |
657 |
@{thm resbar_def}, @{thm S_def}, @{thm S2_def}, @{thm S3_def}]) [] [] 1 *}) |
|
21624 | 658 |
|
659 |
lemma Step1_4_3a: "|- RPCFwd crCh rmCh rst p & $S3 rmhist p & (S4 rmhist p)$ |
|
660 |
& unchanged (e p, c p, m p, rmhist!p) |
|
661 |
--> unchanged (rtrner memCh!p, resbar rmhist!p)" |
|
662 |
apply clarsimp |
|
663 |
apply (drule S3_excl [temp_use] S4_excl [temp_use])+ |
|
39159 | 664 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm e_def}, |
665 |
@{thm c_def}, @{thm m_def}, @{thm resbar_def}, @{thm S_def}, @{thm S3_def}]) [] [] 1 *}) |
|
21624 | 666 |
done |
667 |
||
668 |
lemma Step1_4_3b: "|- RPCFail crCh rmCh rst p & $S3 rmhist p & (S6 rmhist p)$ |
|
669 |
& unchanged (e p, c p, m p) |
|
670 |
--> MemFail memCh (resbar rmhist) p" |
|
671 |
apply clarsimp |
|
672 |
apply (drule S6_excl [temp_use]) |
|
673 |
apply (auto simp: RPCFail_def MemFail_def e_def c_def m_def resbar_def) |
|
674 |
apply (force simp: S3_def S_def) |
|
675 |
apply (auto simp: Return_def) |
|
676 |
done |
|
677 |
||
678 |
lemma Step1_4_4a1: "|- $S4 rmhist p & (S4 rmhist p)$ & ReadInner rmCh mm ires p l |
|
679 |
& unchanged (e p, c p, r p, rmhist!p) & $MemInv mm l |
|
680 |
--> ReadInner memCh mm (resbar rmhist) p l" |
|
681 |
apply clarsimp |
|
682 |
apply (drule S4_excl [temp_use])+ |
|
39159 | 683 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm ReadInner_def}, |
684 |
@{thm GoodRead_def}, @{thm BadRead_def}, @{thm e_def}, @{thm c_def}, @{thm m_def}]) [] [] 1 *}) |
|
21624 | 685 |
apply (auto simp: resbar_def) |
686 |
apply (tactic {* ALLGOALS (action_simp_tac |
|
39159 | 687 |
(@{simpset} addsimps [@{thm RPCRelayArg_def}, @{thm MClkRelayArg_def}, |
688 |
@{thm S_def}, @{thm S4_def}, @{thm RdRequest_def}, @{thm MemInv_def}]) |
|
689 |
[] [@{thm impE}, @{thm MemValNotAResultE}]) *}) |
|
21624 | 690 |
done |
691 |
||
692 |
lemma Step1_4_4a: "|- Read rmCh mm ires p & $S4 rmhist p & (S4 rmhist p)$ |
|
693 |
& unchanged (e p, c p, r p, rmhist!p) & (!l. $(MemInv mm l)) |
|
694 |
--> Read memCh mm (resbar rmhist) p" |
|
695 |
by (force simp: Read_def elim!: Step1_4_4a1 [temp_use]) |
|
696 |
||
697 |
lemma Step1_4_4b1: "|- $S4 rmhist p & (S4 rmhist p)$ & WriteInner rmCh mm ires p l v |
|
698 |
& unchanged (e p, c p, r p, rmhist!p) |
|
699 |
--> WriteInner memCh mm (resbar rmhist) p l v" |
|
700 |
apply clarsimp |
|
701 |
apply (drule S4_excl [temp_use])+ |
|
26342 | 702 |
apply (tactic {* action_simp_tac (@{simpset} addsimps |
39159 | 703 |
[@{thm WriteInner_def}, @{thm GoodWrite_def}, @{thm BadWrite_def}, @{thm e_def}, |
704 |
@{thm c_def}, @{thm m_def}]) [] [] 1 *}) |
|
21624 | 705 |
apply (auto simp: resbar_def) |
26342 | 706 |
apply (tactic {* ALLGOALS (action_simp_tac (@{simpset} addsimps |
39159 | 707 |
[@{thm RPCRelayArg_def}, @{thm MClkRelayArg_def}, @{thm S_def}, |
708 |
@{thm S4_def}, @{thm WrRequest_def}]) [] []) *}) |
|
21624 | 709 |
done |
710 |
||
711 |
lemma Step1_4_4b: "|- Write rmCh mm ires p l & $S4 rmhist p & (S4 rmhist p)$ |
|
712 |
& unchanged (e p, c p, r p, rmhist!p) |
|
713 |
--> Write memCh mm (resbar rmhist) p l" |
|
714 |
by (force simp: Write_def elim!: Step1_4_4b1 [temp_use]) |
|
715 |
||
716 |
lemma Step1_4_4c: "|- MemReturn rmCh ires p & $S4 rmhist p & (S5 rmhist p)$ |
|
717 |
& unchanged (e p, c p, r p) |
|
718 |
--> unchanged (rtrner memCh!p, resbar rmhist!p)" |
|
39159 | 719 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm e_def}, |
720 |
@{thm c_def}, @{thm r_def}, @{thm resbar_def}]) [] [] 1 *}) |
|
21624 | 721 |
apply (drule S4_excl [temp_use] S5_excl [temp_use])+ |
42771
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
722 |
using [[fast_solver]] |
b6037ae5027d
eliminated old-style MI_fast_css -- replaced by fast_solver with config option;
wenzelm
parents:
42770
diff
changeset
|
723 |
apply (auto elim!: squareE [temp_use] simp: MemReturn_def Return_def) |
21624 | 724 |
done |
725 |
||
726 |
lemma Step1_4_5a: "|- RPCReply crCh rmCh rst p & $S5 rmhist p & (S6 rmhist p)$ |
|
727 |
& unchanged (e p, c p, m p) |
|
728 |
--> unchanged (rtrner memCh!p, resbar rmhist!p)" |
|
729 |
apply clarsimp |
|
730 |
apply (drule S5_excl [temp_use] S6_excl [temp_use])+ |
|
731 |
apply (auto simp: e_def c_def m_def resbar_def) |
|
732 |
apply (auto simp: RPCReply_def Return_def S5_def S_def dest!: MVOKBAnotRF [temp_use]) |
|
733 |
done |
|
734 |
||
735 |
lemma Step1_4_5b: "|- RPCFail crCh rmCh rst p & $S5 rmhist p & (S6 rmhist p)$ |
|
736 |
& unchanged (e p, c p, m p) |
|
737 |
--> MemFail memCh (resbar rmhist) p" |
|
738 |
apply clarsimp |
|
739 |
apply (drule S6_excl [temp_use]) |
|
740 |
apply (auto simp: e_def c_def m_def RPCFail_def Return_def MemFail_def resbar_def) |
|
741 |
apply (auto simp: S5_def S_def) |
|
742 |
done |
|
743 |
||
744 |
lemma Step1_4_6a: "|- MClkReply memCh crCh cst p & $S6 rmhist p & (S1 rmhist p)$ |
|
745 |
& unchanged (e p, r p, m p) |
|
746 |
--> MemReturn memCh (resbar rmhist) p" |
|
747 |
apply clarsimp |
|
748 |
apply (drule S6_excl [temp_use])+ |
|
39159 | 749 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm e_def}, |
750 |
@{thm r_def}, @{thm m_def}, @{thm MClkReply_def}, @{thm MemReturn_def}, |
|
751 |
@{thm Return_def}, @{thm resbar_def}]) [] [] 1 *}) |
|
21624 | 752 |
apply simp_all (* simplify if-then-else *) |
26342 | 753 |
apply (tactic {* ALLGOALS (action_simp_tac (@{simpset} addsimps |
39159 | 754 |
[@{thm MClkReplyVal_def}, @{thm S6_def}, @{thm S_def}]) [] [@{thm MVOKBARFnotNR}]) *}) |
21624 | 755 |
done |
756 |
||
757 |
lemma Step1_4_6b: "|- MClkRetry memCh crCh cst p & $S6 rmhist p & (S3 rmhist p)$ |
|
758 |
& unchanged (e p, r p, m p, rmhist!p) |
|
759 |
--> MemFail memCh (resbar rmhist) p" |
|
760 |
apply clarsimp |
|
761 |
apply (drule S3_excl [temp_use])+ |
|
39159 | 762 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm e_def}, @{thm r_def}, |
763 |
@{thm m_def}, @{thm MClkRetry_def}, @{thm MemFail_def}, @{thm resbar_def}]) [] [] 1 *}) |
|
21624 | 764 |
apply (auto simp: S6_def S_def) |
765 |
done |
|
766 |
||
767 |
lemma S_lemma: "|- unchanged (e p, c p, r p, m p, rmhist!p) |
|
768 |
--> unchanged (S rmhist ec cc rc cs rs hs1 hs2 p)" |
|
769 |
by (auto simp: e_def c_def r_def m_def caller_def rtrner_def S_def Calling_def) |
|
770 |
||
771 |
lemma Step1_4_7H: "|- unchanged (e p, c p, r p, m p, rmhist!p) |
|
772 |
--> unchanged (rtrner memCh!p, S1 rmhist p, S2 rmhist p, S3 rmhist p, |
|
773 |
S4 rmhist p, S5 rmhist p, S6 rmhist p)" |
|
774 |
apply clarsimp |
|
775 |
apply (rule conjI) |
|
776 |
apply (force simp: c_def) |
|
777 |
apply (force simp: S1_def S2_def S3_def S4_def S5_def S6_def intro!: S_lemma [temp_use]) |
|
778 |
done |
|
779 |
||
780 |
lemma Step1_4_7: "|- unchanged (e p, c p, r p, m p, rmhist!p) |
|
781 |
--> unchanged (rtrner memCh!p, resbar rmhist!p, S1 rmhist p, S2 rmhist p, |
|
782 |
S3 rmhist p, S4 rmhist p, S5 rmhist p, S6 rmhist p)" |
|
783 |
apply (rule actionI) |
|
784 |
apply (unfold action_rews) |
|
785 |
apply (rule impI) |
|
786 |
apply (frule Step1_4_7H [temp_use]) |
|
787 |
apply (auto simp: e_def c_def r_def m_def rtrner_def resbar_def) |
|
788 |
done |
|
789 |
||
790 |
(* Frequently needed abbreviation: distinguish between idling and non-idling |
|
791 |
steps of the implementation, and try to solve the idling case by simplification |
|
792 |
*) |
|
793 |
ML {* |
|
27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
794 |
fun split_idle_tac ctxt simps i = |
32149
ef59550a55d3
renamed simpset_of to global_simpset_of, and local_simpset_of to simpset_of -- same for claset and clasimpset;
wenzelm
parents:
27208
diff
changeset
|
795 |
let val ss = simpset_of ctxt in |
27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
796 |
TRY (rtac @{thm actionI} i) THEN |
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
797 |
InductTacs.case_tac ctxt "(s,t) |= unchanged (e p, c p, r p, m p, rmhist!p)" i THEN |
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
798 |
rewrite_goals_tac @{thms action_rews} THEN |
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
799 |
forward_tac [temp_use @{thm Step1_4_7}] i THEN |
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
800 |
asm_full_simp_tac (ss addsimps simps) i |
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
801 |
end |
21624 | 802 |
*} |
803 |
(* ---------------------------------------------------------------------- |
|
804 |
Combine steps 1.2 and 1.4 to prove that the implementation satisfies |
|
805 |
the specification's next-state relation. |
|
806 |
*) |
|
807 |
||
808 |
(* Steps that leave all variables unchanged are safe, so I may assume |
|
809 |
that some variable changes in the proof that a step is safe. *) |
|
810 |
lemma unchanged_safe: "|- (~unchanged (e p, c p, r p, m p, rmhist!p) |
|
811 |
--> [UNext memCh mm (resbar rmhist) p]_(rtrner memCh!p, resbar rmhist!p)) |
|
812 |
--> [UNext memCh mm (resbar rmhist) p]_(rtrner memCh!p, resbar rmhist!p)" |
|
39159 | 813 |
apply (tactic {* split_idle_tac @{context} [@{thm square_def}] 1 *}) |
21624 | 814 |
apply force |
815 |
done |
|
816 |
(* turn into (unsafe, looping!) introduction rule *) |
|
817 |
lemmas unchanged_safeI = impI [THEN unchanged_safe [action_use], standard] |
|
818 |
||
819 |
lemma S1safe: "|- $S1 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
820 |
--> [UNext memCh mm (resbar rmhist) p]_(rtrner memCh!p, resbar rmhist!p)" |
|
821 |
apply clarsimp |
|
822 |
apply (rule unchanged_safeI) |
|
823 |
apply (rule idle_squareI) |
|
824 |
apply (auto dest!: Step1_2_1 [temp_use] Step1_4_1 [temp_use]) |
|
825 |
done |
|
826 |
||
827 |
lemma S2safe: "|- $S2 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
828 |
--> [UNext memCh mm (resbar rmhist) p]_(rtrner memCh!p, resbar rmhist!p)" |
|
829 |
apply clarsimp |
|
830 |
apply (rule unchanged_safeI) |
|
831 |
apply (rule idle_squareI) |
|
832 |
apply (auto dest!: Step1_2_2 [temp_use] Step1_4_2 [temp_use]) |
|
833 |
done |
|
834 |
||
835 |
lemma S3safe: "|- $S3 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
836 |
--> [UNext memCh mm (resbar rmhist) p]_(rtrner memCh!p, resbar rmhist!p)" |
|
837 |
apply clarsimp |
|
838 |
apply (rule unchanged_safeI) |
|
839 |
apply (auto dest!: Step1_2_3 [temp_use]) |
|
840 |
apply (auto simp: square_def UNext_def dest!: Step1_4_3a [temp_use] Step1_4_3b [temp_use]) |
|
841 |
done |
|
842 |
||
843 |
lemma S4safe: "|- $S4 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
844 |
& (!l. $(MemInv mm l)) |
|
845 |
--> [UNext memCh mm (resbar rmhist) p]_(rtrner memCh!p, resbar rmhist!p)" |
|
846 |
apply clarsimp |
|
847 |
apply (rule unchanged_safeI) |
|
848 |
apply (auto dest!: Step1_2_4 [temp_use]) |
|
849 |
apply (auto simp: square_def UNext_def RNext_def |
|
850 |
dest!: Step1_4_4a [temp_use] Step1_4_4b [temp_use] Step1_4_4c [temp_use]) |
|
851 |
done |
|
852 |
||
853 |
lemma S5safe: "|- $S5 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
854 |
--> [UNext memCh mm (resbar rmhist) p]_(rtrner memCh!p, resbar rmhist!p)" |
|
855 |
apply clarsimp |
|
856 |
apply (rule unchanged_safeI) |
|
857 |
apply (auto dest!: Step1_2_5 [temp_use]) |
|
858 |
apply (auto simp: square_def UNext_def dest!: Step1_4_5a [temp_use] Step1_4_5b [temp_use]) |
|
859 |
done |
|
860 |
||
861 |
lemma S6safe: "|- $S6 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
862 |
--> [UNext memCh mm (resbar rmhist) p]_(rtrner memCh!p, resbar rmhist!p)" |
|
863 |
apply clarsimp |
|
864 |
apply (rule unchanged_safeI) |
|
865 |
apply (auto dest!: Step1_2_6 [temp_use]) |
|
866 |
apply (auto simp: square_def UNext_def RNext_def |
|
867 |
dest!: Step1_4_6a [temp_use] Step1_4_6b [temp_use]) |
|
868 |
done |
|
869 |
||
870 |
(* ---------------------------------------------------------------------- |
|
871 |
Step 1.5: Temporal refinement proof, based on previous steps. |
|
872 |
*) |
|
873 |
||
874 |
section "The liveness part" |
|
875 |
||
876 |
(* Liveness assertions for the different implementation states, based on the |
|
877 |
fairness conditions. Prove subgoals of WF1 / SF1 rules as separate lemmas |
|
878 |
for readability. Reuse action proofs from safety part. |
|
879 |
*) |
|
880 |
||
881 |
(* ------------------------------ State S1 ------------------------------ *) |
|
882 |
||
883 |
lemma S1_successors: "|- $S1 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
884 |
--> (S1 rmhist p)$ | (S2 rmhist p)$" |
|
27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
885 |
apply (tactic "split_idle_tac @{context} [] 1") |
21624 | 886 |
apply (auto dest!: Step1_2_1 [temp_use]) |
887 |
done |
|
888 |
||
889 |
(* Show that the implementation can satisfy the high-level fairness requirements |
|
890 |
by entering the state S1 infinitely often. |
|
891 |
*) |
|
892 |
||
893 |
lemma S1_RNextdisabled: "|- S1 rmhist p --> |
|
894 |
~Enabled (<RNext memCh mm (resbar rmhist) p>_(rtrner memCh!p, resbar rmhist!p))" |
|
39159 | 895 |
apply (tactic {* action_simp_tac (@{simpset} addsimps [@{thm angle_def}, |
896 |
@{thm S_def}, @{thm S1_def}]) [notI] [@{thm enabledE}, temp_elim @{thm Memoryidle}] 1 *}) |
|
21624 | 897 |
apply force |
898 |
done |
|
899 |
||
900 |
lemma S1_Returndisabled: "|- S1 rmhist p --> |
|
901 |
~Enabled (<MemReturn memCh (resbar rmhist) p>_(rtrner memCh!p, resbar rmhist!p))" |
|
39159 | 902 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm angle_def}, @{thm MemReturn_def}, |
903 |
@{thm Return_def}, @{thm S_def}, @{thm S1_def}]) [notI] [@{thm enabledE}] 1 *}) |
|
21624 | 904 |
|
905 |
lemma RNext_fair: "|- []<>S1 rmhist p |
|
906 |
--> WF(RNext memCh mm (resbar rmhist) p)_(rtrner memCh!p, resbar rmhist!p)" |
|
907 |
by (auto simp: WF_alt [try_rewrite] intro!: S1_RNextdisabled [temp_use] |
|
908 |
elim!: STL4E [temp_use] DmdImplE [temp_use]) |
|
909 |
||
910 |
lemma Return_fair: "|- []<>S1 rmhist p |
|
911 |
--> WF(MemReturn memCh (resbar rmhist) p)_(rtrner memCh!p, resbar rmhist!p)" |
|
912 |
by (auto simp: WF_alt [try_rewrite] |
|
913 |
intro!: S1_Returndisabled [temp_use] elim!: STL4E [temp_use] DmdImplE [temp_use]) |
|
914 |
||
915 |
(* ------------------------------ State S2 ------------------------------ *) |
|
916 |
||
917 |
lemma S2_successors: "|- $S2 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
918 |
--> (S2 rmhist p)$ | (S3 rmhist p)$" |
|
27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
919 |
apply (tactic "split_idle_tac @{context} [] 1") |
21624 | 920 |
apply (auto dest!: Step1_2_2 [temp_use]) |
921 |
done |
|
922 |
||
923 |
lemma S2MClkFwd_successors: "|- ($S2 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p)) |
|
924 |
& <MClkFwd memCh crCh cst p>_(c p) |
|
925 |
--> (S3 rmhist p)$" |
|
926 |
by (auto simp: angle_def dest!: Step1_2_2 [temp_use]) |
|
927 |
||
928 |
lemma S2MClkFwd_enabled: "|- $S2 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
929 |
--> $Enabled (<MClkFwd memCh crCh cst p>_(c p))" |
|
930 |
apply (auto simp: c_def intro!: MClkFwd_ch_enabled [temp_use] MClkFwd_enabled [temp_use]) |
|
931 |
apply (cut_tac MI_base) |
|
932 |
apply (blast dest: base_pair) |
|
933 |
apply (simp_all add: S_def S2_def) |
|
934 |
done |
|
935 |
||
936 |
lemma S2_live: "|- [](ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p)) |
|
937 |
& WF(MClkFwd memCh crCh cst p)_(c p) |
|
938 |
--> (S2 rmhist p ~> S3 rmhist p)" |
|
939 |
by (rule WF1 S2_successors S2MClkFwd_successors S2MClkFwd_enabled)+ |
|
940 |
||
941 |
(* ------------------------------ State S3 ------------------------------ *) |
|
942 |
||
943 |
lemma S3_successors: "|- $S3 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
944 |
--> (S3 rmhist p)$ | (S4 rmhist p | S6 rmhist p)$" |
|
27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
945 |
apply (tactic "split_idle_tac @{context} [] 1") |
21624 | 946 |
apply (auto dest!: Step1_2_3 [temp_use]) |
947 |
done |
|
948 |
||
949 |
lemma S3RPC_successors: "|- ($S3 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p)) |
|
950 |
& <RPCNext crCh rmCh rst p>_(r p) |
|
951 |
--> (S4 rmhist p | S6 rmhist p)$" |
|
952 |
apply (auto simp: angle_def dest!: Step1_2_3 [temp_use]) |
|
953 |
done |
|
954 |
||
955 |
lemma S3RPC_enabled: "|- $S3 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
956 |
--> $Enabled (<RPCNext crCh rmCh rst p>_(r p))" |
|
957 |
apply (auto simp: r_def intro!: RPCFail_Next_enabled [temp_use] RPCFail_enabled [temp_use]) |
|
958 |
apply (cut_tac MI_base) |
|
959 |
apply (blast dest: base_pair) |
|
960 |
apply (simp_all add: S_def S3_def) |
|
961 |
done |
|
962 |
||
963 |
lemma S3_live: "|- [](ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p)) |
|
964 |
& WF(RPCNext crCh rmCh rst p)_(r p) |
|
965 |
--> (S3 rmhist p ~> S4 rmhist p | S6 rmhist p)" |
|
966 |
by (rule WF1 S3_successors S3RPC_successors S3RPC_enabled)+ |
|
967 |
||
968 |
(* ------------- State S4 -------------------------------------------------- *) |
|
969 |
||
970 |
lemma S4_successors: "|- $S4 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
971 |
& (ALL l. $MemInv mm l) |
|
972 |
--> (S4 rmhist p)$ | (S5 rmhist p)$" |
|
27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
973 |
apply (tactic "split_idle_tac @{context} [] 1") |
21624 | 974 |
apply (auto dest!: Step1_2_4 [temp_use]) |
975 |
done |
|
976 |
||
977 |
(* --------- State S4a: S4 /\ (ires p = NotAResult) ------------------------ *) |
|
978 |
||
979 |
lemma S4a_successors: "|- $(S4 rmhist p & ires!p = #NotAResult) |
|
980 |
& ImpNext p & [HNext rmhist p]_(c p,r p,m p,rmhist!p) & (ALL l. $MemInv mm l) |
|
981 |
--> (S4 rmhist p & ires!p = #NotAResult)$ |
|
982 |
| ((S4 rmhist p & ires!p ~= #NotAResult) | S5 rmhist p)$" |
|
39159 | 983 |
apply (tactic {* split_idle_tac @{context} [@{thm m_def}] 1 *}) |
21624 | 984 |
apply (auto dest!: Step1_2_4 [temp_use]) |
985 |
done |
|
986 |
||
987 |
lemma S4aRNext_successors: "|- ($(S4 rmhist p & ires!p = #NotAResult) |
|
988 |
& ImpNext p & [HNext rmhist p]_(c p,r p,m p,rmhist!p) & (ALL l. $MemInv mm l)) |
|
989 |
& <RNext rmCh mm ires p>_(m p) |
|
990 |
--> ((S4 rmhist p & ires!p ~= #NotAResult) | S5 rmhist p)$" |
|
991 |
by (auto simp: angle_def |
|
992 |
dest!: Step1_2_4 [temp_use] ReadResult [temp_use] WriteResult [temp_use]) |
|
993 |
||
994 |
lemma S4aRNext_enabled: "|- $(S4 rmhist p & ires!p = #NotAResult) |
|
995 |
& ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) & (ALL l. $MemInv mm l) |
|
996 |
--> $Enabled (<RNext rmCh mm ires p>_(m p))" |
|
997 |
apply (auto simp: m_def intro!: RNext_enabled [temp_use]) |
|
998 |
apply (cut_tac MI_base) |
|
999 |
apply (blast dest: base_pair) |
|
1000 |
apply (simp add: S_def S4_def) |
|
1001 |
done |
|
1002 |
||
1003 |
lemma S4a_live: "|- [](ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
1004 |
& (ALL l. $MemInv mm l)) & WF(RNext rmCh mm ires p)_(m p) |
|
1005 |
--> (S4 rmhist p & ires!p = #NotAResult |
|
1006 |
~> (S4 rmhist p & ires!p ~= #NotAResult) | S5 rmhist p)" |
|
1007 |
by (rule WF1 S4a_successors S4aRNext_successors S4aRNext_enabled)+ |
|
1008 |
||
1009 |
(* ---------- State S4b: S4 /\ (ires p # NotAResult) --------------------------- *) |
|
1010 |
||
1011 |
lemma S4b_successors: "|- $(S4 rmhist p & ires!p ~= #NotAResult) |
|
1012 |
& ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) & (ALL l. $MemInv mm l) |
|
1013 |
--> (S4 rmhist p & ires!p ~= #NotAResult)$ | (S5 rmhist p)$" |
|
39159 | 1014 |
apply (tactic {* split_idle_tac @{context} [@{thm m_def}] 1 *}) |
21624 | 1015 |
apply (auto dest!: WriteResult [temp_use] Step1_2_4 [temp_use] ReadResult [temp_use]) |
1016 |
done |
|
1017 |
||
1018 |
lemma S4bReturn_successors: "|- ($(S4 rmhist p & ires!p ~= #NotAResult) |
|
1019 |
& ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
1020 |
& (ALL l. $MemInv mm l)) & <MemReturn rmCh ires p>_(m p) |
|
1021 |
--> (S5 rmhist p)$" |
|
1022 |
by (force simp: angle_def dest!: Step1_2_4 [temp_use] dest: ReturnNotReadWrite [temp_use]) |
|
1023 |
||
1024 |
lemma S4bReturn_enabled: "|- $(S4 rmhist p & ires!p ~= #NotAResult) |
|
1025 |
& ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
1026 |
& (ALL l. $MemInv mm l) |
|
1027 |
--> $Enabled (<MemReturn rmCh ires p>_(m p))" |
|
1028 |
apply (auto simp: m_def intro!: MemReturn_enabled [temp_use]) |
|
1029 |
apply (cut_tac MI_base) |
|
1030 |
apply (blast dest: base_pair) |
|
1031 |
apply (simp add: S_def S4_def) |
|
1032 |
done |
|
1033 |
||
1034 |
lemma S4b_live: "|- [](ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) & (!l. $MemInv mm l)) |
|
1035 |
& WF(MemReturn rmCh ires p)_(m p) |
|
1036 |
--> (S4 rmhist p & ires!p ~= #NotAResult ~> S5 rmhist p)" |
|
1037 |
by (rule WF1 S4b_successors S4bReturn_successors S4bReturn_enabled)+ |
|
1038 |
||
1039 |
(* ------------------------------ State S5 ------------------------------ *) |
|
1040 |
||
1041 |
lemma S5_successors: "|- $S5 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
1042 |
--> (S5 rmhist p)$ | (S6 rmhist p)$" |
|
27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
1043 |
apply (tactic "split_idle_tac @{context} [] 1") |
21624 | 1044 |
apply (auto dest!: Step1_2_5 [temp_use]) |
1045 |
done |
|
1046 |
||
1047 |
lemma S5RPC_successors: "|- ($S5 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p)) |
|
1048 |
& <RPCNext crCh rmCh rst p>_(r p) |
|
1049 |
--> (S6 rmhist p)$" |
|
1050 |
by (auto simp: angle_def dest!: Step1_2_5 [temp_use]) |
|
1051 |
||
1052 |
lemma S5RPC_enabled: "|- $S5 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
1053 |
--> $Enabled (<RPCNext crCh rmCh rst p>_(r p))" |
|
1054 |
apply (auto simp: r_def intro!: RPCFail_Next_enabled [temp_use] RPCFail_enabled [temp_use]) |
|
1055 |
apply (cut_tac MI_base) |
|
1056 |
apply (blast dest: base_pair) |
|
1057 |
apply (simp_all add: S_def S5_def) |
|
1058 |
done |
|
1059 |
||
1060 |
lemma S5_live: "|- [](ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p)) |
|
1061 |
& WF(RPCNext crCh rmCh rst p)_(r p) |
|
1062 |
--> (S5 rmhist p ~> S6 rmhist p)" |
|
1063 |
by (rule WF1 S5_successors S5RPC_successors S5RPC_enabled)+ |
|
1064 |
||
1065 |
(* ------------------------------ State S6 ------------------------------ *) |
|
1066 |
||
1067 |
lemma S6_successors: "|- $S6 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) |
|
1068 |
--> (S1 rmhist p)$ | (S3 rmhist p)$ | (S6 rmhist p)$" |
|
27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
1069 |
apply (tactic "split_idle_tac @{context} [] 1") |
21624 | 1070 |
apply (auto dest!: Step1_2_6 [temp_use]) |
1071 |
done |
|
1072 |
||
1073 |
lemma S6MClkReply_successors: |
|
1074 |
"|- ($S6 rmhist p & ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p)) |
|
1075 |
& <MClkReply memCh crCh cst p>_(c p) |
|
1076 |
--> (S1 rmhist p)$" |
|
1077 |
by (auto simp: angle_def dest!: Step1_2_6 [temp_use] MClkReplyNotRetry [temp_use]) |
|
1078 |
||
1079 |
lemma MClkReplyS6: |
|
1080 |
"|- $ImpInv rmhist p & <MClkReply memCh crCh cst p>_(c p) --> $S6 rmhist p" |
|
39159 | 1081 |
by (tactic {* action_simp_tac (@{simpset} addsimps [@{thm angle_def}, |
1082 |
@{thm MClkReply_def}, @{thm Return_def}, @{thm ImpInv_def}, @{thm S_def}, |
|
1083 |
@{thm S1_def}, @{thm S2_def}, @{thm S3_def}, @{thm S4_def}, @{thm S5_def}]) [] [] 1 *}) |
|
21624 | 1084 |
|
1085 |
lemma S6MClkReply_enabled: "|- S6 rmhist p --> Enabled (<MClkReply memCh crCh cst p>_(c p))" |
|
1086 |
apply (auto simp: c_def intro!: MClkReply_enabled [temp_use]) |
|
1087 |
apply (cut_tac MI_base) |
|
1088 |
apply (blast dest: base_pair) |
|
26342 | 1089 |
apply (tactic {* ALLGOALS (action_simp_tac (@{simpset} |
39159 | 1090 |
addsimps [@{thm S_def}, @{thm S6_def}]) [] []) *}) |
21624 | 1091 |
done |
1092 |
||
1093 |
lemma S6_live: "|- [](ImpNext p & [HNext rmhist p]_(c p,r p,m p, rmhist!p) & $(ImpInv rmhist p)) |
|
1094 |
& SF(MClkReply memCh crCh cst p)_(c p) & []<>(S6 rmhist p) |
|
1095 |
--> []<>(S1 rmhist p)" |
|
1096 |
apply clarsimp |
|
1097 |
apply (subgoal_tac "sigma |= []<> (<MClkReply memCh crCh cst p>_ (c p))") |
|
1098 |
apply (erule InfiniteEnsures) |
|
1099 |
apply assumption |
|
26342 | 1100 |
apply (tactic {* action_simp_tac @{simpset} [] |
39159 | 1101 |
(map temp_elim [@{thm MClkReplyS6}, @{thm S6MClkReply_successors}]) 1 *}) |
21624 | 1102 |
apply (auto simp: SF_def) |
1103 |
apply (erule contrapos_np) |
|
1104 |
apply (auto intro!: S6MClkReply_enabled [temp_use] elim!: STL4E [temp_use] DmdImplE [temp_use]) |
|
1105 |
done |
|
1106 |
||
1107 |
(* --------------- aggregate leadsto properties----------------------------- *) |
|
1108 |
||
1109 |
lemma S5S6LeadstoS6: "sigma |= S5 rmhist p ~> S6 rmhist p |
|
1110 |
==> sigma |= (S5 rmhist p | S6 rmhist p) ~> S6 rmhist p" |
|
1111 |
by (auto intro!: LatticeDisjunctionIntro [temp_use] LatticeReflexivity [temp_use]) |
|
1112 |
||
1113 |
lemma S4bS5S6LeadstoS6: "[| sigma |= S4 rmhist p & ires!p ~= #NotAResult ~> S5 rmhist p; |
|
1114 |
sigma |= S5 rmhist p ~> S6 rmhist p |] |
|
1115 |
==> sigma |= (S4 rmhist p & ires!p ~= #NotAResult) | S5 rmhist p | S6 rmhist p |
|
1116 |
~> S6 rmhist p" |
|
1117 |
by (auto intro!: LatticeDisjunctionIntro [temp_use] |
|
1118 |
S5S6LeadstoS6 [temp_use] intro: LatticeTransitivity [temp_use]) |
|
1119 |
||
1120 |
lemma S4S5S6LeadstoS6: "[| sigma |= S4 rmhist p & ires!p = #NotAResult |
|
1121 |
~> (S4 rmhist p & ires!p ~= #NotAResult) | S5 rmhist p; |
|
1122 |
sigma |= S4 rmhist p & ires!p ~= #NotAResult ~> S5 rmhist p; |
|
1123 |
sigma |= S5 rmhist p ~> S6 rmhist p |] |
|
1124 |
==> sigma |= S4 rmhist p | S5 rmhist p | S6 rmhist p ~> S6 rmhist p" |
|
1125 |
apply (subgoal_tac "sigma |= (S4 rmhist p & ires!p = #NotAResult) | |
|
1126 |
(S4 rmhist p & ires!p ~= #NotAResult) | S5 rmhist p | S6 rmhist p ~> S6 rmhist p") |
|
1127 |
apply (erule_tac G = "PRED ((S4 rmhist p & ires!p = #NotAResult) | |
|
1128 |
(S4 rmhist p & ires!p ~= #NotAResult) | S5 rmhist p | S6 rmhist p)" in |
|
1129 |
LatticeTransitivity [temp_use]) |
|
1130 |
apply (force simp: Init_defs intro!: ImplLeadsto_gen [temp_use] necT [temp_use]) |
|
1131 |
apply (rule LatticeDisjunctionIntro [temp_use]) |
|
1132 |
apply (erule LatticeTransitivity [temp_use]) |
|
1133 |
apply (erule LatticeTriangle2 [temp_use]) |
|
1134 |
apply assumption |
|
1135 |
apply (auto intro!: S4bS5S6LeadstoS6 [temp_use]) |
|
1136 |
done |
|
1137 |
||
1138 |
lemma S3S4S5S6LeadstoS6: "[| sigma |= S3 rmhist p ~> S4 rmhist p | S6 rmhist p; |
|
1139 |
sigma |= S4 rmhist p & ires!p = #NotAResult |
|
1140 |
~> (S4 rmhist p & ires!p ~= #NotAResult) | S5 rmhist p; |
|
1141 |
sigma |= S4 rmhist p & ires!p ~= #NotAResult ~> S5 rmhist p; |
|
1142 |
sigma |= S5 rmhist p ~> S6 rmhist p |] |
|
1143 |
==> sigma |= S3 rmhist p | S4 rmhist p | S5 rmhist p | S6 rmhist p ~> S6 rmhist p" |
|
1144 |
apply (rule LatticeDisjunctionIntro [temp_use]) |
|
1145 |
apply (erule LatticeTriangle2 [temp_use]) |
|
1146 |
apply (rule S4S5S6LeadstoS6 [THEN LatticeTransitivity [temp_use]]) |
|
1147 |
apply (auto intro!: S4S5S6LeadstoS6 [temp_use] necT [temp_use] |
|
1148 |
intro: ImplLeadsto_gen [temp_use] simp: Init_defs) |
|
1149 |
done |
|
1150 |
||
1151 |
lemma S2S3S4S5S6LeadstoS6: "[| sigma |= S2 rmhist p ~> S3 rmhist p; |
|
1152 |
sigma |= S3 rmhist p ~> S4 rmhist p | S6 rmhist p; |
|
1153 |
sigma |= S4 rmhist p & ires!p = #NotAResult |
|
1154 |
~> S4 rmhist p & ires!p ~= #NotAResult | S5 rmhist p; |
|
1155 |
sigma |= S4 rmhist p & ires!p ~= #NotAResult ~> S5 rmhist p; |
|
1156 |
sigma |= S5 rmhist p ~> S6 rmhist p |] |
|
1157 |
==> sigma |= S2 rmhist p | S3 rmhist p | S4 rmhist p | S5 rmhist p | S6 rmhist p |
|
1158 |
~> S6 rmhist p" |
|
1159 |
apply (rule LatticeDisjunctionIntro [temp_use]) |
|
1160 |
apply (rule LatticeTransitivity [temp_use]) |
|
1161 |
prefer 2 apply assumption |
|
1162 |
apply (rule S3S4S5S6LeadstoS6 [THEN LatticeTransitivity [temp_use]]) |
|
1163 |
apply (auto intro!: S3S4S5S6LeadstoS6 [temp_use] necT [temp_use] |
|
1164 |
intro: ImplLeadsto_gen [temp_use] simp: Init_defs) |
|
1165 |
done |
|
1166 |
||
1167 |
lemma NotS1LeadstoS6: "[| sigma |= []ImpInv rmhist p; |
|
1168 |
sigma |= S2 rmhist p ~> S3 rmhist p; |
|
1169 |
sigma |= S3 rmhist p ~> S4 rmhist p | S6 rmhist p; |
|
1170 |
sigma |= S4 rmhist p & ires!p = #NotAResult |
|
1171 |
~> S4 rmhist p & ires!p ~= #NotAResult | S5 rmhist p; |
|
1172 |
sigma |= S4 rmhist p & ires!p ~= #NotAResult ~> S5 rmhist p; |
|
1173 |
sigma |= S5 rmhist p ~> S6 rmhist p |] |
|
1174 |
==> sigma |= ~S1 rmhist p ~> S6 rmhist p" |
|
1175 |
apply (rule S2S3S4S5S6LeadstoS6 [THEN LatticeTransitivity [temp_use]]) |
|
1176 |
apply assumption+ |
|
1177 |
apply (erule INV_leadsto [temp_use]) |
|
1178 |
apply (rule ImplLeadsto_gen [temp_use]) |
|
1179 |
apply (rule necT [temp_use]) |
|
1180 |
apply (auto simp: ImpInv_def Init_defs intro!: necT [temp_use]) |
|
1181 |
done |
|
1182 |
||
1183 |
lemma S1Infinite: "[| sigma |= ~S1 rmhist p ~> S6 rmhist p; |
|
1184 |
sigma |= []<>S6 rmhist p --> []<>S1 rmhist p |] |
|
1185 |
==> sigma |= []<>S1 rmhist p" |
|
1186 |
apply (rule classical) |
|
26342 | 1187 |
apply (tactic {* asm_lr_simp_tac (@{simpset} addsimps |
39159 | 1188 |
[temp_use @{thm NotBox}, temp_rewrite @{thm NotDmd}]) 1 *}) |
21624 | 1189 |
apply (auto elim!: leadsto_infinite [temp_use] mp dest!: DBImplBD [temp_use]) |
1190 |
done |
|
1191 |
||
1192 |
section "Refinement proof (step 1.5)" |
|
1193 |
||
1194 |
(* Prove invariants of the implementation: |
|
1195 |
a. memory invariant |
|
1196 |
b. "implementation invariant": always in states S1,...,S6 |
|
1197 |
*) |
|
1198 |
lemma Step1_5_1a: "|- IPImp p --> (ALL l. []$MemInv mm l)" |
|
1199 |
by (auto simp: IPImp_def box_stp_act [temp_use] intro!: MemoryInvariantAll [temp_use]) |
|
1200 |
||
1201 |
lemma Step1_5_1b: "|- Init(ImpInit p & HInit rmhist p) & [](ImpNext p) |
|
1202 |
& [][HNext rmhist p]_(c p, r p, m p, rmhist!p) & [](ALL l. $MemInv mm l) |
|
1203 |
--> []ImpInv rmhist p" |
|
42770
3ebce8d71a05
eliminated obsolete MI_css -- use current context directly;
wenzelm
parents:
42018
diff
changeset
|
1204 |
apply invariant |
21624 | 1205 |
apply (auto simp: Init_def ImpInv_def box_stp_act [temp_use] |
1206 |
dest!: Step1_1 [temp_use] dest: S1_successors [temp_use] S2_successors [temp_use] |
|
1207 |
S3_successors [temp_use] S4_successors [temp_use] S5_successors [temp_use] |
|
1208 |
S6_successors [temp_use]) |
|
1209 |
done |
|
1210 |
||
1211 |
(*** Initialization ***) |
|
1212 |
lemma Step1_5_2a: "|- Init(ImpInit p & HInit rmhist p) --> Init(PInit (resbar rmhist) p)" |
|
1213 |
by (auto simp: Init_def intro!: Step1_1 [temp_use] Step1_3 [temp_use]) |
|
1214 |
||
1215 |
(*** step simulation ***) |
|
1216 |
lemma Step1_5_2b: "|- [](ImpNext p & [HNext rmhist p]_(c p, r p, m p, rmhist!p) |
|
1217 |
& $ImpInv rmhist p & (!l. $MemInv mm l)) |
|
1218 |
--> [][UNext memCh mm (resbar rmhist) p]_(rtrner memCh!p, resbar rmhist!p)" |
|
1219 |
by (auto simp: ImpInv_def elim!: STL4E [temp_use] |
|
1220 |
dest!: S1safe [temp_use] S2safe [temp_use] S3safe [temp_use] S4safe [temp_use] |
|
1221 |
S5safe [temp_use] S6safe [temp_use]) |
|
1222 |
||
1223 |
(*** Liveness ***) |
|
1224 |
lemma GoodImpl: "|- IPImp p & HistP rmhist p |
|
1225 |
--> Init(ImpInit p & HInit rmhist p) |
|
1226 |
& [](ImpNext p & [HNext rmhist p]_(c p, r p, m p, rmhist!p)) |
|
1227 |
& [](ALL l. $MemInv mm l) & []($ImpInv rmhist p) |
|
1228 |
& ImpLive p" |
|
1229 |
apply clarsimp |
|
1230 |
apply (subgoal_tac "sigma |= Init (ImpInit p & HInit rmhist p) & [] (ImpNext p) & |
|
1231 |
[][HNext rmhist p]_ (c p, r p, m p, rmhist!p) & [] (ALL l. $MemInv mm l)") |
|
1232 |
apply (auto simp: split_box_conj [try_rewrite] box_stp_act [try_rewrite] |
|
1233 |
dest!: Step1_5_1b [temp_use]) |
|
1234 |
apply (force simp: IPImp_def MClkIPSpec_def RPCIPSpec_def RPSpec_def |
|
1235 |
ImpLive_def c_def r_def m_def) |
|
1236 |
apply (force simp: IPImp_def MClkIPSpec_def RPCIPSpec_def RPSpec_def |
|
1237 |
HistP_def Init_def ImpInit_def) |
|
1238 |
apply (force simp: IPImp_def MClkIPSpec_def RPCIPSpec_def RPSpec_def |
|
1239 |
ImpNext_def c_def r_def m_def split_box_conj [temp_use]) |
|
1240 |
apply (force simp: HistP_def) |
|
1241 |
apply (force simp: allT [temp_use] dest!: Step1_5_1a [temp_use]) |
|
1242 |
done |
|
1243 |
||
1244 |
(* The implementation is infinitely often in state S1... *) |
|
1245 |
lemma Step1_5_3a: "|- [](ImpNext p & [HNext rmhist p]_(c p, r p, m p, rmhist!p)) |
|
1246 |
& [](ALL l. $MemInv mm l) |
|
1247 |
& []($ImpInv rmhist p) & ImpLive p |
|
1248 |
--> []<>S1 rmhist p" |
|
1249 |
apply (clarsimp simp: ImpLive_def) |
|
1250 |
apply (rule S1Infinite) |
|
1251 |
apply (force simp: split_box_conj [try_rewrite] box_stp_act [try_rewrite] |
|
1252 |
intro!: NotS1LeadstoS6 [temp_use] S2_live [temp_use] S3_live [temp_use] |
|
1253 |
S4a_live [temp_use] S4b_live [temp_use] S5_live [temp_use]) |
|
1254 |
apply (auto simp: split_box_conj [temp_use] intro!: S6_live [temp_use]) |
|
1255 |
done |
|
1256 |
||
1257 |
(* ... and therefore satisfies the fairness requirements of the specification *) |
|
1258 |
lemma Step1_5_3b: "|- [](ImpNext p & [HNext rmhist p]_(c p, r p, m p, rmhist!p)) |
|
1259 |
& [](ALL l. $MemInv mm l) & []($ImpInv rmhist p) & ImpLive p |
|
1260 |
--> WF(RNext memCh mm (resbar rmhist) p)_(rtrner memCh!p, resbar rmhist!p)" |
|
1261 |
by (auto intro!: RNext_fair [temp_use] Step1_5_3a [temp_use]) |
|
1262 |
||
1263 |
lemma Step1_5_3c: "|- [](ImpNext p & [HNext rmhist p]_(c p, r p, m p, rmhist!p)) |
|
1264 |
& [](ALL l. $MemInv mm l) & []($ImpInv rmhist p) & ImpLive p |
|
1265 |
--> WF(MemReturn memCh (resbar rmhist) p)_(rtrner memCh!p, resbar rmhist!p)" |
|
1266 |
by (auto intro!: Return_fair [temp_use] Step1_5_3a [temp_use]) |
|
1267 |
||
1268 |
(* QED step of step 1 *) |
|
1269 |
lemma Step1: "|- IPImp p & HistP rmhist p --> UPSpec memCh mm (resbar rmhist) p" |
|
1270 |
by (auto simp: UPSpec_def split_box_conj [temp_use] |
|
1271 |
dest!: GoodImpl [temp_use] intro!: Step1_5_2a [temp_use] Step1_5_2b [temp_use] |
|
1272 |
Step1_5_3b [temp_use] Step1_5_3c [temp_use]) |
|
1273 |
||
1274 |
(* ------------------------------ Step 2 ------------------------------ *) |
|
1275 |
section "Step 2" |
|
1276 |
||
1277 |
lemma Step2_2a: "|- Write rmCh mm ires p l & ImpNext p |
|
1278 |
& [HNext rmhist p]_(c p, r p, m p, rmhist!p) |
|
1279 |
& $ImpInv rmhist p |
|
1280 |
--> (S4 rmhist p)$ & unchanged (e p, c p, r p, rmhist!p)" |
|
1281 |
apply clarsimp |
|
1282 |
apply (drule WriteS4 [action_use]) |
|
1283 |
apply assumption |
|
27208
5fe899199f85
proper context for tactics derived from res_inst_tac;
wenzelm
parents:
27117
diff
changeset
|
1284 |
apply (tactic "split_idle_tac @{context} [] 1") |
21624 | 1285 |
apply (auto simp: ImpNext_def dest!: S4EnvUnch [temp_use] S4ClerkUnch [temp_use] |
1286 |
S4RPCUnch [temp_use]) |
|
1287 |
apply (auto simp: square_def dest: S4Write [temp_use]) |
|
1288 |
done |
|
1289 |
||
1290 |
lemma Step2_2: "|- (ALL p. ImpNext p) |
|
1291 |
& (ALL p. [HNext rmhist p]_(c p, r p, m p, rmhist!p)) |
|
1292 |
& (ALL p. $ImpInv rmhist p) |
|
1293 |
& [EX q. Write rmCh mm ires q l]_(mm!l) |
|
1294 |
--> [EX q. Write memCh mm (resbar rmhist) q l]_(mm!l)" |
|
1295 |
apply (auto intro!: squareCI elim!: squareE) |
|
1296 |
apply (assumption | rule exI Step1_4_4b [action_use])+ |
|
1297 |
apply (force intro!: WriteS4 [temp_use]) |
|
1298 |
apply (auto dest!: Step2_2a [temp_use]) |
|
1299 |
done |
|
1300 |
||
1301 |
lemma Step2_lemma: "|- []( (ALL p. ImpNext p) |
|
1302 |
& (ALL p. [HNext rmhist p]_(c p, r p, m p, rmhist!p)) |
|
1303 |
& (ALL p. $ImpInv rmhist p) |
|
1304 |
& [EX q. Write rmCh mm ires q l]_(mm!l)) |
|
1305 |
--> [][EX q. Write memCh mm (resbar rmhist) q l]_(mm!l)" |
|
1306 |
by (force elim!: STL4E [temp_use] dest!: Step2_2 [temp_use]) |
|
1307 |
||
1308 |
lemma Step2: "|- #l : #MemLoc & (ALL p. IPImp p & HistP rmhist p) |
|
1309 |
--> MSpec memCh mm (resbar rmhist) l" |
|
1310 |
apply (auto simp: MSpec_def) |
|
1311 |
apply (force simp: IPImp_def MSpec_def) |
|
1312 |
apply (auto intro!: Step2_lemma [temp_use] simp: split_box_conj [temp_use] all_box [temp_use]) |
|
1313 |
prefer 4 |
|
1314 |
apply (force simp: IPImp_def MSpec_def) |
|
1315 |
apply (auto simp: split_box_conj [temp_use] elim!: allE dest!: GoodImpl [temp_use]) |
|
1316 |
done |
|
1317 |
||
1318 |
(* ----------------------------- Main theorem --------------------------------- *) |
|
1319 |
section "Memory implementation" |
|
1320 |
||
1321 |
(* The combination of a legal caller, the memory clerk, the RPC component, |
|
1322 |
and a reliable memory implement the unreliable memory. |
|
1323 |
*) |
|
1324 |
||
1325 |
(* Implementation of internal specification by combination of implementation |
|
1326 |
and history variable with explicit refinement mapping |
|
1327 |
*) |
|
1328 |
lemma Impl_IUSpec: "|- Implementation & Hist rmhist --> IUSpec memCh mm (resbar rmhist)" |
|
1329 |
by (auto simp: IUSpec_def Implementation_def IPImp_def MClkISpec_def |
|
1330 |
RPCISpec_def IRSpec_def Hist_def intro!: Step1 [temp_use] Step2 [temp_use]) |
|
1331 |
||
1332 |
(* The main theorem: introduce hiding and eliminate history variable. *) |
|
1333 |
lemma Implementation: "|- Implementation --> USpec memCh" |
|
1334 |
apply clarsimp |
|
1335 |
apply (frule History [temp_use]) |
|
1336 |
apply (auto simp: USpec_def intro: eexI [temp_use] Impl_IUSpec [temp_use] |
|
1337 |
MI_base [temp_use] elim!: eexE) |
|
1338 |
done |
|
3807 | 1339 |
|
1340 |
end |