gen_find_term : (term list * term -> 'a option) -> term -> 'a option
The additional list of terms passed to the function f is the list of bound variables “governing” the sub-term in question, with the innermost bound variable first in the list.
> gen_find_term (fn x => SOME x) ``SUC x``; val it = SOME ([], ``SUC x``) : (term list * term) option > gen_find_term (fn (bvs,t) => if null bvs andalso (is_var t orelse numSyntax.is_numeral t) then Lib.total (match_term ``x:num``) t else NONE) ``SUC z + (\y. y) 5``; val it = SOME ([{redex = ``x``, residue = ``z``}], [])] : ((term, term) Term.subst * (hol_type, hol_type) Term.subst) option