]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground/lib/list_rcons.ma
update in ground
[helm.git] / matita / matita / contribs / lambdadelta / ground / lib / list_rcons.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "ground/notation/functions/oplusleft_3.ma".
16 include "ground/lib/list_append.ma".
17 include "ground/generated/pull_2.ma". 
18
19 (* RIGHT CONS FOR LISTS *****************************************************)
20
21 interpretation
22   "right cons (lists)"
23   'OPlusLeft A hd tl = (list_append A hd (list_lcons A tl (list_empty A))).
24
25 (* Basic constructions ******************************************************)
26
27 lemma list_cons_comm (A):
28       ∀a. a ⨮ ⓔ = ⓔ ⨭{A} a.
29 // qed.
30
31 lemma list_cons_shift (A):
32       ∀a1,l,a2. a1 ⨮{A} l ⨭ a2 = (a1 ⨮ l) ⨭ a2.
33 // qed.
34
35 (* Advanced constructions ***************************************************)
36
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.
40 // qed.
41
42 lemma list_append_rcons_dx (A):
43       ∀l1,l2,a. (l1 ⨁ l2) ⨭ a = l1 ⨁{A} (l2 ⨭ a).
44 // qed.
45
46 (* Basic inversions *********************************************************)
47
48 lemma eq_inv_list_empty_rcons (A):
49       ∀l,a. ⓔ = l⨭{A}a → ⊥.
50 #A #l #a #H0
51 elim (eq_inv_list_empty_append … H0) -H0 #_ #H0 destruct
52 qed-.
53
54 lemma eq_inv_list_rcons_empty (A):
55       ∀l,a. l⨭{A}a = ⓔ → ⊥.
56 #A #l #a #H0
57 elim (eq_inv_list_append_empty … H0) -H0 #_ #H0 destruct
58 qed-.
59
60 (* Advanced inversions ******************************************************)
61
62 lemma eq_inv_list_rcons_bi (A):
63       ∀a1,a2,l1,l2. l1 ⨭{A} a1 = l2 ⨭ a2 →
64       ∧∧ l1 = l2 & a1 = a2.
65 #A #a1 #a2 #l1 elim l1 -l1 [| #b1 #l1 #IH ] *
66 [ <list_append_empty_sn <list_append_empty_sn #H destruct
67   /2 width=1 by conj/
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
74   /2 width=1 by conj/
75 ]
76 qed-.
77
78 (* Advanced eliminations ****************************************************)
79
80 lemma list_ind_rcons (A) (Q:predicate …):
81       Q (ⓔ{A}) →
82       (∀l,a. Q l -> Q (l⨭a)) →
83       ∀l. Q l.
84 #A #Q #IH1 #IH2 #l
85 @(list_ind_append_dx … l) -l //
86 @pull_2 #l2 elim l2 -l2 //
87 #a2 #l2 #IH0 #l1 #IH /3 width=1 by/
88 qed-.
89
90 (* Advanced inversions with list_append *************************************)
91
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 #_
97 /2 width=1 by/
98 qed-.