I am compiling the following simple program using Idris2.
import Data.Fin
%default total
negate : {k:_} -> Fin k -> Fin k
subt : {k:_} -> Fin k -> Fin k -> Fin k
add : {k:_} -> Fin k -> Fin k -> Fin k
mult : {k:_} -> Fin k -> Fin k -> Fin k
mult FZ b = FZ
mult (FS a) b = add b $ mult (weaken a) b
However, the compiler spits an error:
Error: mult is not total, possibly not terminating due to recursive
path Main.mult -> Main.mult -> Main.mult
Isn't the recursive call on input a
which is smaller than (FS a)
? Why is the totality check failing?
Thanks!