Debian Codegraph @

test-suite/bugs/bug_4287.v

raw
1 Unset Strict Universe Declaration.
2
3 Universe b.
4
5 Universe c.
6
7 Definition UU : Type@{b} := Type@{c}.
8
9 Module Type MT.
10
11 Definition T := Prop.
12 End MT.
13
14 Module M : MT.
15 Definition T := Type@{b}.
16
17 Print Universes.
18 Fail End M.
19
20 Reset T.
21 Definition T := Prop.
22 End M.
23
24 Set Universe Polymorphism.
25
26 (* This is a modified version of Hurkens with all universes floating *)
27 Section Hurkens.
28
29 Variable down : Type -> Type.
30 Variable up : Type -> Type.
31
32 Hypothesis back : forall A, up (down A) -> A.
33
34 Hypothesis forth : forall A, A -> up (down A).
35
36 Hypothesis backforth : forall (A:Type) (P:A->Type) (a:A),
37 P (back A (forth A a)) -> P a.
38
39 Hypothesis backforth_r : forall (A:Type) (P:A->Type) (a:A),
40 P a -> P (back A (forth A a)).
41
42 (** Proof *)
43 Definition V : Type := forall A:Type, ((up A -> Type) -> up A -> Type) -> up A -> Type.
44 Definition U : Type := V -> Type.
45
46 Definition sb (z:V) : V := fun A r a => r (z A r) a.
47 Definition le (i:U -> Type) (x:U) : Type := x (fun A r a => i (fun v => sb v A r a)).
48 Definition le' (i:up (down U) -> Type) (x:up (down U)) : Type := le (fun a:U => i (forth _ a)) (back _ x).
49 Definition induct (i:U -> Type) : Type := forall x:U, up (le i x) -> up (i x).
50 Definition WF : U := fun z => down (induct (fun a => z (down U) le' (forth _ a))).
51 Definition I (x:U) : Type :=
52 (forall i:U -> Type, up (le i x) -> up (i (fun v => sb v (down U) le' (forth _ x)))) -> False.
53
54 Lemma Omega : forall i:U -> Type, induct i -> up (i WF).
55 Proof.
56 intros i y.
57 apply y.
58 unfold le, WF, induct.
59 apply forth.
60 intros x H0.
61 apply y.
62 unfold sb, le', le.
63 compute.
64 apply backforth_r.
65 exact H0.
66 Qed.
67
68 Lemma lemma1 : induct (fun u => down (I u)).
69 Proof.
70 unfold induct.
71 intros x p.
72 apply forth.
73 intro q.
74 generalize (q (fun u => down (I u)) p).
75 intro r.
76 apply back in r.
77 apply r.
78 intros i j.
79 unfold le, sb, le', le in j |-.
80 apply backforth in j.
81 specialize q with (i := fun y => i (fun v:V => sb v (down U) le' (forth _ y))).
82 apply q.
83 exact j.
84 Qed.
85
86 Lemma lemma2 : (forall i:U -> Type, induct i -> up (i WF)) -> False.
87 Proof.
88 intro x.
89 generalize (x (fun u => down (I u)) lemma1).
90 intro r; apply back in r.
91 apply r.
92 intros i H0.
93 apply (x (fun y => i (fun v => sb v (down U) le' (forth _ y)))).
94 unfold le, WF in H0.
95 apply back in H0.
96 exact H0.
97 Qed.
98
99 Theorem paradox : False.
100 Proof.
101 exact (lemma2 Omega).
102 Qed.
103
104 End Hurkens.
105
106 Polymorphic Record box (T : Type) := wrap {unwrap : T}.
107
108 (* Here we instantiate to Set *)
109
110 Fail Definition down (x : Type) : Prop := box x.
111 Definition up (x : Prop) : Type := x.
112
113 Fail Definition back A : up (down A) -> A := unwrap A.
114
115 Fail Definition forth A : A -> up (down A) := wrap A.
116
117 Definition id {A : Type} (a : A) := a.
118 Definition setlt (A : Type@{i}) :=
119 let foo := Type@{i} : Type@{j} in True.
120
121 Definition setle (B : Type@{i}) :=
122 let foo (A : Type@{j}) := A in foo B.
123
124 Fail Check @setlt@{j Prop}.
125 Fail Definition foo := @setle@{j Prop}.
126 Check setlt@{Set i}.
127 Check setlt@{Set j}.