简体   繁体   中英

Are Z3 caches additive?

I'm aware that Z3 has stack-based caching, where additional formulas can be added and cached. Is there a built-in way or extension that allows two Z3 caches to be combined?

Example (Z3 py)

from z3 import Solver

solver = Solver()
solver.push()
solver2 = Solver()
# solver.combine(solver2) ?

Not quite cleear what you mean by "combine." But, you can get the assertions from one and add it to the other:

from z3 import *

i = Int('x')
s1 = Solver()
s1.add(i == 3)
s1.push()

s2 = Solver()
s2.add(s1.assertions())
print s2.check()
print s2.model()

This prints:

sat
[x = 3]

You can use this trick to do your own combinations I suppose.

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