-
Notifications
You must be signed in to change notification settings - Fork 2
/
BridgeTactics.v
275 lines (205 loc) · 5.17 KB
/
BridgeTactics.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
(*
General tactics to help discharge properties about Bridge relation
Author: Aslan Askarov
Created: 2016-07-26
*)
Require Import Bool Arith List CpdtTactics SfLib LibTactics Omega.
Require Import Coq.Program.Equality.
Set Implicit Arguments.
Require Import Identifier Environment Imperative Types Augmented Bridge.
Require Import WellFormedness LowEq.
Require Import InductionPrinciple.
Require Import UtilTactics.
Ltac invert_low_event:=
match goal with [ H: low_event _ _ _ |- _ ] => inversion H end.
Ltac invert_low_steps :=
repeat
match
goal with
| [ H: context [low_event_step] |- _ ] => inversion H; subst; clear H
| [ H: context [event_step] |- _ ] => inversion H; subst; clear H
| [ H: context [low_event ] |- _ ] => inversion H; subst; clear H
end.
Ltac invert_high_steps :=
repeat
match
goal with
| [ H: context [high_event_step] |- _ ] => inversion H; subst; clear H
| [ H: context [event_step] |- _ ] => inversion H; subst; clear H
end.
Ltac stop_contradiction:=
match goal with [H: context [is_stop] |- _ ] => repeat unfolds in H ; inverts H end.
(*
match goal with
| [ H : context [is_not_stop_config 〈STOP, ?M 〉]|- _ ] =>
unfold is_not_stop_config in H;
unfold not in H;
assert (is_stop_config 〈STOP, M 〉) by ( exists M; crush);
contradiction
end.
*)
(*
Ltac prove_is_not_stop_config:=
unfold is_not_stop_config;
unfold not; intros;
match goal with
| [ H: is_stop_config 〈?C, ?S 〉 |- _] =>
(inversion H;
match goal with
| [ H': 〈C, S〉 = 〈STOP, _〉 |- _] => inversion H'; contradiction
end
)
end.
*)
Ltac impossible_flows:=
match goal with
| [ H: High ⊑ Low |- _ ] => inverts H
end.
Ltac invert_bridge_step_num:=
match goal with
| [H : context [bridge_step_num] |- _ ] => inverts H
end.
Ltac invert_low_event_step:=
match goal with
| [H : context [low_event_step ] |-_ ]=> inverts H
end.
Ltac invert_high_event_step:=
match goal with
| [H : context [high_event_step ] |-_ ]=> inverts H
end.
Ltac _find keyword:=
match goal with
| [H : context [keyword] |- _ ] => H
end.
Ltac _eapply_in_ctxt keyw what :=
let H := _find (keyw)
in eapply what in H.
(* LEMMAS that go into Hints *)
Lemma is_stop_trivial : forall m, is_stop 〈STOP, m 〉.
Proof.
intros.
unfolds.
constructor.
Qed.
Hint Resolve is_stop_trivial.
Lemma is_not_stop_config_inversion:
forall c st,
is_not_stop 〈c, st 〉 ->
c <> STOP.
intros.
unfolds.
intros.
unfolds in H.
unfolds in H.
subst.
destruct H.
unfolds.
auto.
Qed.
Hint Resolve is_not_stop_config_inversion.
Lemma is_stop_config_inversion:
forall c st,
is_stop 〈c, st 〉 ->
c = STOP.
intros.
unfolds in H.
unfolds in H.
auto.
Qed.
Hint Resolve is_stop_config_inversion.
Lemma empty_event_is_high :
forall Γ,
high_event Γ Low EmptyEvent.
Proof.
intros.
do 2 unfolds; intros;
match goal with [H : context [low_event] |- _ ] => inverts H end.
Qed.
Hint Resolve empty_event_is_high.
Lemma bridge_steps_are_nonneg:
forall Γ c m ev n cfg,
〈 c, m 〉 ⇨+/(SL, Γ, ev, n) cfg ->
n >= 0.
Proof.
intros; inverts * H; omega.
Qed.
Hint Resolve bridge_steps_are_nonneg.
Lemma is_non_stop_config_trivial:
forall c st,
c <> STOP ->
is_not_stop 〈c, st 〉.
Proof.
intros.
do 2 unfolds.
intros.
inversion H0.
inversion H1.
subst.
tauto.
Qed.
Hint Resolve is_non_stop_config_trivial.
Lemma multi_stop_trivial:
forall m m',
〈 STOP, m 〉⇒*〈STOP, m' 〉 ->
m = m'.
Proof.
intros.
inverts* H.
inverts H0.
Qed.
Hint Resolve multi_stop_trivial.
Lemma multi_idx_stop_trivial:
forall m m' n,
〈 STOP, m 〉⇒/+ n +/ 〈STOP, m' 〉 ->
m = m'.
Proof.
intros.
inverts* H.
inversion H0.
Qed.
Hint Resolve multi_idx_stop_trivial.
Lemma high_assignments_are_high_events:
forall Γ x u,
high_event Γ Low (AssignmentEvent High x u).
Proof.
intros.
do 2 unfolds.
intros.
inversion H.
subst.
impossible_flows.
Qed.
Hint Resolve high_assignments_are_high_events.
Ltac stop_contradiction_more:=
match goal with
| [ H: is_stop 〈?C, ?M 〉, H' : ?C <> STOP |- _ ] =>
inverts* H
end.
Lemma stop_contradiction_more_lemma :
forall c m, is_stop 〈c, m 〉 -> c <> STOP -> False.
Proof.
intros.
stop_contradiction_more.
Qed.
Hint Resolve stop_contradiction_more_lemma.
Ltac stop_contradiction_alt :=
match goal with [ H : is_not_stop 〈 STOP, ?m 〉 |- _ ] =>
do 2 unfolds in H;
assert (cmd_of 〈STOP, m 〉 = STOP ) by
(
unfolds;
auto
);
specialize_gen;
exfalso;
assumption
end.
Lemma stop_contradiction_alt_lemma_exf :
forall m, is_not_stop 〈 STOP, m 〉 -> False.
Proof.
intros.
stop_contradiction_alt.
Qed.
Hint Resolve stop_contradiction_alt_lemma_exf.
Ltac invert_step:=
match goal with [H : context[step] |- _ ] => inverts H end.