]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/static_2/syntax/lenv_length.ma
partial update in static_2
[helm.git] / matita / matita / contribs / lambdadelta / static_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 "ground/arith/nat_succ.ma".
16 include "static_2/syntax/lenv.ma".
17
18 (* LENGTH OF A LOCAL ENVIRONMENT ********************************************)
19
20 rec definition length L ≝ match L with
21 [ LAtom     ⇒ 𝟎
22 | LBind L _ ⇒ ↑(length L)
23 ].
24
25 interpretation "length (local environment)" 'card L = (length L).
26
27 (* Basic properties *********************************************************)
28
29 lemma length_atom: |⋆| = 𝟎.
30 // qed.
31
32 (* Basic_2A1: uses: length_pair *)
33 lemma length_bind: ∀I,L. |L.ⓘ[I]| = ↑|L|.
34 // qed.
35
36 (* Basic inversion lemmas ***************************************************)
37
38 lemma length_inv_zero_dx: ∀L. |L| = 𝟎 → L = ⋆.
39 * // #L #I
40 >length_bind #H
41 elim (eq_inv_nsucc_zero … H) 
42 qed-.
43
44 lemma length_inv_zero_sn: ∀L. 𝟎 = |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
52   elim (eq_inv_zero_nsucc … H) 
53 | #L #I >length_bind
54   /3 width=4 by ex2_2_intro, eq_inv_nsucc_bi/
55 ]
56 qed-.
57
58 (* Basic_2A1: was: length_inv_pos_sn *)
59 lemma length_inv_succ_sn: ∀n,L. ↑n = |L| →
60                           ∃∃I,K. n = |K| & L = K. ⓘ[I].
61 #n #L #H lapply (sym_eq ??? H) -H
62 #H elim (length_inv_succ_dx … H) -H /2 width=4 by ex2_2_intro/
63 qed-.
64
65 (* Basic_2A1: removed theorems 1: length_inj *)