-
Notifications
You must be signed in to change notification settings - Fork 5
/
Preservation.v
465 lines (439 loc) · 21.3 KB
/
Preservation.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
Require Import CoqlibC.
Require Import MemoryC.
Require Import Values.
Require Import Maps.
Require Import Events.
Require Import Globalenvs.
Require Import sflib.
Require Import RelationClasses.
Require Import FSets.
Require Import Ordered.
Require Import AST.
Require Import Integers.
Require Import Smallstep.
Require Import ModSem.
Require Import Skeleton SimSymb Ord.
Require Import Sound.
Set Implicit Arguments.
Section PRSV.
Context `{SU: Sound.class}.
Variable ms: ModSem.t.
Inductive local_preservation (sound_state: Sound.t -> mem -> ms.(state) -> Prop): Prop :=
| local_preservation_intro
(INIT: forall su_init args st_init
(SUARG: Sound.args su_init args)
(SKENVLINK: Sound.skenv su_init (Args.get_m args) ms.(ModSem.skenv_link))
(SKENV: Sound.skenv su_init (Args.get_m args) ms.(ModSem.skenv))
(INIT: ms.(ModSem.initial_frame) args st_init)
,
<<SUST: sound_state su_init (Args.get_m args) st_init>>)
(STEP: forall
m_arg su0 st0 tr st1
(SUST: sound_state su0 m_arg st0)
(SAFE: ~ ms.(ModSem.is_call) st0 /\ ~ ms.(ModSem.is_return) st0)
(STEP: Step ms st0 tr st1),
<<SUST: sound_state su0 m_arg st1>>)
(CALL: forall m_arg su0 st0 args
(SUST: sound_state su0 m_arg st0)
(AT: ms.(ModSem.at_external) st0 args),
<<MLE: Sound.mle su0 m_arg (Args.get_m args)>> /\
exists su_gr,
(<<ARGS: Sound.args su_gr args>>) /\
(<<LE: Sound.lepriv su0 su_gr>>) /\
(<<K: forall su_ret retv st1
(LE: Sound.hle su_gr su_ret)
(RETV: su_ret.(Sound.retv) retv)
(MLE: Sound.mle su_gr (Args.get_m args) (Retv.get_m retv))
(AFTER: ms.(ModSem.after_external) st0 retv st1)
,
(<<SUST: sound_state su0 m_arg st1>>)>>))
(RET: forall m_arg su0 st0 retv
(SUST: sound_state su0 m_arg st0)
(FINAL: ms.(ModSem.final_frame) st0 retv),
exists su_ret, <<LE: Sound.hle su0 su_ret>> /\
<<RETV: su_ret.(Sound.retv) retv>> /\ <<MLE: su0.(Sound.mle) m_arg (Retv.get_m retv)>>)
.
(* It does not need to show "mle". *)
Inductive local_preservation_noguarantee (sound_state: Sound.t -> mem -> ms.(state) -> Prop): Prop :=
| local_preservation_noguarantee_intro
(INIT: forall su_init args st_init
(SUARG: Sound.args su_init args)
(SKENVLINK: Sound.skenv su_init (Args.get_m args) ms.(ModSem.skenv_link))
(SKENV: Sound.skenv su_init (Args.get_m args) ms.(ModSem.skenv))
(INIT: ms.(ModSem.initial_frame) args st_init)
,
<<SUST: sound_state su_init (Args.get_m args) st_init>>)
(STEP: forall
m_arg su0 st0 tr st1
(SUST: sound_state su0 m_arg st0)
(SAFE: ~ ms.(ModSem.is_call) st0 /\ ~ ms.(ModSem.is_return) st0)
(STEP: Step ms st0 tr st1),
<<SUST: sound_state su0 m_arg st1>>)
(CALL: forall m_arg su0 st0 args
(SUST: sound_state su0 m_arg st0)
(AT: ms.(ModSem.at_external) st0 args),
exists su_gr,
(<<ARGS: Sound.args su_gr args>>) /\
(<<LE: Sound.lepriv su0 su_gr>>) /\
(<<K: forall su_ret retv st1
(LE: Sound.hle su_gr su_ret)
(RETV: su_ret.(Sound.retv) retv)
(MLE: Sound.mle su_gr (Args.get_m args) (Retv.get_m retv))
(AFTER: ms.(ModSem.after_external) st0 retv st1)
,
(<<SUST: sound_state su0 m_arg st1>>)>>))
.
Lemma local_preservation_noguarantee_weak:
<<INCL: local_preservation <1= local_preservation_noguarantee>>.
Proof.
ii. inv PR. econs; eauto. ii; ss. exploit CALL; eauto. i; des. esplits; eauto.
Qed.
Variable get_mem: ms.(ModSem.state) -> mem.
(* "strong_horizontal" without "lift" *)
Inductive local_preservation_standard (sound_state: Sound.t -> ms.(state) -> Prop): Prop :=
| local_preservation_standard_intro
(INIT: forall su_arg args st_init
(SUARG: Sound.args su_arg args)
(SKENVLINK: Sound.skenv su_arg (Args.get_m args) ms.(ModSem.skenv_link))
(SKENV: Sound.skenv su_arg (Args.get_m args) ms.(ModSem.skenv))
(INIT: ms.(ModSem.initial_frame) args st_init)
,
exists su_init, (<<LE: Sound.hle su_arg su_init>>) /\
(<<SUST: sound_state su_init st_init>>)
/\ (<<MLE: su_init.(Sound.mle) (Args.get_m args) st_init.(get_mem)>>))
(STEP: forall
su0 st0 tr st1
(SUST: sound_state su0 st0)
(SAFE: ~ ms.(ModSem.is_call) st0 /\ ~ ms.(ModSem.is_return) st0)
(STEP: Step ms st0 tr st1),
exists su1, <<LE: Sound.hle su0 su1>> /\ <<SUST: sound_state su1 st1>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) st1.(get_mem)>>)
(CALL: forall su0 st0 args
(SUST: sound_state su0 st0)
(AT: ms.(ModSem.at_external) st0 args)
,
<<MLE: Sound.mle su0 st0.(get_mem) (Args.get_m args)>> /\
exists su_gr,
(<<ARGS: Sound.args su_gr args>>) /\
(<<LE: Sound.lepriv su0 su_gr>>) /\
(<<K: forall su_ret retv st1
(LE: Sound.hle su_gr su_ret)
(RETV: su_ret.(Sound.retv) retv)
(MLE: Sound.mle su_gr (Args.get_m args) (Retv.get_m retv))
(AFTER: ms.(ModSem.after_external) st0 retv st1)
,
exists su1,
<<LE: Sound.hle su0 su1>> /\
(<<SUST: sound_state su1 st1>> /\ <<MLE: su0.(Sound.mle) (Args.get_m args) st1.(get_mem)>>)>>))
(RET: forall
su0 st0 retv
(SUST: sound_state su0 st0)
(FINAL: ms.(ModSem.final_frame) st0 retv),
exists su_ret, <<LE: Sound.hle su0 su_ret>> /\
<<RETV: su_ret.(Sound.retv) retv>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) (Retv.get_m retv)>>)
.
Theorem local_preservation_standard_spec
sound_state
(PRSV: local_preservation_standard sound_state):
<<PRSV: local_preservation (fun su m_init st =>
<<MLE: su.(Sound.mle) m_init st.(get_mem)>> /\
<<WF: Sound.wf su>> /\
exists su_h, <<LE: Sound.hle su su_h>> /\ sound_state su_h st)>>.
Proof.
inv PRSV.
econs; eauto.
- ii. exploit INIT; eauto. i; des. r in SUARG. des_ifs; des; esplits; eauto; eapply Sound.hle_mle; eauto.
- ii. des. exploit STEP; eauto. i; des. esplits; try apply SUST; eauto.
+ etrans; eauto. eapply Sound.hle_mle; eauto.
+ etrans; eauto.
- ii. des. exploit CALL; eauto. i; des. esplits; eauto.
{ etrans; eauto. eapply Sound.hle_mle; eauto. }
{ etrans; eauto. eapply Sound.hle_lepriv; eauto. }
ii. exploit K; eauto. i; des. esplits; try apply SUST; eauto; etrans; eauto. eapply Sound.hle_mle; eauto. etrans; eauto.
- ii; des. exploit RET; eauto. i; des. esplits; try apply RETV; eauto; etrans; eauto. eapply Sound.hle_mle; eauto.
Qed.
Variable lift: Sound.t -> Sound.t -> Prop.
Inductive local_preservation_strong (sound_state: Sound.t -> ms.(state) -> Prop): Prop :=
| local_preservation_strong_intro
(LIFTSPEC: forall su0 su1 m0 m1 (MLE: Sound.mle su1 m0 m1) (LE: lift su0 su1), <<MLE: Sound.mle su0 m0 m1>>)
(LIFTPRIV: lift <2= Sound.lepriv)
(INIT: forall su_init args st_init
(SUARG: Sound.args su_init args)
(SKENVLINK: Sound.skenv su_init (Args.get_m args) ms.(ModSem.skenv_link))
(SKENV: Sound.skenv su_init (Args.get_m args) ms.(ModSem.skenv))
(INIT: ms.(ModSem.initial_frame) args st_init)
,
<<SUST: sound_state su_init st_init>> /\ <<MLE: su_init.(Sound.mle) (Args.get_m args) st_init.(get_mem)>>)
(STEP: forall
su0 st0 tr st1
(SKENV: Sound.skenv su0 st0.(get_mem) ms.(ModSem.skenv))
(SUST: sound_state su0 st0)
(SAFE: ~ ms.(ModSem.is_call) st0 /\ ~ ms.(ModSem.is_return) st0)
(STEP: Step ms st0 tr st1),
<<SUST: sound_state su0 st1>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) st1.(get_mem)>>)
(CALL: forall su0 st0 args
(SKENV: Sound.skenv su0 st0.(get_mem) ms.(ModSem.skenv))
(SUST: sound_state su0 st0)
(AT: ms.(ModSem.at_external) st0 args)
,
<<MLE: Sound.mle su0 st0.(get_mem) (Args.get_m args)>> /\
<<WF: Sound.wf su0>> /\
exists su_gr,
(<<ARGS: Sound.args su_gr args>>) /\
(<<LE: exists su_imd, Sound.hle su0 su_imd /\ lift su_imd su_gr>>) /\
(<<K: forall su_ret retv st1
(LE: Sound.hle su_gr su_ret)
(RETV: su_ret.(Sound.retv) retv)
(MLE: Sound.mle su_gr (Args.get_m args) (Retv.get_m retv))
(AFTER: ms.(ModSem.after_external) st0 retv st1)
,
(<<SUST: forall
(MLE: su0.(Sound.mle) (Retv.get_m retv) st1.(get_mem))
(SKENV: Sound.skenv su0 st1.(get_mem) ms.(ModSem.skenv)),
sound_state su0 st1>> /\ <<MLE: su0.(Sound.mle) (Retv.get_m retv) st1.(get_mem)>>)>>))
(RET: forall
su0 st0 retv
(SKENV: Sound.skenv su0 st0.(get_mem) ms.(ModSem.skenv))
(SUST: sound_state su0 st0)
(FINAL: ms.(ModSem.final_frame) st0 retv),
exists su_ret, <<LE: Sound.hle su0 su_ret>> /\
<<RETV: su_ret.(Sound.retv) retv>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) (Retv.get_m retv)>>).
Theorem local_preservation_strong_spec
sound_state
(PRSV: local_preservation_strong sound_state):
<<PRSV: local_preservation (fun su m_init st => sound_state su st
/\ su.(Sound.skenv) st.(get_mem) ms.(ModSem.skenv)
/\ su.(Sound.mle) m_init st.(get_mem))>>.
Proof.
inv PRSV. econs; eauto.
- i. exploit INIT; et. i; des. esplits; et. eapply Sound.skenv_mle; et.
- ii. des. exploit STEP; eauto. i; des. esplits; eauto.
{ eapply Sound.skenv_mle; et. }
etrans; eauto.
- ii. des. exploit CALL; eauto. i; des. esplits; eauto.
{ etrans; eauto. }
{ etrans; eauto. eapply Sound.hle_lepriv; et. }
ii. exploit K; try apply RETV; eauto. i; des.
assert(SKENV: Sound.skenv su0 (get_mem st1) (ModSem.skenv ms)).
{ eapply Sound.skenv_mle; et. etrans; et. etrans; et. eapply Sound.hle_mle; [eapply LIFTSPEC; eauto|..]; ss. }
esplits; eauto. etrans; eauto. etrans; eauto. etrans; eauto. eapply Sound.hle_mle; [eapply LIFTSPEC; eauto|..]; ss.
- ii; des. exploit RET; eauto. i; des. esplits; eauto. etrans; eauto.
Qed.
Inductive local_preservation_strong_horizontal (sound_state: Sound.t -> ms.(state) -> Prop): Prop :=
| local_preservation_strong_horizontal_intro
(LIFTSPEC: forall su0 su1 m0 m1 (MLE: Sound.mle su1 m0 m1) (LE: lift su0 su1), <<MLE: Sound.mle su0 m0 m1>>)
(LIFTPRIV: lift <2= Sound.lepriv)
(INIT: forall su_arg args st_init
(SUARG: Sound.args su_arg args)
(SKENVLINK: Sound.skenv su_arg (Args.get_m args) ms.(ModSem.skenv_link))
(SKENV: Sound.skenv su_arg (Args.get_m args) ms.(ModSem.skenv))
(INIT: ms.(ModSem.initial_frame) args st_init)
,
exists su_init, (<<LE: Sound.hle su_arg su_init>>) /\
(<<SUST: sound_state su_init st_init>>)
/\ (<<MLE: su_init.(Sound.mle) (Args.get_m args) st_init.(get_mem)>>))
(STEP: forall
su0 st0 tr st1
(SUST: sound_state su0 st0)
(SAFE: ~ ms.(ModSem.is_call) st0 /\ ~ ms.(ModSem.is_return) st0)
(STEP: Step ms st0 tr st1),
exists su1, <<LE: Sound.hle su0 su1>> /\ <<SUST: sound_state su1 st1>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) st1.(get_mem)>>)
(CALL: forall su0 st0 args
(SUST: sound_state su0 st0)
(AT: ms.(ModSem.at_external) st0 args),
<<MLE: Sound.mle su0 st0.(get_mem) (Args.get_m args)>> /\
exists su_gr,
(<<ARGS: Sound.args su_gr args>>) /\
(<<LE: lift su0 su_gr>>) /\
(<<K: forall su_ret retv st1
(LE: Sound.hle su_gr su_ret)
(RETV: su_ret.(Sound.retv) retv)
(MLE: Sound.mle su_gr (Args.get_m args) (Retv.get_m retv))
(AFTER: ms.(ModSem.after_external) st0 retv st1),
exists su1,
<<LE: Sound.hle su0 su1>> /\
(<<SUST: sound_state su1 st1>> /\ <<MLE: su0.(Sound.mle) (Retv.get_m retv) st1.(get_mem)>>)>>))
(RET: forall
su0 st0 retv
(SUST: sound_state su0 st0)
(FINAL: ms.(ModSem.final_frame) st0 retv),
exists su_ret, <<LE: Sound.hle su0 su_ret>> /\
<<RETV: su_ret.(Sound.retv) retv>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) (Retv.get_m retv)>>).
Theorem local_preservation_strong_horizontal_spec
sound_state
(PRSV: local_preservation_strong_horizontal sound_state):
<<PRSV: local_preservation (fun su m_init st =>
<<MLE: su.(Sound.mle) m_init st.(get_mem)>> /\
<<WF: Sound.wf su>> /\
exists su_h,
<<LE: Sound.hle su su_h>> /\ sound_state su_h st)>>.
Proof.
inv PRSV.
econs; eauto.
- ii. exploit INIT; eauto. i; des. r in SUARG. des_ifs; des; esplits; eauto; eapply Sound.hle_mle; eauto.
- ii. des. exploit STEP; eauto. i; des. esplits; try apply SUST; eauto.
+ etrans; eauto.
eapply Sound.hle_mle; eauto.
+ etrans; eauto.
- ii. des. exploit CALL; eauto. i; des.
esplits; eauto.
{ etrans; eauto. eapply Sound.hle_mle; eauto. }
{ etrans; eauto. eapply Sound.hle_lepriv; eauto. }
ii. exploit K; eauto. i; des. esplits; try apply SUST; eauto; etrans; eauto.
eapply Sound.hle_mle; eauto. etrans; eauto. etrans; eauto. eapply LIFTSPEC; eauto.
- ii; des. exploit RET; eauto. i; des. esplits; try apply RETV; eauto; etrans; eauto. eapply Sound.hle_mle; eauto.
Qed.
Inductive local_preservation_strong_excl (sound_state: Sound.t -> ms.(state) -> Prop): Prop :=
| local_preservation_strong_excl_intro
(LIFTSPEC: forall su0 su1 m0 m1 (MLE: Sound.mle su1 m0 m1) (LE: lift su0 su1), <<MLE: Sound.mle su0 m0 m1>>)
(LIFTPRIV: lift <2= Sound.lepriv)
(has_footprint: ms.(state) -> Sound.t -> mem -> Prop) (mle_excl: ms.(state) -> Sound.t -> mem -> mem -> Prop)
(FOOTEXCL: forall su0 st_at m0 m1 m2
(FOOT: has_footprint st_at su0 m0)
(MLEEXCL: (mle_excl st_at) su0 m1 m2)
(MLE: su0.(Sound.mle) m0 m1),
<<MLE: Sound.mle su0 m0 m2>>)
(INIT: forall su_init args st_init
(SUARG: Sound.args su_init args)
(SKENVLINK: Sound.skenv su_init (Args.get_m args) ms.(ModSem.skenv_link))
(SKENV: Sound.skenv su_init (Args.get_m args) ms.(ModSem.skenv))
(INIT: ms.(ModSem.initial_frame) args st_init)
,
<<SUST: sound_state su_init st_init>> /\ <<MLE: su_init.(Sound.mle) (Args.get_m args) st_init.(get_mem)>>)
(STEP: forall
su0 st0 tr st1
(SUST: sound_state su0 st0)
(SAFE: ~ ms.(ModSem.is_call) st0 /\ ~ ms.(ModSem.is_return) st0)
(STEP: Step ms st0 tr st1),
<<SUST: sound_state su0 st1>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) st1.(get_mem)>>)
(CALL: forall su0 st0 args
(SUST: sound_state su0 st0)
(AT: ms.(ModSem.at_external) st0 args),
<<MLE: Sound.mle su0 st0.(get_mem) (Args.get_m args)>> /\
<<FOOT: has_footprint st0 su0 st0.(get_mem)>> /\
<<WF: Sound.wf su0>> /\
exists su_gr,
(<<ARGS: Sound.args su_gr args>>) /\
(<<LE: lift su0 su_gr>>) /\
(<<K: forall su_ret retv st1
(LE: Sound.hle su_gr su_ret)
(RETV: su_ret.(Sound.retv) retv)
(MLE: Sound.mle su_gr (Args.get_m args) (Retv.get_m retv))
(AFTER: ms.(ModSem.after_external) st0 retv st1),
(<<SUST: sound_state su0 st1>> /\ <<MLE: (mle_excl st0) su0 (Retv.get_m retv) st1.(get_mem)>>)>>))
(RET: forall
su0 st0 retv
(SUST: sound_state su0 st0)
(FINAL: ms.(ModSem.final_frame) st0 retv),
exists su_ret, <<LE: Sound.hle su0 su_ret>> /\
<<RETV: su_ret.(Sound.retv) retv>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) (Retv.get_m retv)>>).
Theorem local_preservation_strong_excl_spec
sound_state
(PRSV: local_preservation_strong_excl sound_state):
<<PRSV: local_preservation (fun su m_init st => sound_state su st /\ su.(Sound.mle) m_init st.(get_mem))>>.
Proof.
inv PRSV. econs; eauto.
- ii. des. exploit STEP; eauto. i; des. esplits; eauto. etrans; eauto.
- ii. des. exploit CALL; eauto. i; des. esplits; eauto.
{ etrans; eauto. }
ii. exploit K; eauto. i; des. esplits; eauto. etrans; eauto. eapply FOOTEXCL; try apply MLE1; eauto.
{ etrans; eauto. eapply LIFTSPEC; eauto. }
- ii; des. exploit RET; eauto. i; des. esplits; eauto. etrans; eauto.
Qed.
Inductive local_preservation_strong_horizontal_excl (sound_state: Sound.t -> ms.(state) -> Prop): Prop :=
| local_preservation_strong_horizontal_excl_intro
(LIFTSPEC: forall su0 su1 m0 m1 (MLE: Sound.mle su1 m0 m1) (LE: lift su0 su1), <<MLE: Sound.mle su0 m0 m1>>)
(LIFTPRIV: lift <2= Sound.lepriv)
(has_footprint: ms.(state) -> Sound.t -> mem -> Prop) (mle_excl: ms.(state) -> Sound.t -> mem -> mem -> Prop)
(FOOTEXCL: forall su0 st_at m0 m1 m2
(FOOT: has_footprint st_at su0 m0)
(MLEEXCL: (mle_excl st_at) su0 m1 m2)
(MLE: su0.(Sound.mle) m0 m1),
<<MLE: Sound.mle su0 m0 m2>>)
(INIT: forall su_arg args st_init
(SUARG: Sound.args su_arg args)
(SKENVLINK: Sound.skenv su_arg (Args.get_m args) ms.(ModSem.skenv_link))
(SKENV: Sound.skenv su_arg (Args.get_m args) ms.(ModSem.skenv))
(INIT: ms.(ModSem.initial_frame) args st_init),
exists su_init, (<<LE: Sound.hle su_arg su_init>>) /\
(<<SUST: sound_state su_init st_init>>)
/\ (<<MLE: su_init.(Sound.mle) (Args.get_m args) st_init.(get_mem)>>))
(STEP: forall
su0 st0 tr st1
(SUST: sound_state su0 st0)
(SAFE: ~ ms.(ModSem.is_call) st0 /\ ~ ms.(ModSem.is_return) st0)
(STEP: Step ms st0 tr st1),
exists su1, <<LE: Sound.hle su0 su1>> /\ <<SUST: sound_state su1 st1>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) st1.(get_mem)>>)
(CALL: forall su0 st0 args
(SUST: sound_state su0 st0)
(AT: ms.(ModSem.at_external) st0 args),
<<MLE: Sound.mle su0 st0.(get_mem) (Args.get_m args)>> /\
<<FOOT: has_footprint st0 su0 st0.(get_mem)>> /\
exists su_gr,
(<<ARGS: Sound.args su_gr args>>) /\
(<<LE: lift su0 su_gr>>) /\
(<<K: forall su_ret retv st1
(LE: Sound.hle su_gr su_ret)
(RETV: su_ret.(Sound.retv) retv)
(MLE: Sound.mle su_gr (Args.get_m args) (Retv.get_m retv))
(AFTER: ms.(ModSem.after_external) st0 retv st1),
exists su1,
<<LE: Sound.hle su0 su1>> /\
(<<SUST: sound_state su1 st1>> /\ <<MLE: (mle_excl st0) su0 (Retv.get_m retv) st1.(get_mem)>>)>>))
(RET: forall
su0 st0 retv
(SUST: sound_state su0 st0)
(FINAL: ms.(ModSem.final_frame) st0 retv),
exists su_ret, <<LE: Sound.hle su0 su_ret>> /\
<<RETV: su_ret.(Sound.retv) retv>> /\ <<MLE: su0.(Sound.mle) st0.(get_mem) (Retv.get_m retv)>>).
Theorem local_preservation_strong_horizontal_excl_spec
sound_state
(PRSV: local_preservation_strong_horizontal_excl sound_state):
<<PRSV: local_preservation (fun su m_init st =>
<<MLE: su.(Sound.mle) m_init st.(get_mem)>> /\
<<WF: Sound.wf su>> /\
exists su_h, <<LE: Sound.hle su su_h>> /\ sound_state su_h st)>>.
Proof.
inv PRSV.
econs; eauto.
- ii. exploit INIT; eauto. i; des. r in SUARG. des_ifs; des; esplits; eauto; eapply Sound.hle_mle; eauto.
- ii. des. exploit STEP; eauto. i; des. esplits; try apply SUST; eauto.
+ etrans; eauto.
eapply Sound.hle_mle; eauto.
+ etrans; eauto.
- ii. des. exploit CALL; eauto. i; des.
esplits; eauto.
{ etrans; eauto. eapply Sound.hle_mle; eauto. }
{ etrans; eauto. eapply Sound.hle_lepriv; eauto. }
ii. exploit K; eauto. i; des. esplits; try apply SUST; eauto.
+ etrans; eauto. eapply Sound.hle_mle; eauto. eapply FOOTEXCL; eauto. etrans; eauto. eapply LIFTSPEC; eauto.
+ etrans; eauto.
- ii; des. exploit RET; eauto. i; des. esplits; try apply RETV; eauto; etrans; eauto. eapply Sound.hle_mle; eauto.
Qed.
End PRSV.
Definition system_sound_state `{SU: Sound.class} (ms: ModSem.t): Sound.t -> mem -> System.state -> Prop :=
fun su m_arg st =>
match st with
| System.Callstate fptr vs m => su.(Sound.args) (Args.Cstyle fptr vs m) /\ su.(Sound.mle) m_arg m
/\ su.(Sound.skenv) m_arg ms.(ModSem.skenv_link)
| System.Returnstate v m =>
exists su_ret, Sound.hle su su_ret /\ su_ret.(Sound.retv) (Retv.Cstyle v m) /\ su.(Sound.mle) m_arg m
/\ su.(Sound.skenv) m ms.(ModSem.skenv_link)
end.
Lemma system_local_preservation
`{SU: Sound.class}
skenv:
exists system_sound_state, local_preservation (System.modsem skenv) system_sound_state.
Proof.
exists (system_sound_state (System.modsem skenv)).
econs; ii; ss; eauto.
- inv INIT. rr. esplits; eauto; try refl.
- inv STEP. ss. inv SUST. des. exploit Sound.system_axiom; try apply EXTCALL; eauto.
{ instantiate (1:= Args.Cstyle _ _ _). ss. }
{ rr. esplits; eauto. }
{ eapply Sound.skenv_mle; eauto. }
{ eauto. }
i; des. r in RETV. ss. des. ss. esplits; eauto.
+ etrans; eauto.
+ eapply Sound.skenv_mle; eauto. etrans; eauto.
- inv FINAL. ss. des. esplits; eauto.
Qed.