Debian Codegraph @

test-suite/bugs/bug_5797.v

raw
1 Set Implicit Arguments.
2
3 Open Scope type_scope.
4
5 Inductive One : Set := inOne: One.
6
7 Definition maybe: forall A B:Set,(A -> B) -> One + A -> One + B.
8 Proof.
9 intros A B f c.
10 case c.
11 left; assumption.
12 right; apply f; assumption.
13 Defined.
14
15 Definition id (A:Set)(a:A):=a.
16
17 Definition LamF (X: Set -> Set)(A:Set) :Set :=
18 A + (X A)*(X A) + X(One + A).
19
20 Definition LamF' (X: Set -> Set)(A:Set) :Set :=
21 LamF X A.
22
23 Definition index := list bool.
24
25 Inductive L (A:Set) : index -> Set :=
26 initL: A -> L A nil
27 | pluslL: forall l:index, One -> L A (cons false l)
28 | plusrL: forall l:index, L A l -> L A (cons false l)
29 | varL: forall l:index, L A l -> L A (cons true l)
30 | appL: forall l:index, L A (cons true l) -> L A (cons true l) -> L A (cons true l)
31 | absL: forall l:index, L A (cons true (cons false l)) -> L A (cons true l).
32
33 Scheme L_rec_simp := Minimality for L Sort Set.
34
35 Definition Lam' (A:Set) := L A (cons true nil).
36
37 Definition aczelapp: forall (l1 l2: index)(A:Set), L (L A l2) l1 -> L A
38 (app l1 l2).
39 Proof.
40 intros l1 l2 A.
41 generalize l1.
42 clear l1.
43 (* Check (fun i:index => L A (i++l2)). *)
44 apply (L_rec_simp (A:=L A l2) (fun i:index => L A (app i l2))).
45 trivial.
46 intros l o.
47 simpl app.
48 apply pluslL; assumption.
49 intros l _ t.
50 simpl app.
51 apply plusrL; assumption.
52 intros l _ t.
53 simpl app.
54 apply varL; assumption.
55 intros l _ t1 _ t2.
56 simpl app in *|-*.
57 Check 0.
58 apply appL; [exact t1| exact t2].
59 intros l _ t.
60 simpl app in *|-*.
61 Check 0.
62 apply absL; assumption.
63 Defined.
64
65 Definition monL: forall (l:index)(A:Set)(B:Set), (A->B) -> L A l -> L B l.
66 Proof.
67 intros l A B f.
68 intro t.
69 elim t.
70 intro a.
71 exact (initL (f a)).
72 intros i u.
73 exact (pluslL _ _ u).
74 intros i _ r.
75 exact (plusrL r).
76 intros i _ r.
77 exact (varL r).
78 intros i _ r1 _ r2.
79 exact (appL r1 r2).
80 intros i _ r.
81 exact (absL r).
82 Defined.
83
84 Definition lam': forall (A B:Set), (A -> B) -> Lam' A -> Lam' B.
85 Proof.
86 intros A B f t.
87 unfold Lam' in *|-*.
88 Check 0.
89 exact (monL f t).
90 Defined.
91
92 Definition inLam': forall A:Set, LamF' Lam' A -> Lam' A.
93 Proof.
94 intros A [[a|[t1 t2]]|r].
95 unfold Lam'.
96 exact (varL (initL a)).
97 exact (appL t1 t2).
98 unfold Lam' in * |- *.
99 Check 0.
100 apply absL.
101 change (L A (app (cons true nil) (cons false nil))).
102 apply aczelapp.
103 (* Check (fun x:One + A => (match (maybe (fun a:A => initL a) x) with
104 | inl u => pluslL _ _ u
105 | inr t' => plusrL t' end)). *)
106 exact (monL (fun x:One + A =>
107 (match (maybe (fun a:A => initL a) x) with
108 | inl u => pluslL _ _ u
109 | inr t' => plusrL t' end)) r).
110 Defined.
111
112 Section minimal.
113
114 Definition sub1 (F G: Set -> Set):= forall A:Set, F A->G A.
115 Hypothesis G: Set -> Set.
116 Hypothesis step: sub1 (LamF' G) G.
117
118 Fixpoint L'(A:Set)(i:index){struct i} : Set :=
119 match i with
120 nil => A
121 | cons false l => One + L' A l
122 | cons true l => G (L' A l)
123 end.
124
125 Definition LinL': forall (A:Set)(i:index), L A i -> L' A i.
126 Proof.
127 intros A i t.
128 elim t.
129 intro a.
130 unfold L'.
131 assumption.
132 intros l u.
133 left; assumption.
134 intros l _ r.
135 right; assumption.
136 intros l _ r.
137 apply (step (A:=L' A l)).
138 exact (inl _ (inl _ r)).
139 intros l _ r1 _ r2.
140 apply (step (A:=L' A l)).
141 (* unfold L' in * |- *.
142 Check 0. *)
143 exact (inl _ (inr _ (pair r1 r2))).
144 intros l _ r.
145 apply (step (A:=L' A l)).
146 exact (inr _ r).
147 Defined.
148
149 Definition L'inG: forall A: Set, L' A (cons true nil) -> G A.
150 Proof.
151 intros A t.
152 unfold L' in t.
153 assumption.
154 Defined.
155
156 Definition Itbasic: sub1 Lam' G.
157 Proof.
158 intros A t.
159 apply L'inG.
160 unfold Lam' in t.
161 exact (LinL' t).
162 Defined.
163
164 End minimal.
165
166 Definition recid := Itbasic inLam'.
167
168 Definition L'Lam'inL: forall (i:index)(A:Set), L' Lam' A i -> L A i.
169 Proof.
170 intros i A t.
171 induction i.
172 unfold L' in t.
173 apply initL.
174 assumption.
175 induction a.
176 simpl L' in t.
177 apply (aczelapp (l1:=cons true nil) (l2:=i)).
178 exact (lam' IHi t).
179 simpl L' in t.
180 induction t.
181 exact (pluslL _ _ a).
182 exact (plusrL (IHi b)).
183 Defined.
184
185
186 Lemma recidgen: forall(A:Set)(i:index)(t:L A i), L'Lam'inL i A (LinL' inLam' t)
187 = t.
188 Proof.
189 intros A i t.
190 induction t.
191 trivial.
192 trivial.
193 simpl.
194 rewrite IHt.
195 trivial.
196 simpl L'Lam'inL.
197 rewrite IHt.
198 trivial.
199 simpl L'Lam'inL.
200 simpl L'Lam'inL in IHt1.
201 unfold lam' in IHt1.
202 simpl L'Lam'inL in IHt2.
203 unfold lam' in IHt2.
204
205 (* going on. This fails for the original solution. *)
206 rewrite IHt1.
207 rewrite IHt2.
208 trivial.
209 Abort. (* one goal still left *)