-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSN_CC_Real.v
437 lines (367 loc) · 10.2 KB
/
SN_CC_Real.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
Require Export Relations Wellfounded.
Require Import Sat.
Require Import ZF ZFcoc ZFuniv_real.
Require Import ZFlambda.
Require Import Models SnModels.
Require GenRealSN.
Set Implicit Arguments.
(** Strong normalization proof of the Calculus of Constructions.
It is based on GenRealSN, so it does support strong eliminations.
Inhabitation of all types is obtained by adding the empty set in every
type (cf ZFuniv_real). The product is interpreted by the set of *partial*
functions.
*)
Module SN := GenRealSN.MakeModel CC_Real.
Export SN.
Hint Unfold inX.
Existing Instance in_ext.
(** Derived properties *)
Notation daimont := Sat.SatSet.daimon.
Lemma val_ok_cons_default e T i j :
val_ok e i j ->
T <> kind ->
val_ok (T::e) (V.cons empty i) (I.cons daimont j).
intros.
apply vcons_add_var; trivial.
split.
red; auto.
apply varSAT.
Qed.
Lemma El_int_prod U V i :
El (int (Prod U V) i) == cc_prod (El (int U i)) (fun x => El (int V (V.cons x i))).
simpl.
apply El_prod.
do 2 red; intros.
rewrite H0; reflexivity.
Qed.
Lemma El_int_arr U V i :
El (int (Prod U (lift 1 V)) i) == cc_arr (El (int U i)) (El (int V i)).
rewrite El_int_prod.
apply cc_prod_morph; auto with *.
red; intros.
rewrite int_cons_lift_eq; reflexivity.
Qed.
Lemma Real_int_prod U V i f :
f ∈ cc_prod (El (int U i)) (fun x => El (int V (V.cons x i))) ->
eqSAT (Real (int (Prod U V) i) f)
(piSAT (int U i) (fun x => int V (V.cons x i)) (cc_app f)).
simpl; intros.
apply Real_prod.
do 2 red; intros.
rewrite H1; reflexivity.
change (f ∈ El (int (Prod U V) i)).
rewrite El_int_prod; trivial.
Qed.
Lemma Real_int_arr U V i f :
f ∈ cc_arr (El (int U i)) (El (int V i)) ->
eqSAT (Real (int (Prod U (lift 1 V)) i) f)
(piSAT (int U i) (fun _ => int V i) (cc_app f)).
intros.
rewrite Real_int_prod.
apply piSAT_morph; auto with *.
red; intros.
apply int_cons_lift_eq.
red; intros; apply cc_app_morph; auto with *.
revert H; apply eq_elim; apply cc_prod_ext; auto with *.
red; intros.
symmetry; apply El_morph; apply int_cons_lift_eq.
Qed.
Lemma kind_ok_trivial T : kind_ok T.
exists nil.
exists T; simpl; auto with *.
exists empty; auto with *.
Qed.
Hint Resolve kind_ok_trivial.
(** ** Extendability *)
Definition cst (x:set) : term.
(* begin show *)
left; exists (fun _ =>x) (fun _ =>Lambda.K).
(* end show *)
do 2 red; reflexivity.
do 2 red; reflexivity.
red; reflexivity.
red; reflexivity.
Defined.
Definition mkSET (x:set) := cst (mkTY x (fun _ => snSAT)).
Lemma mkSET_kind e x :
typ e (mkSET x) kind.
red; intros.
split;[discriminate|].
split; trivial.
apply Lambda.sn_K.
Qed.
Lemma cst_typ e x y :
in_set x y ->
typ e (cst x) (mkSET y).
red; intros.
apply in_int_intro; intros; try discriminate.
apply and_split; intros.
simpl.
red; rewrite El_def.
apply union2_intro2; trivial.
simpl.
rewrite Real_def.
apply Lambda.sn_K.
reflexivity.
apply union2_intro2; trivial.
Qed.
Lemma cst_eq_typ e x y :
x == y ->
eq_typ e (cst x) (cst y).
red; simpl; intros; trivial.
Qed.
Lemma cst_eq_typ_inv x y :
eq_typ nil (cst x) (cst y) ->
x == y.
intros.
assert (val_ok nil (V.nil empty) (I.nil Lambda.K)).
red; intros.
destruct n; inversion H0.
apply H in H0.
simpl in H0; trivial.
Qed.
Lemma mkSET_eq_typ e x y :
x == y ->
eq_typ e (mkSET x) (mkSET y).
red; simpl; intros; trivial.
apply mkTY_ext; auto with *.
Qed.
Lemma mkSET_eq_typ_inv x y :
eq_typ nil (mkSET x) (mkSET y) ->
x == y.
intros.
assert (val_ok nil (V.nil empty) (I.nil Lambda.K)).
red; intros.
destruct n; inversion H0.
apply H in H0.
simpl in H0.
apply couple_injection in H0; destruct H0; trivial.
Qed.
Definition sub_typ_covariant : forall e U1 U2 V1 V2,
U1 <> kind ->
eq_typ e U1 U2 ->
sub_typ (U1::e) V1 V2 ->
sub_typ e (Prod U1 V1) (Prod U2 V2).
intros.
apply sub_typ_covariant; trivial.
unfold eqX, inX; intros.
rewrite El_prod in H3; trivial.
apply cc_eta_eq in H3; trivial.
Qed.
(** ** Choice *)
(*Require Import ZFcoc SATtypes.
Module Lc:=Lambda.
Definition Ch (X:term) : term.
(* begin show *)
left;
exists (fun i => mkTY (trunc (El(int X i)))
(fun _ => depSAT(fun Y=>forall x,x ∈El(int X i)->
inclSAT(cartSAT(Real (int X i) x)unitSAT) Y)
(fun Y=>Y)))
(fun j => tm X j).
(* end show *)
do 2 red; intros.
apply mkTY_ext; intros.
rewrite H; auto with *.
apply interSAT_morph_subset; simpl; intros; auto with *.
apply fa_morph; intros z.
rewrite H; reflexivity.
do 2 red; intros; apply tm_morph; auto with *.
red; intros; apply tm_liftable.
red; intros; apply tm_substitutive.
Defined.
Definition ChI (W:term) : term.
(* begin show *)
left; exists (fun i => empty) (fun j => COUPLE (tm W j) ID).
(* end show *)
do 2 red; intros; reflexivity.
do 2 red; intros.
f_equal; trivial.
apply tm_morph; auto with *.
(**)
red; intros.
unfold COUPLE; simpl.
rewrite tm_liftable.
rewrite Lc.permute_lift; reflexivity.
(**)
red; intros.
unfold COUPLE; simpl.
rewrite tm_substitutive.
rewrite Lc.commut_lift_subst; reflexivity.
Defined.
Lemma ChI_typ e X W :
X <> kind ->
typ e W X ->
typ e (ChI W) (Ch X).
unfold typ.
intros Xnk tyW; intros.
apply in_int_intro; try discriminate.
apply and_split; simpl; intros.
red; auto.
red in H0; rewrite El_def in H0.
specialize tyW with (1:=H).
apply in_int_not_kind in tyW; trivial.
destruct tyW.
rewrite Real_def; intros; auto.
2:apply interSAT_morph_subset; simpl; auto with *.
apply interSAT_intro.
exists snSAT; intros.
red; intros; apply snSAT_intro.
apply sat_sn in H4; trivial.
intros (Y,?); simpl.
apply i0 with (int W i); trivial.
apply cartSAT_intro; trivial.
apply ID_intro.
Qed.
Definition ChE (X C:term) : term.
left; exists (fun i => ZFrepl.uchoice (fun x => x ∈ Elt (int X i)))
(fun j => Lc.App (tm C j) (Lc.Abs (Lc.Abs (Lc.Ref 1)))).
admit.
admit.
admit.
admit.
Defined.
Lemma ChE_typ e W X :
X <> kind ->
typ e W (Ch X) ->
typ e (ChE X W) X.
unfold typ; intros Xnk tyW i j valok.
specialize tyW with (1:=valok).
apply in_int_not_kind in tyW;[|discriminate].
destruct tyW as (tyW,satW).
red in tyW; simpl in tyW; rewrite El_def in tyW.
simpl in satW; rewrite Real_def in satW; trivial.
apply in_int_intro; trivial; try discriminate.
apply and_split; intros.
red; simpl.
apply cc_bot_intro.
apply ZFrepl.uchoice_def.
split.
intros.
rewrite <- H; trivial.
split; intros.
admit.
admit.
simpl.
red in H; simpl in H.
set (w:=ZFrepl.uchoice (fun x => x ∈ Elt(int X i))) in *.
clearbody w.
apply depSAT_elim' in satW.
red in satW.
eapply cartSAT_case with (X:=Real(int X i) w) (Y:=unitSAT).
apply satW; intros.
intros ? h; apply h.
reflexivity.
eexact (fun _ h => h).
assert (inSAT (tm W j) ; rewrite El_def in H.
split.
(** ** Unique choice *)
Definition Tr (X:term) : term.
(* begin show *)
left;
exists (fun i => mkTY (ZFcoc.trunc (El(int X i)))
(fun _ => interSAT(fun Y:{Y|forall x,x ∈El(int X i)->
inclSAT(Real (int X i) x) Y}=>proj1_sig Y)))
(fun j => tm X j).
(* end show *)
do 2 red; intros.
apply mkTY_ext; intros.
rewrite H; auto with *.
apply interSAT_morph_subset; simpl; intros; auto with *.
apply fa_morph; intros z.
rewrite H; reflexivity.
do 2 red; intros; apply tm_morph; auto with *.
red; intros; apply tm_liftable.
red; intros; apply tm_substitutive.
Defined.
Definition TrI (W:term) : term.
(* begin show *)
left; exists (fun i => empty) (fun j => tm W j).
(* end show *)
do 2 red; intros; reflexivity.
do 2 red; intros; apply tm_morph; auto with *.
red; intros; apply tm_liftable.
red; intros; apply tm_substitutive.
Defined.
Lemma TrI_typ e X W :
X <> kind ->
typ e W X ->
typ e (TrI W) (Tr X).
unfold typ.
intros Xnk tyW; intros.
apply in_int_intro; try discriminate.
apply and_split; simpl; intros.
red; auto.
red in H0; rewrite El_def in H0.
specialize tyW with (1:=H).
apply in_int_not_kind in tyW; trivial.
destruct tyW.
rewrite Real_def; intros; auto.
apply interSAT_intro' with (F:=fun X=>X); intros.
apply sat_sn in H2; trivial.
apply (H3 (int W i)); trivial.
apply interSAT_morph_subset; simpl; auto with *.
Qed.
Definition TrE (X P F W:term) : term.
(* begin show *)
left; exists (fun i => cond_set (int W i ∈ Elt (int (Tr X) i))
(trunc_descr (El(int P i))))
(fun j => Lambda.App (tm F j) (tm W j)).
(* end show *)
do 2 red; intros; rewrite H; reflexivity.
do 2 red; intros; rewrite H; reflexivity.
red; intros.
do 2 rewrite tm_liftable.
reflexivity.
red; intros.
do 2 rewrite tm_substitutive.
reflexivity.
Defined.
Definition EQ A t1 t2 :=
Prod (Prod A prop) (Prod (App (Ref 0) (lift 1 t1)) (App (Ref 1) (lift 2 t2))).
Definition IsProp X :=
Prod X (Prod (lift 1 X) (EQ (lift 2 X) (Ref 1) (Ref 0))).
Lemma TrE_typ e X P Pp F W :
P <> kind ->
typ e Pp (IsProp P) ->
typ e F (Prod X (lift 1 P)) ->
typ e W (Tr X) ->
typ e (TrE X P F W) P.
unfold typ; intros Pnk tyPp tyF tyW i j valok.
specialize tyPp with (1:=valok); apply in_int_not_kind in tyPp;[|discriminate].
specialize tyF with (1:=valok); apply in_int_not_kind in tyF;[|discriminate].
specialize tyW with (1:=valok); apply in_int_not_kind in tyW;[|discriminate].
clear valok.
destruct tyPp as (isPp,_).
destruct tyF as (tyF,satF).
destruct tyW as (tyW,satW).
apply in_int_intro; trivial; try discriminate.
split; simpl.
red.
rewrite Elt_def.
red in tyW; simpl in tyW; rewrite El_def in tyW.
apply cc_bot_ax in tyW; destruct tyW.
admit.
rewrite cond_set_ok; trivial.
apply trunc_ind with (El(int X i)) (fun x => cc_app (int F i) x) (int W i); trivial.
admit. (*!*)
red; intros.
admit.
rewrite Elt_def.
red; intros.
*)
(***********************************************************************************************)
(** * Consistency out of the strong normalization model *)
(** Another consistency proof. *)
Theorem consistency : forall M, ~ typ List.nil M (Prod prop (Ref 0)).
red; intros.
apply model_consistency with (FF:=mkTY (singl prf_trm) (fun _ => neuSAT)) in H;
trivial.
apply sn_sort_intro.
reflexivity.
apply one_in_props.
intros.
red in H0; rewrite El_def in H0.
rewrite Real_def; auto with *.
Qed.
Print Assumptions consistency.