Debian Codegraph @

test-suite/prerequisite/hurkens.v

raw
1 (************************************************************************)
2 (* * The Coq Proof Assistant / The Coq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10 (* Hurkens.v *)
11 (************************************************************************)
12
13 (** Exploiting Hurkens's paradox [[Hurkens95]] for system U- so as to
14 derive various contradictory contexts.
15
16 The file is divided into various sub-modules which all follow the
17 same structure: a section introduces the contradictory hypotheses
18 and a theorem named [paradox] concludes the module with a proof of
19 [False].
20
21 - The [Generic] module contains the actual Hurkens's paradox for a
22 postulated shallow encoding of system U- in Coq. This is an
23 adaptation by Arnaud Spiwack of a previous, more restricted
24 implementation by Herman Geuvers. It is used to derive every
25 other special cases of the paradox in this file.
26
27 - The [NoRetractToImpredicativeUniverse] module contains a simple
28 and effective formulation by Herman Geuvers [[Geuvers01]] of a
29 result by Thierry Coquand [[Coquand90]]. It states that no
30 impredicative sort can contain a type of which it is a
31 retract. This result implies that Coq with classical logic
32 stated in impredicative Set is inconsistent and that classical
33 logic stated in Prop implies proof-irrelevance (see
34 [ClassicalFacts.v])
35
36 - The [NoRetractFromSmallPropositionToProp] module is a
37 specialisation of the [NoRetractToImpredicativeUniverse] module
38 to the case where the impredicative sort is [Prop].
39
40 - The [NoRetractToModalProposition] module is a strengthening of
41 the [NoRetractFromSmallPropositionToProp] module. It shows that
42 given a monadic modality (aka closure operator) [M], the type of
43 modal propositions (i.e. such that [M A -> A]) cannot be a
44 retract of a modal proposition. It is an example of use of the
45 paradox where the universes of system U- are not mapped to
46 universes of Coq.
47
48 - The [NoRetractToNegativeProp] module is the specialisation of
49 the [NoRetractFromSmallPropositionToProp] module where the
50 modality is double-negation. This result implies that the
51 principle of weak excluded middle ([forall A, ~~A\/~A]) implies
52 a weak variant of proof irrelevance.
53
54 - The [NoRetractFromTypeToProp] module proves that [Prop] cannot
55 be a retract of a larger type.
56
57 - The [TypeNeqSmallType] module proves that [Type] is different
58 from any smaller type.
59
60 - The [PropNeqType] module proves that [Prop] is different from
61 any larger [Type]. It is an instance of the previous result.
62
63 References:
64
65 - [[Coquand90]] T. Coquand, "Metamathematical Investigations of a
66 Calculus of Constructions", Proceedings of Logic in Computer
67 Science (LICS'90), 1990.
68
69 - [[Hurkens95]] A. J. Hurkens, "A simplification of Girard's paradox",
70 Proceedings of the 2nd international conference Typed Lambda-Calculi
71 and Applications (TLCA'95), 1995.
72
73 - [[Geuvers01]] H. Geuvers, "Inconsistency of Classical Logic in Type
74 Theory", 2001, revised 2007
75 (see external link {{http://www.cs.ru.nl/~herman/PUBS/newnote.ps.gz}}).
76 *)
77
78
79 Set Universe Polymorphism.
80
81 (* begin show *)
82
83 (** * A modular proof of Hurkens's paradox. *)
84
85 (** It relies on an axiomatisation of a shallow embedding of system U-
86 (i.e. types of U- are interpreted by types of Coq). The
87 universes are encoded in a style, due to Martin-Löf, where they
88 are given by a set of names and a family [El:Name->Type] which
89 interprets each name into a type. This allows the encoding of
90 universe to be decoupled from Coq's universes. Dependent products
91 and abstractions are similarly postulated rather than encoded as
92 Coq's dependent products and abstractions. *)
93
94 Module Generic.
95
96 (* begin hide *)
97 (* Notations used in the proof. Hidden in coqdoc. *)
98
99 Reserved Notation "'∀₁' x : A , B" (at level 200, x name, A at level 200,right associativity).
100 Reserved Notation "A '⟶₁' B" (at level 99, right associativity, B at level 200).
101 Reserved Notation "'λ₁' x , u" (at level 200, x name, right associativity).
102 Reserved Notation "f '·₁' x" (at level 5, left associativity).
103 Reserved Notation "'∀₂' A , F" (at level 200, A name, right associativity).
104 Reserved Notation "'λ₂' x , u" (at level 200, x name, right associativity).
105 #[warning="-postfix-notation-not-level-1"]
106 Reserved Notation "f '·₁' [ A ]" (at level 5, left associativity).
107 Reserved Notation "'∀₀' x : A , B" (at level 200, x name, A at level 200,right associativity).
108 Reserved Notation "A '⟶₀' B" (at level 99, right associativity, B at level 200).
109 Reserved Notation "'λ₀' x , u" (at level 200, x name, right associativity).
110 Reserved Notation "f '·₀' x" (at level 5, left associativity).
111 Reserved Notation "'∀₀¹' A : U , F" (at level 200, A name, right associativity).
112 Reserved Notation "'λ₀¹' x , u" (at level 200, x name, right associativity).
113 #[warning="-postfix-notation-not-level-1"]
114 Reserved Notation "f '·₀' [ A ]" (at level 5, left associativity).
115
116 (* end hide *)
117
118 Section Paradox.
119
120 (** ** Axiomatisation of impredicative universes in a Martin-Löf style *)
121
122 (** System U- has two impredicative universes. In the proof of the
123 paradox they are slightly asymmetric (in particular the reduction
124 rules of the small universe are not needed). Therefore, the
125 axioms are duplicated allowing for a weaker requirement than the
126 actual system U-. *)
127
128
129 (** *** Large universe *)
130 Variable U1 : Type.
131 Variable El1 : U1 -> Type.
132 (** **** Closure by small product *)
133 Variable Forall1 : forall u:U1, (El1 u -> U1) -> U1.
134 Notation "'∀₁' x : A , B" := (Forall1 A (fun x => B)).
135 Notation "A '⟶₁' B" := (Forall1 A (fun _ => B)).
136 Variable lam1 : forall u B, (forall x:El1 u, El1 (B x)) -> El1 (∀₁ x:u, B x).
137 Notation "'λ₁' x , u" := (lam1 _ _ (fun x => u)).
138 Variable app1 : forall u B (f:El1 (Forall1 u B)) (x:El1 u), El1 (B x).
139 Notation "f '·₁' x" := (app1 _ _ f x).
140 Variable beta1 : forall u B (f:forall x:El1 u, El1 (B x)) x,
141 (λ₁ y, f y) ·₁ x = f x.
142 (** **** Closure by large products *)
143 (** [U1] only needs to quantify over itself. *)
144 Variable ForallU1 : (U1->U1) -> U1.
145 Notation "'∀₂' A , F" := (ForallU1 (fun A => F)).
146 Variable lamU1 : forall F, (forall A:U1, El1 (F A)) -> El1 (∀₂ A, F A).
147 Notation "'λ₂' x , u" := (lamU1 _ (fun x => u)).
148 Variable appU1 : forall F (f:El1(∀₂ A,F A)) (A:U1), El1 (F A).
149 Notation "f '·₁' [ A ]" := (appU1 _ f A).
150 Variable betaU1 : forall F (f:forall A:U1, El1 (F A)) A,
151 (λ₂ x, f x) ·₁ [ A ] = f A.
152
153 (** *** Small universe *)
154 (** The small universe is an element of the large one. *)
155 Variable u0 : U1.
156 Notation U0 := (El1 u0).
157 Variable El0 : U0 -> Type.
158 (** **** Closure by small product *)
159 (** [U0] does not need reduction rules *)
160 Variable Forall0 : forall u:U0, (El0 u -> U0) -> U0.
161 Notation "'∀₀' x : A , B" := (Forall0 A (fun x => B)).
162 Notation "A '⟶₀' B" := (Forall0 A (fun _ => B)).
163 Variable lam0 : forall u B, (forall x:El0 u, El0 (B x)) -> El0 (∀₀ x:u, B x).
164 Notation "'λ₀' x , u" := (lam0 _ _ (fun x => u)).
165 Variable app0 : forall u B (f:El0 (Forall0 u B)) (x:El0 u), El0 (B x).
166 Notation "f '·₀' x" := (app0 _ _ f x).
167 (** **** Closure by large products *)
168 Variable ForallU0 : forall u:U1, (El1 u->U0) -> U0.
169 Notation "'∀₀¹' A : U , F" := (ForallU0 U (fun A => F)).
170 Variable lamU0 : forall U F, (forall A:El1 U, El0 (F A)) -> El0 (∀₀¹ A:U, F A).
171 Notation "'λ₀¹' x , u" := (lamU0 _ _ (fun x => u)).
172 Variable appU0 : forall U F (f:El0(∀₀¹ A:U,F A)) (A:El1 U), El0 (F A).
173 Notation "f '·₀' [ A ]" := (appU0 _ _ f A).
174
175 (** ** Automating the rewrite rules of our encoding. *)
176 Local Ltac simplify :=
177 (* spiwack: ideally we could use [rewrite_strategy] here, but I am a tad
178 scared of the idea of depending on setoid rewrite in such a simple
179 file. *)
180 (repeat rewrite ?beta1, ?betaU1);
181 lazy beta.
182
183 Local Ltac simplify_in h :=
184 (repeat rewrite ?beta1, ?betaU1 in h);
185 lazy beta in h.
186
187
188 (** ** Hurkens's paradox. *)
189
190 (** An inhabitant of [U0] standing for [False]. *)
191 Variable F:U0.
192
193 (** *** Preliminary definitions *)
194
195 Definition V : U1 := ∀₂ A, ((A ⟶₁ u0) ⟶₁ A ⟶₁ u0) ⟶₁ A ⟶₁ u0.
196 Definition U : U1 := V ⟶₁ u0.
197
198 Definition sb (z:El1 V) : El1 V := λ₂ A, λ₁ r, λ₁ a, r ·₁ (z·₁[A]·₁r) ·₁ a.
199
200 Definition le (i:El1 (U⟶₁u0)) (x:El1 U) : U0 :=
201 x ·₁ (λ₂ A, λ₁ r, λ₁ a, i ·₁ (λ₁ v, (sb v) ·₁ [A] ·₁ r ·₁ a)).
202 Definition le' : El1 ((U⟶₁u0) ⟶₁ U ⟶₁ u0) := λ₁ i, λ₁ x, le i x.
203 Definition induct (i:El1 (U⟶₁u0)) : U0 :=
204 ∀₀¹ x:U, le i x ⟶₀ i ·₁ x.
205
206 Definition WF : El1 U := λ₁ z, (induct (z·₁[U] ·₁ le')).
207 Definition I (x:El1 U) : U0 :=
208 (∀₀¹ i:U⟶₁u0, le i x ⟶₀ i ·₁ (λ₁ v, (sb v) ·₁ [U] ·₁ le' ·₁ x)) ⟶₀ F
209 .
210
211 (** *** Proof *)
212
213 Lemma Omega : El0 (∀₀¹ i:U⟶₁u0, induct i ⟶₀ i ·₁ WF).
214 Proof.
215 refine (λ₀¹ i, λ₀ y, _).
216 refine (y·₀[_]·₀_).
217 unfold le,WF,induct. simplify.
218 refine (λ₀¹ x, λ₀ h0, _). simplify.
219 refine (y·₀[_]·₀_).
220 unfold le. simplify.
221 unfold sb at 1. simplify.
222 unfold le' at 1. simplify.
223 exact h0.
224 Qed.
225
226 Lemma lemma1 : El0 (induct (λ₁ u, I u)).
227 Proof.
228 unfold induct.
229 refine (λ₀¹ x, λ₀ p, _). simplify.
230 refine (λ₀ q,_).
231 assert (El0 (I (λ₁ v, (sb v)·₁[U]·₁le'·₁x))) as h.
232 { generalize (q·₀[λ₁ u, I u]·₀p). simplify.
233 intros q'.
234 exact q'. }
235 refine (h·₀_).
236 refine (λ₀¹ i,_).
237 refine (λ₀ h', _).
238 generalize (q·₀[λ₁ y, i ·₁ (λ₁ v, (sb v)·₁[U] ·₁ le' ·₁ y)]). simplify.
239 intros q'.
240 refine (q'·₀_). clear q'.
241 unfold le at 1 in h'. simplify_in h'.
242 unfold sb at 1 in h'. simplify_in h'.
243 unfold le' at 1 in h'. simplify_in h'.
244 exact h'.
245 Qed.
246
247 Lemma lemma2 : El0 ((∀₀¹i:U⟶₁u0, induct i ⟶₀ i·₁WF) ⟶₀ F).
248 Proof.
249 refine (λ₀ x, _).
250 assert (El0 (I WF)) as h.
251 { generalize (x·₀[λ₁ u, I u]·₀lemma1). simplify.
252 intros q.
253 exact q. }
254 refine (h·₀_). clear h.
255 refine (λ₀¹ i, λ₀ h0, _).
256 generalize (x·₀[λ₁ y, i·₁(λ₁ v, (sb v)·₁[U]·₁le'·₁y)]). simplify.
257 intros q.
258 refine (q·₀_). clear q.
259 unfold le in h0. simplify_in h0.
260 unfold WF in h0. simplify_in h0.
261 exact h0.
262 Qed.
263
264 Theorem paradox : El0 F.
265 Proof.
266 exact (lemma2·₀Omega).
267 Qed.
268
269 End Paradox.
270
271 (** The [paradox] tactic can be called as a shortcut to use the paradox. *)
272 Ltac paradox h :=
273 unshelve (refine ((fun h => _) (paradox _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ))).
274
275 End Generic.
276
277 (** * Impredicative universes are not retracts. *)
278
279 (** There can be no retract to an impredicative Coq universe from a
280 smaller type. In this version of the proof, the impredicativity of
281 the universe is postulated with a pair of functions from the
282 universe to its type and back which commute with dependent product
283 in an appropriate way. *)
284
285 Module NoRetractToImpredicativeUniverse.
286
287 Section Paradox.
288
289 Let U2 := Type.
290 Let U1:U2 := Type.
291 Variable U0:U1.
292
293 (** *** [U1] is impredicative *)
294 Variable u22u1 : U2 -> U1.
295 Hypothesis u22u1_unit : forall (c:U2), c -> u22u1 c.
296 (** [u22u1_counit] and [u22u1_coherent] only apply to dependent
297 product so that the equations happen in the smaller [U1] rather
298 than [U2]. Indeed, it is not generally the case that one can
299 project from a large universe to an impredicative universe and
300 then get back the original type again. It would be too strong a
301 hypothesis to require (in particular, it is not true of
302 [Prop]). The formulation is reminiscent of the monadic
303 characteristic of the projection from a large type to [Prop].*)
304 Hypothesis u22u1_counit : forall (F:U1->U1), u22u1 (forall A,F A) -> (forall A,F A).
305 Hypothesis u22u1_coherent : forall (F:U1 -> U1) (f:forall x:U1, F x) (x:U1),
306 u22u1_counit _ (u22u1_unit _ f) x = f x.
307
308 (** *** [U0] is a retract of [U1] *)
309 Variable u02u1 : U0 -> U1.
310 Variable u12u0 : U1 -> U0.
311 Hypothesis u12u0_unit : forall (b:U1), b -> u02u1 (u12u0 b).
312 Hypothesis u12u0_counit : forall (b:U1), u02u1 (u12u0 b) -> b.
313
314 (** ** Paradox *)
315
316 Theorem paradox : forall F:U1, F.
317 Proof.
318 intros F.
319 Generic.paradox h.
320 (** Large universe *)
321 + exact U1.
322 + exact (fun X => X).
323 + cbn. exact (fun u F => forall x:u, F x).
324 + cbn. exact (fun _ _ x => x).
325 + cbn. exact (fun _ _ x => x).
326
327 + cbn. exact (fun F => u22u1 (forall x, F x)).
328 + cbn. exact (fun _ x => u22u1_unit _ x).
329 + cbn. exact (fun _ x => u22u1_counit _ x).
330 (** Small universe *)
331 + exact U0.
332 (** The interpretation of the small universe is the image of
333 [U0] in [U1]. *)
334 + cbn. exact (fun X => u02u1 X).
335 + cbn. exact (fun u F => u12u0 (forall x:(u02u1 u), u02u1 (F x))).
336 + cbn. exact (fun u F => u12u0 (forall x:u, u02u1 (F x))).
337 + cbn. exact (u12u0 F).
338 + cbn in h.
339 exact (u12u0_counit _ h).
340 + cbn. easy.
341 + cbn. intros **. now rewrite u22u1_coherent.
342 + cbn. intros * x. exact (u12u0_unit _ x).
343 + cbn. intros * x. exact (u12u0_counit _ x).
344 + cbn. intros * x. exact (u12u0_unit _ x).
345 + cbn. intros * x. exact (u12u0_counit _ x).
346 Qed.
347
348 End Paradox.
349
350 End NoRetractToImpredicativeUniverse.
351
352 (** * Modal fragments of [Prop] are not retracts *)
353
354 (** In presence of a a monadic modality on [Prop], we can define a
355 subset of [Prop] of modal propositions which is also a complete
356 Heyting algebra. These cannot be a retract of a modal
357 proposition. This is a case where the universe in system U- are
358 not encoded as Coq universes. *)
359
360 Module NoRetractToModalProposition.
361
362 (** ** Monadic modality *)
363
364 Section Paradox.
365
366 Variable M : Prop -> Prop.
367 Hypothesis incr : forall A B:Prop, (A->B) -> M A -> M B.
368
369 Lemma strength: forall A (P:A->Prop), M(forall x:A,P x) -> forall x:A,M(P x).
370 Proof.
371 intros A P h x.
372 eapply incr in h; eauto.
373 Qed.
374
375 (** ** The universe of modal propositions *)
376
377 Definition MProp := { P:Prop | M P -> P }.
378 Definition El : MProp -> Prop := @proj1_sig _ _.
379
380 Lemma modal : forall P:MProp, M(El P) -> El P.
381 Proof.
382 intros [P m]. cbn.
383 exact m.
384 Qed.
385
386 Definition Forall {A:Type} (P:A->MProp) : MProp.
387 Proof.
388 unshelve (refine (exist _ _ _)).
389 + exact (forall x:A, El (P x)).
390 + intros h x.
391 eapply strength in h.
392 eauto using modal.
393 Defined.
394
395 (** ** Retract of the modal fragment of [Prop] in a small type *)
396
397 (** The retract is axiomatized using logical equivalence as the
398 equality on propositions. *)
399
400 Variable bool : MProp.
401 Variable p2b : MProp -> El bool.
402 Variable b2p : El bool -> MProp.
403 Hypothesis p2p1 : forall A:MProp, El (b2p (p2b A)) -> El A.
404 Hypothesis p2p2 : forall A:MProp, El A -> El (b2p (p2b A)).
405
406 (** ** Paradox *)
407
408 Theorem paradox : forall B:MProp, El B.
409 Proof.
410 intros B.
411 Generic.paradox h.
412 (** Large universe *)
413 + exact MProp.
414 + exact El.
415 + exact (fun _ => Forall).
416 + cbn. exact (fun _ _ f => f).
417 + cbn. exact (fun _ _ f => f).
418 + exact Forall.
419 + cbn. exact (fun _ f => f).
420 + cbn. exact (fun _ f => f).
421 (** Small universe *)
422 + exact bool.
423 + exact (fun b => El (b2p b)).
424 + cbn. exact (fun _ F => p2b (Forall (fun x => b2p (F x)))).
425 + exact (fun _ F => p2b (Forall (fun x => b2p (F x)))).
426 + apply p2b.
427 exact B.
428 + cbn in h. auto.
429 + cbn. easy.
430 + cbn. easy.
431 + cbn. auto.
432 + cbn. intros * f.
433 apply p2p1 in f. cbn in f.
434 exact f.
435 + cbn. auto.
436 + cbn. intros * f.
437 apply p2p1 in f. cbn in f.
438 exact f.
439 Qed.
440
441 End Paradox.
442
443 End NoRetractToModalProposition.
444
445 (** * The negative fragment of [Prop] is not a retract *)
446
447 (** The existence in the pure Calculus of Constructions of a retract
448 from the negative fragment of [Prop] into a negative proposition
449 is inconsistent. This is an instance of the previous result. *)
450
451 Module NoRetractToNegativeProp.
452
453 (** ** The universe of negative propositions. *)
454
455 Definition NProp := { P:Prop | ~~P -> P }.
456 Definition El : NProp -> Prop := @proj1_sig _ _.
457
458 Section Paradox.
459
460 (** ** Retract of the negative fragment of [Prop] in a small type *)
461
462 (** The retract is axiomatized using logical equivalence as the
463 equality on propositions. *)
464
465 Variable bool : NProp.
466 Variable p2b : NProp -> El bool.
467 Variable b2p : El bool -> NProp.
468 Hypothesis p2p1 : forall A:NProp, El (b2p (p2b A)) -> El A.
469 Hypothesis p2p2 : forall A:NProp, El A -> El (b2p (p2b A)).
470
471 (** ** Paradox *)
472
473 Theorem paradox : forall B:NProp, El B.
474 Proof.
475 intros B.
476 unshelve (refine ((fun h => _) (NoRetractToModalProposition.paradox _ _ _ _ _ _ _ _))).
477 + exact (fun P => ~~P).
478 + exact bool.
479 + exact p2b.
480 + exact b2p.
481 + exact B.
482 + exact h.
483 + cbn. auto.
484 + cbn. auto.
485 + cbn. auto.
486 Qed.
487
488 End Paradox.
489
490 End NoRetractToNegativeProp.
491
492 (** * Prop is not a retract *)
493
494 (** The existence in the pure Calculus of Constructions of a retract
495 from [Prop] into a small type of [Prop] is inconsistent. This is a
496 special case of the previous result. *)
497
498 Module NoRetractFromSmallPropositionToProp.
499
500 (** ** The universe of propositions. *)
501
502 Definition NProp := { P:Prop | P -> P}.
503 Definition El : NProp -> Prop := @proj1_sig _ _.
504
505 Section MParadox.
506
507 (** ** Retract of [Prop] in a small type, using the identity modality. *)
508
509 Variable bool : NProp.
510 Variable p2b : NProp -> El bool.
511 Variable b2p : El bool -> NProp.
512 Hypothesis p2p1 : forall A:NProp, El (b2p (p2b A)) -> El A.
513 Hypothesis p2p2 : forall A:NProp, El A -> El (b2p (p2b A)).
514
515 (** ** Paradox *)
516
517 Theorem mparadox : forall B:NProp, El B.
518 Proof.
519 intros B.
520 unshelve (refine ((fun h => _) (NoRetractToModalProposition.paradox _ _ _ _ _ _ _ _))).
521 + exact (fun P => P).
522 + exact bool.
523 + exact p2b.
524 + exact b2p.
525 + exact B.
526 + exact h.
527 + cbn. auto.
528 + cbn. auto.
529 + cbn. auto.
530 Qed.
531
532 End MParadox.
533
534 Section Paradox.
535
536 (** ** Retract of [Prop] in a small type *)
537
538 (** The retract is axiomatized using logical equivalence as the
539 equality on propositions. *)
540 Variable bool : Prop.
541 Variable p2b : Prop -> bool.
542 Variable b2p : bool -> Prop.
543 Hypothesis p2p1 : forall A:Prop, b2p (p2b A) -> A.
544 Hypothesis p2p2 : forall A:Prop, A -> b2p (p2b A).
545
546 (** ** Paradox *)
547
548 Theorem paradox : forall B:Prop, B.
549 Proof.
550 intros B.
551 unshelve (refine (mparadox (exist _ bool (fun x => x)) _ _ _ _
552 (exist _ B (fun x => x)))).
553 + intros p. red. red. exact (p2b (El p)).
554 + cbn. intros b. red. exists (b2p b). exact (fun x => x).
555 + cbn. intros [A H]. cbn. apply p2p1.
556 + cbn. intros [A H]. cbn. apply p2p2.
557 Qed.
558
559 End Paradox.
560
561 End NoRetractFromSmallPropositionToProp.
562
563
564 (** * Large universes are not retracts of [Prop]. *)
565
566 (** The existence in the Calculus of Constructions with universes of a
567 retract from some [Type] universe into [Prop] is inconsistent. *)
568
569 (* Note: Assuming the context [down:Type->Prop; up:Prop->Type; forth:
570 forall (A:Type), A -> up (down A); back: forall (A:Type), up
571 (down A) -> A; H: forall (A:Type) (P:A->Type) (a:A),
572 P (back A (forth A a)) -> P a] is probably enough. *)
573
574 Module NoRetractFromTypeToProp.
575
576 Definition Type2 := Type.
577 Definition Type1 := Type : Type2.
578
579 Section Paradox.
580
581 (** ** Assumption of a retract from Type into Prop *)
582
583 Variable down : Type1 -> Prop.
584 Variable up : Prop -> Type1.
585 Hypothesis up_down : forall (A:Type1), up (down A) = A :> Type1.
586
587 (** ** Paradox *)
588
589 Theorem paradox : forall P:Prop, P.
590 Proof.
591 intros P.
592 Generic.paradox h.
593 (** Large universe. *)
594 + exact Type1.
595 + exact (fun X => X).
596 + cbn. exact (fun u F => forall x, F x).
597 + cbn. exact (fun _ _ x => x).
598 + cbn. exact (fun _ _ x => x).
599 + exact (fun F => forall A:Prop, F(up A)).
600 + cbn. exact (fun F f A => f (up A)).
601 + cbn.
602 intros F f A.
603 specialize (f (down A)).
604 rewrite up_down in f.
605 exact f.
606 + exact Prop.
607 + cbn. exact (fun X => X).
608 + cbn. exact (fun A P => forall x:A, P x).
609 + cbn. exact (fun A P => forall x:A, P x).
610 + cbn. exact P.
611 + exact h.
612 + cbn. easy.
613 + cbn.
614 intros F f A.
615 destruct (up_down A). cbn.
616 reflexivity.
617 + cbn. exact (fun _ _ x => x).
618 + cbn. exact (fun _ _ x => x).
619 + cbn. exact (fun _ _ x => x).
620 + cbn. exact (fun _ _ x => x).
621 Qed.
622
623 End Paradox.
624
625 End NoRetractFromTypeToProp.
626
627 (** * [A<>Type] *)
628
629 (** No Coq universe can be equal to one of its elements. *)
630
631 Module TypeNeqSmallType.
632
633 Unset Universe Polymorphism.
634
635 Section Paradox.
636
637 (** ** Universe [U] is equal to one of its elements. *)
638
639 Let U := Type.
640 Variable A:U.
641 Hypothesis h : U=A.
642
643 (** ** Universe [U] is a retract of [A] *)
644
645 (** The following context is actually sufficient for the paradox to
646 hold. The hypothesis [h:U=A] is only used to define [down], [up]
647 and [up_down]. *)
648
649 Let down (X:U) : A := @eq_rect _ _ (fun X => X) X _ h.
650 Let up (X:A) : U := @eq_rect_r _ _ (fun X => X) X _ h.
651
652 Lemma up_down : forall (X:U), up (down X) = X.
653 Proof.
654 unfold up,down.
655 rewrite <- h.
656 reflexivity.
657 Qed.
658
659 Theorem paradox : False.
660 Proof.
661 Generic.paradox p.
662 (** Large universe *)
663 + exact U.
664 + exact (fun X=>X).
665 + cbn. exact (fun X F => forall x:X, F x).
666 + cbn. exact (fun _ _ x => x).
667 + cbn. exact (fun _ _ x => x).
668 + exact (fun F => forall x:A, F (up x)).
669 + cbn. exact (fun _ f => fun x:A => f (up x)).
670 + cbn. intros * f X.
671 specialize (f (down X)).
672 rewrite up_down in f.
673 exact f.
674 (** Small universe *)
675 + exact A.
676 (** The interpretation of [A] as a universe is [U]. *)
677 + cbn. exact up.
678 + cbn. exact (fun _ F => down (forall x, up (F x))).
679 + cbn. exact (fun _ F => down (forall x, up (F x))).
680 + cbn. exact (down False).
681 + rewrite up_down in p.
682 exact p.
683 + cbn. easy.
684 + cbn. intros ? f X.
685 destruct (up_down X). cbn.
686 reflexivity.
687 + cbn. intros ? ? f.
688 rewrite up_down.
689 exact f.
690 + cbn. intros ? ? f.
691 rewrite up_down in f.
692 exact f.
693 + cbn. intros ? ? f.
694 rewrite up_down.
695 exact f.
696 + cbn. intros ? ? f.
697 rewrite up_down in f.
698 exact f.
699 Qed.
700
701 End Paradox.
702
703 End TypeNeqSmallType.
704
705 (** * [Prop<>Type]. *)
706
707 (** Special case of [TypeNeqSmallType]. *)
708
709 Module PropNeqType.
710
711 Theorem paradox : Prop <> Type.
712 Proof.
713 intros h.
714 unshelve (refine (TypeNeqSmallType.paradox _ _)).
715 + exact Prop.
716 + easy.
717 Qed.
718
719 End PropNeqType.
720
721 (* end show *)