]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/lambda/levels/interpretations.ma
nat: we added a non-indexed theorem
[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/iterated_abstraction.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 lemma bylevel_abst: ∀i,h,d,M. ⇑[d, h] 𝛌i. M = ⇑[i+d, i+h] M.
37 #i elim i -i normalize //
38 qed.
39
40 let rec bydepth h d M on M ≝ match M with
41 [ LVRef i e   ⇒ 𝛌i.#(tri … e (d+i-h) (d+i-h-e-1) e e)
42 | LAppl i C A ⇒ 𝛌i.@(bydepth h (d+i) C).(bydepth h (d+i) A)
43 ].
44
45 interpretation "backward interpretation (term by level) general"
46    'Backward h d M = (bydepth h d M).
47
48 interpretation "backward interpretation (term by level)"
49    'Backward M = (bydepth O O M).
50
51 lemma by_depth_level_gen: ∀M,e,d,h. d ≤ e + h → ⇓[e, e+h-d] ⇑[d, h] M = 𝛌h.M.
52 #M elim M -M normalize
53 [ #i #e #d #h #Hdeh >(minus_minus_m_m … Hdeh)
54   elim (lt_or_eq_or_gt i d) #Hid
55   [ >(tri_lt ???? … Hid) >(tri_lt ???? d (d-i-1))
56     /5 width=1 by minus_le_minus_minus_comm, monotonic_lt_minus_l, eq_f/ 
57   | destruct >(tri_eq ???? …) >(tri_eq ???? …) //
58   | >(tri_gt ???? … Hid) >(tri_gt ???? … Hid) //
59   ]
60 | #A #IHA #e #d #h #Hdeh lapply (IHA e (d+1) (h+1) ?) -IHA
61   /2 width=1 by le_S_S, eq_f2/
62 | #C #A #IHC #IHA #e #d #h #Hdeh
63   lapply (IHC (e+h) d 0 ?) -IHC // lapply (IHA (e+h) d 0 ?) -IHA //
64   normalize /2 width=1 by/
65 ]
66 qed-.
67
68 theorem by_depth_level: ∀M. ⇓⇑M = M.
69 #M lapply (by_depth_level_gen M 0 0 0 ?) normalize //
70 qed.
71
72 lemma by_level_depth_gen: ∀M,e,d,h. d ≤ e → ⇑[d, h] ⇓[e, e-d] M = 𝛌h.M.
73 #M elim M -M
74 [ #i #k #e #d #h #Hde >bylevel_abst normalize >(minus_plus_minus_l … Hde)
75   elim (lt_or_eq_or_gt k (i+d)) #Hkid
76   [ >(tri_lt ???? … Hkid) >(tri_lt ???? (i+d) (i+d-k-1))
77     /5 width=1 by minus_le_minus_minus_comm, monotonic_lt_minus_l, eq_f/ 
78   | destruct >(tri_eq ???? …) >(tri_eq ???? …) //
79   | >(tri_gt ???? … Hkid) >(tri_gt ???? … Hkid) //
80   ]
81 | #i #C #A #IHC #IHA #e #d #h #Hdeh >bylevel_abst normalize
82   lapply (IHC (e+i) (i+d) 0 ?) -IHC /2 width=1 by monotonic_le_plus_r/
83   lapply (IHA (e+i) (i+d) 0 ?) -IHA /2 width=1 by monotonic_le_plus_r/
84   /3 width=1 by eq_f3, eq_f2/
85 ]
86 qed-.
87
88 theorem by_level_depth: ∀M. ⇑⇓M = M.
89 #M lapply (by_level_depth_gen M 0 0 0 ?) //
90 qed.