DEPTH_CONV : (conv -> conv)
#DEPTH_CONV BETA_CONV "(\x. (\y. y + x) 1) 2";; |- (\x. (\y. y + x)1)2 = 1 + 2Here, there are two beta-redexes in the input term, one of which occurs within the other. DEPTH_CONV BETA_CONV applies beta-conversion to innermost beta-redex (\y. y + x) 1 first. The outermost beta-redex is then (\x. 1 + x) 2, and beta-conversion of this redex gives 1 + 2.
Because DEPTH_CONV applies a conversion bottom-up, the final result may still
contain subterms to which the supplied conversion applies. For example, in:
#DEPTH_CONV BETA_CONV "(\f x. (f x) + 1) (\y.y) 2";;
|- (\f x. (f x) + 1)(\y. y)2 = ((\y. y)2) + 1
the right-hand side of the result still contains a beta-redex,
because the redex "(\y.y)2" is introduced by virtue an application of
BETA_CONV higher-up in the structure of the input term. By contrast, in the
example:
#DEPTH_CONV BETA_CONV "(\f x. (f x)) (\y.y) 2";;
|- (\f x. f x)(\y. y)2 = 2
all beta-redexes are eliminated, because DEPTH_CONV repeats the
supplied conversion (in this case, BETA_CONV) at each subterm (in this case,
at the top-level term).
#DEPTH_CONV ADD_CONV "(1 + 2) + (3 + 4 + 5)";; |- (1 + 2) + (3 + (4 + 5)) = 15is to compute the sum represented by the input term.