]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/contribs/lambdadelta/basic_2/substitution/lsubr.ma
milestone in basic_2
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / substitution / lsubr.ma
index 89359533aafe83615077962f65f5561a398a0e93..c782c471fe2382447ce291a455dd89a7f06a8117 100644 (file)
 (*                                                                        *)
 (**************************************************************************)
 
-include "basic_2/grammar/lenv_length.ma".
+include "basic_2/relocation/ldrop.ma".
 
 (* LOCAL ENVIRONMENT REFINEMENT FOR SUBSTITUTION ****************************)
 
-inductive lsubr: nat → nat → relation lenv ≝
-| lsubr_sort: ∀d,e. lsubr d e (⋆) (⋆)
-| lsubr_OO:   ∀L1,L2. lsubr 0 0 L1 L2
-| lsubr_abbr: ∀L1,L2,V,e. lsubr 0 e L1 L2 →
-              lsubr 0 (e + 1) (L1. ⓓV) (L2.ⓓV)
-| lsubr_abst: ∀L1,L2,I,V1,V2,e. lsubr 0 e L1 L2 →
-              lsubr 0 (e + 1) (L1. ⓑ{I}V1) (L2. ⓛV2)
-| lsubr_skip: ∀L1,L2,I1,I2,V1,V2,d,e.
-              lsubr d e L1 L2 → lsubr (d + 1) e (L1. ⓑ{I1} V1) (L2. ⓑ{I2} V2)
+inductive lsubr: relation lenv ≝
+| lsubr_sort: ∀L. lsubr L (⋆)
+| lsubr_abbr: ∀L1,L2,V. lsubr L1 L2 → lsubr (L1. ⓓV) (L2.ⓓV)
+| lsubr_abst: ∀I,L1,L2,V1,V2. lsubr L1 L2 → lsubr (L1. ⓑ{I}V1) (L2. ⓛV2)
 .
 
 interpretation
   "local environment refinement (substitution)"
-  'SubEq L1 d e L2 = (lsubr d e L1 L2).
-
-definition lsubr_trans: ∀S. (lenv → relation S) → Prop ≝ λS,R.
-                        ∀L2,s1,s2. R L2 s1 s2 →
-                        ∀L1,d,e. L1 ⊑ [d, e] L2 → R L1 s1 s2.
+  'CrSubEq L1 L2 = (lsubr L1 L2).
 
 (* Basic properties *********************************************************)
 
-lemma lsubr_bind_eq: ∀L1,L2,e. L1 ⊑ [0, e] L2 → ∀I,V.
-                     L1. ⓑ{I} V ⊑ [0, e + 1] L2.ⓑ{I} V.
-#L1 #L2 #e #HL12 #I #V elim I -I /2 width=1/
-qed.
-
-lemma lsubr_abbr_lt: ∀L1,L2,V,e. L1 ⊑ [0, e - 1] L2 → 0 < e →
-                     L1. ⓓV ⊑ [0, e] L2.ⓓV.
-#L1 #L2 #V #e #HL12 #He >(plus_minus_m_m e 1) // /2 width=1/
-qed.
-
-lemma lsubr_abst_lt: ∀L1,L2,I,V1,V2,e. L1 ⊑ [0, e - 1] L2 → 0 < e →
-                     L1. ⓑ{I}V1 ⊑ [0, e] L2. ⓛV2.
-#L1 #L2 #I #V1 #V2 #e #HL12 #He >(plus_minus_m_m e 1) // /2 width=1/
-qed.
-
-lemma lsubr_skip_lt: ∀L1,L2,d,e. L1 ⊑ [d - 1, e] L2 → 0 < d →
-                     ∀I1,I2,V1,V2. L1. ⓑ{I1} V1 ⊑ [d, e] L2. ⓑ{I2} V2.
-#L1 #L2 #d #e #HL12 #Hd >(plus_minus_m_m d 1) // /2 width=1/
-qed.
-
-lemma lsubr_bind_lt: ∀I,L1,L2,V,e. L1 ⊑ [0, e - 1] L2 → 0 < e →
-                     L1. ⓓV ⊑ [0, e] L2. ⓑ{I}V.
+lemma lsubr_bind: ∀I,L1,L2,V. L1 ⊑ L2 → L1. ⓑ{I} V ⊑ L2.ⓑ{I} V.
 * /2 width=1/ qed.
 
-lemma lsubr_refl: ∀d,e,L. L ⊑ [d, e] L.
-#d elim d -d
-[ #e elim e -e // #e #IHe #L elim L -L // /2 width=1/
-| #d #IHd #e #L elim L -L // /2 width=1/
-]
-qed.
+lemma lsubr_abbr: ∀I,L1,L2,V. L1 ⊑ L2 → L1. ⓓV ⊑ L2. ⓑ{I}V.
+* /2 width=1/ qed.
 
-lemma TC_lsubr_trans: ∀S,R. lsubr_trans S R → lsubr_trans S (λL. (TC … (R L))).
-#S #R #HR #L1 #s1 #s2 #H elim H -s2
-[ /3 width=5/
-| #s #s2 #_ #Hs2 #IHs1 #L2 #d #e #HL12
-  lapply (HR … Hs2 … HL12) -HR -Hs2 -HL12 /3 width=3/
-]
+lemma lsubr_refl: ∀L. L ⊑ L.
+#L elim L -L // /2 width=1/
 qed.
 
 (* Basic inversion lemmas ***************************************************)
 
-fact lsubr_inv_atom1_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 → L1 = ⋆ →
-                          L2 = ⋆ ∨ (d = 0 ∧ e = 0).
-#L1 #L2 #d #e * -L1 -L2 -d -e
-[ /2 width=1/
-| /3 width=1/
-| #L1 #L2 #W #e #_ #H destruct
-| #L1 #L2 #I #W1 #W2 #e #_ #H destruct
-| #L1 #L2 #I1 #I2 #W1 #W2 #d #e #_ #H destruct
+fact lsubr_inv_atom1_aux: ∀L1,L2. L1 ⊑ L2 → L1 = ⋆ → L2 = ⋆.
+#L1 #L2 * -L1 -L2 //
+[ #L1 #L2 #V #_ #H destruct
+| #I #L1 #L2 #V1 #V2 #_ #H destruct
 ]
-qed.
+qed-.
 
-lemma lsubr_inv_atom1: ∀L2,d,e. ⋆ ⊑ [d, e] L2 →
-                       L2 = ⋆ ∨ (d = 0 ∧ e = 0).
-/2 width=3/ qed-.
-
-fact lsubr_inv_skip1_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
-                          ∀I1,K1,V1. L1 = K1.ⓑ{I1}V1 → 0 < d →
-                          ∃∃I2,K2,V2. K1 ⊑ [d - 1, e] K2 & L2 = K2.ⓑ{I2}V2.
-#L1 #L2 #d #e * -L1 -L2 -d -e
-[ #d #e #I1 #K1 #V1 #H destruct
-| #L1 #L2 #I1 #K1 #V1 #_ #H
-  elim (lt_zero_false … H)
-| #L1 #L2 #W #e #_ #I1 #K1 #V1 #_ #H
-  elim (lt_zero_false … H)
-| #L1 #L2 #I #W1 #W2 #e #_ #I1 #K1 #V1 #_ #H
-  elim (lt_zero_false … H)
-| #L1 #L2 #J1 #J2 #W1 #W2 #d #e #HL12 #I1 #K1 #V1 #H #_ destruct /2 width=5/
-]
-qed.
+lemma lsubr_inv_atom1: ∀L2. ⋆ ⊑ L2 → L2 = ⋆.
+/2 width=3 by lsubr_inv_atom1_aux/ qed-.
 
-lemma lsubr_inv_skip1: ∀I1,K1,L2,V1,d,e. K1.ⓑ{I1}V1 ⊑ [d, e] L2 → 0 < d →
-                       ∃∃I2,K2,V2. K1 ⊑ [d - 1, e] K2 & L2 = K2.ⓑ{I2}V2.
-/2 width=5/ qed-.
-
-fact lsubr_inv_atom2_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 → L2 = ⋆ →
-                          L1 = ⋆ ∨ (d = 0 ∧ e = 0).
-#L1 #L2 #d #e * -L1 -L2 -d -e
-[ /2 width=1/
-| /3 width=1/
-| #L1 #L2 #W #e #_ #H destruct
-| #L1 #L2 #I #W1 #W2 #e #_ #H destruct
-| #L1 #L2 #I1 #I2 #W1 #W2 #d #e #_ #H destruct
+fact lsubr_inv_abbr2_aux: ∀L1,L2. L1 ⊑ L2 → ∀K2,W. L2 = K2.ⓓW →
+                          ∃∃K1. K1 ⊑ K2 & L1 = K1.ⓓW.
+#L1 #L2 * -L1 -L2
+[ #L #K2 #W #H destruct
+| #L1 #L2 #V #HL12 #K2 #W #H destruct /2 width=3/
+| #I #L1 #L2 #V1 #V2 #_ #K2 #W #H destruct
 ]
-qed.
-
-lemma lsubr_inv_atom2: ∀L1,d,e. L1 ⊑ [d, e] ⋆ →
-                       L1 = ⋆ ∨ (d = 0 ∧ e = 0).
-/2 width=3/ qed-.
-
-fact lsubr_inv_abbr2_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
-                          ∀K2,V. L2 = K2.ⓓV → d = 0 → 0 < e →
-                          ∃∃K1. K1 ⊑ [0, e - 1] K2 & L1 = K1.ⓓV.
-#L1 #L2 #d #e * -L1 -L2 -d -e
-[ #d #e #K1 #V #H destruct
-| #L1 #L2 #K1 #V #_ #_ #H
-  elim (lt_zero_false … H)
-| #L1 #L2 #W #e #HL12 #K1 #V #H #_ #_ destruct /2 width=3/
-| #L1 #L2 #I #W1 #W2 #e #_ #K1 #V #H destruct
-| #L1 #L2 #I1 #I2 #W1 #W2 #d #e #_ #K1 #V #_ >commutative_plus normalize #H destruct
+qed-.
+
+lemma lsubr_inv_abbr2: ∀L1,K2,W. L1 ⊑ K2.ⓓW →
+                       ∃∃K1. K1 ⊑ K2 & L1 = K1.ⓓW.
+/2 width=3 by lsubr_inv_abbr2_aux/ qed-.
+
+fact lsubr_inv_abst2_aux: ∀L1,L2. L1 ⊑ L2 → ∀K2,W2. L2 = K2.ⓛW2 →
+                          ∃∃I,K1,W1. K1 ⊑ K2 & L1 = K1.ⓑ{I}W1.
+#L1 #L2 * -L1 -L2
+[ #L #K2 #W2 #H destruct
+| #L1 #L2 #V #_ #K2 #W2 #H destruct
+| #I #L1 #L2 #V1 #V2 #HL12 #K2 #W2 #H destruct /2 width=5/
 ]
-qed.
+qed-.
 
-lemma lsubr_inv_abbr2: ∀L1,K2,V,e. L1 ⊑ [0, e] K2.ⓓV → 0 < e →
-                       ∃∃K1. K1 ⊑ [0, e - 1] K2 & L1 = K1.ⓓV.
-/2 width=5/ qed-.
-
-fact lsubr_inv_skip2_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
-                          ∀I2,K2,V2. L2 = K2.ⓑ{I2}V2 → 0 < d →
-                          ∃∃I1,K1,V1. K1 ⊑ [d - 1, e] K2 & L1 = K1.ⓑ{I1}V1.
-#L1 #L2 #d #e * -L1 -L2 -d -e
-[ #d #e #I1 #K1 #V1 #H destruct
-| #L1 #L2 #I1 #K1 #V1 #_ #H
-  elim (lt_zero_false … H)
-| #L1 #L2 #W #e #_ #I1 #K1 #V1 #_ #H
-  elim (lt_zero_false … H)
-| #L1 #L2 #I #W1 #W2 #e #_ #I1 #K1 #V1 #_ #H
-  elim (lt_zero_false … H)
-| #L1 #L2 #J1 #J2 #W1 #W2 #d #e #HL12 #I1 #K1 #V1 #H #_ destruct /2 width=5/
-]
-qed.
-
-lemma lsubr_inv_skip2: ∀I2,L1,K2,V2,d,e. L1 ⊑ [d, e] K2.ⓑ{I2}V2 → 0 < d →
-                       ∃∃I1,K1,V1. K1 ⊑ [d - 1, e] K2 & L1 = K1.ⓑ{I1}V1.
-/2 width=5/ qed-.
+lemma lsubr_inv_abst2: ∀L1,K2,W2. L1 ⊑ K2.ⓛW2 →
+                       ∃∃I,K1,W1. K1 ⊑ K2 & L1 = K1.ⓑ{I}W1.
+/2 width=4 by lsubr_inv_abst2_aux/ qed-.
 
 (* Basic forward lemmas *****************************************************)
 
-fact lsubr_fwd_length_full1_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
-                                 d = 0 → e = |L1| → |L1| ≤ |L2|.
-#L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize
-[ //
-| /2 width=1/
-| /3 width=1/
-| /3 width=1/
-| #L1 #L2 #_ #_ #_ #_ #d #e #_ #_ >commutative_plus normalize #H destruct
-]
-qed.
-
-lemma lsubr_fwd_length_full1: ∀L1,L2. L1 ⊑ [0, |L1|] L2 → |L1| ≤ |L2|.
-/2 width=5/ qed-.
-
-fact lsubr_fwd_length_full2_aux: ∀L1,L2,d,e. L1 ⊑ [d, e] L2 →
-                                 d = 0 → e = |L2| → |L2| ≤ |L1|.
-#L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize
-[ //
-| /2 width=1/
-| /3 width=1/
-| /3 width=1/
-| #L1 #L2 #_ #_ #_ #_ #d #e #_ #_ >commutative_plus normalize #H destruct
+lemma lsubr_fwd_length: ∀L1,L2. L1 ⊑ L2 → |L2| ≤ |L1|.
+#L1 #L2 #H elim H -L1 -L2 // /2 width=1/
+qed-.
+
+lemma lsubr_fwd_ldrop2_abbr: ∀L1,L2. L1 ⊑ L2 →
+                             ∀K2,W,i. ⇩[0, i] L2 ≡ K2. ⓓW →
+                             ∃∃K1. K1 ⊑ K2 & ⇩[0, i] L1 ≡ K1. ⓓW.
+#L1 #L2 #H elim H -L1 -L2
+[ #L #K2 #W #i #H
+  elim (ldrop_inv_atom1 … H) -H #H destruct
+| #L1 #L2 #V #HL12 #IHL12 #K2 #W #i #H
+  elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK2 destruct [ -IHL12 | -HL12 ]
+  [ /2 width=3/
+  | elim (IHL12 … HLK2) -IHL12 -HLK2 /3 width=3/
+  ]
+| #I #L1 #L2 #V1 #V2 #_ #IHL12 #K2 #W #i #H
+  elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK2 destruct
+  elim (IHL12 … HLK2) -IHL12 -HLK2 /3 width=3/
 ]
-qed.
-
-lemma lsubr_fwd_length_full2: ∀L1,L2. L1 ⊑ [0, |L2|] L2 → |L2| ≤ |L1|.
-/2 width=5/ qed-.
+qed-.