-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAbsTheoryIntp.v
More file actions
269 lines (211 loc) · 10.2 KB
/
AbsTheoryIntp.v
File metadata and controls
269 lines (211 loc) · 10.2 KB
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
(************************************************************************************)
(************************************************************************************)
(*This file describes the interpretation from syntax to semantic*)
(************************************************************************************)
(************************************************************************************)
Require Export GenLemmas.
Require Import AbsTheorySyn.
Require Import AbsTheorySem.
(************************************************************************************)
(*Abstract interpretation of signature*)
(************************************************************************************)
Module Type SigIntp (Msyn : TheorySyn).
Import Msyn.
(*Interpretation first-order term*)
Parameter intp_foterm : foterm -> term.
(*Interpretation is not kind*)
Axiom intp_foterm_not_kind : forall t, intp_foterm t <> kind.
(*Properties about lift and interpretation term*)
Axiom lift_intp_lift_term_rec : forall t n k,
eq_term (lift_rec n k (intp_foterm t))
(intp_foterm (lift_term_rec t n k)).
Axiom lift_intp_lift_term : forall t n,
eq_term (lift n (intp_foterm t))
(intp_foterm (lift_term t n)).
(*Properties about substitution and interpretation term*)
Axiom subst_intp_subst_term_rec : forall t N k,
eq_term (subst_rec (intp_foterm N) k (intp_foterm t))
(intp_foterm (subst_term_rec t N k)).
Axiom subst_intp_subst_term : forall t N,
eq_term (subst (intp_foterm N) (intp_foterm t))
(intp_foterm (subst_term t N)).
End SigIntp.
(************************************************************************************)
(*Interpret first-order language and hypothesis*)
(************************************************************************************)
Module LangHypIntp (Msyn : TheorySyn) (Msem : TheorySem) (MSI : SigIntp Msyn).
Import Msyn Msem MSI.
(*Interpretation of foformula*)
Fixpoint intp_fofml f:=
match f with
| eq_foterm x y => EQ_term (intp_foterm x) (intp_foterm y)
| TF => True_symb
| BF => False_symb
| neg f => Neg (intp_fofml f)
| conj f1 f2 => Conj (intp_fofml f1) (intp_fofml f2)
| disj f1 f2 => Disj (intp_fofml f1) (intp_fofml f2)
| implf f1 f2 => Impl (intp_fofml f1) (intp_fofml f2)
| fall f => Fall (intp_fofml f)
| exst f => Exst (intp_fofml f)
end.
(*Properties about lift and interpretation formula*)
Lemma lift_intp_lift_fml_rec : forall f n k,
eq_term (lift_rec n k (intp_fofml f))
(intp_fofml (lift_fml_rec f n k)).
induction f; simpl intp_fofml; intros.
unfold EQ_term; unfold lift. repeat rewrite red_lift_prod. repeat rewrite red_lift_app.
apply Prod_morph; [apply Prod_morph; [generalize sort_clsd; intro H; destruct H as (H, _); apply H
|simpl; split; red; reflexivity]|]; repeat rewrite eq_term_lift_ref_bd by omega;
repeat rewrite <- lift_intp_lift_term_rec; repeat rewrite lift_rec_comm with (q:=k) by omega; reflexivity.
simpl; split; red; reflexivity.
simpl; split; red; reflexivity.
unfold Neg, Impl. rewrite red_lift_prod.
apply Prod_morph; trivial.
simpl; split; red; reflexivity.
unfold Conj, lift. do 4 rewrite red_lift_prod.
apply Prod_morph; [simpl; split; red; reflexivity|].
repeat rewrite eq_term_lift_ref_bd by omega.
rewrite <- IHf1, <- IHf2.
repeat rewrite lift_rec_comm with (q:=k) by omega; reflexivity.
unfold Disj, lift. do 5 rewrite red_lift_prod.
apply Prod_morph; [simpl; split; red; reflexivity|].
repeat rewrite eq_term_lift_ref_bd by omega.
rewrite <- IHf1, <- IHf2.
repeat rewrite lift_rec_comm with (q:=k) by omega; reflexivity.
unfold Impl, lift. rewrite red_lift_prod. apply Prod_morph; trivial.
rewrite <- IHf2. rewrite lift_rec_comm with (q:=k) by omega; reflexivity.
unfold Fall; rewrite red_lift_prod.
apply Prod_morph; [generalize sort_clsd; intro H; destruct H as (H, _); apply H|trivial].
unfold Exst. do 4 rewrite red_lift_prod.
apply Prod_morph; [simpl; split; red; reflexivity|].
do 2 rewrite subst0_lift. do 2 rewrite eq_term_lift_ref_bd by omega.
rewrite <- IHf. rewrite lift_rec_comm with (q:=S k) by omega.
generalize sort_clsd; intro H; destruct H as (H, _).
apply Prod_morph; [apply Prod_morph; [unfold lift; do 2 rewrite H|]|]; reflexivity.
Qed.
Lemma lift_intp_lift_fml : forall f n,
eq_term (lift n (intp_fofml f)) (intp_fofml (lift_fml f n)).
unfold lift, lift_fml; intros. apply lift_intp_lift_fml_rec.
Qed.
(*Properties about substitution and interpretation foformula*)
Lemma subst_intp_subst_fml_rec : forall f N k,
eq_term (subst_rec (intp_foterm N) k (intp_fofml f))
(intp_fofml (subst_fml_rec f N k)).
induction f; simpl intp_fofml; intros.
unfold EQ_term. do 3 rewrite red_sigma_prod.
apply Prod_morph; [apply Prod_morph; [
generalize sort_clsd; intro H; destruct H as (_, H); apply H|simpl; split; red; reflexivity]|].
repeat rewrite red_sigma_app. repeat rewrite red_sigma_var_lt by omega.
do 2 rewrite <- subst_intp_subst_term_rec.
unfold lift. repeat rewrite subst_lift_ge by omega.
fold (lift 0 (intp_foterm f)). fold (lift 0 (intp_foterm f0)).
repeat rewrite lift0. rewrite lift_rec_acc; [reflexivity|omega].
simpl; split; red; reflexivity.
simpl; split; red; reflexivity.
unfold Neg, Impl. rewrite red_sigma_prod.
apply Prod_morph; [trivial|simpl; split; red; reflexivity].
unfold Conj. do 4 rewrite red_sigma_prod.
apply Prod_morph; [simpl; split; red; reflexivity|].
unfold lift. repeat rewrite subst_lift_ge by omega.
fold (lift 0 (intp_fofml f1)). fold (lift 0 (intp_fofml f2)).
do 2 rewrite lift0. rewrite lift_rec_acc by omega.
do 2 rewrite red_sigma_var_lt by omega.
rewrite IHf1, IHf2; reflexivity.
unfold Disj. do 5 rewrite red_sigma_prod.
apply Prod_morph; [simpl; split; red; reflexivity|].
unfold lift. repeat rewrite subst_lift_ge by omega.
fold (lift 0 (intp_fofml f1)). fold (lift 0 (intp_fofml f2)).
do 2 rewrite lift0. rewrite lift_rec_acc by omega.
do 2 rewrite red_sigma_var_lt by omega.
rewrite IHf1, IHf2; reflexivity.
unfold Impl. rewrite red_sigma_prod. apply Prod_morph; trivial.
rewrite <- IHf2. unfold lift.
rewrite subst_lift_ge by omega.
fold (lift 0 (intp_fofml f2)); rewrite lift0; reflexivity.
unfold Fall; rewrite red_sigma_prod.
apply Prod_morph; [generalize sort_clsd; intro H; destruct H as (_, H); apply H|trivial].
unfold Exst. do 4 rewrite red_sigma_prod.
apply Prod_morph; [simpl; split; red; reflexivity|].
repeat rewrite subst0_lift. do 2 rewrite red_sigma_var_lt by omega.
unfold lift; repeat rewrite subst_lift_ge by omega. rewrite <- IHf. fold (lift 0 sort). rewrite lift0.
apply Prod_morph; [apply Prod_morph;
[generalize sort_clsd; intro H; destruct H as (_, H); rewrite H; reflexivity|]|reflexivity].
apply Prod_morph; [|reflexivity].
apply lift_rec_morph. apply subst_rec_morph; [reflexivity|reflexivity|].
apply eq_term_intro; [| |destruct (intp_fofml f); simpl; trivial]; intros.
rewrite int_lift_rec_eq. unfold V.lams, V.shift.
apply int_morph; [reflexivity|do 2 red; intros].
destruct (le_gt_dec 1 a); [|reflexivity].
replace (1+(0+(a-1))) with a; [reflexivity|omega].
rewrite tm_lift_rec_eq. unfold I.lams, I.shift.
apply tm_morph; [reflexivity|do 2 red; intros].
destruct (le_gt_dec 1 a); [|reflexivity].
replace (1+(0+(a-1))) with a; [reflexivity|omega].
Qed.
Lemma subst_intp_subst_fml : forall f N,
eq_term (subst (intp_foterm N) (intp_fofml f))
(intp_fofml (subst_fml f N)).
unfold subst; intros; apply subst_intp_subst_fml_rec with (k:=0).
Qed.
(*Interpretation of the context*)
Fixpoint intp_hyp (hyp : HYP) :=
match hyp with
| nil => nil
| h::hyp' =>
match h with
| Some f => (intp_fofml f)::(intp_hyp hyp')
| None => sort :: (intp_hyp hyp')
end
end.
Lemma intp_hyp_nth_fml : forall hyp f n, nth_error hyp n = Some (Some f) ->
nth_error (intp_hyp hyp) n = Some (intp_fofml f).
induction hyp; destruct n; simpl; intros; [discriminate | discriminate |
injection H; intro Hinj; rewrite Hinj |]; trivial.
destruct a; simpl; apply IHhyp; trivial.
Qed.
End LangHypIntp.
(***********************************************************************************)
(*Interpret axioms*)
(***********************************************************************************)
Module Type AxIntp (Msyn : TheorySyn) (Msem : TheorySem) (MSI : SigIntp Msyn).
Include LangHypIntp Msyn Msem MSI.
Import Msyn Msem MSI.
Axiom intp_foterm_sort : forall hyp t,
wf_term hyp t ->
typ (intp_hyp hyp) (intp_foterm t) sort.
(*The interpretation of the foformula is prop*)
Lemma intp_fofml_prop : forall f hyp,
wf_fml hyp f ->
typ (intp_hyp hyp) (intp_fofml f) prop.
induction f; simpl; intros.
apply EQ_term_typ; apply intp_foterm_sort; red in H |- *; simpl in H |- *; intros;
apply H; apply in_or_app; [left|right]; trivial.
apply True_symb_typ.
apply False_symb_typ.
apply Neg_typ; apply IHf.
red in H |- *; intros; apply H; simpl; trivial.
apply Conj_typ; [apply IHf1|apply IHf2]; red in H |- *; simpl in H |- *; intros;
apply H; apply in_or_app; [left|right]; trivial.
apply Disj_typ; [apply IHf1|apply IHf2]; red in H |- *; simpl in H |- *; intros;
apply H; apply in_or_app; [left|right]; trivial.
apply Impl_typ; [apply IHf1|apply IHf2]; red in H |- *; simpl in H |- *; intros;
apply H; apply in_or_app; [left|right]; trivial.
apply Fall_typ. replace (sort::intp_hyp hyp) with (intp_hyp (None::hyp)) by (simpl; trivial).
apply IHf. red in H |- *. intros. simpl in H.
destruct n; simpl; [|apply H; apply in_S_fv_fml]; trivial.
apply Exst_typ. replace (sort::intp_hyp hyp) with (intp_hyp (None::hyp)) by (simpl; trivial).
apply IHf. red in H |- *. intros; simpl in H.
destruct n; simpl; [|apply H; apply in_S_fv_fml]; trivial.
Qed.
(*Axioms in first-order theory is provable in the associated module*)
Parameter intp_ax : forall (hyp : HYP) f,
ax_syn hyp f ->
exists t, typ (intp_hyp hyp) t (intp_fofml f).
End AxIntp.
(***********************************************************************************)
(*Interpret Theory*)
(***********************************************************************************)
Module Type TheoryIntp (Msyn : TheorySyn) (Msem : TheorySem).
Declare Module MSI : SigIntp Msyn.
Declare Module MAI : AxIntp Msyn Msem MSI.
End TheoryIntp.