]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground/lib/list_rcons.ma
update in delayed_updating
[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 (* Advanced inversions ******************************************************)
55
56 lemma eq_inv_list_rcons_bi (A):
57       ∀a1,a2,l1,l2. l1 ⨭{A} a1 = l2 ⨭ a2 →
58       ∧∧ l1 = l2 & a1 = a2.
59 #A #a1 #a2 #l1 elim l1 -l1 [| #b1 #l1 #IH ] *
60 [ <list_append_empty_sn <list_append_empty_sn #H destruct
61   /2 width=1 by conj/
62 | #b2 #l2 <list_append_empty_sn <list_append_lcons_sn #H destruct -H
63   elim (eq_inv_list_empty_rcons ??? e0)
64 | <list_append_lcons_sn <list_append_empty_sn #H destruct -H
65   elim (eq_inv_list_empty_rcons ??? (sym_eq … e0))
66 | #b2 #l2 <list_append_lcons_sn <list_append_lcons_sn #H destruct -H
67   elim (IH … e0) -IH -e0 #H1 #H2 destruct
68   /2 width=1 by conj/
69 ]
70 qed-.
71
72 (* Advanced eliminations ****************************************************)
73
74 lemma list_ind_rcons (A) (Q:predicate …):
75       Q (ⓔ{A}) →
76       (∀l,a. Q l -> Q (l⨭a)) →
77       ∀l. Q l.
78 #A #Q #IH1 #IH2 #l
79 @(list_ind_append_dx … l) -l //
80 @pull_2 #l2 elim l2 -l2 //
81 #a2 #l2 #IH0 #l1 #IH /3 width=1 by/
82 qed-.