问题
There is no direct way in Z3 to traverse an already existing Z3_ast
for an expression, that much seems clear to me from the API. Is there however an indirect way how to, e.g., split a conjunction, substitute a term for a term in a Z3_ast
obtained for example by Z3_parse_smtlib2_string
or as an interpolant obtained with Z3_get_interpolant
(these are output from Z3, so it makes sense to be able to examine them).
回答1:
Traversal is possible, in the C API the functions for that are Z3_get_app_num_args and Z3_get_app_arg. However, this works only if the AST is a function application (an app, cast via Z3_to_app if necessary), other AST types may not have arguments to traverse (e.g., vars and numerals, see Z3_ast_kind).
来源:https://stackoverflow.com/questions/32475007/z3-api-is-inspection-of-ast-possible