]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/etc_new/lenv/lenv_length.ma
ground_2 milestone: multiple relocation with lists of booleans
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / etc_new / lenv / 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_2/ynat/ynat_lt.ma".
16 include "basic_2/grammar/lenv.ma".
17
18 (* LENGTH OF A LOCAL ENVIRONMENT ********************************************)
19
20 let rec length L ≝ match L with
21 [ LAtom       ⇒ 0
22 | LPair L _ _ ⇒ ⫯(length L)
23 ].
24
25 interpretation "length (local environment)" 'card L = (length L).
26
27 (* Basic properties *********************************************************)
28
29 lemma length_atom: |⋆| = 0.
30 // qed.
31
32 lemma length_pair: ∀I,L,V. |L.ⓑ{I}V| = ⫯|L|.
33 // qed.
34
35 lemma length_inj: ∀L. |L| < ∞.
36 #L elim L -L /2 width=1 by ylt_succ_Y/
37 qed.
38
39 (* Basic inversion lemmas ***************************************************)
40
41 lemma length_inv_zero_dx: ∀L. |L| = 0 → L = ⋆.
42 * // #L #I #V >length_pair
43 #H elim (ysucc_inv_O_dx … H)
44 qed-.
45
46 lemma length_inv_zero_sn: ∀L. yinj 0 = |L| → L = ⋆.
47 /2 width=1 by length_inv_zero_dx/ qed-.
48
49 lemma length_inv_pos_dx: ∀l,L. |L| = ⫯l →
50                          ∃∃I,K,V. |K| = l & L = K. ⓑ{I}V.
51 #l * /3 width=5 by ysucc_inj, ex2_3_intro/
52 >length_atom #H elim (ysucc_inv_O_sn … H)
53 qed-.
54
55 lemma length_inv_pos_sn: ∀l,L. ⫯l = |L| →
56                          ∃∃I,K,V. l = |K| & L = K. ⓑ{I}V.
57 #l #L #H lapply (sym_eq ??? H) -H 
58 #H elim (length_inv_pos_dx … H) -H /2 width=5 by ex2_3_intro/
59 qed-.