]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda_delta/Basic_2/grammar/lsubs.ma
- "grammar" component updated to new syntax ...
[helm.git] / matita / matita / contribs / lambda_delta / Basic_2 / grammar / lsubs.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 "Basic_2/grammar/lenv_length.ma".
16
17 (* LOCAL ENVIRONMENT REFINEMENT FOR SUBSTITUTION ****************************)
18
19 inductive lsubs: nat → nat → relation lenv ≝
20 | lsubs_sort: ∀d,e. lsubs d e (⋆) (⋆)
21 | lsubs_OO:   ∀L1,L2. lsubs 0 0 L1 L2
22 | lsubs_abbr: ∀L1,L2,V,e. lsubs 0 e L1 L2 →
23               lsubs 0 (e + 1) (L1. 𝕓{Abbr} V) (L2.𝕓{Abbr} V)
24 | lsubs_abst: ∀L1,L2,I,V1,V2,e. lsubs 0 e L1 L2 →
25               lsubs 0 (e + 1) (L1. 𝕓{Abst} V1) (L2.𝕓{I} V2)
26 | lsubs_skip: ∀L1,L2,I1,I2,V1,V2,d,e.
27               lsubs d e L1 L2 → lsubs (d + 1) e (L1. 𝕓{I1} V1) (L2. 𝕓{I2} V2)
28 .
29
30 interpretation
31   "local environment refinement (substitution)"
32   'SubEq L1 d e L2 = (lsubs d e L1 L2).
33
34 definition lsubs_conf: ∀S. (lenv → relation S) → Prop ≝ λS,R.
35                        ∀L1,s1,s2. R L1 s1 s2 →
36                        ∀L2,d,e. L1 [d, e] ≼ L2 → R L2 s1 s2.
37
38 (* Basic properties *********************************************************)
39
40 lemma TC_lsubs_conf: ∀S,R. lsubs_conf S R → lsubs_conf S (λL. (TC … (R L))).
41 #S #R #HR #L1 #s1 #s2 #H elim H -s2
42 [ /3 width=5/
43 | #s #s2 #_ #Hs2 #IHs1 #L2 #d #e #HL12
44   lapply (HR … Hs2 … HL12) -HR -Hs2 -HL12 /3 width=3/
45 ]
46 qed.
47
48 lemma lsubs_bind_eq: ∀L1,L2,e. L1 [0, e] ≼ L2 → ∀I,V.
49                      L1. 𝕓{I} V [0, e + 1] ≼ L2.𝕓{I} V.
50 #L1 #L2 #e #HL12 #I #V elim I -I /2 width=1/
51 qed.
52
53 lemma lsubs_refl: ∀d,e,L. L [d, e] ≼ L.
54 #d elim d -d
55 [ #e elim e -e // #e #IHe #L elim L -L // /2 width=1/
56 | #d #IHd #e #L elim L -L // /2 width=1/
57 ]
58 qed.
59
60 lemma lsubs_skip_lt: ∀L1,L2,d,e. L1 [d - 1, e] ≼ L2 → 0 < d →
61                      ∀I1,I2,V1,V2. L1. 𝕓{I1} V1 [d, e] ≼ L2. 𝕓{I2} V2.
62
63 #L1 #L2 #d #e #HL12 #Hd >(plus_minus_m_m d 1) // /2 width=1/
64 qed.
65
66 (* Basic inversion lemmas ***************************************************)
67
68 (* Basic forward lemmas ***************************************************)
69
70 fact lsubs_fwd_length_full1_aux: ∀L1,L2,d,e. L1 [d, e] ≼ L2 →
71                                  d = 0 → e = |L1| → |L1| ≤ |L2|.
72 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize
73 [ //
74 | /2 width=1/
75 | /3 width=1/
76 | /3 width=1/
77 | #L1 #L2 #_ #_ #_ #_ #d #e #_ #_ #H
78   elim (plus_S_eq_O_false … H)
79 ]
80 qed.
81
82 lemma lsubs_fwd_length_full1: ∀L1,L2. L1 [0, |L1|] ≼ L2 → |L1| ≤ |L2|.
83 /2 width=5/ qed-.
84
85 fact lsubs_fwd_length_full2_aux: ∀L1,L2,d,e. L1 [d, e] ≼ L2 →
86                                  d = 0 → e = |L2| → |L2| ≤ |L1|.
87 #L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize
88 [ //
89 | /2 width=1/
90 | /3 width=1/
91 | /3 width=1/
92 | #L1 #L2 #_ #_ #_ #_ #d #e #_ #_ #H
93   elim (plus_S_eq_O_false … H)
94 ]
95 qed.
96
97 lemma lsubs_fwd_length_full2: ∀L1,L2. L1 [0, |L2|] ≼ L2 → |L2| ≤ |L1|.
98 /2 width=5/ qed-.