I have a definition with the following type:
insert : ∀ {n} → (i : Fin (suc n)) → ∀ t → Env n → Env (suc n)
weaken : ∀ {t t₀ n} {Γ : Env n} → (i : Fin (suc n)) → (e : Γ ⊢ t₀) → (insert i t Γ) ⊢ t₀
Given two environments Γ : Env n
and Γ′ : Env n′
, and a pointer to a position in the second one, i : Fin (suc n)
, I would like to weaken an e : (Γ′ ++ Γ) ⊢ t₀
.
In theory, this should be easy by using something like
let i′ = raise n′ i
weaken {t} i′ e : insert i′ t (Γ′ ++ Γ) ⊢ t₀
However, in practice it doesn't work out so nicely, because the typechecker is not convinced that raise n′ i
has type Fin (suc _)
(required by weaken
):
(n′ + suc n)
!=(suc (_n_550 i e))
of typeℕ
when checking that the expressioni′
has typeFin (suc (_n_550 i e))
My problem is, I could use something like +-suc : ∀ n′ n → n′ + suc n ≡ suc (n′ + n)
to subst
itute the type of i′
, but then the resulting type from weaken i′ e
will not have the form insert i′ t (Γ′ ++ Γ) ⊢ t₀
.