]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/grammar/lenv_length.ma
theory of cpy is complete!
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / grammar / 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/grammar/lenv.ma".
16
17 (* LENGTH OF A LOCAL ENVIRONMENT ********************************************)
18
19 let rec length L ≝ match L with
20 [ LAtom       ⇒ 0
21 | LPair L _ _ ⇒ length L + 1
22 ].
23
24 interpretation "length (local environment)" 'card L = (length L).
25
26 (* Basic inversion lemmas ***************************************************)
27
28 lemma length_inv_zero_dx: ∀L. |L| = 0 → L = ⋆.
29 * // #L #I #V normalize <plus_n_Sm #H destruct
30 qed-.
31
32 lemma length_inv_zero_sn: ∀L. 0 = |L| → L = ⋆.
33 * // #L #I #V normalize <plus_n_Sm #H destruct
34 qed-.
35
36 lemma length_inv_pos_dx: ∀d,L. |L| = d + 1 →
37                          ∃∃I,K,V. |K| = d & L = K. ⓑ{I}V.
38 #d *
39 [ normalize <plus_n_Sm #H destruct
40 | #K #I #V #H
41   lapply (injective_plus_l … H) -H /2 width=5/
42 ]
43 qed-.
44
45 lemma length_inv_pos_sn: ∀d,L. d + 1 = |L| →
46                          ∃∃I,K,V. d = |K| & L = K. ⓑ{I}V.
47 #d *
48 [ normalize <plus_n_Sm #H destruct
49 | #K #I #V #H
50   lapply (injective_plus_l … H) -H /2 width=5/
51 ]
52 qed-.