From: Ferruccio Guidi Date: Wed, 10 Aug 2011 12:49:38 +0000 (+0000) Subject: the refactoring continues ... X-Git-Tag: make_still_working~2335 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=e4f11cddf44dd9bba21f689d4f56e2d00d8d7bb5;p=helm.git the refactoring continues ... --- diff --git a/matita/matita/contribs/lambda-delta/Basic-2/reduction/cpr.ma b/matita/matita/contribs/lambda-delta/Basic-2/reduction/cpr.ma new file mode 100644 index 000000000..cfd51af8a --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/reduction/cpr.ma @@ -0,0 +1,52 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/reduction/tpr.ma". + +(* CONTEXT-SENSITIVE PARALLEL REDUCTION ON TERMS ****************************) + +definition cpr: lenv → term → term → Prop ≝ + λL,T1,T2. ∃∃T. T1 ⇒ T & L ⊢ T [0, |L|] ≫ T2. + +interpretation + "context-sensitive parallel reduction (term)" + 'PRed L T1 T2 = (cpr L T1 T2). + +(* Basic properties *********************************************************) + +lemma cpr_pr: ∀T1,T2. T1 ⇒ T2 → ∀L. L ⊢ T1 ⇒ T2. +/2/ qed. + +lemma cpr_tps: ∀L,T1,T2,d,e. L ⊢ T1 [d, e] ≫ T2 → L ⊢ T1 ⇒ T2. +/3 width=5/ qed. + +lemma cpr_refl: ∀L,T. L ⊢ T ⇒ T. +/2/ qed. + +(* NOTE: new property *) +lemma cpr_flat: ∀I,L,V1,V2,T1,T2. + L ⊢ V1 ⇒ V2 → L ⊢ T1 ⇒ T2 → L ⊢ 𝕗{I} V1. T1 ⇒ 𝕗{I} V2. T2. +#I #L #V1 #V2 #T1 #T2 * #V #HV1 #HV2 * /3 width=5/ +qed. + +lemma cpr_delta: ∀L,K,V1,V2,V,i. + ↓[0, i] L ≡ K. 𝕓{Abbr} V1 → K ⊢ V1 [0, |L| - i - 1] ≫ V2 → + ↑[0, i + 1] V2 ≡ V → L ⊢ #i ⇒ V. +#L #K #V1 #V2 #V #i #HLK #HV12 #HV2 +@ex2_1_intro [2: // | skip ] /3 width=8/ (**) (* /4/ is too slow *) +qed. + +lemma cpr_cast: ∀L,V,T1,T2. + L ⊢ T1 ⇒ T2 → L ⊢ 𝕗{Cast} V. T1 ⇒ T2. +#L #V #T1 #T2 * /3/ +qed. + +(* Basic inversion lemmas ***************************************************) diff --git a/matita/matita/contribs/lambda-delta/Basic-2/reduction/lpr.ma b/matita/matita/contribs/lambda-delta/Basic-2/reduction/lpr.ma new file mode 100644 index 000000000..92f77215c --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/reduction/lpr.ma @@ -0,0 +1,41 @@ +(**************************************************************************) +(* ___ *) +(* ||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 "lambda-delta/reduction/tpr.ma". + +(* CONTEXT-FREE PARALLEL REDUCTION ON LOCAL ENVIRONMENTS ********************) + +inductive lpr: lenv → lenv → Prop ≝ +| lpr_sort: lpr (⋆) (⋆) +| lpr_item: ∀K1,K2,I,V1,V2. + lpr K1 K2 → V1 ⇒ V2 → lpr (K1. 𝕓{I} V1) (K2. 𝕓{I} V2) (*𝕓*) +. + +interpretation + "context-free parallel reduction (environment)" + 'PRed L1 L2 = (lpr L1 L2). + +(* Basic inversion lemmas ***************************************************) + +lemma lpr_inv_item1_aux: ∀L1,L2. L1 ⇒ L2 → ∀K1,I,V1. L1 = K1. 𝕓{I} V1 → + ∃∃K2,V2. K1 ⇒ K2 & V1 ⇒ V2 & L2 = K2. 𝕓{I} V2. +#L1 #L2 * -L1 L2 +[ #K1 #I #V1 #H destruct +| #K1 #K2 #I #V1 #V2 #HK12 #HV12 #L #J #W #H destruct - K1 I V1 /2 width=5/ +] +qed. + +lemma lpr_inv_item1: ∀K1,I,V1,L2. K1. 𝕓{I} V1 ⇒ L2 → + ∃∃K2,V2. K1 ⇒ K2 & V1 ⇒ V2 & L2 = K2. 𝕓{I} V2. +/2/ qed. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr.ma b/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr.ma new file mode 100644 index 000000000..fbf4d47c4 --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr.ma @@ -0,0 +1,240 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/substitution/tps.ma". + +(* CONTEXT-FREE PARALLEL REDUCTION ON TERMS *********************************) + +inductive tpr: term → term → Prop ≝ +| tpr_sort : ∀k. tpr (⋆k) (⋆k) +| tpr_lref : ∀i. tpr (#i) (#i) +| tpr_bind : ∀I,V1,V2,T1,T2. tpr V1 V2 → tpr T1 T2 → + tpr (𝕓{I} V1. T1) (𝕓{I} V2. T2) +| tpr_flat : ∀I,V1,V2,T1,T2. tpr V1 V2 → tpr T1 T2 → + tpr (𝕗{I} V1. T1) (𝕗{I} V2. T2) +| tpr_beta : ∀V1,V2,W,T1,T2. + tpr V1 V2 → tpr T1 T2 → + tpr (𝕚{Appl} V1. 𝕚{Abst} W. T1) (𝕚{Abbr} V2. T2) +| tpr_delta: ∀V1,V2,T1,T2,T. + tpr V1 V2 → tpr T1 T2 → ⋆. 𝕓{Abbr} V2 ⊢ T2 [0, 1] ≫ T → + tpr (𝕚{Abbr} V1. T1) (𝕚{Abbr} V2. T) +| tpr_theta: ∀V,V1,V2,W1,W2,T1,T2. + tpr V1 V2 → ↑[0,1] V2 ≡ V → tpr W1 W2 → tpr T1 T2 → + tpr (𝕚{Appl} V1. 𝕚{Abbr} W1. T1) (𝕚{Abbr} W2. 𝕚{Appl} V. T2) +| tpr_zeta : ∀V,T,T1,T2. ↑[0,1] T1 ≡ T → tpr T1 T2 → + tpr (𝕚{Abbr} V. T) T2 +| tpr_tau : ∀V,T1,T2. tpr T1 T2 → tpr (𝕚{Cast} V. T1) T2 +. + +interpretation + "context-free parallel reduction (term)" + 'PRed T1 T2 = (tpr T1 T2). + +(* Basic properties *********************************************************) + +lemma tpr_refl: ∀T. T ⇒ T. +#T elim T -T // +#I elim I -I /2/ +qed. + +(* Basic inversion lemmas ***************************************************) + +lemma tpr_inv_sort1_aux: ∀U1,U2. U1 ⇒ U2 → ∀k. U1 = ⋆k → U2 = ⋆k. +#U1 #U2 * -U1 U2 +[ #k0 #k #H destruct -k0 // +| #i #k #H destruct +| #I #V1 #V2 #T1 #T2 #_ #_ #k #H destruct +| #I #V1 #V2 #T1 #T2 #_ #_ #k #H destruct +| #V1 #V2 #W #T1 #T2 #_ #_ #k #H destruct +| #V1 #V2 #T1 #T2 #T #_ #_ #_ #k #H destruct +| #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #k #H destruct +| #V #T #T1 #T2 #_ #_ #k #H destruct +| #V #T1 #T2 #_ #k #H destruct +] +qed. + +lemma tpr_inv_sort1: ∀k,U2. ⋆k ⇒ U2 → U2 = ⋆k. +/2/ qed. + +lemma tpr_inv_lref1_aux: ∀U1,U2. U1 ⇒ U2 → ∀i. U1 = #i → U2 = #i. +#U1 #U2 * -U1 U2 +[ #k #i #H destruct +| #j #i #H destruct -j // +| #I #V1 #V2 #T1 #T2 #_ #_ #i #H destruct +| #I #V1 #V2 #T1 #T2 #_ #_ #i #H destruct +| #V1 #V2 #W #T1 #T2 #_ #_ #i #H destruct +| #V1 #V2 #T1 #T2 #T #_ #_ #_ #i #H destruct +| #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #i #H destruct +| #V #T #T1 #T2 #_ #_ #i #H destruct +| #V #T1 #T2 #_ #i #H destruct +] +qed. + +lemma tpr_inv_lref1: ∀i,U2. #i ⇒ U2 → U2 = #i. +/2/ qed. + +lemma tpr_inv_abbr1_aux: ∀U1,U2. U1 ⇒ U2 → ∀V1,T1. U1 = 𝕚{Abbr} V1. T1 → + ∨∨ ∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕚{Abbr} V2. T2 + | ∃∃V2,T2,T. V1 ⇒ V2 & T1 ⇒ T2 & + ⋆. 𝕓{Abbr} V2 ⊢ T2 [0, 1] ≫ T & + U2 = 𝕚{Abbr} V2. T + | ∃∃T. ↑[0,1] T ≡ T1 & T ⇒ U2. +#U1 #U2 * -U1 U2 +[ #k #V #T #H destruct +| #i #V #T #H destruct +| #I #V1 #V2 #T1 #T2 #HV12 #HT12 #V #T #H destruct -I V1 T1 /3 width=5/ +| #I #V1 #V2 #T1 #T2 #_ #_ #V #T #H destruct +| #V1 #V2 #W #T1 #T2 #_ #_ #V #T #H destruct +| #V1 #V2 #T1 #T2 #T #HV12 #HT12 #HT2 #V0 #T0 #H destruct -V1 T1 /3 width=7/ +| #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #V0 #T0 #H destruct +| #V #T #T1 #T2 #HT1 #HT12 #V0 #T0 #H destruct -V T /3/ +| #V #T1 #T2 #_ #V0 #T0 #H destruct +] +qed. + +lemma tpr_inv_abbr1: ∀V1,T1,U2. 𝕚{Abbr} V1. T1 ⇒ U2 → + ∨∨ ∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕚{Abbr} V2. T2 + | ∃∃V2,T2,T. V1 ⇒ V2 & T1 ⇒ T2 & + ⋆. 𝕓{Abbr} V2 ⊢ T2 [0, 1] ≫ T & + U2 = 𝕚{Abbr} V2. T + | ∃∃T. ↑[0,1] T ≡ T1 & tpr T U2. +/2/ qed. + +lemma tpr_inv_abst1_aux: ∀U1,U2. U1 ⇒ U2 → ∀V1,T1. U1 = 𝕚{Abst} V1. T1 → + ∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕚{Abst} V2. T2. +#U1 #U2 * -U1 U2 +[ #k #V #T #H destruct +| #i #V #T #H destruct +| #I #V1 #V2 #T1 #T2 #HV12 #HT12 #V #T #H destruct -I V1 T1 /2 width=5/ +| #I #V1 #V2 #T1 #T2 #_ #_ #V #T #H destruct +| #V1 #V2 #W #T1 #T2 #_ #_ #V #T #H destruct +| #V1 #V2 #T1 #T2 #T #_ #_ #_ #V0 #T0 #H destruct +| #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #V0 #T0 #H destruct +| #V #T #T1 #T2 #_ #_ #V0 #T0 #H destruct +| #V #T1 #T2 #_ #V0 #T0 #H destruct +] +qed. + +lemma tpr_inv_abst1: ∀V1,T1,U2. 𝕚{Abst} V1. T1 ⇒ U2 → + ∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕚{Abst} V2. T2. +/2/ qed. + +lemma tpr_inv_bind1: ∀V1,T1,U2,I. 𝕓{I} V1. T1 ⇒ U2 → + ∨∨ ∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕓{I} V2. T2 + | ∃∃V2,T2,T. V1 ⇒ V2 & T1 ⇒ T2 & + ⋆. 𝕓{Abbr} V2 ⊢ T2 [0, 1] ≫ T & + U2 = 𝕚{Abbr} V2. T & I = Abbr + | ∃∃T. ↑[0,1] T ≡ T1 & tpr T U2 & I = Abbr. +#V1 #T1 #U2 * #H +[ elim (tpr_inv_abbr1 … H) -H * /3 width=7/ +| /3/ +] +qed. + +lemma tpr_inv_appl1_aux: ∀U1,U2. U1 ⇒ U2 → ∀V1,U0. U1 = 𝕚{Appl} V1. U0 → + ∨∨ ∃∃V2,T2. V1 ⇒ V2 & U0 ⇒ T2 & + U2 = 𝕚{Appl} V2. T2 + | ∃∃V2,W,T1,T2. V1 ⇒ V2 & T1 ⇒ T2 & + U0 = 𝕚{Abst} W. T1 & + U2 = 𝕓{Abbr} V2. T2 + | ∃∃V2,V,W1,W2,T1,T2. V1 ⇒ V2 & W1 ⇒ W2 & T1 ⇒ T2 & + ↑[0,1] V2 ≡ V & + U0 = 𝕚{Abbr} W1. T1 & + U2 = 𝕚{Abbr} W2. 𝕚{Appl} V. T2. +#U1 #U2 * -U1 U2 +[ #k #V #T #H destruct +| #i #V #T #H destruct +| #I #V1 #V2 #T1 #T2 #_ #_ #V #T #H destruct +| #I #V1 #V2 #T1 #T2 #HV12 #HT12 #V #T #H destruct -I V1 T1 /3 width=5/ +| #V1 #V2 #W #T1 #T2 #HV12 #HT12 #V #T #H destruct -V1 T /3 width=8/ +| #V1 #V2 #T1 #T2 #T #_ #_ #_ #V0 #T0 #H destruct +| #V #V1 #V2 #W1 #W2 #T1 #T2 #HV12 #HV2 #HW12 #HT12 #V0 #T0 #H + destruct -V1 T0 /3 width=12/ +| #V #T #T1 #T2 #_ #_ #V0 #T0 #H destruct +| #V #T1 #T2 #_ #V0 #T0 #H destruct +] +qed. + +lemma tpr_inv_appl1: ∀V1,U0,U2. 𝕚{Appl} V1. U0 ⇒ U2 → + ∨∨ ∃∃V2,T2. V1 ⇒ V2 & U0 ⇒ T2 & + U2 = 𝕚{Appl} V2. T2 + | ∃∃V2,W,T1,T2. V1 ⇒ V2 & T1 ⇒ T2 & + U0 = 𝕚{Abst} W. T1 & + U2 = 𝕓{Abbr} V2. T2 + | ∃∃V2,V,W1,W2,T1,T2. V1 ⇒ V2 & W1 ⇒ W2 & T1 ⇒ T2 & + ↑[0,1] V2 ≡ V & + U0 = 𝕚{Abbr} W1. T1 & + U2 = 𝕚{Abbr} W2. 𝕚{Appl} V. T2. +/2/ qed. + +lemma tpr_inv_cast1_aux: ∀U1,U2. U1 ⇒ U2 → ∀V1,T1. U1 = 𝕚{Cast} V1. T1 → + (∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕚{Cast} V2. T2) + ∨ T1 ⇒ U2. +#U1 #U2 * -U1 U2 +[ #k #V #T #H destruct +| #i #V #T #H destruct +| #I #V1 #V2 #T1 #T2 #_ #_ #V #T #H destruct +| #I #V1 #V2 #T1 #T2 #HV12 #HT12 #V #T #H destruct -I V1 T1 /3 width=5/ +| #V1 #V2 #W #T1 #T2 #_ #_ #V #T #H destruct +| #V1 #V2 #T1 #T2 #T #_ #_ #_ #V0 #T0 #H destruct +| #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #V0 #T0 #H destruct +| #V #T #T1 #T2 #_ #_ #V0 #T0 #H destruct +| #V #T1 #T2 #HT12 #V0 #T0 #H destruct -V T1 /2/ +] +qed. + +lemma tpr_inv_cast1: ∀V1,T1,U2. 𝕚{Cast} V1. T1 ⇒ U2 → + (∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕚{Cast} V2. T2) + ∨ T1 ⇒ U2. +/2/ qed. + +lemma tpr_inv_flat1: ∀V1,U0,U2,I. 𝕗{I} V1. U0 ⇒ U2 → + ∨∨ ∃∃V2,T2. V1 ⇒ V2 & U0 ⇒ T2 & + U2 = 𝕗{I} V2. T2 + | ∃∃V2,W,T1,T2. V1 ⇒ V2 & T1 ⇒ T2 & + U0 = 𝕚{Abst} W. T1 & + U2 = 𝕓{Abbr} V2. T2 & I = Appl + | ∃∃V2,V,W1,W2,T1,T2. V1 ⇒ V2 & W1 ⇒ W2 & T1 ⇒ T2 & + ↑[0,1] V2 ≡ V & + U0 = 𝕚{Abbr} W1. T1 & + U2 = 𝕚{Abbr} W2. 𝕚{Appl} V. T2 & + I = Appl + | (U0 ⇒ U2 ∧ I = Cast). +#V1 #U0 #U2 * #H +[ elim (tpr_inv_appl1 … H) -H * /3 width=12/ +| elim (tpr_inv_cast1 … H) -H [1: *] /3 width=5/ +] +qed. + +lemma tpr_inv_lref2_aux: ∀T1,T2. T1 ⇒ T2 → ∀i. T2 = #i → + ∨∨ T1 = #i + | ∃∃V,T,T0. ↑[O,1] T0 ≡ T & T0 ⇒ #i & + T1 = 𝕚{Abbr} V. T + | ∃∃V,T. T ⇒ #i & T1 = 𝕚{Cast} V. T. +#T1 #T2 * -T1 T2 +[ #k #i #H destruct +| #j #i /2/ +| #I #V1 #V2 #T1 #T2 #_ #_ #i #H destruct +| #I #V1 #V2 #T1 #T2 #_ #_ #i #H destruct +| #V1 #V2 #W #T1 #T2 #_ #_ #i #H destruct +| #V1 #V2 #T1 #T2 #T #_ #_ #_ #i #H destruct +| #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #i #H destruct +| #V #T #T1 #T2 #HT1 #HT12 #i #H destruct /3 width=6/ +| #V #T1 #T2 #HT12 #i #H destruct /3/ +] +qed. + +lemma tpr_inv_lref2: ∀T1,i. T1 ⇒ #i → + ∨∨ T1 = #i + | ∃∃V,T,T0. ↑[O,1] T0 ≡ T & T0 ⇒ #i & + T1 = 𝕓{Abbr} V. T + | ∃∃V,T. T ⇒ #i & T1 = 𝕗{Cast} V. T. +/2/ qed. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_lift.ma b/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_lift.ma new file mode 100644 index 000000000..e6fd96454 --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_lift.ma @@ -0,0 +1,102 @@ +(**************************************************************************) +(* ___ *) +(* ||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 "lambda-delta/substitution/tps_lift.ma". +include "lambda-delta/reduction/tpr.ma". + +(* Relocation properties ****************************************************) + +lemma tpr_lift: ∀T1,T2. T1 ⇒ T2 → + ∀d,e,U1. ↑[d, e] T1 ≡ U1 → ∀U2. ↑[d, e] T2 ≡ U2 → U1 ⇒ U2. +#T1 #T2 #H elim H -H T1 T2 +[ #k #d #e #U1 #HU1 #U2 #HU2 + lapply (lift_mono … HU1 … HU2) -HU1 #H destruct -U1; + lapply (lift_inv_sort1 … HU2) -HU2 #H destruct -U2 // +| #i #d #e #U1 #HU1 #U2 #HU2 + lapply (lift_mono … HU1 … HU2) -HU1 #H destruct -U1; + lapply (lift_inv_lref1 … HU2) * * #Hid #H destruct -U2 // +| #I #V1 #V2 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X1 #HX1 #X2 #HX2 + elim (lift_inv_bind1 … HX1) -HX1 #W1 #U1 #HVW1 #HTU1 #HX1 destruct -X1; + elim (lift_inv_bind1 … HX2) -HX2 #W2 #U2 #HVW2 #HTU2 #HX2 destruct -X2 /3/ +| #I #V1 #V2 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X1 #HX1 #X2 #HX2 + elim (lift_inv_flat1 … HX1) -HX1 #W1 #U1 #HVW1 #HTU1 #HX1 destruct -X1; + elim (lift_inv_flat1 … HX2) -HX2 #W2 #U2 #HVW2 #HTU2 #HX2 destruct -X2 /3/ +| #V1 #V2 #W #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X1 #HX1 #X2 #HX2 + elim (lift_inv_flat1 … HX1) -HX1 #V0 #X #HV10 #HX #HX1 destruct -X1; + elim (lift_inv_bind1 … HX) -HX #W0 #T0 #HW0 #HT10 #HX destruct -X; + elim (lift_inv_bind1 … HX2) -HX2 #V3 #T3 #HV23 #HT23 #HX2 destruct -X2 /3/ +| #V1 #V2 #T1 #T2 #T0 #HV12 #HT12 #HT2 #IHV12 #IHT12 #d #e #X1 #HX1 #X2 #HX2 + elim (lift_inv_bind1 … HX1) -HX1 #W1 #U1 #HVW1 #HTU1 #HX1 destruct -X1; + elim (lift_inv_bind1 … HX2) -HX2 #W2 #U0 #HVW2 #HTU0 #HX2 destruct -X2; + elim (lift_total T2 (d + 1) e) #U2 #HTU2 + @tpr_delta + [4: @(tps_lift_le … HT2 … HTU2 HTU0 ?) /2/ |1: skip |2: /2/ |3: /2/ ] (**) (*/3. is too slow *) +| #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #HV2 #_ #_ #IHV12 #IHW12 #IHT12 #d #e #X1 #HX1 #X2 #HX2 + elim (lift_inv_flat1 … HX1) -HX1 #V0 #X #HV10 #HX #HX1 destruct -X1; + elim (lift_inv_bind1 … HX) -HX #W0 #T0 #HW0 #HT10 #HX destruct -X; + elim (lift_inv_bind1 … HX2) -HX2 #W3 #X #HW23 #HX #HX2 destruct -X2; + elim (lift_inv_flat1 … HX) -HX #V3 #T3 #HV3 #HT23 #HX destruct -X; + elim (lift_trans_ge … HV2 … HV3 ?) -HV2 HV3 V // /3/ +| #V #T #T1 #T2 #HT1 #_ #IHT12 #d #e #X #HX #T0 #HT20 + elim (lift_inv_bind1 … HX) -HX #V3 #T3 #_ #HT3 #HX destruct -X; + elim (lift_trans_ge … HT1 … HT3 ?) -HT1 HT3 T // /3 width=6/ +| #V #T1 #T2 #_ #IHT12 #d #e #X #HX #T #HT2 + elim (lift_inv_flat1 … HX) -HX #V0 #T0 #_ #HT0 #HX destruct -X /3/ +] +qed. + +lemma tpr_inv_lift: ∀T1,T2. T1 ⇒ T2 → + ∀d,e,U1. ↑[d, e] U1 ≡ T1 → + ∃∃U2. ↑[d, e] U2 ≡ T2 & U1 ⇒ U2. +#T1 #T2 #H elim H -H T1 T2 +[ #k #d #e #U1 #HU1 + lapply (lift_inv_sort2 … HU1) -HU1 #H destruct -U1 /2/ +| #i #d #e #U1 #HU1 + lapply (lift_inv_lref2 … HU1) -HU1 * * #Hid #H destruct -U1 /3/ +| #I #V1 #V2 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X #HX + elim (lift_inv_bind2 … HX) -HX #V0 #T0 #HV01 #HT01 #HX destruct -X; + elim (IHV12 … HV01) -IHV12 HV01; + elim (IHT12 … HT01) -IHT12 HT01 /3 width=5/ +| #I #V1 #V2 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X #HX + elim (lift_inv_flat2 … HX) -HX #V0 #T0 #HV01 #HT01 #HX destruct -X; + elim (IHV12 … HV01) -IHV12 HV01; + elim (IHT12 … HT01) -IHT12 HT01 /3 width=5/ +| #V1 #V2 #W1 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X #HX + elim (lift_inv_flat2 … HX) -HX #V0 #Y #HV01 #HY #HX destruct -X; + elim (lift_inv_bind2 … HY) -HY #W0 #T0 #HW01 #HT01 #HY destruct -Y; + elim (IHV12 … HV01) -IHV12 HV01; + elim (IHT12 … HT01) -IHT12 HT01 /3 width=5/ +| #V1 #V2 #T1 #T2 #T0 #_ #_ #HT20 #IHV12 #IHT12 #d #e #X #HX + elim (lift_inv_bind2 … HX) -HX #W1 #U1 #HWV1 #HUT1 #HX destruct -X; + elim (IHV12 … HWV1) -IHV12 HWV1 #W2 #HWV2 #HW12 + elim (IHT12 … HUT1) -IHT12 HUT1 #U2 #HUT2 #HU12 + elim (tps_inv_lift1_le … HT20 … HUT2 ?) -HT20 HUT2 // [3: /2 width=5/ |2: skip ] #U0 #HU20 #HUT0 + @ex2_1_intro [2: /2/ |1: skip |3: /2/ ] (**) (* /3 width=5/ is slow *) +| #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #HV2 #_ #_ #IHV12 #IHW12 #IHT12 #d #e #X #HX + elim (lift_inv_flat2 … HX) -HX #V0 #Y #HV01 #HY #HX destruct -X; + elim (lift_inv_bind2 … HY) -HY #W0 #T0 #HW01 #HT01 #HY destruct -Y; + elim (IHV12 … HV01) -IHV12 HV01 #V3 #HV32 #HV03 + elim (IHW12 … HW01) -IHW12 HW01 #W3 #HW32 #HW03 + elim (IHT12 … HT01) -IHT12 HT01 #T3 #HT32 #HT03 + elim (lift_trans_le … HV32 … HV2 ?) -HV32 HV2 V2 // #V2 #HV32 #HV2 + @ex2_1_intro [2: /3/ |1: skip |3: /2/ ] (**) (* /4 width=5/ is slow *) +| #V #T #T1 #T2 #HT1 #_ #IHT12 #d #e #X #HX + elim (lift_inv_bind2 … HX) -HX #V0 #T0 #_ #HT0 #H destruct -X; + elim (lift_div_le … HT1 … HT0 ?) -HT1 HT0 T // #T #HT0 #HT1 + elim (IHT12 … HT1) -IHT12 HT1 /3 width=5/ +| #V #T1 #T2 #_ #IHT12 #d #e #X #HX + elim (lift_inv_flat2 … HX) -HX #V0 #T0 #_ #HT01 #H destruct -X; + elim (IHT12 … HT01) -IHT12 HT01 /3/ +] +qed. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_tpr.ma b/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_tpr.ma new file mode 100644 index 000000000..ee22bfc21 --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_tpr.ma @@ -0,0 +1,351 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/substitution/lift_weight.ma". +include "lambda-delta/substitution/tps_tps.ma". +include "lambda-delta/reduction/tpr_lift.ma". +include "lambda-delta/reduction/tpr_tps.ma". + +(* CONTEXT-FREE PARALLEL REDUCTION ON TERMS *********************************) + +(* Confluence lemmas ********************************************************) + +lemma tpr_conf_sort_sort: ∀k. ∃∃X. ⋆k ⇒ X & ⋆k ⇒ X. +/2/ qed. + +lemma tpr_conf_lref_lref: ∀i. ∃∃X. #i ⇒ X & #i ⇒ X. +/2/ qed. + +lemma tpr_conf_bind_bind: + ∀I,V0,V1,T0,T1,V2,T2. ( + ∀X0:term. #X0 < #V0 + #T0 + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → V0 ⇒ V2 → T0 ⇒ T1 → T0 ⇒ T2 → + ∃∃X. 𝕓{I} V1. T1 ⇒ X & 𝕓{I} V2. T2 ⇒ X. +#I #V0 #V1 #T0 #T1 #V2 #T2 #IH #HV01 #HV02 #HT01 #HT02 +elim (IH … HV01 … HV02) -HV01 HV02 // #V #HV1 #HV2 +elim (IH … HT01 … HT02) -HT01 HT02 IH /3 width=5/ +qed. + +lemma tpr_conf_bind_delta: + ∀V0,V1,T0,T1,V2,T2,T. ( + ∀X0:term. #X0 < #V0 + #T0 + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → V0 ⇒ V2 → + T0 ⇒ T1 → T0 ⇒ T2 → ⋆. 𝕓{Abbr} V2 ⊢ T2 [O,1] ≫ T → + ∃∃X. 𝕓{Abbr} V1. T1 ⇒ X & 𝕓{Abbr} V2. T ⇒ X. +#V0 #V1 #T0 #T1 #V2 #T2 #T #IH #HV01 #HV02 #HT01 #HT02 #HT2 +elim (IH … HV01 … HV02) -HV01 HV02 // #V #HV1 #HV2 +elim (IH … HT01 … HT02) -HT01 HT02 IH // -V0 T0 #T0 #HT10 #HT20 +elim (tpr_tps_bind … HV2 HT20 … HT2) -HT20 HT2 /3 width=5/ +qed. + +lemma tpr_conf_bind_zeta: + ∀X2,V0,V1,T0,T1,T. ( + ∀X0:term. #X0 < #V0 + #T0 +1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → T0 ⇒ T1 → T ⇒ X2 → ↑[O, 1] T ≡ T0 → + ∃∃X. 𝕓{Abbr} V1. T1 ⇒ X & X2 ⇒ X. +#X2 #V0 #V1 #T0 #T1 #T #IH #HV01 #HT01 #HTX2 #HT0 +elim (tpr_inv_lift … HT01 … HT0) -HT01 #U #HUT1 #HTU +lapply (tw_lift … HT0) -HT0 #HT0 +elim (IH … HTX2 … HTU) -HTX2 HTU IH /3/ +qed. + +lemma tpr_conf_flat_flat: + ∀I,V0,V1,T0,T1,V2,T2. ( + ∀X0:term. #X0 < #V0 + #T0 + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → V0 ⇒ V2 → T0 ⇒ T1 → T0 ⇒ T2 → + ∃∃T0. 𝕗{I} V1. T1 ⇒ T0 & 𝕗{I} V2. T2 ⇒ T0. +#I #V0 #V1 #T0 #T1 #V2 #T2 #IH #HV01 #HV02 #HT01 #HT02 +elim (IH … HV01 … HV02) -HV01 HV02 // #V #HV1 #HV2 +elim (IH … HT01 … HT02) -HT01 HT02 /3 width=5/ +qed. + +lemma tpr_conf_flat_beta: + ∀V0,V1,T1,V2,W0,U0,T2. ( + ∀X0:term. #X0 < #V0 + (#W0 + #U0 + 1) + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → V0 ⇒ V2 → + U0 ⇒ T2 → 𝕓{Abst} W0. U0 ⇒ T1 → + ∃∃X. 𝕗{Appl} V1. T1 ⇒ X & 𝕓{Abbr} V2. T2 ⇒ X. +#V0 #V1 #T1 #V2 #W0 #U0 #T2 #IH #HV01 #HV02 #HT02 #H +elim (tpr_inv_abst1 … H) -H #W1 #U1 #HW01 #HU01 #H destruct -T1; +elim (IH … HV01 … HV02) -HV01 HV02 // #V #HV1 #HV2 +elim (IH … HT02 … HU01) -HT02 HU01 IH /3 width=5/ +qed. + +lemma tpr_conf_flat_theta: + ∀V0,V1,T1,V2,V,W0,W2,U0,U2. ( + ∀X0:term. #X0 < #V0 + (#W0 + #U0 + 1) + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → V0 ⇒ V2 → ↑[O,1] V2 ≡ V → + W0 ⇒ W2 → U0 ⇒ U2 → 𝕓{Abbr} W0. U0 ⇒ T1 → + ∃∃X. 𝕗{Appl} V1. T1 ⇒ X & 𝕓{Abbr} W2. 𝕗{Appl} V. U2 ⇒ X. +#V0 #V1 #T1 #V2 #V #W0 #W2 #U0 #U2 #IH #HV01 #HV02 #HV2 #HW02 #HU02 #H +elim (IH … HV01 … HV02) -HV01 HV02 // #VV #HVV1 #HVV2 +elim (lift_total VV 0 1) #VVV #HVV +lapply (tpr_lift … HVV2 … HV2 … HVV) #HVVV +elim (tpr_inv_abbr1 … H) -H * +(* case 1: bind *) +[ -HV2 HVV2 #WW #UU #HWW0 #HUU0 #H destruct -T1; + elim (IH … HW02 … HWW0) -HW02 HWW0 // #W #HW2 #HWW + elim (IH … HU02 … HUU0) -HU02 HUU0 IH // #U #HU2 #HUU + @ex2_1_intro [2: @tpr_theta |1:skip |3: @tpr_bind ] /2 width=7/ (**) (* /4 width=7/ is too slow *) +(* case 2: delta *) +| -HV2 HVV2 #WW2 #UU2 #UU #HWW2 #HUU02 #HUU2 #H destruct -T1; + elim (IH … HW02 … HWW2) -HW02 HWW2 // #W #HW02 #HWW2 + elim (IH … HU02 … HUU02) -HU02 HUU02 IH // #U #HU2 #HUUU2 + elim (tpr_tps_bind … HWW2 HUUU2 … HUU2) -HUU2 HUUU2 #UUU #HUUU2 #HUUU1 + @ex2_1_intro + [2: @tpr_theta [6: @HVV |7: @HWW2 |8: @HUUU2 |1,2,3,4: skip | // ] + |1:skip + |3: @tpr_delta [3: @tpr_flat |1: skip ] /2 width=5/ + ] (**) (* /5 width=14/ is too slow *) +(* case 3: zeta *) +| -HW02 HVV HVVV #UU1 #HUU10 #HUUT1 + elim (tpr_inv_lift … HU02 … HUU10) -HU02 #UU #HUU2 #HUU1 + lapply (tw_lift … HUU10) -HUU10 #HUU10 + elim (IH … HUUT1 … HUU1) -HUUT1 HUU1 IH // -HUU10 #U #HU2 #HUUU2 + @ex2_1_intro + [2: @tpr_flat + |1: skip + |3: @tpr_zeta [2: @lift_flat |1: skip |3: @tpr_flat ] + ] /2 width=5/ (**) (* /5 width=5/ is too slow *) +] +qed. + +lemma tpr_conf_flat_cast: + ∀X2,V0,V1,T0,T1. ( + ∀X0:term. #X0 < #V0 + # T0 + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → T0 ⇒ T1 → T0 ⇒ X2 → + ∃∃X. 𝕗{Cast} V1. T1 ⇒ X & X2 ⇒ X. +#X2 #V0 #V1 #T0 #T1 #IH #_ #HT01 #HT02 +elim (IH … HT01 … HT02) -HT01 HT02 IH /3/ +qed. + +lemma tpr_conf_beta_beta: + ∀W0:term. ∀V0,V1,T0,T1,V2,T2. ( + ∀X0:term. #X0 < #V0 + (#W0 + #T0 + 1) + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → V0 ⇒ V2 → T0 ⇒ T1 → T0 ⇒ T2 → + ∃∃X. 𝕓{Abbr} V1. T1 ⇒X & 𝕓{Abbr} V2. T2 ⇒ X. +#W0 #V0 #V1 #T0 #T1 #V2 #T2 #IH #HV01 #HV02 #HT01 #HT02 +elim (IH … HV01 … HV02) -HV01 HV02 // +elim (IH … HT01 … HT02) -HT01 HT02 IH /3 width=5/ +qed. + +lemma tpr_conf_delta_delta: + ∀V0,V1,T0,T1,TT1,V2,T2,TT2. ( + ∀X0:term. #X0 < #V0 +#T0 + 1→ + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → V0 ⇒ V2 → T0 ⇒ T1 → T0 ⇒ T2 → + ⋆. 𝕓{Abbr} V1 ⊢ T1 [O, 1] ≫ TT1 → + ⋆. 𝕓{Abbr} V2 ⊢ T2 [O, 1] ≫ TT2 → + ∃∃X. 𝕓{Abbr} V1. TT1 ⇒ X & 𝕓{Abbr} V2. TT2 ⇒ X. +#V0 #V1 #T0 #T1 #TT1 #V2 #T2 #TT2 #IH #HV01 #HV02 #HT01 #HT02 #HTT1 #HTT2 +elim (IH … HV01 … HV02) -HV01 HV02 // #V #HV1 #HV2 +elim (IH … HT01 … HT02) -HT01 HT02 IH // #T #HT1 #HT2 +elim (tpr_tps_bind … HV1 HT1 … HTT1) -HT1 HTT1 #U1 #TTU1 #HTU1 +elim (tpr_tps_bind … HV2 HT2 … HTT2) -HT2 HTT2 #U2 #TTU2 #HTU2 +elim (tps_conf … HTU1 … HTU2) -HTU1 HTU2 #U #HU1 #HU2 +@ex2_1_intro [2,3: @tpr_delta |1: skip ] /width=10/ (**) (* /3 width=10/ is too slow *) +qed. + +lemma tpr_conf_delta_zeta: + ∀X2,V0,V1,T0,T1,TT1,T2. ( + ∀X0:term. #X0 < #V0 +#T0 + 1→ + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → T0 ⇒ T1 → ⋆. 𝕓{Abbr} V1 ⊢ T1 [O,1] ≫ TT1 → + T2 ⇒ X2 → ↑[O, 1] T2 ≡ T0 → + ∃∃X. 𝕓{Abbr} V1. TT1 ⇒ X & X2 ⇒ X. +#X2 #V0 #V1 #T0 #T1 #TT1 #T2 #IH #_ #HT01 #HTT1 #HTX2 #HTT20 +elim (tpr_inv_lift … HT01 … HTT20) -HT01 #TT2 #HTT21 #HTT2 +lapply (tps_inv_lift1_eq … HTT1 … HTT21) -HTT1 #HTT1 destruct -T1; +lapply (tw_lift … HTT20) -HTT20 #HTT20 +elim (IH … HTX2 … HTT2) -HTX2 HTT2 IH /3/ +qed. + +lemma tpr_conf_theta_theta: + ∀VV1,V0,V1,W0,W1,T0,T1,V2,VV2,W2,T2. ( + ∀X0:term. #X0 < #V0 + (#W0 + #T0 + 1) + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + V0 ⇒ V1 → V0 ⇒ V2 → W0 ⇒ W1 → W0 ⇒ W2 → T0 ⇒ T1 → T0 ⇒ T2 → + ↑[O, 1] V1 ≡ VV1 → ↑[O, 1] V2 ≡ VV2 → + ∃∃X. 𝕓{Abbr} W1. 𝕗{Appl} VV1. T1 ⇒ X & 𝕓{Abbr} W2. 𝕗{Appl} VV2. T2 ⇒ X. +#VV1 #V0 #V1 #W0 #W1 #T0 #T1 #V2 #VV2 #W2 #T2 #IH #HV01 #HV02 #HW01 #HW02 #HT01 #HT02 #HVV1 #HVV2 +elim (IH … HV01 … HV02) -HV01 HV02 // #V #HV1 #HV2 +elim (IH … HW01 … HW02) -HW01 HW02 // #W #HW1 #HW2 +elim (IH … HT01 … HT02) -HT01 HT02 IH // #T #HT1 #HT2 +elim (lift_total V 0 1) #VV #HVV +lapply (tpr_lift … HV1 … HVV1 … HVV) -HV1 HVV1 #HVV1 +lapply (tpr_lift … HV2 … HVV2 … HVV) -HV2 HVV2 HVV #HVV2 +@ex2_1_intro [2,3: @tpr_bind |1:skip ] /2 width=5/ (**) (* /4 width=5/ is too slow *) +qed. + +lemma tpr_conf_zeta_zeta: + ∀V0:term. ∀X2,TT0,T0,T1,T2. ( + ∀X0:term. #X0 < #V0 + #TT0 + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + T0 ⇒ T1 → T2 ⇒ X2 → + ↑[O, 1] T0 ≡ TT0 → ↑[O, 1] T2 ≡ TT0 → + ∃∃X. T1 ⇒ X & X2 ⇒ X. +#V0 #X2 #TT0 #T0 #T1 #T2 #IH #HT01 #HTX2 #HTT0 #HTT20 +lapply (lift_inj … HTT0 … HTT20) -HTT0 #H destruct -T0; +lapply (tw_lift … HTT20) -HTT20 #HTT20 +elim (IH … HT01 … HTX2) -HT01 HTX2 IH /2/ +qed. + +lemma tpr_conf_tau_tau: + ∀V0,T0:term. ∀X2,T1. ( + ∀X0:term. #X0 < #V0 + #T0 + 1 → + ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + T0 ⇒ T1 → T0 ⇒ X2 → + ∃∃X. T1 ⇒ X & X2 ⇒ X. +#V0 #T0 #X2 #T1 #IH #HT01 #HT02 +elim (IH … HT01 … HT02) -HT01 HT02 IH /2/ +qed. + +(* Confluence ***************************************************************) + +lemma tpr_conf_aux: + ∀Y0:term. ( + ∀X0:term. #X0 < #Y0 → ∀X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → + ∃∃X. X1 ⇒ X & X2 ⇒ X + ) → + ∀X0,X1,X2. X0 ⇒ X1 → X0 ⇒ X2 → X0 = Y0 → + ∃∃X. X1 ⇒ X & X2 ⇒ X. +#Y0 #IH #X0 #X1 #X2 * -X0 X1 +[ #k1 #H1 #H2 destruct -Y0; + lapply (tpr_inv_sort1 … H1) -H1 +(* case 1: sort, sort *) + #H1 destruct -X2 // +| #i1 #H1 #H2 destruct -Y0; + lapply (tpr_inv_lref1 … H1) -H1 +(* case 2: lref, lref *) + #H1 destruct -X2 // +| #I #V0 #V1 #T0 #T1 #HV01 #HT01 #H1 #H2 destruct -Y0; + elim (tpr_inv_bind1 … H1) -H1 * +(* case 3: bind, bind *) + [ #V2 #T2 #HV02 #HT02 #H destruct -X2 + /3 width=7 by tpr_conf_bind_bind/ (**) (* /3 width=7/ is too slow *) +(* case 4: bind, delta *) + | #V2 #T2 #T #HV02 #HT02 #HT2 #H1 #H2 destruct -X2 I + /3 width=9 by tpr_conf_bind_delta/ (**) (* /3 width=9/ is too slow *) +(* case 5: bind, zeta *) + | #T #HT0 #HTX2 #H destruct -I + /3 width=8 by tpr_conf_bind_zeta/ (**) (* /3 width=8/ is too slow *) + ] +| #I #V0 #V1 #T0 #T1 #HV01 #HT01 #H1 #H2 destruct -Y0; + elim (tpr_inv_flat1 … H1) -H1 * +(* case 6: flat, flat *) + [ #V2 #T2 #HV02 #HT02 #H destruct -X2 + /3 width=7 by tpr_conf_flat_flat/ (**) (* /3 width=7/ is too slow *) +(* case 7: flat, beta *) + | #V2 #W #U0 #T2 #HV02 #HT02 #H1 #H2 #H3 destruct -T0 X2 I + /3 width=8 by tpr_conf_flat_beta/ (**) (* /3 width=8/ is too slow *) +(* case 8: flat, theta *) + | #V2 #V #W0 #W2 #U0 #U2 #HV02 #HW02 #HT02 #HV2 #H1 #H2 #H3 destruct -T0 X2 I + /3 width=11 by tpr_conf_flat_theta/ (**) (* /3 width=11/ is too slow *) +(* case 9: flat, tau *) + | #HT02 #H destruct -I + /3 width=6 by tpr_conf_flat_cast/ (**) (* /3 width=6/ is too slow *) + ] +| #V0 #V1 #W0 #T0 #T1 #HV01 #HT01 #H1 #H2 destruct -Y0; + elim (tpr_inv_appl1 … H1) -H1 * +(* case 10: beta, flat (repeated) *) + [ #V2 #T2 #HV02 #HT02 #H destruct -X2 + @ex2_1_comm /3 width=8 by tpr_conf_flat_beta/ +(* case 11: beta, beta *) + | #V2 #WW0 #TT0 #T2 #HV02 #HT02 #H1 #H2 destruct -W0 T0 X2 + /3 width=8 by tpr_conf_beta_beta/ (**) (* /3 width=8/ is too slow *) +(* case 12, beta, theta (excluded) *) + | #V2 #VV2 #WW0 #W2 #TT0 #T2 #_ #_ #_ #_ #H destruct + ] +| #V0 #V1 #T0 #T1 #TT1 #HV01 #HT01 #HTT1 #H1 #H2 destruct -Y0; + elim (tpr_inv_abbr1 … H1) -H1 * +(* case 13: delta, bind (repeated) *) + [ #V2 #T2 #HV02 #T02 #H destruct -X2 + @ex2_1_comm /3 width=9 by tpr_conf_bind_delta/ +(* case 14: delta, delta *) + | #V2 #T2 #TT2 #HV02 #HT02 #HTT2 #H destruct -X2 + /3 width=11 by tpr_conf_delta_delta/ (**) (* /3 width=11/ is too slow *) +(* case 15: delta, zata *) + | #T2 #HT20 #HTX2 + /3 width=10 by tpr_conf_delta_zeta/ (**) (* /3 width=10/ is too slow *) + ] +| #VV1 #V0 #V1 #W0 #W1 #T0 #T1 #HV01 #HVV1 #HW01 #HT01 #H1 #H2 destruct -Y0; + elim (tpr_inv_appl1 … H1) -H1 * +(* case 16: theta, flat (repeated) *) + [ #V2 #T2 #HV02 #HT02 #H destruct -X2 + @ex2_1_comm /3 width=11 by tpr_conf_flat_theta/ +(* case 17: theta, beta (repeated) *) + | #V2 #WW0 #TT0 #T2 #_ #_ #H destruct +(* case 18: theta, theta *) + | #V2 #VV2 #WW0 #W2 #TT0 #T2 #V02 #HW02 #HT02 #HVV2 #H1 #H2 destruct -W0 T0 X2 + /3 width=14 by tpr_conf_theta_theta/ (**) (* /3 width=14/ is too slow *) + ] +| #V0 #TT0 #T0 #T1 #HTT0 #HT01 #H1 #H2 destruct -Y0; + elim (tpr_inv_abbr1 … H1) -H1 * +(* case 19: zeta, bind (repeated) *) + [ #V2 #T2 #HV02 #T02 #H destruct -X2 + @ex2_1_comm /3 width=8 by tpr_conf_bind_zeta/ +(* case 20: zeta, delta (repeated) *) + | #V2 #T2 #TT2 #HV02 #HT02 #HTT2 #H destruct -X2 + @ex2_1_comm /3 width=10 by tpr_conf_delta_zeta/ +(* case 21: zeta, zeta *) + | #T2 #HTT20 #HTX2 + /3 width=9 by tpr_conf_zeta_zeta/ (**) (* /3 width=9/ is too slow *) + ] +| #V0 #T0 #T1 #HT01 #H1 #H2 destruct -Y0; + elim (tpr_inv_cast1 … H1) -H1 +(* case 22: tau, flat (repeated) *) + [ * #V2 #T2 #HV02 #HT02 #H destruct -X2 + @ex2_1_comm /3 width=6 by tpr_conf_flat_cast/ +(* case 23: tau, tau *) + | #HT02 + /2 by tpr_conf_tau_tau/ + ] +] +qed. + +theorem tpr_conf: ∀T0:term. ∀T1,T2. T0 ⇒ T1 → T0 ⇒ T2 → + ∃∃T. T1 ⇒ T & T2 ⇒ T. +#T @(tw_wf_ind … T) -T /3 width=6 by tpr_conf_aux/ +qed. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_tps.ma b/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_tps.ma new file mode 100644 index 000000000..96bc9b76e --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_tps.ma @@ -0,0 +1,26 @@ +(**************************************************************************) +(* ___ *) +(* ||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 "lambda-delta/reduction/lpr.ma". + +(* CONTEXT-FREE PARALLEL REDUCTION ON TERMS *********************************) + +axiom tpr_tps_lpr: ∀L1,L2. L1 ⇒ L2 → ∀T1,T2. T1 ⇒ T2 → + ∀d,e,U1. L1 ⊢ T1 [d, e] ≫ U1 → + ∃∃U2. U1 ⇒ U2 & L2 ⊢ T2 [d, e] ≫ U2. + +lemma tpr_tps_bind: ∀I,V1,V2,T1,T2,U1. V1 ⇒ V2 → T1 ⇒ T2 → + ⋆. 𝕓{I} V1 ⊢ T1 [0, 1] ≫ U1 → + ∃∃U2. U1 ⇒ U2 & ⋆. 𝕓{I} V2 ⊢ T2 [0, 1] ≫ U2. +/3 width=5/ qed. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/substitution/drop.ma b/matita/matita/contribs/lambda-delta/Basic-2/substitution/drop.ma new file mode 100644 index 000000000..29b57405f --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/substitution/drop.ma @@ -0,0 +1,193 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/substitution/leq.ma". +include "lambda-delta/substitution/lift.ma". + +(* DROPPING *****************************************************************) + +inductive drop: lenv → nat → nat → lenv → Prop ≝ +| drop_sort: ∀d,e. drop (⋆) d e (⋆) +| drop_comp: ∀L1,L2,I,V. drop L1 0 0 L2 → drop (L1. 𝕓{I} V) 0 0 (L2. 𝕓{I} V) +| drop_drop: ∀L1,L2,I,V,e. drop L1 0 e L2 → drop (L1. 𝕓{I} V) 0 (e + 1) L2 +| drop_skip: ∀L1,L2,I,V1,V2,d,e. + drop L1 d e L2 → ↑[d,e] V2 ≡ V1 → + drop (L1. 𝕓{I} V1) (d + 1) e (L2. 𝕓{I} V2) +. + +interpretation "dropping" 'RDrop L1 d e L2 = (drop L1 d e L2). + +(* Basic inversion lemmas ***************************************************) + +lemma drop_inv_refl_aux: ∀d,e,L1,L2. ↓[d, e] L1 ≡ L2 → d = 0 → e = 0 → L1 = L2. +#d #e #L1 #L2 #H elim H -H d e L1 L2 +[ // +| #L1 #L2 #I #V #_ #IHL12 #H1 #H2 + >(IHL12 H1 H2) -IHL12 H1 H2 L1 // +| #L1 #L2 #I #V #e #_ #_ #_ #H + elim (plus_S_eq_O_false … H) +| #L1 #L2 #I #V1 #V2 #d #e #_ #_ #_ #H + elim (plus_S_eq_O_false … H) +] +qed. + +lemma drop_inv_refl: ∀L1,L2. ↓[0, 0] L1 ≡ L2 → L1 = L2. +/2 width=5/ qed. + +lemma drop_inv_sort1_aux: ∀d,e,L1,L2. ↓[d, e] L1 ≡ L2 → L1 = ⋆ → + L2 = ⋆. +#d #e #L1 #L2 * -d e L1 L2 +[ // +| #L1 #L2 #I #V #_ #H destruct +| #L1 #L2 #I #V #e #_ #H destruct +| #L1 #L2 #I #V1 #V2 #d #e #_ #_ #H destruct +] +qed. + +lemma drop_inv_sort1: ∀d,e,L2. ↓[d, e] ⋆ ≡ L2 → L2 = ⋆. +/2 width=5/ qed. + +lemma drop_inv_O1_aux: ∀d,e,L1,L2. ↓[d, e] L1 ≡ L2 → d = 0 → + ∀K,I,V. L1 = K. 𝕓{I} V → + (e = 0 ∧ L2 = K. 𝕓{I} V) ∨ + (0 < e ∧ ↓[d, e - 1] K ≡ L2). +#d #e #L1 #L2 * -d e L1 L2 +[ #d #e #_ #K #I #V #H destruct +| #L1 #L2 #I #V #HL12 #H #K #J #W #HX destruct -L1 I V + >(drop_inv_refl … HL12) -HL12 K /3/ +| #L1 #L2 #I #V #e #HL12 #_ #K #J #W #H destruct -L1 I V /3/ +| #L1 #L2 #I #V1 #V2 #d #e #_ #_ #H elim (plus_S_eq_O_false … H) +] +qed. + +lemma drop_inv_O1: ∀e,K,I,V,L2. ↓[0, e] K. 𝕓{I} V ≡ L2 → + (e = 0 ∧ L2 = K. 𝕓{I} V) ∨ + (0 < e ∧ ↓[0, e - 1] K ≡ L2). +/2/ qed. + +lemma drop_inv_drop1: ∀e,K,I,V,L2. + ↓[0, e] K. 𝕓{I} V ≡ L2 → 0 < e → ↓[0, e - 1] K ≡ L2. +#e #K #I #V #L2 #H #He +elim (drop_inv_O1 … H) -H * // #H destruct -e; +elim (lt_refl_false … He) +qed. + +lemma drop_inv_skip1_aux: ∀d,e,L1,L2. ↓[d, e] L1 ≡ L2 → 0 < d → + ∀I,K1,V1. L1 = K1. 𝕓{I} V1 → + ∃∃K2,V2. ↓[d - 1, e] K1 ≡ K2 & + ↑[d - 1, e] V2 ≡ V1 & + L2 = K2. 𝕓{I} V2. +#d #e #L1 #L2 * -d e L1 L2 +[ #d #e #_ #I #K #V #H destruct +| #L1 #L2 #I #V #_ #H elim (lt_refl_false … H) +| #L1 #L2 #I #V #e #_ #H elim (lt_refl_false … H) +| #X #L2 #Y #Z #V2 #d #e #HL12 #HV12 #_ #I #L1 #V1 #H destruct -X Y Z + /2 width=5/ +] +qed. + +lemma drop_inv_skip1: ∀d,e,I,K1,V1,L2. ↓[d, e] K1. 𝕓{I} V1 ≡ L2 → 0 < d → + ∃∃K2,V2. ↓[d - 1, e] K1 ≡ K2 & + ↑[d - 1, e] V2 ≡ V1 & + L2 = K2. 𝕓{I} V2. +/2/ qed. + +lemma drop_inv_skip2_aux: ∀d,e,L1,L2. ↓[d, e] L1 ≡ L2 → 0 < d → + ∀I,K2,V2. L2 = K2. 𝕓{I} V2 → + ∃∃K1,V1. ↓[d - 1, e] K1 ≡ K2 & + ↑[d - 1, e] V2 ≡ V1 & + L1 = K1. 𝕓{I} V1. +#d #e #L1 #L2 * -d e L1 L2 +[ #d #e #_ #I #K #V #H destruct +| #L1 #L2 #I #V #_ #H elim (lt_refl_false … H) +| #L1 #L2 #I #V #e #_ #H elim (lt_refl_false … H) +| #L1 #X #Y #V1 #Z #d #e #HL12 #HV12 #_ #I #L2 #V2 #H destruct -X Y Z + /2 width=5/ +] +qed. + +lemma drop_inv_skip2: ∀d,e,I,L1,K2,V2. ↓[d, e] L1 ≡ K2. 𝕓{I} V2 → 0 < d → + ∃∃K1,V1. ↓[d - 1, e] K1 ≡ K2 & ↑[d - 1, e] V2 ≡ V1 & + L1 = K1. 𝕓{I} V1. +/2/ qed. + +(* Basic properties *********************************************************) + +lemma drop_refl: ∀L. ↓[0, 0] L ≡ L. +#L elim L -L /2/ +qed. + +lemma drop_drop_lt: ∀L1,L2,I,V,e. + ↓[0, e - 1] L1 ≡ L2 → 0 < e → ↓[0, e] L1. 𝕓{I} V ≡ L2. +#L1 #L2 #I #V #e #HL12 #He >(plus_minus_m_m e 1) /2/ +qed. + +lemma drop_leq_drop1: ∀L1,L2,d,e. L1 [d, e] ≈ L2 → + ∀I,K1,V,i. ↓[0, i] L1 ≡ K1. 𝕓{I} V → + d ≤ i → i < d + e → + ∃∃K2. K1 [0, d + e - i - 1] ≈ K2 & + ↓[0, i] L2 ≡ K2. 𝕓{I} V. +#L1 #L2 #d #e #H elim H -H L1 L2 d e +[ #d #e #I #K1 #V #i #H + lapply (drop_inv_sort1 … H) -H #H destruct +| #L1 #L2 #I1 #I2 #V1 #V2 #_ #_ #I #K1 #V #i #_ #_ #H + elim (lt_zero_false … H) +| #L1 #L2 #I #V #e #HL12 #IHL12 #J #K1 #W #i #H #_ #Hie + elim (drop_inv_O1 … H) -H * #Hi #HLK1 + [ -IHL12 Hie; destruct -i K1 J W; + arith_g1 // /3/ + ] +| #L1 #L2 #I1 #I2 #V1 #V2 #d #e #_ #IHL12 #I #K1 #V #i #H #Hdi >plus_plus_comm_23 #Hide + lapply (plus_S_le_to_pos … Hdi) #Hi + lapply (drop_inv_drop1 … H ?) -H // #HLK1 + elim (IHL12 … HLK1 ? ?) -IHL12 HLK1 [2: /2/ |3: /2/ ] -Hdi Hide >arith_g1 // /3/ +] +qed. + +(* Basic forvard lemmas *****************************************************) + +lemma drop_fwd_drop2: ∀L1,I2,K2,V2,e. ↓[O, e] L1 ≡ K2. 𝕓{I2} V2 → + ↓[O, e + 1] L1 ≡ K2. +#L1 elim L1 -L1 +[ #I2 #K2 #V2 #e #H lapply (drop_inv_sort1 … H) -H #H destruct +| #K1 #I1 #V1 #IHL1 #I2 #K2 #V2 #e #H + elim (drop_inv_O1 … H) -H * #He #H + [ -IHL1; destruct -e K2 I2 V2 /2/ + | @drop_drop >(plus_minus_m_m e 1) /2/ + ] +] +qed. + +lemma drop_fwd_drop2_length: ∀L1,I2,K2,V2,e. + ↓[0, e] L1 ≡ K2. 𝕓{I2} V2 → e < |L1|. +#L1 elim L1 -L1 +[ #I2 #K2 #V2 #e #H lapply (drop_inv_sort1 … H) -H #H destruct +| #K1 #I1 #V1 #IHL1 #I2 #K2 #V2 #e #H + elim (drop_inv_O1 … H) -H * #He #H + [ -IHL1; destruct -e K2 I2 V2 // + | lapply (IHL1 … H) -IHL1 H #HeK1 whd in ⊢ (? ? %) /2/ + ] +] +qed. + +lemma drop_fwd_O1_length: ∀L1,L2,e. ↓[0, e] L1 ≡ L2 → |L2| = |L1| - e. +#L1 elim L1 -L1 +[ #L2 #e #H >(drop_inv_sort1 … H) -H // +| #K1 #I1 #V1 #IHL1 #L2 #e #H + elim (drop_inv_O1 … H) -H * #He #H + [ -IHL1; destruct -e L2 // + | lapply (IHL1 … H) -IHL1 H #H >H -H; normalize + >minus_le_minus_minus_comm // + ] +] +qed. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/substitution/drop_drop.ma b/matita/matita/contribs/lambda-delta/Basic-2/substitution/drop_drop.ma new file mode 100644 index 000000000..812fb7e06 --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/substitution/drop_drop.ma @@ -0,0 +1,125 @@ +(**************************************************************************) +(* ___ *) +(* ||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 "lambda-delta/substitution/lift_lift.ma". +include "lambda-delta/substitution/drop.ma". + +(* DROPPING *****************************************************************) + +(* Main properties **********************************************************) + +theorem drop_mono: ∀d,e,L,L1. ↓[d, e] L ≡ L1 → + ∀L2. ↓[d, e] L ≡ L2 → L1 = L2. +#d #e #L #L1 #H elim H -H d e L L1 +[ #d #e #L2 #H + >(drop_inv_sort1 … H) -H L2 // +| #K1 #K2 #I #V #HK12 #_ #L2 #HL12 + <(drop_inv_refl … HK12) -HK12 K2 + <(drop_inv_refl … HL12) -HL12 L2 // +| #L #K #I #V #e #_ #IHLK #L2 #H + lapply (drop_inv_drop1 … H ?) -H /2/ +| #L #K1 #I #T #V1 #d #e #_ #HVT1 #IHLK1 #X #H + elim (drop_inv_skip1 … H ?) -H // (lift_inj … HVT1 … HVT2) -HVT1 HVT2 + >(IHLK1 … HLK2) -IHLK1 HLK2 // +] +qed. + +theorem drop_conf_ge: ∀d1,e1,L,L1. ↓[d1, e1] L ≡ L1 → + ∀e2,L2. ↓[0, e2] L ≡ L2 → d1 + e1 ≤ e2 → + ↓[0, e2 - e1] L1 ≡ L2. +#d1 #e1 #L #L1 #H elim H -H d1 e1 L L1 +[ #d #e #e2 #L2 #H + >(drop_inv_sort1 … H) -H L2 // +| #K1 #K2 #I #V #HK12 #_ #e2 #L2 #H #_ minus_minus_comm /3/ (**) (* explicit constructor *) +] +qed. + +theorem drop_conf_lt: ∀d1,e1,L,L1. ↓[d1, e1] L ≡ L1 → + ∀e2,K2,I,V2. ↓[0, e2] L ≡ K2. 𝕓{I} V2 → + e2 < d1 → let d ≝ d1 - e2 - 1 in + ∃∃K1,V1. ↓[0, e2] L1 ≡ K1. 𝕓{I} V1 & + ↓[d, e1] K2 ≡ K1 & ↑[d, e1] V1 ≡ V2. +#d1 #e1 #L #L1 #H elim H -H d1 e1 L L1 +[ #d #e #e2 #K2 #I #V2 #H + lapply (drop_inv_sort1 … H) -H #H destruct +| #L1 #L2 #I #V #_ #_ #e2 #K2 #J #V2 #_ #H + elim (lt_zero_false … H) +| #L1 #L2 #I #V #e #_ #_ #e2 #K2 #J #V2 #_ #H + elim (lt_zero_false … H) +| #L1 #L2 #I #V1 #V2 #d #e #HL12 #HV12 #IHL12 #e2 #K2 #J #V #H #He2d + elim (drop_inv_O1 … H) -H * + [ -IHL12 He2d #H1 #H2 destruct -e2 K2 J V /2 width=5/ + | -HL12 -HV12 #He #HLK + elim (IHL12 … HLK ?) -IHL12 HLK [ (drop_inv_sort1 … H) -H L2 /2/ +| #K1 #K2 #I #V #HK12 #_ #e2 #L2 #HL2 #H + >(drop_inv_refl … HK12) -HK12 K1; + lapply (le_O_to_eq_O … H) -H #H destruct -e2 /2/ +| #L1 #L2 #I #V #e #_ #IHL12 #e2 #L #HL2 #H + lapply (le_O_to_eq_O … H) -H #H destruct -e2; + elim (IHL12 … HL2 ?) -IHL12 HL2 // #L0 #H #HL0 + lapply (drop_inv_refl … H) -H #H destruct -L1 /3 width=5/ +| #L1 #L2 #I #V1 #V2 #d #e #HL12 #HV12 #IHL12 #e2 #L #H #He2d + elim (drop_inv_O1 … H) -H * + [ -He2d IHL12 #H1 #H2 destruct -e2 L /3 width=5/ + | -HL12 HV12 #He2 #HL2 + elim (IHL12 … HL2 ?) -IHL12 HL2 L2 + [ >minus_le_minus_minus_comm // /3/ | /2/ ] + ] +] +qed. + +theorem drop_trans_ge: ∀d1,e1,L1,L. ↓[d1, e1] L1 ≡ L → + ∀e2,L2. ↓[0, e2] L ≡ L2 → d1 ≤ e2 → ↓[0, e1 + e2] L1 ≡ L2. +#d1 #e1 #L1 #L #H elim H -H d1 e1 L1 L +[ #d #e #e2 #L2 #H + >(drop_inv_sort1 … H) -H L2 // +| #K1 #K2 #I #V #HK12 #_ #e2 #L2 #H #_ normalize + >(drop_inv_refl … HK12) -HK12 K1 // +| /3/ +| #L1 #L2 #I #V1 #V2 #d #e #H_ #_ #IHL12 #e2 #L #H #Hde2 + lapply (lt_to_le_to_lt 0 … Hde2) // #He2 + lapply (lt_to_le_to_lt … (e + e2) He2 ?) // #Hee2 + lapply (drop_inv_drop1 … H ?) -H // #HL2 + @drop_drop_lt // >le_plus_minus // @IHL12 /2/ (**) (* explicit constructor *) +] +qed. + +theorem drop_trans_ge_comm: ∀d1,e1,e2,L1,L2,L. + ↓[d1, e1] L1 ≡ L → ↓[0, e2] L ≡ L2 → d1 ≤ e2 → + ↓[0, e2 + e1] L1 ≡ L2. +#e1 #e1 #e2 >commutative_plus /2 width=5/ +qed. + +axiom drop_div: ∀e1,L1,L. ↓[0, e1] L1 ≡ L → ∀e2,L2. ↓[0, e2] L2 ≡ L → + ∃∃L0. ↓[0, e1] L0 ≡ L2 & ↓[e1, e2] L0 ≡ L1. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/substitution/leq.ma b/matita/matita/contribs/lambda-delta/Basic-2/substitution/leq.ma new file mode 100644 index 000000000..b0e28d48e --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/substitution/leq.ma @@ -0,0 +1,64 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/syntax/length.ma". + +(* LOCAL ENVIRONMENT EQUALITY ***********************************************) + +inductive leq: lenv → nat → nat → lenv → Prop ≝ +| leq_sort: ∀d,e. leq (⋆) d e (⋆) +| leq_comp: ∀L1,L2,I1,I2,V1,V2. + leq L1 0 0 L2 → leq (L1. 𝕓{I1} V1) 0 0 (L2. 𝕓{I2} V2) +| leq_eq: ∀L1,L2,I,V,e. leq L1 0 e L2 → leq (L1. 𝕓{I} V) 0 (e + 1) (L2.𝕓{I} V) +| leq_skip: ∀L1,L2,I1,I2,V1,V2,d,e. + leq L1 d e L2 → leq (L1. 𝕓{I1} V1) (d + 1) e (L2. 𝕓{I2} V2) +. + +interpretation "local environment equality" 'Eq L1 d e L2 = (leq L1 d e L2). + +(* Basic properties *********************************************************) + +lemma leq_refl: ∀d,e,L. L [d, e] ≈ L. +#d elim d -d +[ #e elim e -e [ #L elim L -L /2/ | #e #IHe #L elim L -L /2/ ] +| #d #IHd #e #L elim L -L /2/ +] +qed. + +lemma leq_sym: ∀L1,L2,d,e. L1 [d, e] ≈ L2 → L2 [d, e] ≈ L1. +#L1 #L2 #d #e #H elim H -H L1 L2 d e /2/ +qed. + +lemma leq_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/ +qed. + +lemma leq_fwd_length: ∀L1,L2,d,e. L1 [d, e] ≈ L2 → |L1| = |L2|. +#L1 #L2 #d #e #H elim H -H L1 L2 d e; normalize // +qed. + +(* Basic inversion lemmas ***************************************************) + +lemma leq_inv_sort1_aux: ∀L1,L2,d,e. L1 [d, e] ≈ L2 → L1 = ⋆ → L2 = ⋆. +#L1 #L2 #d #e #H elim H -H L1 L2 d e +[ // +| #L1 #L2 #I1 #I2 #V1 #V2 #_ #_ #H destruct +| #L1 #L2 #I #V #e #_ #_ #H destruct +| #L1 #L2 #I1 #I2 #V1 #V2 #d #e #_ #_ #H destruct +qed. + +lemma leq_inv_sort1: ∀L2,d,e. ⋆ [d, e] ≈ L2 → L2 = ⋆. +/2 width=5/ qed. + +lemma leq_inv_sort2: ∀L1,d,e. L1 [d, e] ≈ ⋆ → L1 = ⋆. +/3/ qed. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/substitution/lift.ma b/matita/matita/contribs/lambda-delta/Basic-2/substitution/lift.ma new file mode 100644 index 000000000..a5b15e110 --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/substitution/lift.ma @@ -0,0 +1,230 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/syntax/term.ma". + +(* RELOCATION ***************************************************************) + +inductive lift: term → nat → nat → term → Prop ≝ +| lift_sort : ∀k,d,e. lift (⋆k) d e (⋆k) +| lift_lref_lt: ∀i,d,e. i < d → lift (#i) d e (#i) +| lift_lref_ge: ∀i,d,e. d ≤ i → lift (#i) d e (#(i + e)) +| lift_bind : ∀I,V1,V2,T1,T2,d,e. + lift V1 d e V2 → lift T1 (d + 1) e T2 → + lift (𝕓{I} V1. T1) d e (𝕓{I} V2. T2) +| lift_flat : ∀I,V1,V2,T1,T2,d,e. + lift V1 d e V2 → lift T1 d e T2 → + lift (𝕗{I} V1. T1) d e (𝕗{I} V2. T2) +. + +interpretation "relocation" 'RLift T1 d e T2 = (lift T1 d e T2). + +(* Basic properties *********************************************************) + +lemma lift_lref_ge_minus: ∀d,e,i. d + e ≤ i → ↑[d, e] #(i - e) ≡ #i. +#d #e #i #H >(plus_minus_m_m i e) in ⊢ (? ? ? ? %) /3/ +qed. + +lemma lift_refl: ∀T,d. ↑[d, 0] T ≡ T. +#T elim T -T +[ // +| #i #d elim (lt_or_ge i d) /2/ +| #I elim I -I /2/ +] +qed. + +lemma lift_total: ∀T1,d,e. ∃T2. ↑[d,e] T1 ≡ T2. +#T1 elim T1 -T1 +[ /2/ +| #i #d #e elim (lt_or_ge i d) /3/ +| * #I #V1 #T1 #IHV1 #IHT1 #d #e + elim (IHV1 d e) -IHV1 #V2 #HV12 + [ elim (IHT1 (d+1) e) -IHT1 /3/ + | elim (IHT1 d e) -IHT1 /3/ + ] +] +qed. + +lemma lift_split: ∀d1,e2,T1,T2. ↑[d1, e2] T1 ≡ T2 → ∀d2,e1. + d1 ≤ d2 → d2 ≤ d1 + e1 → e1 ≤ e2 → + ∃∃T. ↑[d1, e1] T1 ≡ T & ↑[d2, e2 - e1] T ≡ T2. +#d1 #e2 #T1 #T2 #H elim H -H d1 e2 T1 T2 +[ /3/ +| #i #d1 #e2 #Hid1 #d2 #e1 #Hd12 #_ #_ + lapply (lt_to_le_to_lt … Hid1 Hd12) -Hd12 #Hid2 /4/ +| #i #d1 #e2 #Hid1 #d2 #e1 #_ #Hd21 #He12 + lapply (transitive_le …(i+e1) Hd21 ?) /2/ -Hd21 #Hd21 + <(arith_d1 i e2 e1) // /3/ +| #I #V1 #V2 #T1 #T2 #d1 #e2 #_ #_ #IHV #IHT #d2 #e1 #Hd12 #Hd21 #He12 + elim (IHV … Hd12 Hd21 He12) -IHV #V0 #HV0a #HV0b + elim (IHT (d2+1) … ? ? He12) /3 width = 5/ +| #I #V1 #V2 #T1 #T2 #d1 #e2 #_ #_ #IHV #IHT #d2 #e1 #Hd12 #Hd21 #He12 + elim (IHV … Hd12 Hd21 He12) -IHV #V0 #HV0a #HV0b + elim (IHT d2 … ? ? He12) /3 width = 5/ +] +qed. + +(* Basic inversion lemmas ***************************************************) + +lemma lift_inv_refl_aux: ∀d,e,T1,T2. ↑[d, e] T1 ≡ T2 → e = 0 → T1 = T2. +#d #e #T1 #T2 #H elim H -H d e T1 T2 /3/ +qed. + +lemma lift_inv_refl: ∀d,T1,T2. ↑[d, 0] T1 ≡ T2 → T1 = T2. +/2/ qed. + +lemma lift_inv_sort1_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 → ∀k. T1 = ⋆k → T2 = ⋆k. +#d #e #T1 #T2 * -d e T1 T2 // +[ #i #d #e #_ #k #H destruct +| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #k #H destruct +| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #k #H destruct +] +qed. + +lemma lift_inv_sort1: ∀d,e,T2,k. ↑[d,e] ⋆k ≡ T2 → T2 = ⋆k. +/2 width=5/ qed. + +lemma lift_inv_lref1_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 → ∀i. T1 = #i → + (i < d ∧ T2 = #i) ∨ (d ≤ i ∧ T2 = #(i + e)). +#d #e #T1 #T2 * -d e T1 T2 +[ #k #d #e #i #H destruct +| #j #d #e #Hj #i #Hi destruct /3/ +| #j #d #e #Hj #i #Hi destruct /3/ +| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #i #H destruct +| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #i #H destruct +] +qed. + +lemma lift_inv_lref1: ∀d,e,T2,i. ↑[d,e] #i ≡ T2 → + (i < d ∧ T2 = #i) ∨ (d ≤ i ∧ T2 = #(i + e)). +/2/ qed. + +lemma lift_inv_lref1_lt: ∀d,e,T2,i. ↑[d,e] #i ≡ T2 → i < d → T2 = #i. +#d #e #T2 #i #H elim (lift_inv_lref1 … H) -H * // +#Hdi #_ #Hid lapply (le_to_lt_to_lt … Hdi Hid) -Hdi Hid #Hdd +elim (lt_refl_false … Hdd) +qed. + +lemma lift_inv_lref1_ge: ∀d,e,T2,i. ↑[d,e] #i ≡ T2 → d ≤ i → T2 = #(i + e). +#d #e #T2 #i #H elim (lift_inv_lref1 … H) -H * // +#Hid #_ #Hdi lapply (le_to_lt_to_lt … Hdi Hid) -Hdi Hid #Hdd +elim (lt_refl_false … Hdd) +qed. + +lemma lift_inv_bind1_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 → + ∀I,V1,U1. T1 = 𝕓{I} V1.U1 → + ∃∃V2,U2. ↑[d,e] V1 ≡ V2 & ↑[d+1,e] U1 ≡ U2 & + T2 = 𝕓{I} V2. U2. +#d #e #T1 #T2 * -d e T1 T2 +[ #k #d #e #I #V1 #U1 #H destruct +| #i #d #e #_ #I #V1 #U1 #H destruct +| #i #d #e #_ #I #V1 #U1 #H destruct +| #J #W1 #W2 #T1 #T2 #d #e #HW #HT #I #V1 #U1 #H destruct /2 width=5/ +| #J #W1 #W2 #T1 #T2 #d #e #HW #HT #I #V1 #U1 #H destruct +] +qed. + +lemma lift_inv_bind1: ∀d,e,T2,I,V1,U1. ↑[d,e] 𝕓{I} V1. U1 ≡ T2 → + ∃∃V2,U2. ↑[d,e] V1 ≡ V2 & ↑[d+1,e] U1 ≡ U2 & + T2 = 𝕓{I} V2. U2. +/2/ qed. + +lemma lift_inv_flat1_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 → + ∀I,V1,U1. T1 = 𝕗{I} V1.U1 → + ∃∃V2,U2. ↑[d,e] V1 ≡ V2 & ↑[d,e] U1 ≡ U2 & + T2 = 𝕗{I} V2. U2. +#d #e #T1 #T2 * -d e T1 T2 +[ #k #d #e #I #V1 #U1 #H destruct +| #i #d #e #_ #I #V1 #U1 #H destruct +| #i #d #e #_ #I #V1 #U1 #H destruct +| #J #W1 #W2 #T1 #T2 #d #e #HW #HT #I #V1 #U1 #H destruct +| #J #W1 #W2 #T1 #T2 #d #e #HW #HT #I #V1 #U1 #H destruct /2 width=5/ +] +qed. + +lemma lift_inv_flat1: ∀d,e,T2,I,V1,U1. ↑[d,e] 𝕗{I} V1. U1 ≡ T2 → + ∃∃V2,U2. ↑[d,e] V1 ≡ V2 & ↑[d,e] U1 ≡ U2 & + T2 = 𝕗{I} V2. U2. +/2/ qed. + +lemma lift_inv_sort2_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 → ∀k. T2 = ⋆k → T1 = ⋆k. +#d #e #T1 #T2 * -d e T1 T2 // +[ #i #d #e #_ #k #H destruct +| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #k #H destruct +| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #k #H destruct +] +qed. + +lemma lift_inv_sort2: ∀d,e,T1,k. ↑[d,e] T1 ≡ ⋆k → T1 = ⋆k. +/2 width=5/ qed. + +lemma lift_inv_lref2_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 → ∀i. T2 = #i → + (i < d ∧ T1 = #i) ∨ (d + e ≤ i ∧ T1 = #(i - e)). +#d #e #T1 #T2 * -d e T1 T2 +[ #k #d #e #i #H destruct +| #j #d #e #Hj #i #Hi destruct /3/ +| #j #d #e #Hj #i #Hi destruct le_plus_minus_comm [ @lift_lref_ge @(transitive_le … Hd12) -Hd12 /2/ | -Hd12 /2/ ] + | -Hd12 >(plus_minus_m_m i e2) in ⊢ (? ? ? ? %) /3/ + ] + ] +| #I #W1 #W #U1 #U #d1 #e1 #_ #_ #IHW #IHU #d2 #e2 #T2 #H #Hd12 + lapply (lift_inv_bind2 … H) -H * #W2 #U2 #HW2 #HU2 #H destruct -T2; + elim (IHW … HW2 ?) // -IHW HW2 #W0 #HW2 #HW1 + >plus_plus_comm_23 in HU2 #HU2 elim (IHU … HU2 ?) /3 width = 5/ +| #I #W1 #W #U1 #U #d1 #e1 #_ #_ #IHW #IHU #d2 #e2 #T2 #H #Hd12 + lapply (lift_inv_flat2 … H) -H * #W2 #U2 #HW2 #HU2 #H destruct -T2; + elim (IHW … HW2 ?) // -IHW HW2 #W0 #HW2 #HW1 + elim (IHU … HU2 ?) /3 width = 5/ +] +qed. + +theorem lift_mono: ∀d,e,T,U1. ↑[d,e] T ≡ U1 → ∀U2. ↑[d,e] T ≡ U2 → U1 = U2. +#d #e #T #U1 #H elim H -H d e T U1 +[ #k #d #e #X #HX + lapply (lift_inv_sort1 … HX) -HX // +| #i #d #e #Hid #X #HX + lapply (lift_inv_lref1_lt … HX ?) -HX // +| #i #d #e #Hdi #X #HX + lapply (lift_inv_lref1_ge … HX ?) -HX // +| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #X #HX + elim (lift_inv_bind1 … HX) -HX #V #T #HV1 #HT1 #HX destruct -X /3/ +| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #X #HX + elim (lift_inv_flat1 … HX) -HX #V #T #HV1 #HT1 #HX destruct -X /3/ +] +qed. + +theorem lift_trans_be: ∀d1,e1,T1,T. ↑[d1, e1] T1 ≡ T → + ∀d2,e2,T2. ↑[d2, e2] T ≡ T2 → + d1 ≤ d2 → d2 ≤ d1 + e1 → ↑[d1, e1 + e2] T1 ≡ T2. +#d1 #e1 #T1 #T #H elim H -H d1 e1 T1 T +[ #k #d1 #e1 #d2 #e2 #T2 #HT2 #_ #_ + >(lift_inv_sort1 … HT2) -HT2 // +| #i #d1 #e1 #Hid1 #d2 #e2 #T2 #HT2 #Hd12 #_ + lapply (lt_to_le_to_lt … Hid1 Hd12) -Hd12 #Hid2 + lapply (lift_inv_lref1_lt … HT2 Hid2) /2/ +| #i #d1 #e1 #Hid1 #d2 #e2 #T2 #HT2 #_ #Hd21 + lapply (lift_inv_lref1_ge … HT2 ?) -HT2 + [ @(transitive_le … Hd21 ?) -Hd21 /2/ + | -Hd21 /2/ + ] +| #I #V1 #V2 #T1 #T2 #d1 #e1 #_ #_ #IHV12 #IHT12 #d2 #e2 #X #HX #Hd12 #Hd21 + elim (lift_inv_bind1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct -X; + lapply (IHV12 … HV20 ? ?) // -IHV12 HV20 #HV10 + lapply (IHT12 … HT20 ? ?) /2/ +| #I #V1 #V2 #T1 #T2 #d1 #e1 #_ #_ #IHV12 #IHT12 #d2 #e2 #X #HX #Hd12 #Hd21 + elim (lift_inv_flat1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct -X; + lapply (IHV12 … HV20 ? ?) // -IHV12 HV20 #HV10 + lapply (IHT12 … HT20 ? ?) /2/ +] +qed. + +theorem lift_trans_le: ∀d1,e1,T1,T. ↑[d1, e1] T1 ≡ T → + ∀d2,e2,T2. ↑[d2, e2] T ≡ T2 → d2 ≤ d1 → + ∃∃T0. ↑[d2, e2] T1 ≡ T0 & ↑[d1 + e2, e1] T0 ≡ T2. +#d1 #e1 #T1 #T #H elim H -H d1 e1 T1 T +[ #k #d1 #e1 #d2 #e2 #X #HX #_ + >(lift_inv_sort1 … HX) -HX /2/ +| #i #d1 #e1 #Hid1 #d2 #e2 #X #HX #_ + lapply (lt_to_le_to_lt … (d1+e2) Hid1 ?) // #Hie2 + elim (lift_inv_lref1 … HX) -HX * #Hid2 #HX destruct -X /4/ +| #i #d1 #e1 #Hid1 #d2 #e2 #X #HX #Hd21 + lapply (transitive_le … Hd21 Hid1) -Hd21 #Hid2 + lapply (lift_inv_lref1_ge … HX ?) -HX /2/ #HX destruct -X; + >plus_plus_comm_23 /4/ +| #I #V1 #V2 #T1 #T2 #d1 #e1 #_ #_ #IHV12 #IHT12 #d2 #e2 #X #HX #Hd21 + elim (lift_inv_bind1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct -X; + elim (IHV12 … HV20 ?) -IHV12 HV20 // + elim (IHT12 … HT20 ?) -IHT12 HT20 /3 width=5/ +| #I #V1 #V2 #T1 #T2 #d1 #e1 #_ #_ #IHV12 #IHT12 #d2 #e2 #X #HX #Hd21 + elim (lift_inv_flat1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct -X; + elim (IHV12 … HV20 ?) -IHV12 HV20 // + elim (IHT12 … HT20 ?) -IHT12 HT20 /3 width=5/ +] +qed. + +theorem lift_trans_ge: ∀d1,e1,T1,T. ↑[d1, e1] T1 ≡ T → + ∀d2,e2,T2. ↑[d2, e2] T ≡ T2 → d1 + e1 ≤ d2 → + ∃∃T0. ↑[d2 - e1, e2] T1 ≡ T0 & ↑[d1, e1] T0 ≡ T2. +#d1 #e1 #T1 #T #H elim H -H d1 e1 T1 T +[ #k #d1 #e1 #d2 #e2 #X #HX #_ + >(lift_inv_sort1 … HX) -HX /2/ +| #i #d1 #e1 #Hid1 #d2 #e2 #X #HX #Hded + lapply (lt_to_le_to_lt … (d1+e1) Hid1 ?) // #Hid1e + lapply (lt_to_le_to_lt … (d2-e1) Hid1 ?) /2/ #Hid2e + lapply (lt_to_le_to_lt … Hid1e Hded) -Hid1e Hded #Hid2 + lapply (lift_inv_lref1_lt … HX ?) -HX // #HX destruct -X /3/ +| #i #d1 #e1 #Hid1 #d2 #e2 #X #HX #_ + elim (lift_inv_lref1 … HX) -HX * #Hied #HX destruct -X; + [2: >plus_plus_comm_23] /4/ +| #I #V1 #V2 #T1 #T2 #d1 #e1 #_ #_ #IHV12 #IHT12 #d2 #e2 #X #HX #Hded + elim (lift_inv_bind1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct -X; + elim (IHV12 … HV20 ?) -IHV12 HV20 // + elim (IHT12 … HT20 ?) -IHT12 HT20 /2/ #T + plus_plus_comm_23 #HV1U2 + lapply (drop_trans_ge_comm … HLK … HKV ?) -HLK HKV K // -Hid #HLKV + @tps_subst [4,5: /2/ |6,7,8: // |1,2,3: skip ] (**) (* /3 width=8/ is too slow *) +| #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hddt + elim (lift_inv_bind1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1 + elim (lift_inv_bind1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct -U1 U2; + @tps_bind [ /2 width=5/ | /3 width=5/ ] (**) (* explicit constructor *) +| #K #I #V1 #V2 #T1 #T2 #dt #et #_ #_ #IHV12 #IHT12 #L #U1 #U2 #d #e #HLK #H1 #H2 #Hddt + elim (lift_inv_flat1 … H1) -H1 #VV1 #TT1 #HVV1 #HTT1 #H1 + elim (lift_inv_flat1 … H2) -H2 #VV2 #TT2 #HVV2 #HTT2 #H2 destruct -U1 U2; + /3 width=5/ +] +qed. + +lemma tps_inv_lift1_le: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 → + ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 → + dt + et ≤ d → + ∃∃T2. K ⊢ T1 [dt, et] ≫ T2 & ↑[d, e] T2 ≡ U2. +#L #U1 #U2 #dt #et #H elim H -H L U1 U2 dt et +[ #L #k #dt #et #K #d #e #_ #T1 #H #_ + lapply (lift_inv_sort2 … H) -H #H destruct -T1 /2/ +| #L #i #dt #et #K #d #e #_ #T1 #H #_ + elim (lift_inv_lref2 … H) -H * #Hid #H destruct -T1 /3/ +| #L #KV #V #V1 #V2 #i #dt #et #Hdti #Hidet #HLKV #_ #HV12 #IHV12 #K #d #e #HLK #T1 #H #Hdetd + lapply (lt_to_le_to_lt … Hidet … Hdetd) #Hid + lapply (lift_inv_lref2_lt … H … Hid) -H #H destruct -T1; + elim (drop_conf_lt … HLK … HLKV ?) -HLK HLKV L // #L #W #HKL #HKVL #HWV + elim (IHV12 … HKVL … HWV ?) -HKVL HWV /2/ -Hdetd #W1 #HW1 #HWV1 + elim (lift_trans_le … HWV1 … HV12 ?) -HWV1 HV12 V1 // >arith_a2 /3 width=6/ +| #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd + elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct -X; + elim (IHV12 … HLK … HWV1 ?) -IHV12 // + elim (IHU12 … HTU1 ?) -IHU12 HTU1 [3: /2/ |4: @drop_skip // |2: skip ] -HLK HWV1 Hdetd /3 width=5/ (**) (* just /3 width=5/ is too slow *) +| #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd + elim (lift_inv_flat2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct -X; + elim (IHV12 … HLK … HWV1 ?) -IHV12 HWV1 // + elim (IHU12 … HLK … HTU1 ?) -IHU12 HLK HTU1 // /3 width=5/ +] +qed. + +lemma tps_inv_lift1_ge: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 → + ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 → + d + e ≤ dt → + ∃∃T2. K ⊢ T1 [dt - e, et] ≫ T2 & ↑[d, e] T2 ≡ U2. +#L #U1 #U2 #dt #et #H elim H -H L U1 U2 dt et +[ #L #k #dt #et #K #d #e #_ #T1 #H #_ + lapply (lift_inv_sort2 … H) -H #H destruct -T1 /2/ +| #L #i #dt #et #K #d #e #_ #T1 #H #_ + elim (lift_inv_lref2 … H) -H * #Hid #H destruct -T1 /3/ +| #L #KV #V #V1 #V2 #i #dt #et #Hdti #Hidet #HLKV #HV1 #HV12 #_ #K #d #e #HLK #T1 #H #Hdedt + lapply (transitive_le … Hdedt … Hdti) #Hdei + lapply (plus_le_weak … Hdedt) -Hdedt #Hedt + lapply (plus_le_weak … Hdei) #Hei + <(arith_h1 ? ? ? e ? ?) in HV1 // #HV1 + lapply (lift_inv_lref2_ge … H … Hdei) -H #H destruct -T1; + lapply (drop_conf_ge … HLK … HLKV ?) -HLK HLKV L // #HKV + elim (lift_split … HV12 d (i - e + 1) ? ? ?) -HV12; [2,3,4: normalize /2/ ] -Hdei >arith_e2 // #V0 #HV10 #HV02 + @ex2_1_intro + [2: @tps_subst [4: /2/ |6,7,8: // |1,2,3: skip |5: @arith5 // ] + |1: skip + | // + ] (**) (* explicitc constructors *) +| #L #I #V1 #V2 #U1 #U2 #dt #et #_ #_ #IHV12 #IHU12 #K #d #e #HLK #X #H #Hdetd + elim (lift_inv_bind2 … H) -H #W1 #T1 #HWV1 #HTU1 #H destruct -X; + lapply (plus_le_weak … Hdetd) #Hedt + elim (IHV12 … HLK … HWV1 ?) -IHV12 // #W2 #HW12 #HWV2 + elim (IHU12 … HTU1 ?) -IHU12 HTU1 [4: @drop_skip // |2: skip |3: /2/ ] + IHV12 // >IHT12 // +| #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #X #HX + elim (lift_inv_flat2 … HX) -HX #V #T #HV1 #HT1 #H destruct -X + >IHV12 // >IHT12 // +] +qed. +(* + Theorem subst0_gen_lift_ge : (u,t1,x:?; i,h,d:?) (subst0 i u (lift h d t1) x) -> + (le (plus d h) i) -> + (EX t2 | x = (lift h d t2) & (subst0 (minus i h) u t1 t2)). + + Theorem subst0_gen_lift_rev_ge: (t1,v,u2:?; i,h,d:?) + (subst0 i v t1 (lift h d u2)) -> + (le (plus d h) i) -> + (EX u1 | (subst0 (minus i h) v u1 u2) & + t1 = (lift h d u1) + ). + + + Theorem subst0_gen_lift_rev_lelt: (t1,v,u2:?; i,h,d:?) + (subst0 i v t1 (lift h d u2)) -> + (le d i) -> (lt i (plus d h)) -> + (EX u1 | t1 = (lift (minus (plus d h) (S i)) (S i) u1)). +*) diff --git a/matita/matita/contribs/lambda-delta/Basic-2/substitution/tps_split.ma b/matita/matita/contribs/lambda-delta/Basic-2/substitution/tps_split.ma new file mode 100644 index 000000000..23cdb39df --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/substitution/tps_split.ma @@ -0,0 +1,58 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/substitution/tps_lift.ma". + +(* PARTIAL SUBSTITUTION ON TERMS ********************************************) + +(* Split properties *********************************************************) + +lemma tps_split_up: ∀L,T1,T2,d,e. L ⊢ T1 [d, e] ≫ T2 → ∀i. d ≤ i → i ≤ d + e → + ∃∃T. L ⊢ T1 [d, i - d] ≫ T & L ⊢ T [i, d + e - i] ≫ T2. +#L #T1 #T2 #d #e #H elim H -L T1 T2 d e +[ /2/ +| /2/ +| #L #K #V #V1 #V2 #i #d #e #Hdi #Hide #HLK #HV1 #HV12 #IHV12 #j #Hdj #Hjde + elim (lt_or_ge i j) #Hij + [ -HV1 Hide; + lapply (drop_fwd_drop2 … HLK) #HLK' + elim (IHV12 (j - i - 1) ? ?) -IHV12; normalize /2/ -Hjde arith_b2 // #W1 #HVW1 #HWV1 + generalize in match HVW1 generalize in match Hij -HVW1 (**) (* rewriting in the premises, rewrites in the goal too *) + >(plus_minus_m_m_comm … Hdj) in ⊢ (% → % → ?) -Hdj #Hij' #HVW1 + elim (lift_total W1 0 (i + 1)) #W2 #HW12 + lapply (tps_lift_ge … HWV1 … HLK' HW12 HV12 ?) -HWV1 HLK' HV12 // >arith_a2 /3 width=6/ + | -IHV12 Hdi Hdj; + generalize in match HV1 generalize in match Hide -HV1 Hide (**) (* rewriting in the premises, rewrites in the goal too *) + >(plus_minus_m_m_comm … Hjde) in ⊢ (% → % → ?) -Hjde #Hide #HV1 + @ex2_1_intro [2: @tps_lref |1: skip | /2 width=6/ ] (**) (* /3 width=6 is too slow *) + ] +| #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #i #Hdi #Hide + elim (IHV12 i ? ?) -IHV12 // #V #HV1 #HV2 + elim (IHT12 (i + 1) ? ?) -IHT12 [2: /2 by arith4/ |3: /2/ ] (* just /2/ is too slow *) + -Hdi Hide >arith_c1 >arith_c1x #T #HT1 #HT2 + @ex2_1_intro [2,3: @tps_bind | skip ] (**) (* explicit constructors *) + [3: @HV1 |4: @HT1 |5: // |1,2: skip | /3 width=5/ ] +| #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #i #Hdi #Hide + elim (IHV12 i ? ?) -IHV12 // elim (IHT12 i ? ?) -IHT12 // + -Hdi Hide /3 width=5/ +] +qed. + +lemma tps_inv_lift1_up: ∀L,U1,U2,dt,et. L ⊢ U1 [dt, et] ≫ U2 → + ∀K,d,e. ↓[d, e] L ≡ K → ∀T1. ↑[d, e] T1 ≡ U1 → + d ≤ dt → dt ≤ d + e → d + e ≤ dt + et → + ∃∃T2. K ⊢ T1 [d, dt + et - (d + e)] ≫ T2 & ↑[d, e] T2 ≡ U2. +#L #U1 #U2 #dt #et #HU12 #K #d #e #HLK #T1 #HTU1 #Hddt #Hdtde #Hdedet +elim (tps_split_up … HU12 (d + e) ? ?) -HU12 // -Hdedet #U #HU1 #HU2 +lapply (tps_weak … HU1 d e ? ?) -HU1 // arith_i2 // | // ] + lapply (tps_weak … HT2 d e ? ?) -HT2 [ >arith_i2 // | // ] + /2/ + | @ex2_1_comm @tps_conf_subst_subst_lt /width=19/ + ] + ] +| #L #I #V0 #V1 #T0 #T1 #d #e #_ #_ #IHV01 #IHT01 #X #HX + elim (tps_inv_bind1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X; + elim (IHV01 … HV02) -IHV01 HV02 #V #HV1 #HV2 + elim (IHT01 … HT02) -IHT01 HT02 #T #HT1 #HT2 + @ex2_1_intro + [2: @tps_bind [4: @(tps_leq_repl … HT1) /2/ |2: skip ] + |1: skip + |3: @tps_bind [2: @(tps_leq_repl … HT2) /2/ ] + ] // (**) (* /5/ is too slow *) +| #L #I #V0 #V1 #T0 #T1 #d #e #_ #_ #IHV01 #IHT01 #X #HX + elim (tps_inv_flat1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X; + elim (IHV01 … HV02) -IHV01 HV02; + elim (IHT01 … HT02) -IHT01 HT02 /3 width=5/ +] +qed. + +(* + Theorem subst0_subst0: (t1,t2,u2:?; j:?) (subst0 j u2 t1 t2) -> + (u1,u:?; i:?) (subst0 i u u1 u2) -> + (EX t | (subst0 j u1 t1 t) & (subst0 (S (plus i j)) u t t2)). + + Theorem subst0_subst0_back: (t1,t2,u2:?; j:?) (subst0 j u2 t1 t2) -> + (u1,u:?; i:?) (subst0 i u u2 u1) -> + (EX t | (subst0 j u1 t1 t) & (subst0 (S (plus i j)) u t2 t)). + +*) diff --git a/matita/matita/contribs/lambda-delta/Basic-2/syntax/item.ma b/matita/matita/contribs/lambda-delta/Basic-2/syntax/item.ma new file mode 100644 index 000000000..ea7a45362 --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/syntax/item.ma @@ -0,0 +1,43 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +(* THE FORMAL SYSTEM λδ - MATITA SOURCE SCRIPTS + * Specification started: 2011 April 17 + * - Patience on me so that I gain peace and perfection! - + * [ suggested invocation to start formal specifications with ] + *) + +include "lambda-delta/ground.ma". +include "lambda-delta/notation.ma". + +(* BINARY ITEMS *************************************************************) + +(* binary binding items *) +inductive bind2: Type[0] ≝ +| Abbr: bind2 (* abbreviation *) +| Abst: bind2 (* abstraction *) +. + +(* binary non-binding items *) +inductive flat2: Type[0] ≝ +| Appl: flat2 (* application *) +| Cast: flat2 (* explicit type annotation *) +. + +(* binary items *) +inductive item2: Type[0] ≝ +| Bind: bind2 → item2 (* binding item *) +| Flat: flat2 → item2 (* non-binding item *) +. + +coercion item2_of_bind2: ∀I:bind2.item2 ≝ Bind on _I:bind2 to item2. + +coercion item2_of_flat2: ∀I:flat2.item2 ≝ Flat on _I:flat2 to item2. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/syntax/length.ma b/matita/matita/contribs/lambda-delta/Basic-2/syntax/length.ma new file mode 100644 index 000000000..91e1bd78c --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/syntax/length.ma @@ -0,0 +1,22 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/syntax/lenv.ma". + +(* LENGTH *******************************************************************) + +(* the length of a local environment *) +let rec length L ≝ match L with +[ LSort ⇒ 0 +| LPair L _ _ ⇒ length L + 1 +]. + +interpretation "length (local environment)" 'card L = (length L). diff --git a/matita/matita/contribs/lambda-delta/Basic-2/syntax/lenv.ma b/matita/matita/contribs/lambda-delta/Basic-2/syntax/lenv.ma new file mode 100644 index 000000000..c3aab910b --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/syntax/lenv.ma @@ -0,0 +1,24 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/syntax/term.ma". + +(* LOCAL ENVIRONMENTS *******************************************************) + +(* local environments *) +inductive lenv: Type[0] ≝ +| LSort: lenv (* empty *) +| LPair: lenv → bind2 → term → lenv (* binary binding construction *) +. + +interpretation "sort (local environment)" 'Star = LSort. + +interpretation "environment binding construction (binary)" 'DBind L I T = (LPair L I T). diff --git a/matita/matita/contribs/lambda-delta/Basic-2/syntax/sh.ma b/matita/matita/contribs/lambda-delta/Basic-2/syntax/sh.ma new file mode 100644 index 000000000..32840edff --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/syntax/sh.ma @@ -0,0 +1,20 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/ground.ma". + +(* SORT HIERARCHY ***********************************************************) + +(* sort hierarchy specifications *) +record sh: Type[0] ≝ { + next: nat → nat; (* next sort in the hierarchy *) + next_lt: ∀k. k < next k (* strict monotonicity condition *) +}. diff --git a/matita/matita/contribs/lambda-delta/Basic-2/syntax/term.ma b/matita/matita/contribs/lambda-delta/Basic-2/syntax/term.ma new file mode 100644 index 000000000..fe84e54b4 --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/syntax/term.ma @@ -0,0 +1,31 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/syntax/item.ma". + +(* TERMS ********************************************************************) + +(* terms *) +inductive term: Type[0] ≝ +| TSort: nat → term (* sort: starting at 0 *) +| TLRef: nat → term (* reference by index: starting at 0 *) +| TPair: item2 → term → term → term (* binary item construction *) +. + +interpretation "sort (term)" 'Star k = (TSort k). + +interpretation "local reference (term)" 'Weight i = (TLRef i). + +interpretation "term construction (binary)" 'SItem I T1 T2 = (TPair I T1 T2). + +interpretation "term binding construction (binary)" 'SBind I T1 T2 = (TPair (Bind I) T1 T2). + +interpretation "term flat construction (binary)" 'SFlat I T1 T2 = (TPair (Flat I) T1 T2). diff --git a/matita/matita/contribs/lambda-delta/Basic-2/syntax/weight.ma b/matita/matita/contribs/lambda-delta/Basic-2/syntax/weight.ma new file mode 100644 index 000000000..d076dea9d --- /dev/null +++ b/matita/matita/contribs/lambda-delta/Basic-2/syntax/weight.ma @@ -0,0 +1,44 @@ +(* + ||M|| This file is part of HELM, an Hypertextual, Electronic + ||A|| Library of Mathematics, developed at the Computer Science + ||T|| Department of the University of Bologna, Italy. + ||I|| + ||T|| + ||A|| This file is distributed under the terms of the + \ / GNU General Public License Version 2 + \ / + V_______________________________________________________________ *) + +include "lambda-delta/syntax/lenv.ma". + +(* WEIGHTS ******************************************************************) + +(* the weight of a term *) +let rec tw T ≝ match T with +[ TSort _ ⇒ 1 +| TLRef _ ⇒ 1 +| TPair _ V T ⇒ tw V + tw T + 1 +]. + +interpretation "weight (term)" 'Weight T = (tw T). + +(* the weight of a local environment *) +let rec lw L ≝ match L with +[ LSort ⇒ 0 +| LPair L _ V ⇒ lw L + #V +]. + +interpretation "weight (local environment)" 'Weight L = (lw L). + +(* the weight of a closure *) +definition cw: lenv → term → ? ≝ λL,T. #L + #T. + +interpretation "weight (closure)" 'Weight L T = (cw L T). + +axiom tw_wf_ind: ∀P:term→Prop. + (∀T2. (∀T1. # T1 < # T2 → P T1) → P T2) → + ∀T. P T. + +axiom cw_wf_ind: ∀P:lenv→term→Prop. + (∀L2,T2. (∀L1,T1. #[L1,T1] < #[L2,T2] → P L1 T1) → P L2 T2) → + ∀L,T. P L T. diff --git a/matita/matita/contribs/lambda-delta/root b/matita/matita/contribs/lambda-delta/root new file mode 100644 index 000000000..b1f51c9b9 --- /dev/null +++ b/matita/matita/contribs/lambda-delta/root @@ -0,0 +1 @@ +baseuri=cic:/matita/lambda-delta/