]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/contribs/lambdadelta/basic_2A/etc/lcoeq/lcoeq.etc
milestone update in ground_2 and basic_2A
[helm.git] / matita / matita / contribs / lambdadelta / basic_2A / etc / lcoeq / lcoeq.etc
diff --git a/matita/matita/contribs/lambdadelta/basic_2A/etc/lcoeq/lcoeq.etc b/matita/matita/contribs/lambdadelta/basic_2A/etc/lcoeq/lcoeq.etc
new file mode 100644 (file)
index 0000000..5338c2a
--- /dev/null
@@ -0,0 +1,165 @@
+(**************************************************************************)
+(*       ___                                                              *)
+(*      ||M||                                                             *)
+(*      ||A||       A project by Andrea Asperti                           *)
+(*      ||T||                                                             *)
+(*      ||I||       Developers:                                           *)
+(*      ||T||         The HELM team.                                      *)
+(*      ||A||         http://helm.cs.unibo.it                             *)
+(*      \   /                                                             *)
+(*       \ /        This file is distributed under the terms of the       *)
+(*        v         GNU General Public License Version 2                  *)
+(*                                                                        *)
+(**************************************************************************)
+
+include "ground_2/ynat/ynat_lt.ma".
+include "basic_2/notation/relations/coeq_4.ma".
+include "basic_2/grammar/lenv_length.ma".
+
+(* COEQUIVALENCE FOR LOCAL ENVIRONMENTS *************************************)
+
+inductive lcoeq: relation4 ynat ynat lenv lenv ≝
+| lcoeq_atom: ∀d,e. lcoeq d e (⋆) (⋆)
+| lcoeq_zero: ∀I,L1,L2,V.
+              lcoeq 0 0 L1 L2 → lcoeq 0 0 (L1.ⓑ{I}V) (L2.ⓑ{I}V)
+| lcoeq_pair: ∀I1,I2,L1,L2,V1,V2,e. lcoeq 0 e L1 L2 →
+              lcoeq 0 (⫯e) (L1.ⓑ{I1}V1) (L2.ⓑ{I2}V2)
+| lcoeq_succ: ∀I,L1,L2,V,d,e.
+              lcoeq d e L1 L2 → lcoeq (⫯d) e (L1.ⓑ{I}V) (L2.ⓑ{I}V)
+.
+
+interpretation
+  "coequivalence (local environment)"
+  'CoEq d e L1 L2 = (lcoeq d e L1 L2).
+
+(* Basic properties *********************************************************)
+
+lemma lcoeq_pair_lt: ∀I1,I2,L1,L2,V1,V2,e. L1 ≅[0, ⫰e] L2 → 0 < e →
+                     L1.ⓑ{I1}V1 ≅[0, e] L2.ⓑ{I2}V2.
+#I1 #I2 #L1 #L2 #V1 #V2 #e #HL12 #He <(ylt_inv_O1 … He) /2 width=1 by lcoeq_pair/
+qed.
+
+lemma lcoeq_succ_lt: ∀I,L1,L2,V,d,e. L1 ≅[⫰d, e] L2 → 0 < d →
+                     L1.ⓑ{I}V ≅[d, e] L2. ⓑ{I}V.
+#I #L1 #L2 #V #d #e #HL12 #Hd <(ylt_inv_O1 … Hd) /2 width=1 by lcoeq_succ/
+qed.
+
+lemma lcoeq_pair_O_Y: ∀L1,L2. L1 ≅[0, ∞] L2 →
+                      ∀I1,I2,V1,V2. L1.ⓑ{I1}V1 ≅[0,∞] L2.ⓑ{I2}V2.
+#L1 #L2 #HL12 #I1 #I2 #V1 #V2 lapply (lcoeq_pair I1 I2 … V1 V2 … HL12) -HL12 //
+qed.
+
+lemma lcoeq_refl: ∀L,d,e. L ≅[d, e] L.
+#L elim L -L //
+#L #I #V #IHL #d elim (ynat_cases … d) [| * #x ]
+#Hd destruct /2 width=1 by lcoeq_succ/
+#e elim (ynat_cases … e) [| * #x ]
+#He destruct /2 width=1 by lcoeq_zero, lcoeq_pair/
+qed.
+
+lemma lcoeq_O_Y: ∀L1,L2. |L1| = |L2| → L1 ≅[0, ∞] L2.
+#L1 elim L1 -L1 [| #L1 #I1 #V1 #IHL1 ]
+* [2,4: #L2 #I2 #V1 ] normalize /3 width=2 by lcoeq_pair_O_Y/
+<plus_n_Sm #H destruct
+qed.
+
+lemma lcoeq_sym: ∀d,e. symmetric … (lcoeq d e).
+#d #e #L1 #L2 #H elim H -L1 -L2
+/2 width=1 by lcoeq_zero, lcoeq_pair, lcoeq_succ/
+qed-.
+
+(* Basic inversion lemmas ***************************************************)
+
+fact lcoeq_inv_atom1_aux: ∀L1,L2,d,e. L1 ≅[d, e] L2 → L1 = ⋆ → L2 = ⋆.
+#L1 #L2 #d #e * -L1 -L2 -d -e //
+[ #I #L1 #L2 #V #_ #H destruct
+| #I1 #I2 #L1 #L2 #V1 #V2 #e #_ #H destruct
+| #I #L1 #L2 #V #d #e #_ #H destruct
+]
+qed-.
+
+lemma lcoeq_inv_atom1: ∀L2,d,e. ⋆ ≅[d, e] L2 → L2 = ⋆.
+/2 width=5 by lcoeq_inv_atom1_aux/ qed-.
+
+fact lcoeq_inv_zero1_aux: ∀L1,L2,d,e. L1 ≅[d, e] L2 →
+                          ∀J,K1,W. L1 = K1.ⓑ{J}W → d = 0 → e = 0 →
+                          ∃∃K2. K1 ≅[0, 0] K2 & L2 = K2.ⓑ{J}W.
+#L1 #L2 #d #e * -L1 -L2 -d -e
+[ #d #e #J #K1 #W #H destruct
+| #I #L1 #L2 #V #HL12 #J #K1 #W #H destruct /2 width=3 by ex2_intro/
+| #I1 #I2 #L1 #L2 #V1 #V2 #e #_ #J #K1 #W #_ #_ #H elim (ysucc_inv_O_dx … H)
+| #I #L1 #L2 #V #d #e #_ #J #K1 #W #_ #H elim (ysucc_inv_O_dx … H)
+]
+qed-.
+
+lemma lcoeq_inv_zero1: ∀I,K1,L2,V. K1.ⓑ{I}V ≅[0, 0] L2 →
+                       ∃∃K2. K1 ≅[0, 0] K2 & L2 = K2.ⓑ{I}V.
+/2 width=7 by lcoeq_inv_zero1_aux/ qed-.
+
+fact lcoeq_inv_pair1_aux: ∀L1,L2,d,e. L1 ≅[d, e] L2 →
+                          ∀J1,K1,W1. L1 = K1.ⓑ{J1}W1 → d = 0 → 0 < e →
+                          ∃∃J2,K2,W2. K1 ≅[0, ⫰e] K2 & L2 = K2.ⓑ{J2}W2.
+#L1 #L2 #d #e * -L1 -L2 -d -e
+[ #d #e #J1 #K1 #W1 #H destruct
+| #I #L1 #L2 #V #_ #J1 #K1 #W1 #_ #_ #H elim (ylt_yle_false … H) //
+| #I1 #I2 #L1 #L2 #V1 #V2 #e #HL12 #J1 #K1 #W1 #H #_ #_ destruct
+  /2 width=5 by ex2_3_intro/
+| #I #L1 #L2 #V #d #e #_ #J1 #K1 #W1 #_ #H elim (ysucc_inv_O_dx … H)
+]
+qed-.
+
+lemma lcoeq_inv_pair1: ∀I1,K1,L2,V1,e. K1.ⓑ{I1}V1 ≅[0, e] L2 → 0 < e →
+                       ∃∃I2,K2,V2. K1 ≅[0, ⫰e] K2 & L2 = K2.ⓑ{I2}V2.
+/2 width=7 by lcoeq_inv_pair1_aux/ qed-.
+
+fact lcoeq_inv_succ1_aux: ∀L1,L2,d,e. L1 ≅[d, e] L2 →
+                          ∀J,K1,W. L1 = K1.ⓑ{J}W → 0 < d →
+                          ∃∃K2. K1 ≅[⫰d, e] K2 & L2 = K2.ⓑ{J}W.
+#L1 #L2 #d #e * -L1 -L2 -d -e
+[ #d #e #J #K1 #W #H destruct
+| #I #L1 #L2 #V #_ #J #K1 #W #_ #H elim (ylt_yle_false … H) //
+| #I1 #I2 #L1 #L2 #V1 #V2 #e #_ #J #K1 #W #_ #H elim (ylt_yle_false … H) //
+| #I #L1 #L2 #V #d #e #HL12 #J #K1 #W #H destruct /2 width=3 by ex2_intro/
+]
+qed-.
+
+lemma lcoeq_inv_succ1: ∀I,K1,L2,V,d,e. K1.ⓑ{I}V ≅[d, e] L2 → 0 < d →
+                       ∃∃K2. K1 ≅[⫰d, e] K2 & L2 = K2.ⓑ{I}V.
+/2 width=3 by lcoeq_inv_succ1_aux/ qed-.
+
+lemma lcoeq_inv_atom2: ∀L1,d,e. L1 ≅[d, e] ⋆ → L1 = ⋆.
+/3 width=3 by lcoeq_inv_atom1, lcoeq_sym/ qed-.
+
+lemma lcoeq_inv_zero2: ∀I,K2,L1,V. L1 ≅[0, 0] K2.ⓑ{I}V →
+                       ∃∃K1. K1 ≅[0, 0] K2 & L1 = K1.ⓑ{I}V.
+#I #K2 #L1 #V #H elim (lcoeq_inv_zero1 … (lcoeq_sym … H)) -H
+/3 width=3 by lcoeq_sym, ex2_intro/
+qed-.
+
+lemma lcoeq_inv_pair2: ∀I2,K2,L1,V2,e. L1 ≅[0, e] K2.ⓑ{I2}V2 → 0 < e →
+                       ∃∃I1,K1,V1. K1 ≅[0, ⫰e] K2 & L1 = K1.ⓑ{I1}V1.
+#I2 #K2 #L1 #V2 #e #H #He elim (lcoeq_inv_pair1 … (lcoeq_sym … H)) -H
+/3 width=5 by lcoeq_sym, ex2_3_intro/
+qed-.
+
+lemma lcoeq_inv_succ2: ∀I,K2,L1,V,d,e. L1 ≅[d, e] K2.ⓑ{I}V → 0 < d →
+                       ∃∃K1. K1 ≅[⫰d, e] K2 & L1 = K1.ⓑ{I}V.
+#I #K2 #L1 #V #d #e #H #Hd elim (lcoeq_inv_succ1 … (lcoeq_sym … H)) -H
+/3 width=3 by lcoeq_sym, ex2_intro/
+qed-.
+
+(* Basic forward lemmas *****************************************************)
+
+lemma lcoeq_fwd_length: ∀L1,L2,d,e. L1 ≅[d, e] L2 → |L2| ≤ |L1|.
+#L1 #L2 #d #e #H elim H -L1 -L2 -d -e normalize /2 width=1 by le_S_S/
+qed-.
+
+(* Advanced inversionn lemmas ***********************************************)
+
+fact lcoeq_inv_O2_aux: ∀L1,L2,d,e. L1 ≅[d, e] L2 → e = 0 → L1 = L2.
+#L1 #L2 #d #e #H elim H -L1 -L2 -d -e /3 width=1 by eq_f3/
+#I1 #I2 #L1 #L2 #V1 #V2 #e #_ #_ #H elim (ysucc_inv_O_dx … H)
+qed-.
+
+lemma lcoeq_inv_O2: ∀L1,L2,d. L1 ≅[d, 0] L2 → L1 = L2.
+/2 width=4 by lcoeq_inv_O2_aux/ qed-.