]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/contribs/lambda/length.ma
- lambda: some parts commented out, some refactoring
[helm.git] / matita / matita / contribs / lambda / length.ma
diff --git a/matita/matita/contribs/lambda/length.ma b/matita/matita/contribs/lambda/length.ma
new file mode 100644 (file)
index 0000000..abb6294
--- /dev/null
@@ -0,0 +1,31 @@
+(**************************************************************************)
+(*       ___                                                              *)
+(*      ||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 "lift.ma".
+
+(* LENGTH *******************************************************************)
+
+(* Note: this gives the number of abstractions and applications in M *)
+let rec length M on M ≝ match M with
+[ VRef i   ⇒ 0
+| Abst A   ⇒ length A + 1
+| Appl B A ⇒ (length B) + (length A) + 1
+].
+
+interpretation "term length"
+   'card M = (length M).
+
+lemma length_lift: ∀h,M,d. |↑[d, h] M| = |M|.
+#h #M elim M -M normalize //
+qed.