f x = f (g subtermOfX)
Is recursion only allowed if the arg to the function is a direct subterm of the arg passed so that Coq can see that it actually terminates?
f x = f (g subtermOfX)
Is recursion only allowed if the arg to the function is a direct subterm of the arg passed so that Coq can see that it actually terminates?
Copyright © 2021 Jogjafile Inc.
It's possible to write such function
f
if functiong
preserves the property of being a subterm.Some of the standard functions have this property, e.g.
pred
,sub
:On the other hand some (standard) functions do not have this property, but can be rewritten to remedy this deficiency. E.g. the standard
tl
function does not preserve the subterm property, so the following fails:but if we redefine the tail function like so
we can recover the desired property:
The only difference between
tl
andnew_tl
is that in the case of empty input listtl
returns[]
, butnew_tl
returns the original list.