-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAnnotatedEquivalentSplit.v
214 lines (203 loc) · 6.58 KB
/
AnnotatedEquivalentSplit.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
Require Import Coq.Lists.List.
Require Export SystemFR.AnnotatedTactics.
Require Export SystemFR.Judgments.
Require Export SystemFR.ErasedEquivalentSplit.
Require Export SystemFR.ErasedEquivalentSplitIte.
Require Export SystemFR.ErasedEquivalentSplitMatch.
Lemma annotated_equivalent_ite:
forall Θ Γ t1 t2 t3 t x,
~(x ∈ fv_context Γ) ->
~(x ∈ fv t) ->
~(x ∈ fv t1) ->
~(x ∈ fv t2) ->
~(x ∈ fv t3) ->
wf t2 0 ->
wf t3 0 ->
subset (fv t2) (support Γ) ->
subset (fv t3) (support Γ) ->
[[ Θ; Γ ⊨ t1 : T_bool ]]->
[[ Θ; (x, T_equiv t1 ttrue) :: Γ ⊨ t2 ≡ t ]]->
[[ Θ; (x, T_equiv t1 tfalse) :: Γ ⊨ t3 ≡ t ]] ->
[[ Θ; Γ ⊨ ite t1 t2 t3 ≡ t ]].
Proof.
unfold open_equivalent;
steps.
apply reducible_equivalent_ite with ρ (erase_context Γ) x;
steps; side_conditions.
Qed.
Lemma annotated_equivalent_match:
forall Θ Γ tn t0 ts t n p,
~(p ∈ fv_context Γ) ->
~(p ∈ fv tn) ->
~(p ∈ fv ts) ->
~(p ∈ fv t0) ->
~(p ∈ fv t) ->
~(n ∈ fv_context Γ) ->
~(n ∈ fv tn) ->
~(n ∈ fv ts) ->
~(n ∈ fv t) ->
~(n = p) ->
wf t0 0 ->
wf ts 1 ->
subset (fv t0) (support Γ) ->
subset (fv ts) (support Γ) ->
is_annotated_term ts ->
[[ Θ; Γ ⊨ tn : T_nat ]] ->
[[ Θ; (p, T_equiv tn zero) :: Γ ⊨ t0 ≡ t ]] ->
[[ Θ; (p, T_equiv tn (succ (fvar n term_var))) :: (n, T_nat) :: Γ ⊨ open 0 ts (fvar n term_var) ≡ t ]] ->
[[ Θ; Γ ⊨ tmatch tn t0 ts ≡ t ]].
Proof.
unfold open_equivalent;
steps.
apply reducible_equivalent_match with ρ (erase_context Γ) n p;
repeat step || erase_open; side_conditions.
Qed.
Lemma annotated_equivalent_split_bool:
forall Θ Γ1 Γ2 b t t' x,
~(x ∈ fv_context Γ1) ->
~(x ∈ fv_context Γ2) ->
~(x ∈ fv t) ->
~(x ∈ fv t') ->
~(x ∈ fv b) ->
~(x ∈ Θ) ->
subset (fv b) (support Γ2) ->
[[ Θ; Γ2 ⊨ b : T_bool ]] ->
[[ Θ; Γ1 ++ (x,T_equiv b ttrue) :: Γ2 ⊨ t ≡ t' ]] ->
[[ Θ; Γ1 ++ (x,T_equiv b tfalse) :: Γ2 ⊨ t ≡ t' ]] ->
[[ Θ; Γ1 ++ Γ2 ⊨ t ≡ t' ]].
Proof.
unfold open_equivalent;
repeat step.
apply equivalent_split_bool
with ρ (erase_context Γ1) (erase_context Γ2) (erase_term b) x;
repeat step || rewrite erase_context_append in *;
repeat side_conditions.
Qed.
Lemma annotated_equivalent_split_nat:
forall Θ Γ1 Γ2 n t t' x y,
~(x ∈ fv_context Γ1) ->
~(x ∈ fv_context Γ2) ->
~(y ∈ fv_context Γ1) ->
~(y ∈ fv_context Γ2) ->
~(x ∈ fv n) ->
~(x ∈ fv t) ->
~(x ∈ fv t') ->
~(y ∈ fv n) ->
~(y ∈ fv t) ->
~(y ∈ fv t') ->
~(x = y) ->
subset (fv n) (support Γ2) ->
[[ Θ; Γ2 ⊨ n : T_nat ]] ->
[[ Θ; Γ1 ++ (x,T_equiv n zero) :: Γ2 ⊨ t ≡ t' ]] ->
[[ Θ; Γ1 ++ (x,T_equiv n (succ (fvar y term_var))) :: (y, T_nat) :: Γ2 ⊨ t ≡ t' ]] ->
[[ Θ; Γ1 ++ Γ2 ⊨ t ≡ t' ]].
Proof.
unfold open_equivalent;
repeat step.
apply equivalent_split_nat with ρ (erase_context Γ1) (erase_context Γ2) (erase_term n) x y;
repeat step || rewrite erase_context_append in *;
repeat side_conditions.
Qed.
Lemma annotated_equivalent_split_ite:
forall Θ Γ1 Γ2 b e1 e2 t t' e x y,
~(x ∈ fv_context Γ1) ->
~(x ∈ support Γ2) ->
~(y ∈ fv_context Γ1) ->
~(y ∈ fv_context Γ2) ->
~(x ∈ fv t) ->
~(x ∈ fv t') ->
~(y ∈ fv t) ->
~(y ∈ fv t') ->
~(x = y) ->
~(y ∈ fv b) ->
~(y ∈ fv e) ->
~(y ∈ fv e1) ->
~(y ∈ fv e2) ->
(forall z, z ∈ fv b -> z ∈ support Γ1 -> False) ->
(forall z, z ∈ fv e -> z ∈ support Γ1 -> False) ->
(forall z, z ∈ fv e1 -> z ∈ support Γ1 -> False) ->
(forall z, z ∈ fv e2 -> z ∈ support Γ1 -> False) ->
subset (fv b) (support Γ2) ->
subset (fv e) (support Γ2) ->
subset (fv e1) (support Γ2) ->
subset (fv e2) (support Γ2) ->
wf b 0 ->
wf e 0 ->
wf e1 0 ->
wf e2 0 ->
[[ Θ; Γ2 ⊨ b : T_bool ]] ->
[[ Θ; Γ1 ++ (x, T_equiv e1 e) :: (y, T_equiv b ttrue) :: Γ2 ⊨ t ≡ t' ]] ->
[[ Θ; Γ1 ++ (x, T_equiv e2 e) :: (y, T_equiv b tfalse) :: Γ2 ⊨ t ≡ t' ]] ->
[[ Θ; Γ1 ++ ((x, T_equiv (ite b e1 e2) e) :: Γ2) ⊨ t ≡ t' ]].
Proof.
unfold open_equivalent;
repeat step.
apply equivalent_split_ite
with ρ (erase_context Γ1) (erase_context Γ2)
(erase_term b) (erase_term e1) (erase_term e2) (erase_term e) x y;
repeat step || rewrite erase_context_append in * || apply union_left;
repeat side_conditions.
Qed.
Lemma annotated_equivalent_split_match:
forall Θ Γ1 Γ2 n t t' e1 e2 e x y z,
~(x ∈ fv_context Γ1) ->
~(x ∈ fv_context Γ2) ->
~(y ∈ fv_context Γ1) ->
~(y ∈ fv_context Γ2) ->
~(z ∈ fv_context Γ1) ->
~(z ∈ fv_context Γ2) ->
~(x ∈ fv t) ->
~(x ∈ fv t') ->
~(x ∈ fv n) ->
~(x ∈ fv e1) ->
~(x ∈ fv e2) ->
~(x ∈ fv e) ->
~(y ∈ fv e) ->
~(y ∈ fv t) ->
~(y ∈ fv t') ->
~(y ∈ fv n) ->
~(y ∈ fv e1) ->
~(y ∈ fv e2) ->
~(z ∈ fv e) ->
~(z ∈ fv t) ->
~(z ∈ fv t') ->
~(z ∈ fv n) ->
~(z ∈ fv e1) ->
~(z ∈ fv e2) ->
~(z ∈ fv e) ->
~(x ∈ Θ) ->
~(y ∈ Θ) ->
~(z ∈ Θ) ->
is_annotated_term e2 ->
NoDup (x :: y :: z :: nil) ->
(forall r, r ∈ fv n -> r ∈ support Γ1 -> False) ->
(forall r, r ∈ fv e -> r ∈ support Γ1 -> False) ->
(forall r, r ∈ fv e1 -> r ∈ support Γ1 -> False) ->
(forall r, r ∈ fv e2 -> r ∈ support Γ1 -> False) ->
subset (fv n) (support Γ2) ->
subset (fv e) (support Γ2) ->
subset (fv e1) (support Γ2) ->
subset (fv e2) (support Γ2) ->
wf n 0 ->
wf e 0 ->
wf e1 0 ->
wf e2 1 ->
is_annotated_term e2 ->
[[ Θ; Γ2 ⊨ n : T_nat ]] ->
[[ Θ; Γ1 ++ (x, T_equiv e1 e) :: (y, T_equiv n zero) :: Γ2 ⊨ t ≡ t' ]] ->
[[ Θ; Γ1 ++ (x, T_equiv (open 0 e2 (fvar z term_var)) e) ::
(y, T_equiv n (succ (fvar z term_var))) ::
(z, T_nat) ::
Γ2 ⊨
t ≡ t' ]] ->
[[ Θ; Γ1 ++ (x, T_equiv (tmatch n e1 e2) e) :: Γ2 ⊨ t ≡ t' ]].
Proof.
unfold open_equivalent;
repeat step.
apply equivalent_split_match
with ρ (erase_context Γ1) (erase_context Γ2)
(erase_term n) (erase_term e1) (erase_term e2) (erase_term e) x y z;
repeat
step || rewrite erase_context_append in * || apply union_left || erase_open;
side_conditions.
Qed.