问题
They seem to serve similar purposes. The one difference I've noticed so far is that while Program Fixpoint will accept a compound measure like {measure (length l1 + length l2) }, Function seems to reject this and will only allow {measure length l1}.
Is Program Fixpoint strictly more powerful than Function, or are they better suited for different use cases?
回答1:
This may not be a complete list, but it is what I have found so far:
- As you already mentioned,
Program Fixpointallows the measure to look at more than one argument. Functioncreates afoo_equationlemma that can be used to rewrite calls tofoowith its RHS. Very useful to avoid problems like Coq simpl for Program Fixpoint.- In some (simple?) cases,
Functioncan define afoo_indlemma to perform induction along the structure of recursive calls offoo. Again, very useful to prove things aboutfoowithout effectively repeating the termination argument in the proof. Program Fixpointcan be tricked into supporting nested recursion, see https://stackoverflow.com/a/46859452/946226. This is also whyProgram Fixpointcan define the Ackermann function whenFunctioncannot.
来源:https://stackoverflow.com/questions/44606245/whats-the-difference-between-program-fixpoint-and-function-in-coq