(* 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_con2 : ∀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_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).
lemma lift_inv_sort2_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 → ∀k. T2 = ⋆k → T1 = ⋆k.
#d #e #T1 #T2 #H elim H -H d e T1 T2 //
- [ #i #d #e #_ #k #H destruct
- | #I #V1 #V2 #T1 #T2 #d #e #_ #_ #_ #_ #k #H destruct
- ]
+[ #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.
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 #H elim H -H 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 <minus_plus_m_m /4/
- | #I #V1 #V2 #T1 #T2 #d #e #_ #_ #_ #_ #i #H destruct
- ]
+[ #k #d #e #i #H destruct
+| #j #d #e #Hj #i #Hi destruct /3/
+| #j #d #e #Hj #i #Hi destruct <minus_plus_m_m /4/
+| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #_ #_ #i #H destruct
+| #I #V1 #V2 #T1 #T2 #d #e #_ #_ #_ #_ #i #H destruct
+]
qed.
lemma lift_inv_lref2: ∀d,e,T1,i. ↑[d,e] T1 ≡ #i →
#d #e #T1 #i #H lapply (lift_inv_lref2_aux … H) /2/
qed.
-lemma lift_inv_con22_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 →
- ∀I,V2,U2. T2 = ♭I V2.U2 →
+lemma lift_inv_bind2_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 →
+ ∀I,V2,U2. T2 = 𝕓{I} V2.U2 →
∃∃V1,U1. ↑[d,e] V1 ≡ V2 & ↑[d+1,e] U1 ≡ U2 &
- T1 = ♭I V1.U1.
+ T1 = 𝕓{I} V1.U1.
#d #e #T1 #T2 #H elim H -H d e T1 T2
- [ #k #d #e #I #V2 #U2 #H destruct
- | #i #d #e #_ #I #V2 #U2 #H destruct
- | #i #d #e #_ #I #V2 #U2 #H destruct
- | #J #W1 #W2 #T1 #T2 #d #e #HW #HT #_ #_ #I #V2 #U2 #H destruct
- /2 width = 5/
- ]
+[ #k #d #e #I #V2 #U2 #H destruct
+| #i #d #e #_ #I #V2 #U2 #H destruct
+| #i #d #e #_ #I #V2 #U2 #H destruct
+| #J #W1 #W2 #T1 #T2 #d #e #HW #HT #_ #_ #I #V2 #U2 #H destruct /2 width = 5/
+| #J #W1 #W2 #T1 #T2 #d #e #HW #HT #_ #_ #I #V2 #U2 #H destruct
+]
qed.
-lemma lift_inv_con22: ∀d,e,T1,I,V2,U2. ↑[d,e] T1 ≡ ♭I V2. U2 →
+lemma lift_inv_bind2: ∀d,e,T1,I,V2,U2. ↑[d,e] T1 ≡ 𝕓{I} V2. U2 →
∃∃V1,U1. ↑[d,e] V1 ≡ V2 & ↑[d+1,e] U1 ≡ U2 &
- T1 = ♭I V1. U1.
-#d #e #T1 #I #V2 #U2 #H lapply (lift_inv_con22_aux … H) /2/
+ T1 = 𝕓{I} V1. U1.
+#d #e #T1 #I #V2 #U2 #H lapply (lift_inv_bind2_aux … H) /2/
+qed.
+
+lemma lift_inv_flat2_aux: ∀d,e,T1,T2. ↑[d,e] T1 ≡ T2 →
+ ∀I,V2,U2. T2 = 𝕗{I} V2.U2 →
+ ∃∃V1,U1. ↑[d,e] V1 ≡ V2 & ↑[d,e] U1 ≡ U2 &
+ T1 = 𝕗{I} V1.U1.
+#d #e #T1 #T2 #H elim H -H d e T1 T2
+[ #k #d #e #I #V2 #U2 #H destruct
+| #i #d #e #_ #I #V2 #U2 #H destruct
+| #i #d #e #_ #I #V2 #U2 #H destruct
+| #J #W1 #W2 #T1 #T2 #d #e #HW #HT #_ #_ #I #V2 #U2 #H destruct
+| #J #W1 #W2 #T1 #T2 #d #e #HW #HT #_ #_ #I #V2 #U2 #H destruct /2 width = 5/
+]
+qed.
+
+lemma lift_inv_flat2: ∀d,e,T1,I,V2,U2. ↑[d,e] T1 ≡ 𝕗{I} V2. U2 →
+ ∃∃V1,U1. ↑[d,e] V1 ≡ V2 & ↑[d,e] U1 ≡ U2 &
+ T1 = 𝕗{I} V1. U1.
+#d #e #T1 #I #V2 #U2 #H lapply (lift_inv_flat2_aux … H) /2/
qed.
(* the main properies *******************************************************)
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/
- | #i #d1 #e1 #Hid1 #d2 #e2 #T2 #Hi #Hd12
- lapply (lift_inv_lref2 … Hi) -Hi * * #Hid2 #H destruct -T2
- [ -Hid2 /4/
- | elim (lt_false d1 ?)
- @(le_to_lt_to_lt … Hd12) -Hd12 @(le_to_lt_to_lt … Hid1) -Hid1 /2/
- ]
- | #i #d1 #e1 #Hid1 #d2 #e2 #T2 #Hi #Hd12
- lapply (lift_inv_lref2 … Hi) -Hi * * #Hid2 #H destruct -T2
- [ -Hd12; lapply (lt_plus_to_lt_l … Hid2) -Hid2 #Hid2 /3/
- | -Hid1; lapply (arith1 … Hid2) -Hid2 #Hid2
- @(ex2_1_intro … #(i - e2))
- [ >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_con22 … 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/
- ]
+[ #k #d1 #e1 #d2 #e2 #T2 #Hk #Hd12
+ lapply (lift_inv_sort2 … Hk) -Hk #Hk destruct -T2 /3/
+| #i #d1 #e1 #Hid1 #d2 #e2 #T2 #Hi #Hd12
+ lapply (lift_inv_lref2 … Hi) -Hi * * #Hid2 #H destruct -T2
+ [ -Hid2 /4/
+ | elim (lt_false d1 ?)
+ @(le_to_lt_to_lt … Hd12) -Hd12 @(le_to_lt_to_lt … Hid1) -Hid1 /2/
+ ]
+| #i #d1 #e1 #Hid1 #d2 #e2 #T2 #Hi #Hd12
+ lapply (lift_inv_lref2 … Hi) -Hi * * #Hid2 #H destruct -T2
+ [ -Hd12; lapply (lt_plus_to_lt_l … Hid2) -Hid2 #Hid2 /3/
+ | -Hid1; lapply (arith1 … Hid2) -Hid2 #Hid2
+ @(ex2_1_intro … #(i - e2))
+ [ >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_free: ∀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
- <(plus_plus_minus_m_m e1 e2 i) /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/
- ]
+[ /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
+ <(plus_plus_minus_m_m e1 e2 i) /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.
(* TELESCOPIC SUBSTITUTION **************************************************)
inductive subst: lenv → term → nat → nat → term → Prop ≝
- | subst_sort : ∀L,k,d,e. subst L (⋆k) d e (⋆k)
- | subst_lref_lt: ∀L,i,d,e. i < d → subst L (#i) d e (#i)
- | subst_lref_O : ∀L,V,e. 0 < e → subst (L. ♭Abbr V) #0 0 e V
- | subst_lref_S : ∀L,I,V,i,T1,T2,d,e.
- d ≤ i → i < d + e → subst L #i d e T1 → ↑[d,1] T1 ≡ T2 →
- subst (L. ♭I V) #(i + 1) (d + 1) e T2
- | subst_lref_ge: ∀L,i,d,e. d + e ≤ i → subst L (#i) d e (#(i - e))
- | subst_con2 : ∀L,I,V1,V2,T1,T2,d,e.
- subst L V1 d e V2 → subst (L. ♭I V1) T1 (d + 1) e T2 →
- subst L (♭I V1. T1) d e (♭I V2. T2)
+| subst_sort : ∀L,k,d,e. subst L (⋆k) d e (⋆k)
+| subst_lref_lt: ∀L,i,d,e. i < d → subst L (#i) d e (#i)
+| subst_lref_O : ∀L,V,e. 0 < e → subst (L. 𝕓{Abbr} V) #0 0 e V
+| subst_lref_S : ∀L,I,V,i,T1,T2,d,e.
+ d ≤ i → i < d + e → subst L #i d e T1 → ↑[d,1] T1 ≡ T2 →
+ subst (L. 𝕓{I} V) #(i + 1) (d + 1) e T2
+| subst_lref_ge: ∀L,i,d,e. d + e ≤ i → subst L (#i) d e (#(i - e))
+| subst_bind : ∀L,I,V1,V2,T1,T2,d,e.
+ subst L V1 d e V2 → subst (L. 𝕓{I} V1) T1 (d + 1) e T2 →
+ subst L (𝕓{I} V1. T1) d e (𝕓{I} V2. T2)
+| subst_flat : ∀L,I,V1,V2,T1,T2,d,e.
+ subst L V1 d e V2 → subst L T1 d e T2 →
+ subst L (𝕗{I} V1. T1) d e (𝕗{I} V2. T2)
.
interpretation "telescopic substritution" 'RSubst L T1 d e T2 = (subst L T1 d e T2).
(* THINNING *****************************************************************)
inductive thin: lenv → nat → nat → lenv → Prop ≝
- | thin_refl: ∀L. thin L 0 0 L
- | thin_thin: ∀L1,L2,I,V,e.
- thin L1 0 e L2 → thin (L1. ♭I V) 0 (e + 1) L2
- | thin_skip: ∀L1,L2,I,V1,V2,d,e.
- thin L1 d e L2 → L1 ⊢ ↓[d,e] V1 ≡ V2 →
- thin (L1. ♭I V1) (d + 1) e (L2. ♭I V2)
+| thin_refl: ∀L. thin L 0 0 L
+| thin_thin: ∀L1,L2,I,V,e. thin L1 0 e L2 → thin (L1. 𝕓{I} V) 0 (e + 1) L2
+| thin_skip: ∀L1,L2,I,V1,V2,d,e.
+ thin L1 d e L2 → L1 ⊢ ↓[d,e] V1 ≡ V2 →
+ thin (L1. 𝕓{I} V1) (d + 1) e (L2. 𝕓{I} V2)
.
interpretation "thinning" 'RSubst L1 d e L2 = (thin L1 d e L2).
∀e2,L2. ↓[0,e2] L ≡ L2 → d1 + e1 ≤ e2 → ↓[0,e2-e1] L1 ≡ L2.
axiom thin_conf_lt: ∀d1,e1,L,L1. ↓[d1,e1] L ≡ L1 →
- ∀e2,K2,I,V2. ↓[0,e2] L ≡ K2. ♭I V2 →
+ ∀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.
+ ∃∃K1,V1. ↓[0,e2] L1 ≡ K1. 𝕓{I} V1 & ↓[d,e1] K2 ≡ K1 & ↑[d,e1] V1 ≡ V2.