So, I can obtain the names associated with bounds of the quantifier using Z3_get_quantifier_bound_name called on the expression representing quantifier. But suppose I’m traversing an AST of quantified subformula. Is it possible to access the name of the index at that point?
Thank you.
if (z3_expr.is_var())
{
// is it possible at this point to get the name of the quantified variable,
// which was associated with it at quantifier creation?
}
Expressions that are variables don’t have names directly associated with them.
The way we access the names is by maintaining a stack of the names from the
quantifiers that were traversed on the way down.
So maintain a vector (stack/list) of symbols, and whenever you
traverse a quantifier push the bound names from the quantifier onto the vector.
You will have to pop the names after you are done traversing the quantifier.
You use the following APIs to access the names of bound variables:
Note that indices of quantified variables are ordered right-to-left.
So if Z3_get_quantifier_num_bound(context, expr) returns 2, and
x = Z3_get_quantifier_bound_name(context, expr, 0)
y = Z3_get_quantifier_bound_name(context, expr, 1)
then y has index 0 and x has index 1.