K-out-of-N constraint in Z3Py

Yes, Z3Py has built-in support for this. There is an undocumented API for this, that isn’t mentioned in the Z3Py docs: use PbEq. In particular, the expression PbEq(((x1,1),(x2,1),..,(xN,1)),K) will be true if exactly K out of the N boolean variables are set to true. There are some reports that this encoding will be faster than … Read more