]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/lambda/terms/size.ma
update in lib
[helm.git] / matita / matita / lib / lambda / terms / size.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 "lambda/terms/relocation.ma".
16 include "basics/core_notation/card_1.ma".
17
18 (* SIZE *********************************************************************)
19
20 (* Note: this gives the number of abstractions and applications in M *)
21 let rec size M on M ≝ match M with
22 [ VRef i   ⇒ 0
23 | Abst A   ⇒ size A + 1
24 | Appl B A ⇒ (size B) + (size A) + 1
25 ].
26
27 interpretation "term size"
28    'card M = (size M).
29
30 lemma size_lift: ∀h,M,d. |↑[d, h] M| = |M|.
31 #h #M elim M -M normalize //
32 qed.