Suppose we wish to define a function for some types A₀ ⋯ Aₙ and B
f : A₀ ⋯ Aₙ → B
f x₀ ⋯ xₙ = ... recursive call to f ...
Assume that this definition is not structurally recursive.
Assume also that I have definitions for the following:
a function
g : A₀ ⋯ Aₙ → ℕ
which takes some subset of the arguments off
to a natural number;for every case of
f
: a proof thatg
of the arguments passed to the recursive call is strictly smaller thang
of the incoming arguments (using the built-in _<_ or _<′_ relation on natural numbers).
How would I put these parts together to make a recursive function,
using the Induction
modules from the Agda "standard" library?
This question is a follow-up to this question on the same subject, to which very complete answers have been given. However, I feel that the example function's type was unfortunately chosen as ℕ → ℕ
, which makes it hard for me to see how this extends to the general case.
Also, note that I'm not expecting a large answer with explanation on the workings behind well-founded induction and its implementation in Agda, as @Vitus as kindly provided quite an elaborate answer for this.