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
(************************************************************************)
9
(*i $Id: MonoList.v 8642 2006-03-17 10:09:02Z notin $ i*)
11
(** THIS IS A OLD CONTRIB. IT IS NO LONGER MAINTAINED ***)
15
Parameter List_Dom : Set.
16
Definition A := List_Dom.
18
Inductive list : Set :=
20
| cons : A -> list -> list.
22
Fixpoint app (l m:list) {struct l} : list :=
23
match l return list with
25
| cons a l1 => cons a (app l1 m)
29
Lemma app_nil_end : forall l:list, l = app l nil.
31
intro l; elim l; simpl in |- *; auto.
32
simple induction 1; auto.
34
Hint Resolve app_nil_end: list v62.
36
Lemma app_ass : forall l m n:list, app (app l m) n = app l (app m n).
38
intros l m n; elim l; simpl in |- *; auto with list.
39
simple induction 1; auto with list.
41
Hint Resolve app_ass: list v62.
43
Lemma ass_app : forall l m n:list, app l (app m n) = app (app l m) n.
47
Hint Resolve ass_app: list v62.
49
Definition tail (l:list) : list :=
50
match l return list with
56
Lemma nil_cons : forall (a:A) (m:list), nil <> cons a m.
60
(****************************************)
62
(****************************************)
64
Fixpoint length (l:list) : nat :=
65
match l return nat with
66
| cons _ m => S (length m)
70
(******************************)
71
(* Length order of lists *)
72
(******************************)
75
Definition lel (l m:list) := length l <= length m.
77
Hint Unfold lel: list.
80
Variables l m n : list.
82
Lemma lel_refl : lel l l.
84
unfold lel in |- *; auto with list.
87
Lemma lel_trans : lel l m -> lel m n -> lel l n.
89
unfold lel in |- *; intros.
90
apply le_trans with (length m); auto with list.
93
Lemma lel_cons_cons : lel l m -> lel (cons a l) (cons b m).
95
unfold lel in |- *; simpl in |- *; auto with list arith.
98
Lemma lel_cons : lel l m -> lel l (cons b m).
100
unfold lel in |- *; simpl in |- *; auto with list arith.
103
Lemma lel_tail : lel (cons a l) (cons b m) -> lel l m.
105
unfold lel in |- *; simpl in |- *; auto with list arith.
108
Lemma lel_nil : forall l':list, lel l' nil -> nil = l'.
110
intro l'; elim l'; auto with list arith.
112
(* <list>nil=(cons a' y)
113
============================
114
H0 : (lel (cons a' y) nil)
115
H : (lel y nil)->(<list>nil=y)
119
absurd (S (length y) <= 0); auto with list arith.
123
Hint Resolve lel_refl lel_cons_cons lel_cons lel_nil lel_nil nil_cons: list
126
Fixpoint In (a:A) (l:list) {struct l} : Prop :=
129
| cons b m => b = a \/ In a m
132
Lemma in_eq : forall (a:A) (l:list), In a (cons a l).
134
simpl in |- *; auto with list.
136
Hint Resolve in_eq: list v62.
138
Lemma in_cons : forall (a b:A) (l:list), In b l -> In b (cons a l).
140
simpl in |- *; auto with list.
142
Hint Resolve in_cons: list v62.
144
Lemma in_app_or : forall (l m:list) (a:A), In a (app l m) -> In a l \/ In a m.
147
elim l; simpl in |- *; auto with list.
149
(* ((<A>a0=a)\/(In a y))\/(In a m)
150
============================
151
H0 : (<A>a0=a)\/(In a (app y m))
152
H : (In a (app y m))->((In a y)\/(In a m))
158
elim H0; auto with list.
160
(* ((<A>a0=a)\/(In a y))\/(In a m)
161
============================
162
H1 : (In a (app y m)) *)
163
elim (H H1); auto with list.
165
Hint Immediate in_app_or: list v62.
167
Lemma in_or_app : forall (l m:list) (a:A), In a l \/ In a m -> In a (app l m).
170
elim l; simpl in |- *; intro H.
172
============================
177
elim H; auto with list; intro H0.
179
============================
181
elim H0. (* subProof completed *)
183
(* 2 (<A>H=a)\/(In a (app y m))
184
============================
185
H1 : ((<A>H=a)\/(In a y))\/(In a m)
186
H0 : ((In a y)\/(In a m))->(In a (app y m))
188
elim H1; auto 4 with list.
190
(* (<A>H=a)\/(In a (app y m))
191
============================
192
H2 : (<A>H=a)\/(In a y) *)
193
elim H2; auto with list.
195
Hint Resolve in_or_app: list v62.
197
Definition incl (l m:list) := forall a:A, In a l -> In a m.
199
Hint Unfold incl: list v62.
201
Lemma incl_refl : forall l:list, incl l l.
205
Hint Resolve incl_refl: list v62.
207
Lemma incl_tl : forall (a:A) (l m:list), incl l m -> incl l (cons a m).
211
Hint Immediate incl_tl: list v62.
213
Lemma incl_tran : forall l m n:list, incl l m -> incl m n -> incl l n.
218
Lemma incl_appl : forall l m n:list, incl l n -> incl l (app n m).
222
Hint Immediate incl_appl: list v62.
224
Lemma incl_appr : forall l m n:list, incl l n -> incl l (app m n).
228
Hint Immediate incl_appr: list v62.
231
forall (a:A) (l m:list), In a m -> incl l m -> incl (cons a l) m.
233
unfold incl in |- *; simpl in |- *; intros a l m H H0 a0 H1.
235
============================
236
H1 : (<A>a=a0)\/(In a0 l)
238
H0 : (a:A)(In a l)->(In a m)
244
(* 1 (<A>a=a0)->(In a0 m) *)
245
elim H1; auto with list; intro H2.
246
(* (<A>a=a0)->(In a0 m)
247
============================
249
elim H2; auto with list. (* solves subgoal *)
250
(* 2 (In a0 l)->(In a0 m) *)
253
Hint Resolve incl_cons: list v62.
255
Lemma incl_app : forall l m n:list, incl l n -> incl m n -> incl (app l m) n.
257
unfold incl in |- *; simpl in |- *; intros l m n H H0 a H1.
259
============================
260
H1 : (In a (app l m))
262
H0 : (a:A)(In a m)->(In a n)
263
H : (a:A)(In a l)->(In a n)
267
elim (in_app_or l m a); auto with list.
269
Hint Resolve incl_app: list v62.
b'\\ No newline at end of file'