Suppose factorial was defined as follows:
- val fact_def = Define `fact n = if n=0 then 1 else n * fact (n-1)`;
Equations stored under "fact_def".
Induction stored under "fact_ind".
> val fact_def = |- fact n = (if n = 0 then 1 else n * fact (n - 1)) : thm
The theorem fact_def is a looping rewrite since the recursive call
fac (n-1) matches the left-hand side of fact_def. Thus, a naive
application of the simplifier will loop:
- SIMP_CONV arith_ss [fact_def] ``fact 6``;
(* looping *)
> Interrupted.
In order to expand the definition of fact_def three times, the
following invocation can be made
- SIMP_CONV arith_ss [Ntimes Fact_def 3] ``fact 6``;
> val it = |- fact 6 = 6 * (5 * (4 * fact 3)) : thm