I am trying to count the number of satisfying assignments by Z3. I am wondering if Z3 provides such information. If so, how can I count models in Z3 and particularly in Z3Py?
相关问题
- How to compute with Quaternion numbers in Z3?
- Z3 real arithmetics and data types theories integr
- Timeout for Z3 Optimize
- Adjusting `simplify` tactic in Z3
- How to setup a Java development environment for Z3
相关文章
- retrieve the matched model in Z3py?
- Simplex in z3 via for-all
- How do I get Z3 to return minimal model?
- How to get z3 to return multiple unsat cores, mult
- ld linking error while compiling z3
- Horn clauses in Z3
- Getting a “good” unsat-core with z3 (logic QF_BV)
- how to get multiple solutions for z3 solver in smt
No, such information is not available by default. However, you could easily implement this (assuming finite number of models) in any of the APIs by combining the model generation capability with adding assertions to prevent future assignments from being assigned the same values as past models. See the following answer for a Z3py script accomplishing this:
Z3: finding all satisfying models
To count the models, simply add a counter to the loop until it becomes unsat, and this will give you the number of models.
While Taylor's answer will give you the number of satisfying assignments, it will iterate over all of them. In principle, it is possible to do it without such an expensive iteration, but Z3 does not offer it.
There are efficient model counters for propositional logic, the same language used in SAT (search for sharpSAT to find such a system), but as far as I know there is no available model counter modulo theories.