V_______________________________________________________________ *)
include "arithmetics/nat.ma".
+include "lambda-delta/xoa_props.ma".
(* ARITHMETICAL PROPERTIES **************************************************)
#m #n elim (decidable_lt m n) /3/
qed.
+lemma lt_or_eq_or_gt: ∀m,n. ∨∨ m < n | n = m | n < m.
+#m elim m -m
+[ * /2/
+| #m #IHm * [ /2/ ]
+ #n elim (IHm n) -IHm #H
+ [ @or3_intro0 | @or3_intro1 destruct | @or3_intro2 ] /2/ (**) (* /3/ is slow *)
+ qed.
+
lemma le_to_lt_or_eq: ∀m,n. m ≤ n → m < n ∨ m = n.
#m #n * -n /3/
qed.
NAMING CONVENTIONS FOR METAVARIABLES
+H : reserved: transient premise
+IH : reserved: inductive premise
I,J : item
K,L : local environment
T,U,V,W: term
+X,Y,Z : reserved: transient objet denoted by a capital letter
d : relocation depth
e : relocation height
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 #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;
+| #L1 #X #Y #V1 #Z #d #e #HL12 #HV12 #_ #I #L2 #V2 #H destruct -X Y Z
/2 width=5/
]
qed.
(* *)
(**************************************************************************)
+include "lambda-delta/substitution/lift_lift.ma".
include "lambda-delta/substitution/drop.ma".
(* DROPPING *****************************************************************)
(* Main properties **********************************************************)
-lemma 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.
+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 // <minus_plus_m_m #K2 #V2 #HLK2 #HVT2 #H destruct -X
+ >(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 //
| #L #K #I #V1 #V2 #d #e #_ #_ #IHLK #e2 #L2 #H #Hdee2
lapply (transitive_le 1 … Hdee2) // #He2
lapply (drop_inv_drop1 … H ?) -H // -He2 #HL2
- lapply (transitive_le (1+e) … Hdee2) // #Hee2
+ lapply (transitive_le (1 + e) … Hdee2) // #Hee2
@drop_drop_lt >minus_minus_comm /3/ (**) (* explicit constructor *)
]
qed.
-lemma 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.
+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
]
qed.
-lemma drop_trans_le: ∀d1,e1,L1,L. ↓[d1, e1] L1 ≡ L →
- ∀e2,L2. ↓[0, e2] L ≡ L2 → e2 ≤ d1 →
- ∃∃L0. ↓[0, e2] L1 ≡ L0 & ↓[d1 - e2, e1] L0 ≡ L2.
+theorem drop_trans_le: ∀d1,e1,L1,L. ↓[d1, e1] L1 ≡ L →
+ ∀e2,L2. ↓[0, e2] L ≡ L2 → e2 ≤ d1 →
+ ∃∃L0. ↓[0, e2] L1 ≡ L0 & ↓[d1 - e2, e1] L0 ≡ L2.
#d1 #e1 #L1 #L #H elim H -H d1 e1 L1 L
[ #d #e #e2 #L2 #H
>(drop_inv_sort1 … H) -H L2 /2/
]
qed.
-lemma drop_trans_ge: ∀d1,e1,L1,L. ↓[d1, e1] L1 ≡ L →
- ∀e2,L2. ↓[0, e2] L ≡ L2 → d1 ≤ e2 → ↓[0, e1 + e2] L1 ≡ L2.
+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 //
]
qed.
-lemma 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.
+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.
(* Main properies ***********************************************************)
-lemma lift_inj: ∀d,e,T1,U. ↑[d,e] T1 ≡ U → ∀T2. ↑[d,e] T2 ≡ U → T1 = T2.
+theorem lift_inj: ∀d,e,T1,U. ↑[d,e] T1 ≡ U → ∀T2. ↑[d,e] T2 ≡ U → T1 = T2.
#d #e #T1 #U #H elim H -H d e T1 U
[ #k #d #e #X #HX
lapply (lift_inv_sort2 … HX) -HX //
]
qed.
-lemma lift_div_le: ∀d1,e1,T1,T. ↑[d1, e1] T1 ≡ T →
- ∀d2,e2,T2. ↑[d2 + e1, e2] T2 ≡ T →
- d1 ≤ d2 →
- ∃∃T0. ↑[d1, e1] T0 ≡ T2 & ↑[d2, e2] T0 ≡ T1.
+theorem lift_div_le: ∀d1,e1,T1,T. ↑[d1, e1] T1 ≡ T →
+ ∀d2,e2,T2. ↑[d2 + e1, e2] T2 ≡ T →
+ d1 ≤ d2 →
+ ∃∃T0. ↑[d1, e1] T0 ≡ T2 & ↑[d2, e2] T0 ≡ T1.
#d1 #e1 #T1 #T #H elim H -H d1 e1 T1 T
[ #k #d1 #e1 #d2 #e2 #T2 #Hk #Hd12
lapply (lift_inv_sort2 … Hk) -Hk #Hk destruct -T2 /3/
]
qed.
-lemma lift_mono: ∀d,e,T,U1. ↑[d,e] T ≡ U1 → ∀U2. ↑[d,e] T ≡ U2 → U1 = U2.
+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 //
]
qed.
-lemma 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.
+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 //
]
qed.
-lemma 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.
+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/
]
qed.
-lemma 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.
+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/
(* Basic inversion lemmas ***************************************************)
+lemma tps_inv_lref1_aux: ∀L,T1,T2,d,e. L ⊢ T1 [d, e] ≫ T2 → ∀i. T1 = #i →
+ T2 = #i ∨
+ ∃∃K,V1,V2,i. d ≤ i & i < d + e &
+ ↓[O, i] L ≡ K. 𝕓{Abbr} V1 &
+ K ⊢ V1 [O, d + e - i - 1] ≫ V2 &
+ ↑[O, i + 1] V2 ≡ T2.
+#L #T1 #T2 #d #e * -L T1 T2 d e
+[ #L #k #d #e #i #H destruct
+| /2/
+| #L #K #V1 #V2 #T2 #i #d #e #Hdi #Hide #HLK #HV12 #HVT2 #j #H destruct -i /3 width=9/
+| #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #i #H destruct
+| #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #i #H destruct
+]
+qed.
+
+lemma tps_inv_lref1: ∀L,T2,i,d,e. L ⊢ #i [d, e] ≫ T2 →
+ T2 = #i ∨
+ ∃∃K,V1,V2,i. d ≤ i & i < d + e &
+ ↓[O, i] L ≡ K. 𝕓{Abbr} V1 &
+ K ⊢ V1 [O, d + e - i - 1] ≫ V2 &
+ ↑[O, i + 1] V2 ≡ T2.
+/2/ qed.
+
lemma tps_inv_bind1_aux: ∀d,e,L,U1,U2. L ⊢ U1 [d, e] ≫ U2 →
∀I,V1,T1. U1 = 𝕓{I} V1. T1 →
∃∃V2,T2. L ⊢ V1 [d, e] ≫ V2 &
\ /
V_______________________________________________________________ *)
-include "lambda-delta/substitution/lift_lift.ma".
include "lambda-delta/substitution/drop_drop.ma".
include "lambda-delta/substitution/tps.ma".
include "lambda-delta/substitution/tps_split.ma".
+lemma arith_i2: ∀a,c1,c2. c1 + c2 ≤ a → c1 + c2 + (a - c1 - c2) = a.
+/2/ qed.
+
(* PARTIAL SUBSTITUTION ON TERMS ********************************************)
(* Main properties **********************************************************)
-
-lemma tps_trans: ∀L,T1,T,d,e. L ⊢ T1 [d, e] ≫ T → ∀T2. L ⊢ T [d, e] ≫ T2 →
- L ⊢ T1 [d, e] ≫ T2.
+(*
+theorem tps_trans: ∀L,T1,T,d,e. L ⊢ T1 [d, e] ≫ T → ∀T2. L ⊢ T [d, e] ≫ T2 →
+ L ⊢ T1 [d, e] ≫ T2.
#L #T1 #T #d #e #H elim H -L T1 T d e
[ //
| //
elim (tps_inv_flat1 … HX) -HX #V #T #HV2 #HT2 #HX destruct -X /3/
]
qed.
+*)
-axiom tps_conf: ∀L,T0,d,e,T1. L ⊢ T0 [d, e] ≫ T1 → ∀T2. L ⊢ T0 [d, e] ≫ T2 →
+axiom tps_conf_subst_subst_lt: ∀L,K1,V1,W1,T1,i1,d,e,T2,K2,V2,W2,i2.
+ ↓[O, i1] L ≡ K1. 𝕓{Abbr} V1 → ↓[O, i2] L≡ K2. 𝕓{Abbr} V2 →
+ K1 ⊢ V1 [O, d + e - i1 - 1] ≫ W1 → K2 ⊢ V2 [O, d + e - i2 - 1] ≫ W2 →
+ ↑[O, i1 + 1] W1 ≡ T1 → ↑[O, i2 + 1] W2 ≡ T2 →
+ d ≤ i1 → i1 < d + e → d ≤ i2 → i2 < d + e → i1 < i2 →
+ ∃∃T. L ⊢ T1 [d, e] ≫ T & L ⊢ T2 [d, e] ≫ T.
+(*
+#L #K1 #V1 #W1 #T1 #i1 #d #e #T2 #K2 #V2 #W2 #i2
+#HLK1 #HLK2 #HVW1 #HVW2 #HWT1 #HWT2 #Hdi1 #Hi1de #Hdi2 #Hi2de #Hi12
+*)
+
+theorem tps_conf: ∀L,T0,T1,d,e. L ⊢ T0 [d, e] ≫ T1 → ∀T2. L ⊢ T0 [d, e] ≫ T2 →
∃∃T. L ⊢ T1 [d, e] ≫ T & L ⊢ T2 [d, e] ≫ T.
+#L #T0 #T1 #d #e #H elim H -H L T0 T1 d e
+[ /2/
+| /2/
+| #L #K1 #V1 #W1 #T1 #i1 #d #e #Hdi1 #Hi1de #HLK1 #HVW1 #HWT1 #IHVW1 #T2 #H
+ elim (tps_inv_lref1 … H) -H
+ [ -IHVW1 #HX destruct -T2
+ @ex2_1_intro [2: // | skip ] /2 width=6/ (**) (* /3 width=9/ is slow *)
+ | * #K2 #V2 #W2 #i2 #Hdi2 #Hi2de #HLK2 #HVW2 #HWT2
+ elim (lt_or_eq_or_gt i1 i2) #Hi12
+ [ @tps_conf_subst_subst_lt /width=19/
+ | -HVW1; destruct -i2;
+ lapply (transitive_le ? ? (i1 + 1) Hdi2 ?) -Hdi2 // #Hdi2
+ lapply (drop_mono … HLK1 … HLK2) -HLK1 Hdi1 Hi1de #H destruct -V1 K1;
+ elim (IHVW1 … HVW2) -IHVW1 HVW2 #W #HW1 #HW2
+ lapply (drop_fwd_drop2 … HLK2) -HLK2 #HLK2
+ elim (lift_total W 0 (i1 + 1)) #T #HWT
+ lapply (tps_lift_ge … HW1 … HLK2 HWT1 HWT ?) -HW1 HWT1 //
+ lapply (tps_lift_ge … HW2 … HLK2 HWT2 HWT ?) -HW2 HWT2 HLK2 HWT // normalize #HT2 #HT1
+ lapply (tps_weak … HT1 d e ? ?) -HT1 [ >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) ->
*)
include "lambda-delta/ground.ma".
-include "lambda-delta/xoa_props.ma".
include "lambda-delta/notation.ma".
(* BINARY ITEMS *************************************************************)