简体   繁体   中英

Size of constraints in the Z3 Solver()

Is there a way for us to get how many constraints were added into the solver? For example, we initialize a z3 solver s = Solver() and then adding constraints to it using s.add() . How can we get the number of constraints which were finally added to the solver?

You can use the assertions method:

from z3 import *

s = Solver()

i = Int('i')
s.add (i > 1)
s.add (i < 12)

print s.assertions()
print len(s.assertions())

This prints:

[i > 1, i < 12]
2

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