prove_rec_fn_exists : (thm -> term -> thm)
|- !f0 f1. ?! fn. (!x. fn(LEAF x) = f0 x) /\ (!b1 b2. fn(NODE b1 b2) = f1(fn b1)(fn b2)b1 b2)prove_rec_fn_exists can be used to prove the existence of primitive recursive functions over binary trees. Suppose the value of th is this theorem. Then the existence of a recursive function Leaves, which computes the number of leaves in a binary tree, can be proved as shown below:
#prove_rec_fn_exists th # "(Leaves (LEAF (x:*)) = 1) /\ # (Leaves (NODE t1 t2) = (Leaves t1) + (Leaves t2))";; |- ?Leaves. (!x. Leaves(LEAF x) = 1) /\ (!t1 t2. Leaves(NODE t1 t2) = (Leaves t1) + (Leaves t2))The result should be compared with the example given under new_recursive_definition.