I've defined an operator, +-
(ignore the terrible name), as follows:
infixr 10 +-
(+-) : Fin (S n) -> Fin (S m) -> Fin (S (n + m))
(+-) {n} {m} FZ f' = rewrite plusCommutative n m in weakenN n f'
(+-) {n = S n} (FS f) f' = FS (f +- f')
The intention is that it behaves exactly like +
as defined on Fin
, but the upper bound of the result is tighter by 1. As far as I can tell, it works correctly.
The problem I'm having is in trying to prove that (FZ +- f) = f
for any f : Fin n
. I'm not expecting this to be true in general, because it will usually be the case that FZ +- f
has a looser bound than f
on account of the call to weakenN
. However, in the particular case where the FZ
has type Fin 1
, then the types (and the values) ought to match up.
Is there any way of indicating to Idris that I only want to assert the equality in that particular case, rather than for all possible types of FZ
? Or is there a completely different approach that I ought to be taking?
((+-) {n=0} FZ f) = f
? – Cactus{n = Z} (FS s) f'
case from your definition. Is that intended? – András Kovács{hole0} : (m : Nat) -> (f : Fin (S m)) -> FZ +- f = f
: no mention of the value ofn
. And when I try tocompute
it does nothing. – j11c