]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/lambda/levels/interpretations.ma
- nat: some additions, plus_minus_commutative renamed plus_minus_associative
[helm.git] / matita / matita / lib / lambda / levels / interpretations.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/notation/functions/forward_1.ma".
16 include "lambda/notation/functions/forward_3.ma".
17 include "lambda/notation/functions/backward_1.ma".
18 include "lambda/notation/functions/backward_3.ma".
19 include "lambda/terms/iterated_abstraction.ma".
20 include "lambda/levels/term.ma".
21
22 (* INTERPRETATIONS **********************************************************)
23
24 let rec bylevel h d M on M ≝ match M with
25 [ VRef i   ⇒ {h}§(tri … i d (d-i-1) i i)
26 | Abst A   ⇒ bylevel (h+1) (d+1) A
27 | Appl C A ⇒ {h}@(bylevel 0 d C).(bylevel 0 d A)
28 ].
29
30 interpretation "forward interpretation (term by depth) general"
31    'Forward h d M = (bylevel h d M).
32
33 interpretation "forward interpretation (term by depth)"
34    'Forward M = (bylevel O O M).
35
36 let rec bydepth h d M on M ≝ match M with
37 [ LVRef i e   ⇒ 𝛌i.#(tri … e (d+i-h) (d+i-h-e-1) e e)
38 | LAppl i C A ⇒ 𝛌i.@(bydepth h (d+i) C).(bydepth h (d+i) A)
39 ].
40
41 interpretation "backward interpretation (term by level) general"
42    'Backward h d M = (bydepth h d M).
43
44 interpretation "backward interpretation (term by level)"
45    'Backward M = (bydepth O O M).
46
47 theorem by_depth_level_gen: ∀M,e,d,h. d ≤ e + h → ⇓[e, e+h-d] ⇑[d, h] M = 𝛌h.M.
48 #M elim M -M normalize
49 [ #i #e #d #h #Hdeh >(minus_minus_m_m … Hdeh)
50   elim (lt_or_eq_or_gt i d) #Hid
51   [ >(tri_lt ???? … Hid) >(tri_lt ???? d (d-i-1))
52     [ >minus_minus_associative /2 width=1 by monotonic_le_minus_r/
53       <minus_plus_m_m >minus_minus_associative /2 width=1 by lt_to_le/
54     | /2 width=1 by monotonic_lt_minus_l/
55     ]
56   | destruct >(tri_eq ???? …) >(tri_eq ???? …) //
57   | >(tri_gt ???? … Hid) >(tri_gt ???? … Hid) //
58   ]
59 | #A #IHA #e #d #h #Hdeh lapply (IHA e (d+1) (h+1) ?) -IHA
60   /2 width=1 by le_S_S, eq_f2/
61 | #C #A #IHC #IHA #e #d #h #Hdeh
62   lapply (IHC (e+h) d 0 ?) -IHC
63   lapply (IHA (e+h) d 0 ?) -IHA
64   normalize /2 width=1 by/
65 ]
66 qed.
67
68 lemma by_depth_level: ∀M. ⇓⇑M = M.
69 #M lapply (by_depth_level_gen M 0 0 0 ?) normalize //
70 qed.