-
Notifications
You must be signed in to change notification settings - Fork 1
/
RSC_DC_MD_Instance.v
208 lines (163 loc) · 6.58 KB
/
RSC_DC_MD_Instance.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
Require Import RSC_DC_MD_Sigs.
Require Import Source.Language.
Require Import Source.GlobalEnv.
Require Import Source.CS.
Require Import Source.Blame.
Require Import Intermediate.Machine.
Require Import Intermediate.Recombination.
Require Import S2I.Compiler.
Require Import S2I.Definitions.
Require Import Definability.
Set Bullet Behavior "Strict Subproofs".
Module Source_Instance <: Source_Sig.
Definition program :=
@Source.program.
Definition prog_interface :=
@Source.prog_interface.
Definition well_formed_program :=
@Source.well_formed_program.
Definition closed_program :=
@Source.closed_program.
Definition linkable_mains :=
@Source.linkable_mains.
Definition linkable_mains_sym :=
@Source.linkable_mains_sym.
Definition linkable_disjoint_mains :=
@Source.linkable_disjoint_mains.
Definition program_link :=
@Source.program_link.
Definition linking_well_formedness :=
@Source.linking_well_formedness.
Definition interface_preserves_closedness_l :=
@Source.interface_preserves_closedness_l.
Module CS.
Definition sem :=
@Source.CS.CS.sem.
End CS.
Definition blame_program :=
@Source.Blame.Blame.blame_program.
End Source_Instance.
Module Intermediate_Instance <: Intermediate_Sig.
Definition program :=
@Intermediate.program.
Definition prog_interface :=
@Intermediate.prog_interface.
Definition well_formed_program :=
@Intermediate.well_formed_program.
Definition closed_program :=
@Intermediate.closed_program.
Definition linkable_mains :=
@Intermediate.linkable_mains.
Definition matching_mains :=
@Intermediate.matching_mains.
Definition program_link :=
@Intermediate.program_link.
Definition linkable_mains_sym :=
@Intermediate.linkable_mains_sym.
Definition program_linkC :=
@Intermediate.program_linkC.
Definition linking_well_formedness :=
@Intermediate.linking_well_formedness.
Definition interface_preserves_closedness_r :=
@Intermediate.interface_preserves_closedness_r.
Module CS.
Definition sem :=
@Intermediate.CS.CS.sem.
End CS.
Definition compose_mergeable_interfaces :=
@Intermediate.compose_mergeable_interfaces.
Definition recombination_prefix :=
@Intermediate.Recombination.recombination_prefix.
End Intermediate_Instance.
Module S2I_Instance <: S2I_Sig (Source_Instance) (Intermediate_Instance).
Definition matching_mains :=
@S2I.Definitions.matching_mains.
Definition matching_mains_equiv :=
@S2I.Definitions.matching_mains_equiv.
End S2I_Instance.
Module Linker_Instance <: Linker_Sig (Source_Instance)
(Intermediate_Instance)
(S2I_Instance).
Definition definability_with_linking :=
@RobustImp.Source.Definability.definability_with_linking.
End Linker_Instance.
Module Compiler_Instance <: Compiler_Sig Source_Instance
Intermediate_Instance
S2I_Instance.
Definition compile_program :=
@Compiler.compile_program.
Definition matching_mains :=
@S2I.Definitions.matching_mains.
Definition matching_mains_trans :=
@S2I.Definitions.matching_mains_trans.
Definition well_formed_compilable :=
@Compiler.well_formed_compilable.
Definition compilation_preserves_well_formedness :=
@Compiler.compilation_preserves_well_formedness.
Definition compilation_preserves_interface :=
@Compiler.compilation_preserves_interface.
Definition compilation_preserves_linkability :=
@Compiler.compilation_preserves_linkability.
Definition compilation_preserves_linkable_mains :=
@Compiler.compilation_preserves_linkable_mains.
Definition compilation_has_matching_mains :=
@Compiler.compilation_has_matching_mains.
Definition separate_compilation_weaker :=
@Compiler.separate_compilation_weaker.
(* Definition S_simulates_I := *)
(* @Compiler.S_simulates_I. *)
Theorem forward_simulation_same_safe_prefix:
forall p p_compiled c c_compiled m,
linkable (Source.prog_interface p) (Source.prog_interface c) ->
Source.closed_program (Source.program_link p c) ->
Source.well_formed_program p ->
Source.well_formed_program c ->
CompCertExtensions.does_prefix (Source_Instance.CS.sem (Source.program_link p c)) m ->
CompCertExtensions.not_wrong_finpref m ->
compile_program p = Some p_compiled ->
compile_program c = Some c_compiled ->
CompCertExtensions.does_prefix (Intermediate_Instance.CS.sem (Intermediate.program_link p_compiled c_compiled)) m.
Proof.
intros p p_compiled c c_compiled m
Hlinkable Hclosed Hwfp Hwfc Hprefix Hnot_wrong Hcompp Hcompc.
pose proof Source.linking_well_formedness Hwfp Hwfc Hlinkable as Hwfpc.
destruct (Compiler.well_formed_compilable _ Hwfpc) as [pc_compiled Hcomppc].
pose proof Compiler.forward_simulation_same_safe_prefix _ _ _
Hclosed Hwfpc Hprefix Hnot_wrong Hcomppc
as [beh [Hbeh Hprefix_beh]].
pose proof Compiler.separate_compilation_weaker _ _ _ _ _
Hwfp Hwfc Hlinkable Hcompp Hcompc Hcomppc
as Hsc.
exists beh. split.
- apply Hsc. exact Hbeh.
- exact Hprefix_beh.
Qed.
Theorem backward_simulation_behavior_improves_prefix :
forall p p_compiled c c_compiled m,
linkable (Source.prog_interface p) (Source.prog_interface c) ->
Source.closed_program (Source.program_link p c) ->
Source.well_formed_program p ->
Source.well_formed_program c ->
compile_program p = Some p_compiled ->
compile_program c = Some c_compiled ->
CompCertExtensions.does_prefix (Intermediate_Instance.CS.sem (Intermediate.program_link p_compiled c_compiled)) m ->
exists b,
Behaviors.program_behaves (Source_Instance.CS.sem (Source.program_link p c)) b /\
(CompCertExtensions.prefix m b \/ CompCertExtensions.behavior_improves_finpref b m).
Proof.
intros p p_compiled c c_compiled m
Hlinkable Hclosed Hwfp Hwfc Hcompp Hcompc Hprefix.
(* Auxiliary results, some used multiple times, some need to be in scope. *)
pose proof Source.linking_well_formedness Hwfp Hwfc Hlinkable as Hwfpc.
destruct (Compiler.well_formed_compilable _ Hwfpc) as [pc_compiled Hcomppc].
pose proof Compiler.separate_compilation_weaker _ _ _ _ _
Hwfp Hwfc Hlinkable Hcompp Hcompc Hcomppc
as Hsc.
eapply Compiler.backward_simulation_behavior_improves_prefix;
try eassumption.
- destruct Hprefix as [beh [Hbeh Hprefix_beh]].
exists beh. split.
+ apply Hsc. exact Hbeh.
+ exact Hprefix_beh.
Qed.
End Compiler_Instance.