~ubuntu-branches/ubuntu/wily/coq-doc/wily

« back to all changes in this revision

Viewing changes to theories/Wellfounded/Lexicographic_Exponentiation.v

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu, Stéphane Glondu, Samuel Mimram
  • Date: 2010-01-07 22:50:39 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100107225039-n3cq82589u0qt0s2
Tags: 8.2pl1-1
[ Stéphane Glondu ]
* New upstream release (Closes: #563669)
  - remove patches
* Packaging overhaul:
  - use git, advertise it in Vcs-* fields of debian/control
  - use debhelper 7 and dh with override
  - use source format 3.0 (quilt)
* debian/control:
  - set Maintainer to d-o-m, set Uploaders to Sam and myself
  - add Homepage field
  - bump Standards-Version to 3.8.3
* Register PDF documentation into doc-base
* Add debian/watch
* Update debian/copyright

[ Samuel Mimram ]
* Change coq-doc's description to mention that it provides documentation in
  pdf format, not postscript, closes: #543545.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(************************************************************************)
 
2
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
 
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
 
4
(*   \VV/  **************************************************************)
 
5
(*    //   *      This file is distributed under the terms of the       *)
 
6
(*         *       GNU Lesser General Public License Version 2.1        *)
 
7
(************************************************************************)
 
8
 
 
9
(*i $Id: Lexicographic_Exponentiation.v 9609 2007-02-07 14:42:26Z herbelin $ i*)
 
10
 
 
11
(** Author: Cristina Cornes
 
12
 
 
13
    From : Constructing Recursion Operators in Type Theory                
 
14
           L. Paulson  JSC (1986) 2, 325-355  *)
 
15
 
 
16
Require Import List.
 
17
Require Import Relation_Operators.
 
18
Require Import Transitive_Closure.
 
19
 
 
20
Section Wf_Lexicographic_Exponentiation.
 
21
  Variable A : Set.
 
22
  Variable leA : A -> A -> Prop.
 
23
  
 
24
  Notation Power := (Pow A leA).
 
25
  Notation Lex_Exp := (lex_exp A leA).
 
26
  Notation ltl := (Ltl A leA).
 
27
  Notation Descl := (Desc A leA).
 
28
  
 
29
  Notation List := (list A).
 
30
  Notation Nil := (nil (A:=A)).
 
31
  (* useless but symmetric *)
 
32
  Notation Cons := (cons (A:=A)).
 
33
  Notation "<< x , y >>" := (exist Descl x y) (at level 0, x, y at level 100).
 
34
 
 
35
  (* Hint Resolve d_one d_nil t_step. *)
 
36
  
 
37
  Lemma left_prefix : forall x y z:List, ltl (x ++ y) z -> ltl x z.
 
38
  Proof.
 
39
    simple induction x.
 
40
    simple induction z.
 
41
    simpl in |- *; intros H.
 
42
    inversion_clear H. 
 
43
    simpl in |- *; intros; apply (Lt_nil A leA).
 
44
    intros a l HInd.
 
45
    simpl in |- *.
 
46
    intros.
 
47
    inversion_clear H.
 
48
    apply (Lt_hd A leA); auto with sets.
 
49
    apply (Lt_tl A leA).
 
50
    apply (HInd y y0); auto with sets.
 
51
  Qed.
 
52
 
 
53
 
 
54
  Lemma right_prefix :
 
55
    forall x y z:List,
 
56
      ltl x (y ++ z) -> ltl x y \/ (exists y' : List, x = y ++ y' /\ ltl y' z).
 
57
  Proof.
 
58
    intros x y; generalize x.
 
59
    elim y; simpl in |- *.
 
60
    right.
 
61
    exists x0; auto with sets.
 
62
    intros.
 
63
    inversion H0.
 
64
    left; apply (Lt_nil A leA).
 
65
    left; apply (Lt_hd A leA); auto with sets.
 
66
    generalize (H x1 z H3).
 
67
    simple induction 1.
 
68
    left; apply (Lt_tl A leA); auto with sets.
 
69
    simple induction 1.
 
70
    simple induction 1; intros.
 
71
    rewrite H8.
 
72
    right; exists x2; auto with sets.
 
73
  Qed.
 
74
  
 
75
  Lemma desc_prefix : forall (x:List) (a:A), Descl (x ++ Cons a Nil) -> Descl x.
 
76
  Proof.
 
77
    intros.
 
78
    inversion H.
 
79
    generalize (app_cons_not_nil _ _ _ H1); simple induction 1. 
 
80
    cut (x ++ Cons a Nil = Cons x0 Nil); auto with sets.
 
81
    intro.
 
82
    generalize (app_eq_unit _ _ H0).
 
83
    simple induction 1; simple induction 1; intros.
 
84
    rewrite H4; auto using d_nil with sets.
 
85
    discriminate H5.
 
86
    generalize (app_inj_tail _ _ _ _ H0).
 
87
    simple induction 1; intros.
 
88
    rewrite <- H4; auto with sets.
 
89
  Qed.
 
90
  
 
91
  Lemma desc_tail :
 
92
    forall (x:List) (a b:A),
 
93
      Descl (Cons b (x ++ Cons a Nil)) -> clos_trans A leA a b.
 
94
  Proof.
 
95
    intro.
 
96
    apply rev_ind with
 
97
      (A := A)
 
98
      (P := fun x:List =>
 
99
        forall a b:A,
 
100
          Descl (Cons b (x ++ Cons a Nil)) -> clos_trans A leA a b).
 
101
    intros.
 
102
    
 
103
    inversion H.
 
104
    cut (Cons b (Cons a Nil) = (Nil ++ Cons b Nil) ++ Cons a Nil);
 
105
      auto with sets; intro.
 
106
    generalize H0.
 
107
    intro.
 
108
    generalize (app_inj_tail (l ++ Cons y Nil) (Nil ++ Cons b Nil) _ _ H4);
 
109
      simple induction 1.
 
110
    intros.
 
111
    
 
112
    generalize (app_inj_tail _ _ _ _ H6); simple induction 1; intros.
 
113
    generalize H1.
 
114
    rewrite <- H10; rewrite <- H7; intro.
 
115
    apply (t_step A leA); auto with sets.
 
116
    
 
117
    intros.
 
118
    inversion H0.
 
119
    generalize (app_cons_not_nil _ _ _ H3); intro.
 
120
    elim H1.
 
121
    
 
122
    generalize H0.
 
123
    generalize (app_comm_cons (l ++ Cons x0 Nil) (Cons a Nil) b);
 
124
      simple induction 1.
 
125
    intro.
 
126
    generalize (desc_prefix (Cons b (l ++ Cons x0 Nil)) a H5); intro.
 
127
    generalize (H x0 b H6).
 
128
    intro.
 
129
    apply t_trans with (A := A) (y := x0); auto with sets.
 
130
    
 
131
    apply t_step.
 
132
    generalize H1.
 
133
    rewrite H4; intro.
 
134
    
 
135
    generalize (app_inj_tail _ _ _ _ H8); simple induction 1.
 
136
    intros.
 
137
    generalize H2; generalize (app_comm_cons l (Cons x0 Nil) b).
 
138
    intro.
 
139
    generalize H10.
 
140
    rewrite H12; intro.
 
141
    generalize (app_inj_tail _ _ _ _ H13); simple induction 1.
 
142
    intros.
 
143
    rewrite <- H11; rewrite <- H16; auto with sets.
 
144
  Qed.
 
145
 
 
146
 
 
147
  Lemma dist_aux :
 
148
    forall z:List, Descl z -> forall x y:List, z = x ++ y -> Descl x /\ Descl y.
 
149
  Proof.
 
150
    intros z D.
 
151
    elim D.
 
152
    intros.
 
153
    cut (x ++ y = Nil); auto with sets; intro.
 
154
    generalize (app_eq_nil _ _ H0); simple induction 1.
 
155
    intros.
 
156
    rewrite H2; rewrite H3; split; apply d_nil.
 
157
    
 
158
    intros.
 
159
    cut (x0 ++ y = Cons x Nil); auto with sets.
 
160
    intros E.
 
161
    generalize (app_eq_unit _ _ E); simple induction 1.
 
162
    simple induction 1; intros.
 
163
    rewrite H2; rewrite H3; split.
 
164
    apply d_nil.
 
165
    
 
166
    apply d_one.
 
167
    
 
168
    simple induction 1; intros.
 
169
    rewrite H2; rewrite H3; split.
 
170
    apply d_one.
 
171
    
 
172
    apply d_nil.
 
173
    
 
174
    do 5 intro.
 
175
    intros Hind.
 
176
    do 2 intro.
 
177
    generalize x0.
 
178
    apply rev_ind with
 
179
      (A := A)
 
180
      (P := fun y0:List =>
 
181
        forall x0:List,
 
182
          (l ++ Cons y Nil) ++ Cons x Nil = x0 ++ y0 ->
 
183
          Descl x0 /\ Descl y0).
 
184
    
 
185
    intro.
 
186
    generalize (app_nil_end x1); simple induction 1; simple induction 1.
 
187
    split. apply d_conc; auto with sets.
 
188
    
 
189
    apply d_nil.
 
190
    
 
191
    do 3 intro.
 
192
    generalize x1.
 
193
    apply rev_ind with
 
194
      (A := A)
 
195
      (P := fun l0:List =>
 
196
        forall (x1:A) (x0:List),
 
197
          (l ++ Cons y Nil) ++ Cons x Nil = x0 ++ l0 ++ Cons x1 Nil ->
 
198
          Descl x0 /\ Descl (l0 ++ Cons x1 Nil)).
 
199
 
 
200
 
 
201
    simpl in |- *.
 
202
    split.
 
203
    generalize (app_inj_tail _ _ _ _ H2); simple induction 1.
 
204
    simple induction 1; auto with sets.
 
205
    
 
206
    apply d_one.
 
207
    do 5 intro.
 
208
    generalize (app_ass x4 (l1 ++ Cons x2 Nil) (Cons x3 Nil)).
 
209
    simple induction 1.
 
210
    generalize (app_ass x4 l1 (Cons x2 Nil)); simple induction 1.
 
211
    intro E.
 
212
    generalize (app_inj_tail _ _ _ _ E).
 
213
    simple induction 1; intros.
 
214
    generalize (app_inj_tail _ _ _ _ H6); simple induction 1; intros.
 
215
    rewrite <- H7; rewrite <- H10; generalize H6.
 
216
    generalize (app_ass x4 l1 (Cons x2 Nil)); intro E1.
 
217
    rewrite E1.
 
218
    intro.
 
219
    generalize (Hind x4 (l1 ++ Cons x2 Nil) H11).
 
220
    simple induction 1; split.
 
221
    auto with sets.
 
222
    
 
223
    generalize H14.
 
224
    rewrite <- H10; intro.
 
225
    apply d_conc; auto with sets.
 
226
  Qed.
 
227
 
 
228
 
 
229
 
 
230
  Lemma dist_Desc_concat :
 
231
    forall x y:List, Descl (x ++ y) -> Descl x /\ Descl y.
 
232
  Proof.
 
233
    intros.
 
234
    apply (dist_aux (x ++ y) H x y); auto with sets.
 
235
  Qed.
 
236
  
 
237
  Lemma desc_end :
 
238
    forall (a b:A) (x:List),
 
239
      Descl (x ++ Cons a Nil) /\ ltl (x ++ Cons a Nil) (Cons b Nil) ->
 
240
      clos_trans A leA a b. 
 
241
  Proof.
 
242
    intros a b x.
 
243
    case x.
 
244
    simpl in |- *.
 
245
    simple induction 1.
 
246
    intros.
 
247
    inversion H1; auto with sets.
 
248
    inversion H3.
 
249
    
 
250
    simple induction 1.
 
251
    generalize (app_comm_cons l (Cons a Nil) a0).
 
252
    intros E; rewrite <- E; intros.
 
253
    generalize (desc_tail l a a0 H0); intro.
 
254
    inversion H1.
 
255
    apply t_trans with (y := a0); auto with sets.
 
256
    
 
257
    inversion H4.
 
258
  Qed.
 
259
 
 
260
 
 
261
 
 
262
 
 
263
  Lemma ltl_unit :
 
264
    forall (x:List) (a b:A),
 
265
      Descl (x ++ Cons a Nil) ->
 
266
      ltl (x ++ Cons a Nil) (Cons b Nil) -> ltl x (Cons b Nil).
 
267
  Proof.
 
268
    intro.
 
269
    case x.
 
270
    intros; apply (Lt_nil A leA).
 
271
    
 
272
    simpl in |- *; intros.
 
273
    inversion_clear H0.
 
274
    apply (Lt_hd A leA a b); auto with sets.
 
275
    
 
276
    inversion_clear H1.
 
277
  Qed.
 
278
  
 
279
  
 
280
  Lemma acc_app :
 
281
    forall (x1 x2:List) (y1:Descl (x1 ++ x2)),
 
282
      Acc Lex_Exp << x1 ++ x2, y1 >> ->
 
283
      forall (x:List) (y:Descl x), ltl x (x1 ++ x2) -> Acc Lex_Exp << x, y >>.
 
284
  Proof.
 
285
    intros.
 
286
    apply (Acc_inv (R:=Lex_Exp) (x:=<< x1 ++ x2, y1 >>)).
 
287
    auto with sets.
 
288
    
 
289
    unfold lex_exp in |- *; simpl in |- *; auto with sets.
 
290
  Qed.
 
291
  
 
292
  
 
293
  Theorem wf_lex_exp : well_founded leA -> well_founded Lex_Exp.
 
294
  Proof.
 
295
    unfold well_founded at 2 in |- *.
 
296
    simple induction a; intros x y.
 
297
    apply Acc_intro.
 
298
    simple induction y0.
 
299
    unfold lex_exp at 1 in |- *; simpl in |- *.
 
300
    apply rev_ind with
 
301
      (A := A)
 
302
      (P := fun x:List =>
 
303
        forall (x0:List) (y:Descl x0), ltl x0 x -> Acc Lex_Exp << x0, y >>).
 
304
    intros.
 
305
    inversion_clear H0.
 
306
    
 
307
    intro.
 
308
    generalize (well_founded_ind (wf_clos_trans A leA H)).
 
309
    intros GR.
 
310
    apply GR with
 
311
      (P := fun x0:A =>
 
312
        forall l:List,
 
313
          (forall (x1:List) (y:Descl x1),
 
314
            ltl x1 l -> Acc Lex_Exp << x1, y >>) ->
 
315
          forall (x1:List) (y:Descl x1),
 
316
            ltl x1 (l ++ Cons x0 Nil) -> Acc Lex_Exp << x1, y >>).
 
317
    intro; intros HInd; intros.
 
318
    generalize (right_prefix x2 l (Cons x1 Nil) H1).
 
319
    simple induction 1.
 
320
    intro; apply (H0 x2 y1 H3).
 
321
    
 
322
    simple induction 1.
 
323
    intro; simple induction 1.
 
324
    clear H4 H2.
 
325
    intro; generalize y1; clear y1.
 
326
    rewrite H2.
 
327
    apply rev_ind with
 
328
      (A := A)
 
329
      (P := fun x3:List =>
 
330
        forall y1:Descl (l ++ x3),
 
331
          ltl x3 (Cons x1 Nil) -> Acc Lex_Exp << l ++ x3, y1 >>).
 
332
    intros.
 
333
    generalize (app_nil_end l); intros Heq.
 
334
    generalize y1.
 
335
    clear y1.
 
336
    rewrite <- Heq.
 
337
    intro.
 
338
    apply Acc_intro.
 
339
    simple induction y2.
 
340
    unfold lex_exp at 1 in |- *.
 
341
    simpl in |- *; intros x4 y3. intros.
 
342
    apply (H0 x4 y3); auto with sets.
 
343
    
 
344
    intros. 
 
345
    generalize (dist_Desc_concat l (l0 ++ Cons x4 Nil) y1).
 
346
    simple induction 1.
 
347
    intros.
 
348
    generalize (desc_end x4 x1 l0 (conj H8 H5)); intros.
 
349
    generalize y1.
 
350
    rewrite <- (app_ass l l0 (Cons x4 Nil)); intro.
 
351
    generalize (HInd x4 H9 (l ++ l0)); intros HInd2.
 
352
    generalize (ltl_unit l0 x4 x1 H8 H5); intro.
 
353
    generalize (dist_Desc_concat (l ++ l0) (Cons x4 Nil) y2).
 
354
    simple induction 1; intros.
 
355
    generalize (H4 H12 H10); intro.
 
356
    generalize (Acc_inv H14).
 
357
    generalize (acc_app l l0 H12 H14).
 
358
    intros f g.
 
359
    generalize (HInd2 f); intro.
 
360
    apply Acc_intro.
 
361
    simple induction y3.
 
362
    unfold lex_exp at 1 in |- *; simpl in |- *; intros.
 
363
    apply H15; auto with sets.
 
364
  Qed.
 
365
 
 
366
 
 
367
End Wf_Lexicographic_Exponentiation.