1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
17 (* DELIFTING SUBSTITUTION ***************************************************)
19 (* Policy: depth (level) metavariables: d, e (as for lift) *)
20 let rec dsubst C d M on M ≝ match M with
21 [ VRef i ⇒ tri … i d (#i) (↑[i] C) (#(i-1))
22 | Abst A ⇒ 𝛌. (dsubst C (d+1) A)
23 | Appl B A ⇒ @ (dsubst C d B). (dsubst C d A)
26 interpretation "delifting substitution"
27 'DSubst C d M = (dsubst C d M).
29 (* Note: the notation with "/" does not work *)
30 notation "hvbox( [ d ⬐ break C ] break term 55 M )"
31 non associative with precedence 55
32 for @{ 'DSubst $C $d $M }.
34 notation > "hvbox( [ ⬐ C ] break term 55 M )"
35 non associative with precedence 55
36 for @{ 'DSubst $C 0 $M }.
38 lemma dsubst_vref_lt: ∀i,d,C. i < d → [ d ⬐ C ] #i = #i.
42 lemma dsubst_vref_eq: ∀d,C. [ d ⬐ C ] #d = ↑[d]C.
46 lemma dsubst_vref_gt: ∀i,d,C. d < i → [ d ⬐ C ] #i = #(i-1).
50 theorem dsubst_lift_le: ∀h,C,M,d1,d2. d2 ≤ d1 →
51 [ d2 ⬐ ↑[d1 - d2, h] C ] ↑[d1 + 1, h] M = ↑[d1, h] [ d2 ⬐ C ] M.
53 [ #i #d1 #d2 #Hd21 elim (lt_or_eq_or_gt i d2) #Hid2
54 [ lapply (lt_to_le_to_lt … Hid2 Hd21) -Hd21 #Hid1
55 >(dsubst_vref_lt … Hid2) >(lift_vref_lt … Hid1) >lift_vref_lt /2 width=1/
56 | destruct >dsubst_vref_eq >lift_vref_lt /2 width=1/
57 | >(dsubst_vref_gt … Hid2) -Hd21 elim (lt_or_ge (i-1) d1) #Hi1d1
58 [ >(lift_vref_lt … Hi1d1) >lift_vref_lt /2 width=1/
59 | lapply (ltn_to_ltO … Hid2) #Hi
60 >(lift_vref_ge … Hi1d1) >lift_vref_ge /2 width=1/ -Hi1d1 >plus_minus // /3 width=1/
63 | normalize #A #IHA #d1 #d2 #Hd21
64 lapply (IHA (d1+1) (d2+1) ?) -IHA /2 width=1/
65 | normalize #B #A #IHB #IHA #d1 #d2 #Hd21
66 >IHB -IHB // >IHA -IHA //
70 theorem dsubst_lift_be: ∀h,C,M,d1,d2. d1 ≤ d2 → d2 ≤ d1 + h →
71 [ d2 ⬐ C ] ↑[d1, h + 1] M = ↑[d1, h] M.
73 [ #i #d1 #d2 #Hd12 #Hd21 elim (lt_or_ge i d1) #Hid1
74 [ lapply (lt_to_le_to_lt … Hid1 Hd12) -Hd12 -Hd21 #Hid2
75 >(lift_vref_lt … Hid1) >(lift_vref_lt … Hid1) /2 width=1/
76 | lapply (transitive_le … (i+h) Hd21 ?) -Hd12 -Hd21 /2 width=1/ #Hd2
77 >(lift_vref_ge … Hid1) >(lift_vref_ge … Hid1) -Hid1
78 >dsubst_vref_gt // /2 width=1/
80 | normalize #A #IHA #d1 #d2 #Hd12 #Hd21
81 >IHA -IHA // /2 width=1/
82 | normalize #B #A #IHB #IHA #d1 #d2 #Hd12 #Hd21
83 >IHB -IHB // >IHA -IHA //