I tidied up the code a bit. See:
https://github.com/githwxi/ATS-Postiats-test/blob/master/core/MISC/test06.datsIf you change
[k: int | k <= n] to [k: nat | k <= n], then the lemma is not needed.
The need for the lemma is due to list_vt_cons requiring its second argument to be
a list of non-negative length. Yes, every length is non-negative, but the typechecker
of ATS does not know this fact.
The tail-call in the filter function is not eliminated. I will fix this issue in the next release
of ATS. For now, if you want the tail-call to be eliminated, please use the following coding
style:
extern fun list_vt_filter ...
implement{a} list_vt_filter (xs, f) = ...