Z3 API: 是否可以检查 AST

Z3 API: Is inspection of AST possible

在 Z3 中没有直接的方法来遍历已经存在的 Z3_ast 表达式,从 API 中我似乎很清楚这一点。然而,有没有一种间接的方法,例如,如何拆分一个连词,用一个术语替换 Z3_ast 中的一个术语,例如通过 Z3_parse_smtlib2_string 或作为一个插值通过 Z3_get_interpolant 获得(这些是 Z3 的输出,因此能够检查它们是有意义的。

遍历是可能的,在 C API 中的函数是 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)。