Suppose we have the following code:
open import Data.Fin
open import Data.Nat
data SType : ℕ → Set where
variable
ℓ : ℕ
ι : Fin ℓ
τ τ' : SType ℓ
infixl 5 _,_
data Ctx : ℕ → Set where
⊘ : Ctx zero
_,_ : Ctx ℓ → SType ℓ → Ctx (suc ℓ)
variable Γ : Ctx ℓ
postulate weaken : SType ℓ → SType (suc ℓ)
infix 4 _∈_at_
data _∈_at_ : SType ℓ → Ctx ℓ → Fin ℓ → Set where
∈-zero : weaken τ ∈ Γ , τ at zero
∈-suc : τ ∈ Γ at ι
→ weaken τ ∈ Γ , τ' at suc ι
which models a tiny part of a well-scoped representation of a type system (and I'm keeping weaken
postulate
d and SType
not having any constructors for the sake of brevity).
Now suppose we want to write a function that's basically an "inverse" of the ∈-suc
constructor:
∈-chop : weaken τ ∈ Γ , τ' at suc ι
→ τ ∈ Γ at ι
∈-chop ∈ = {! !}
Now, if we try to split on ∈
, Agda will get all doubting and hesitant:
I'm not sure if there should be a case for the constructor ∈-suc,
because I get stuck when trying to solve the following unification
problems (inferred index ≟ expected index):
{suc τ.ℓ₁} ≟ {suc τ.ℓ₂}
weaken τ₁ ≟ weaken τ₂
Γ₁ , τ'' ≟ Γ₂ , τ'''
suc ι₁ ≟ suc ι₂
when checking that the expression ? has type τ ∈ Γ at ι
Why is it not sure, and what's the best way to fix this?