]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/contribs/lambdadelta/basic_2A/grammar/lenv_length.ma
update in lambdadelta
[helm.git] / matita / matita / contribs / lambdadelta / basic_2A / grammar / lenv_length.ma
diff --git a/matita/matita/contribs/lambdadelta/basic_2A/grammar/lenv_length.ma b/matita/matita/contribs/lambdadelta/basic_2A/grammar/lenv_length.ma
new file mode 100644 (file)
index 0000000..cefc9b0
--- /dev/null
@@ -0,0 +1,52 @@
+(**************************************************************************)
+(*       ___                                                              *)
+(*      ||M||                                                             *)
+(*      ||A||       A project by Andrea Asperti                           *)
+(*      ||T||                                                             *)
+(*      ||I||       Developers:                                           *)
+(*      ||T||         The HELM team.                                      *)
+(*      ||A||         http://helm.cs.unibo.it                             *)
+(*      \   /                                                             *)
+(*       \ /        This file is distributed under the terms of the       *)
+(*        v         GNU General Public License Version 2                  *)
+(*                                                                        *)
+(**************************************************************************)
+
+include "basic_2A/grammar/lenv.ma".
+
+(* LENGTH OF A LOCAL ENVIRONMENT ********************************************)
+
+let rec length L ≝ match L with
+[ LAtom       ⇒ 0
+| LPair L _ _ ⇒ length L + 1
+].
+
+interpretation "length (local environment)" 'card L = (length L).
+
+(* Basic inversion lemmas ***************************************************)
+
+lemma length_inv_zero_dx: ∀L. |L| = 0 → L = ⋆.
+* // #L #I #V normalize <plus_n_Sm #H destruct
+qed-.
+
+lemma length_inv_zero_sn: ∀L. 0 = |L| → L = ⋆.
+* // #L #I #V normalize <plus_n_Sm #H destruct
+qed-.
+
+lemma length_inv_pos_dx: ∀l,L. |L| = l + 1 →
+                         ∃∃I,K,V. |K| = l & L = K. ⓑ{I}V.
+#l *
+[ normalize <plus_n_Sm #H destruct
+| #K #I #V #H
+  lapply (injective_plus_l … H) -H /2 width=5 by ex2_3_intro/
+]
+qed-.
+
+lemma length_inv_pos_sn: ∀l,L. l + 1 = |L| →
+                         ∃∃I,K,V. l = |K| & L = K. ⓑ{I}V.
+#l *
+[ normalize <plus_n_Sm #H destruct
+| #K #I #V #H
+  lapply (injective_plus_l … H) -H /2 width=5 by ex2_3_intro/
+]
+qed-.