aboutsummaryrefslogtreecommitdiffhomepage
path: root/test-suite/bugs/closed/846.v
blob: ee5ec1fa6a4d0582aa1890a37dfa665eeb09bcbb (plain)
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
Set Implicit Arguments.

Open Scope type_scope.

Inductive One : Set := inOne: One.

Definition maybe: forall A B:Set,(A -> B) -> One + A -> One + B.
Proof.
  intros A B f c.
  case c.
  left; assumption.
  right; apply f; assumption.
Defined.

Definition id (A:Set)(a:A):=a.

Definition LamF (X: Set -> Set)(A:Set) :Set :=
  A + (X A)*(X A) + X(One + A).

Definition LamF' (X: Set -> Set)(A:Set) :Set :=
  LamF X A.

Require Import List.
Require Import Bool.

Definition index := list bool.

Inductive L (A:Set) : index -> Set :=
  initL: A -> L A nil
  | pluslL: forall l:index, One -> L A (false::l)
  | plusrL: forall l:index, L A l -> L A (false::l)
  | varL: forall l:index, L A l -> L A (true::l)
  | appL: forall l:index, L A (true::l) -> L A (true::l) -> L A (true::l)
  | absL: forall l:index, L A (true::false::l) -> L A (true::l).

Scheme L_rec_simp := Minimality for L Sort Set.

Definition Lam' (A:Set) := L A (true::nil).

Definition aczelapp: forall (l1 l2: index)(A:Set), L (L A l2) l1 -> L A
  (l1++l2).
Proof.
  intros l1 l2 A.
  generalize l1.
  clear l1.
  (* Check (fun i:index => L A (i++l2)). *)
  apply (L_rec_simp (A:=L A l2) (fun i:index => L A (i++l2))).
  trivial.
  intros l o.
  simpl app.
  apply pluslL; assumption.
  intros l _ t.
  simpl app.
  apply plusrL; assumption.
  intros l _ t.
  simpl app.
  apply varL; assumption.
  intros l _ t1 _ t2.
  simpl app in *|-*.
  Check 0.
  apply appL; [exact t1| exact t2].
  intros l _ t.
  simpl app in *|-*.
  Check 0.
  apply absL; assumption.
Defined.

Definition monL: forall (l:index)(A:Set)(B:Set), (A->B) -> L A l -> L B l.
Proof.
  intros l A B f.
  intro t.
  elim t.
  intro a.
  exact (initL (f a)).
  intros i u.
  exact (pluslL _ _ u).
  intros i _ r.
  exact (plusrL r).
  intros i _ r.
  exact (varL r).
  intros i _ r1 _ r2.
  exact (appL r1 r2).
  intros i _ r.
  exact (absL r).
Defined.

Definition lam': forall (A B:Set), (A -> B) -> Lam' A -> Lam' B.
Proof.
  intros A B f t.
  unfold Lam' in *|-*.
  Check 0.
  exact (monL f t).
Defined.

Definition inLam': forall A:Set, LamF' Lam' A -> Lam' A.
Proof.
  intros A [[a|[t1 t2]]|r].
  unfold Lam'.
  exact (varL (initL a)).
  exact (appL t1 t2).
  unfold Lam' in * |- *.
  Check 0.
  apply absL.
  change (L A ((true::nil) ++ (false::nil))).
  apply aczelapp.
  (* Check (fun x:One + A =>  (match (maybe (fun a:A => initL a) x) with
    | inl u => pluslL _ _ u
    | inr t' => plusrL t' end)). *)
  exact (monL (fun x:One + A =>
    (match (maybe (fun a:A => initL a) x) with
       | inl u => pluslL _ _ u
       | inr t' => plusrL t' end)) r).
Defined.

Section minimal.

Definition sub1 (F G: Set -> Set):= forall A:Set, F A->G A.
Hypothesis G: Set -> Set.
Hypothesis step: sub1 (LamF' G) G.

Fixpoint L'(A:Set)(i:index){struct i} : Set :=
  match i with
    nil => A
    | false::l => One + L' A l
    | true::l => G (L' A l)
  end.

Definition LinL': forall (A:Set)(i:index), L A i -> L' A i.
Proof.
  intros A i t.
  elim t.
  intro a.
  unfold L'.
  assumption.
  intros l u.
  left; assumption.
  intros l _ r.
  right; assumption.
  intros l _ r.
  apply (step (A:=L' A l)).
  exact (inl _ (inl _ r)).
  intros l _ r1 _ r2.
  apply (step (A:=L' A l)).
  (* unfold L' in * |- *.
  Check 0. *)
  exact (inl _ (inr _ (pair r1 r2))).
  intros l _ r.
  apply  (step (A:=L' A l)).
  exact (inr _ r).
Defined.

Definition L'inG: forall A: Set, L' A (true::nil) -> G A.
Proof.
  intros A t.
  unfold L' in t.
  assumption.
Defined.

Definition Itbasic: sub1 Lam' G.
Proof.
  intros A t.
  apply L'inG.
  unfold Lam' in t.
  exact (LinL' t).
Defined.

End minimal.

Definition recid := Itbasic inLam'.

Definition L'Lam'inL: forall (i:index)(A:Set), L' Lam' A i -> L A i.
Proof.
  intros i A t.
  induction i.
  unfold L' in t.
  apply initL.
  assumption.
  induction a.
  simpl L' in t.
  apply (aczelapp (l1:=true::nil) (l2:=i)).
  exact (lam' IHi t).
  simpl L' in t.
  induction t.
  exact (pluslL _ _ a).
  exact (plusrL (IHi b)).
Defined.


Lemma recidgen: forall(A:Set)(i:index)(t:L A i), L'Lam'inL i A (LinL' inLam' t)
  = t.
Proof.
  intros A i t.
  induction t.
  trivial.
  trivial.
  simpl.
  rewrite IHt.
  trivial.
  simpl L'Lam'inL.
  rewrite IHt.
  trivial.
  simpl L'Lam'inL.
  simpl L'Lam'inL in IHt1.
  unfold lam' in IHt1.
  simpl L'Lam'inL in IHt2.
  unfold lam' in IHt2.

  (* going on. This fails for the original solution. *)
  rewrite IHt1.
  rewrite IHt2.
  trivial.
Abort. (* one goal still left *)