1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "ground/notation/functions/oplusleft_3.ma".
16 include "ground/lib/list_append.ma".
17 include "ground/generated/pull_2.ma".
19 (* RIGHT CONS FOR LISTS *****************************************************)
23 'OPlusLeft A hd tl = (list_append A hd (list_lcons A tl (list_empty A))).
25 (* Basic constructions ******************************************************)
27 lemma list_cons_comm (A):
31 lemma list_cons_shift (A):
32 ∀a1,l,a2. a1 ⨮{A} l ⨭ a2 = (a1 ⨮ l) ⨭ a2.
35 (* Advanced constructions ***************************************************)
37 (* Note: this is list_append_lcons_dx *)
38 lemma list_append_rcons_sn (A):
39 ∀l1,l2,a. l1 ⨁ (a ⨮ l2) = (l1 ⨭ a) ⨁{A} l2.
42 lemma list_append_rcons_dx (A):
43 ∀l1,l2,a. (l1 ⨁ l2) ⨭ a = l1 ⨁{A} (l2 ⨭ a).
46 (* Basic inversions *********************************************************)
48 lemma eq_inv_list_empty_rcons (A):
51 elim (eq_inv_list_empty_append … H0) -H0 #_ #H0 destruct
54 lemma eq_inv_list_rcons_empty (A):
57 elim (eq_inv_list_append_empty … H0) -H0 #_ #H0 destruct
60 (* Advanced inversions ******************************************************)
62 lemma eq_inv_list_rcons_bi (A):
63 ∀a1,a2,l1,l2. l1 ⨭{A} a1 = l2 ⨭ a2 →
65 #A #a1 #a2 #l1 elim l1 -l1 [| #b1 #l1 #IH ] *
66 [ <list_append_empty_sn <list_append_empty_sn #H destruct
68 | #b2 #l2 <list_append_empty_sn <list_append_lcons_sn #H destruct -H
69 elim (eq_inv_list_empty_rcons ??? e0)
70 | <list_append_lcons_sn <list_append_empty_sn #H destruct -H
71 elim (eq_inv_list_empty_rcons ??? (sym_eq … e0))
72 | #b2 #l2 <list_append_lcons_sn <list_append_lcons_sn #H destruct -H
73 elim (IH … e0) -IH -e0 #H1 #H2 destruct
78 (* Advanced eliminations ****************************************************)
80 lemma list_ind_rcons (A) (Q:predicate …):
82 (∀l,a. Q l -> Q (l⨭a)) →
85 @(list_ind_append_dx … l) -l //
86 @pull_2 #l2 elim l2 -l2 //
87 #a2 #l2 #IH0 #l1 #IH /3 width=1 by/
90 (* Advanced inversions with list_append *************************************)
92 lemma eq_inv_list_append_dx_dx_refl (A) (l1) (l2):
93 l1 = l2⨁{A}l1 → ⓔ = l2.
94 #A #l1 @(list_ind_rcons … l1) -l1 [ // ]
95 #l1 #a1 #IH #l2 <list_append_rcons_dx #H0
96 elim (eq_inv_list_rcons_bi ????? H0) -H0 #H0 #_