]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/contribs/lambdadelta/basic_2/substitution/lsubr.ma
A first example that uses a status monad where the status is a tree.
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / substitution / lsubr.ma
index e3afc573dd9bf1dcdd6c6676a0f3c6d743ad273f..faf254e36e6aabeb10892a6e0b4b2a90ff4b7bca 100644 (file)
 (*                                                                        *)
 (**************************************************************************)
 
+include "basic_2/notation/relations/lrsubeq_2.ma".
 include "basic_2/relocation/ldrop.ma".
 
-(* LOCAL ENVIRONMENT REFINEMENT FOR SUBSTITUTION ****************************)
+(* RESTRICTED LOCAL ENVIRONMENT REFINEMENT **********************************)
 
 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)
+| lsubr_bind: ∀I,L1,L2,V. lsubr L1 L2 → lsubr (L1.ⓑ{I}V) (L2.ⓑ{I}V)
+| lsubr_abst: ∀L1,L2,V,W. lsubr L1 L2 → lsubr (L1.ⓓⓝW.V) (L2.ⓛW)
 .
 
 interpretation
-  "local environment refinement (substitution)"
-  'SubEq L1 L2 = (lsubr L1 L2).
-
-definition lsubr_trans: ∀S. predicate (lenv → relation S) ≝ λS,R.
-                        ∀L2,s1,s2. R L2 s1 s2 → ∀L1. L1 ⊑ L2 → R L1 s1 s2.
+  "local environment refinement (restricted)"
+  'LRSubEq L1 L2 = (lsubr L1 L2).
 
 (* Basic properties *********************************************************)
 
-lemma lsubr_bind: ∀I,L1,L2,V. L1 ⊑ L2 → L1. ⓑ{I} V ⊑ L2.ⓑ{I} V.
-* /2 width=1/ qed.
-
-lemma lsubr_abbr: ∀I,L1,L2,V. L1 ⊑ L2 → L1. ⓓV ⊑ L2. ⓑ{I}V.
-* /2 width=1/ qed.
-
 lemma lsubr_refl: ∀L. L ⊑ L.
 #L elim L -L // /2 width=1/
 qed.
 
-lemma TC_lsubr_trans: ∀S,R. lsubr_trans S R → lsubr_trans S (LTC … R).
-#S #R #HR #L1 #s1 #s2 #H elim H -s2
-[ /3 width=3/
-| #s #s2 #_ #Hs2 #IHs1 #L2 #HL12
-  lapply (HR … Hs2 … HL12) -HR -Hs2 /3 width=3/
-]
-qed.
-
 (* Basic inversion lemmas ***************************************************)
 
 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
+[ #I #L1 #L2 #V #_ #H destruct
+| #L1 #L2 #V #W #_ #H destruct
 ]
 qed-.
 
 lemma lsubr_inv_atom1: ∀L2. ⋆ ⊑ L2 → L2 = ⋆.
 /2 width=3 by lsubr_inv_atom1_aux/ qed-.
 
+fact lsubr_inv_abst1_aux: ∀L1,L2. L1 ⊑ L2 → ∀K1,W. L1 = K1.ⓛW →
+                          L2 = ⋆ ∨ ∃∃K2. K1 ⊑ K2 & L2 = K2.ⓛW.
+#L1 #L2 * -L1 -L2
+[ #L #K1 #W #H destruct /2 width=1/
+| #I #L1 #L2 #V #HL12 #K1 #W #H destruct /3 width=3/
+| #L1 #L2 #V1 #V2 #_ #K1 #W #H destruct
+]
+qed-.
+
+lemma lsubr_inv_abst1: ∀K1,L2,W. K1.ⓛW ⊑ L2 →
+                       L2 = ⋆ ∨ ∃∃K2. K1 ⊑ K2 & L2 = K2.ⓛW.
+/2 width=3 by lsubr_inv_abst1_aux/ qed-.
+
 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
+| #I #L1 #L2 #V #HL12 #K2 #W #H destruct /2 width=3/
+| #L1 #L2 #V1 #V2 #_ #K2 #W #H destruct
 ]
 qed-.
 
@@ -74,38 +71,35 @@ 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-.
-
-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 *****************************************************)
 
 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.
+lemma lsubr_fwd_ldrop2_bind: ∀L1,L2. L1 ⊑ L2 →
+                             ∀I,K2,W,i. ⇩[0, i] L2 ≡ K2.ⓑ{I}W →
+                             (∃∃K1. K1 ⊑ K2 & ⇩[0, i] L1 ≡ K1.ⓑ{I}W) ∨
+                             ∃∃K1,V. K1 ⊑ K2 & ⇩[0, i] L1 ≡ K1.ⓓⓝW.V & I = Abst.
 #L1 #L2 #H elim H -L1 -L2
-[ #L #K2 #W #i #H
-  lapply (ldrop_inv_atom1 … H) -H #H destruct
-| #L1 #L2 #V #HL12 #IHL12 #K2 #W #i #H
-  elim (ldrop_inv_O1 … H) -H * #Hi #HLK2 destruct [ -IHL12 | -HL12 ]
-  [ /2 width=3/
-  | elim (IHL12 … HLK2) -IHL12 -HLK2 /3 width=3/
+[ #L #I #K2 #W #i #H
+  elim (ldrop_inv_atom1 … H) -H #H destruct
+| #J #L1 #L2 #V #HL12 #IHL12 #I #K2 #W #i #H
+  elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK2 destruct [ -IHL12 | -HL12 ]
+  [ /3 width=3/
+  | elim (IHL12 … HLK2) -IHL12 -HLK2 * /4 width=3/ /4 width=4/
+  ]
+| #L1 #L2 #V1 #V2 #HL12 #IHL12 #I #K2 #W #i #H
+  elim (ldrop_inv_O1_pair1 … H) -H * #Hi #HLK2 destruct [ -IHL12 | -HL12 ]
+  [ /3 width=4/
+  | elim (IHL12 … HLK2) -IHL12 -HLK2 * /4 width=3/ /4 width=4/
   ]
-| #I #L1 #L2 #V1 #V2 #_ #IHL12 #K2 #W #i #H
-  elim (ldrop_inv_O1 … H) -H * #Hi #HLK2 destruct
-  elim (IHL12 … HLK2) -IHL12 -HLK2 /3 width=3/
 ]
 qed-.
+
+lemma lsubr_fwd_ldrop2_abbr: ∀L1,L2. L1 ⊑ L2 →
+                             ∀K2,V,i. ⇩[0, i] L2 ≡ K2.ⓓV →
+                             ∃∃K1. K1 ⊑ K2 & ⇩[0, i] L1 ≡ K1.ⓓV.
+#L1 #L2 #HL12 #K2 #V #i #HLK2 elim (lsubr_fwd_ldrop2_bind … HL12 … HLK2) -L2 // *
+#K1 #W #_ #_ #H destruct
+qed-.