简体   繁体   中英

z3 getting the size of a symbolic variable C++ API

I'm using Z3_parse_smtlib2_string to parse a smtlib2 formula. The fomula looks like:

(set-logic QF_AUFBV)(declare-fun SymVar_0 () (_ BitVec 32))(declare-fun SymVar_1 () (_ BitVec 8))...

I parse it using:

Z3_ast ast = Z3_parse_smtlib2_string(ctx, (Z3_string)formula, 0, 0, 0, 0, 0, 0);

Let say that I want now to get the size of SymVar_0 (it should return 32). How can I do so?

Thank you

The function called Z3_get_bv_sort_size should do the job. Note that this is a C (not C++) function, so you have to supply the context as well.

In the interest of other users facing similar issues: There is no symbol table in Z3 that lets you look up the types of names. You can create one yourself by running over all the subexpressions and recording all the symbols and their types encountered while doing so. For an example in Python, see Z3py: how to get the list of variables from a formula? .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM