Eliminating subst to prove equality

邮差的信 提交于 2019-12-10 17:15:13

问题


I'm trying to representat mod-n counters as a cut of the interval [0, ..., n-1] into two parts:

data Counter : ℕ → Set where
  cut : (i j : ℕ) → Counter (suc (i + j))

Using this, defining the two crucial operations is straightforward (some proofs omitted for brevity):

_+1 : ∀ {n} → Counter n → Counter n
cut i zero    +1 = subst Counter {!!} (cut zero i)
cut i (suc j) +1 = subst Counter {!!} (cut (suc i) j)

_-1 : ∀ {n} → Counter n → Counter n
cut zero    j -1 = subst Counter {!!} (cut j zero)
cut (suc i) j -1 = subst Counter {!!} (cut i (suc j))

The problem comes when trying to prove that +1 and -1 are inverses. I keep running into situations where I need an eliminator for these substs introduced, i.e. something like

subst-elim : {A : Set} → {B : A → Set} → {x x′ : A} → {x=x′ : x ≡ x′} → {y : B x} → subst B x=x′ y ≡ y
subst-elim {A} {B} {x} {.x} {refl} = refl

but this turns out to be (somewhat) begging the question: it isn't accepted by the type checker, because subst B x=x' y : B x' and y : B x...


回答1:


you can state the type of your subst-elim if you use Relation.Binary.HeterogeneousEquality from the stdlib. However i'd probably just pattern match on the eventual proof of x ≡ x′ in a with or rewrite clause, so you don't have to make an explicit eliminator and so no typing problem.



来源:https://stackoverflow.com/questions/9246705/eliminating-subst-to-prove-equality

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!