Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eliminating subst to prove equality

Tags:

agda

gadt

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...

like image 599
Cactus Avatar asked Feb 12 '12 05:02

Cactus


1 Answers

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.

like image 158
Saizan Avatar answered Oct 17 '22 15:10

Saizan