Published Updated
Z3 merges a repair for Python selection constraints with no candidates
Z3 adopted the reported Python-wrapper repair and six regression examples, restoring meaningful zero-sum constraints for empty candidate lists in development source.
An empty choice list still has a meaning
Assignment and scheduling models often build constraints after filtering eligible candidates. If the filter leaves no candidates, selecting exactly zero is possible; selecting at least one is impossible. A model builder should be able to express both conditions and let the solver use them.
Z3 has merged a repair for the Python-wrapper regression we reported: three selection APIs raised an exception when their input list was empty. The repaired development source constructs the expected zero-sum conditions and includes six regression examples.
Tasuku Kobayashi submitted Z3 issue #11617 on November 9, 2026, with the diagnosis, a proposed repair and regression examples. Nikolaj Bjorner merged repair PR #11621 on November 9, 2026, at 18:31 UTC, and the issue was closed as completed. The PR was authored by Copilot and adopts the reported one-line repair and six regression examples. The latest stable release checked, 5.3.3, predates the repair; stable-release availability remains pending.
Zero candidates, ordinary selection rules
PbEq, PbLe and PbGe construct conditions on a weighted sum of Boolean choices. A weight of one turns the sum into the number selected. With no terms, the sum is zero.
| Rule with no candidates | Expected condition | Affected release | Merged repair |
|---|---|---|---|
| Exactly zero: PbEq([], 0) | True | ValueError | True |
| Exactly one: PbEq([], 1) | False | ValueError | False |
| At most zero: PbLe([], 0) | True | ValueError | True |
| At least one: PbGe([], 1) | False | ValueError | False |
The exception is ValueError: not enough values to unpack (expected 5, got 4). Nonempty inputs work. Empty tuples, sets and AstVector inputs encounter the same error.
import z3
for function in (z3.PbEq, z3.PbLe, z3.PbGe):
for bound in (0, 1):
try:
print(function.__name__, bound, z3.simplify(function([], bound)))
except Exception as exc:
print(function.__name__, bound, type(exc).__name__, str(exc))The result reproduces in releases 4.12.2.0, 5.1.0.0 and 5.3.3.0, and in master at 8573212, built from source. Release 4.8.12.0 returns the expected conditions. Runs used Python 3.12.14 on Linux x86_64 with glibc 2.39.
Track the regression to the missing return value
Z3 previously added empty-input support in the repair for issue #1545. A later 2022 change returned an additional value to keep converted expressions alive and updated all three callers to receive five values. The empty-input branch still returned four. Our report identifies this later regression and preserves the earlier report and repair’s attribution.
The adopted behavior change is one line: return an empty expression list as the fifth value for empty inputs. The normal path retains its expression lifetime protection. Six regression examples were added to the doctests already run by the project’s CI.
Local validation checked 60 combinations of empty collection, operation and bound, plus nonempty weighted constraints against Python integer arithmetic. After the proposal was applied, all five focused unittest methods and all 2,481 Python API and numerical doctest examples passed against the source-built master.
The upstream repair is now merged as commit 7e6d08e. A follow-up check of the unmodified merged helper with the released 5.3.3.0 native library passed all 60 empty-input combinations and 336 nonempty integer-arithmetic controls. This scoped check is separate from the earlier source-built-master doctests and is not a new full build of the merge.
The public issue contains the patch, exact versions and results. The report and upstream merge establish a repaired dependency behavior, not a SciGround production incident. Users of the current stable package still need a fixed build or a future release containing the repair.