I have a recursively defined function in Coq whose arguments in the recursive invocations are surely decreasing, but Coq cannot understand this fact since they are not subterms of the function's argument. This is a snippet exemplifying the situation:
Inductive expression : Type := | Get : expression -> identifier -> expression | IfThenElse : expression -> expression -> expression -> expression ... end. Fixpoint eval (M : memory) (e : expression) : value := match e with | Get (IfThenElse cond e1 e2) var_name => ... eval M (Get e1 var_name) ... eval M (Get e2 var_name) ... ... end.
While the recursive invocations of eval have not a subterm of e as their argument, it is easy to find a decreasing measure for the e argument of eval, e.g., the maximum nesting level of subterms in it. I read that Program Fixpoint allows to specify a measure, but I found the section on Program in the reference manual too obscure, nor I was able to find a tutorial or examples that may suit a beginner as I am. Can anyone provide me some references, or a quick explanation, or perhaps suggest an alternative approach that does not imply restructuring the inductive type definitions?
value. If you design them correctly, then
evalought ot be structurally recursive. Perhaps you can show a real example that is closer to what you are trying to do. $\endgroup$
Get e xsupposed to mean, intuitively? $\endgroup$