]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/lambda/terms/multiplicity.ma
decentralized notation in lambda
[helm.git] / matita / matita / lib / lambda / terms / multiplicity.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/relocating_substitution.ma".
16
17 include "lambda/notation/functions/multiplicity_1.ma".
18
19 (* MULTIPLICITY *************************************************************)
20
21 (* Note: this gives the number of variable references in M *)
22 let rec mult M on M ≝ match M with
23 [ VRef i   ⇒ 1
24 | Abst A   ⇒ mult A
25 | Appl B A ⇒ (mult B) + (mult A)
26 ].
27
28 interpretation "term multiplicity"
29    'Multiplicity M = (mult M).
30
31 lemma mult_positive: ∀M. 0 < ♯{M}.
32 #M elim M -M // /2 width=1/
33 qed.
34
35 lemma mult_lift: ∀h,M,d. ♯{↑[d, h] M} = ♯{M}.
36 #h #M elim M -M normalize //
37 qed.
38
39 theorem mult_dsubst: ∀D,M,d. ♯{[d ↙ D] M} ≤ ♯{M} * ♯{D}.
40 #D #M elim M -M
41 [ #i #d elim (lt_or_eq_or_gt i d) #Hid
42   [ >(dsubst_vref_lt … Hid) normalize //
43   | destruct >dsubst_vref_eq normalize //
44   | >(dsubst_vref_gt … Hid) normalize //
45   ]
46 | normalize //
47 | normalize #B #A #IHB #IHA #d
48   >distributive_times_plus_r /2 width=1/
49 ]
50 qed.