]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/syntax/lenv_length.ma
work in progress with voids and lveq (was: the most recent voids)
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / syntax / lenv_length.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 "basic_2/syntax/lenv.ma".
16
17 (* LENGTH OF A LOCAL ENVIRONMENT ********************************************)
18
19 rec definition length L ≝ match L with
20 [ LAtom     ⇒ 0
21 | LBind L _ ⇒ ⫯(length L)
22 ].
23
24 interpretation "length (local environment)" 'card L = (length L).
25
26 definition length2 (L1) (L2): nat ≝ |L1| + |L2|. 
27
28 (* Basic properties *********************************************************)
29
30 lemma length_atom: |⋆| = 0.
31 // qed.
32
33 (* Basic_2A1: uses: length_pair *)
34 lemma length_bind: ∀I,L. |L.ⓘ{I}| = ⫯|L|.
35 // qed.
36
37 (* Basic inversion lemmas ***************************************************)
38
39 lemma length_inv_zero_dx: ∀L. |L| = 0 → L = ⋆.
40 * // #L #I >length_bind
41 #H destruct
42 qed-.
43
44 lemma length_inv_zero_sn: ∀L. 0 = |L| → L = ⋆.
45 /2 width=1 by length_inv_zero_dx/ qed-.
46
47 (* Basic_2A1: was: length_inv_pos_dx *)
48 lemma length_inv_succ_dx: ∀n,L. |L| = ⫯n →
49                           ∃∃I,K. |K| = n & L = K. ⓘ{I}.
50 #n *
51 [ >length_atom #H destruct
52 | #L #I >length_bind /3 width=4 by ex2_2_intro, injective_S/
53 ]
54 qed-.
55
56 (* Basic_2A1: was: length_inv_pos_sn *)
57 lemma length_inv_succ_sn: ∀n,L. ⫯n = |L| →
58                           ∃∃I,K. n = |K| & L = K. ⓘ{I}.
59 #n #L #H lapply (sym_eq ??? H) -H 
60 #H elim (length_inv_succ_dx … H) -H /2 width=4 by ex2_2_intro/
61 qed-.
62
63 (* Basic_2A1: removed theorems 1: length_inj *)