]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda/terms/length.ma
lambda: some refactoring + support for subsets of subterms started
[helm.git] / matita / matita / contribs / lambda / terms / 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 "terms/lift.ma".
16
17 (* LENGTH *******************************************************************)
18
19 (* Note: this gives the number of abstractions and applications in M *)
20 let rec length M on M ≝ match M with
21 [ VRef i   ⇒ 0
22 | Abst A   ⇒ length A + 1
23 | Appl B A ⇒ (length B) + (length A) + 1
24 ].
25
26 interpretation "term length"
27    'card M = (length M).
28
29 lemma length_lift: ∀h,M,d. |↑[d, h] M| = |M|.
30 #h #M elim M -M normalize //
31 qed.