Expand description
Pigeonhole / bipartite-matching detection for the general solver — the cardinality reasoning
that lets prove_unsat win on pigeonhole-shaped formulas in POLYNOMIAL time.
A conjunction of “each item is in at least one slot” (positive disjunctions) and “each slot
holds at most one item” (pairwise mutual-exclusion clauses) is a bipartite-matching feasibility
question. Encoded as boolean SAT it needs exponentially long resolution refutations — the
classic wall for CDCL (ours and Z3’s). But the underlying matching is decided in polynomial
time with a certified Hall witness (crate::matching).
This module recognizes that structure SOUNDLY — a faithful, fully-verified decomposition or it
bails to None — and routes the UNSAT case to the matching reasoner. Soundness: a
satisfying assignment of (at-least-one rows ∧ fully-encoded at-most-one columns) is exactly a
perfect matching of items to slots (each item ≥1 true variable, each slot ≤1), so “no perfect
matching” (a re-verified Hall witness) ⟺ UNSAT. A true from decide_pigeonhole_unsat is
therefore always a genuine, witnessed refutation; everything else falls back to CDCL.
Structs§
- Counting
Cert - The pigeonhole counting certificate — the symmetry break taken to its absolute limit. For the complete
bipartite instance
PHP(pigeons → holes)(every pigeon may use every hole, each hole ≤ 1 pigeon), the full pigeon set has neighborhood = allholesslots, so Hall’s condition fails the instantpigeons > holes. That single inequality IS the refutation — sound,O(1), and scale-free.
Functions§
- certify_
pigeonhole_ unsat - Certify
PHP(pigeons → holes)UNSAT by pure counting, inO(1).Someiffpigeons > holes(Hall violated by the full pigeon set);Noneotherwise (feasible — a perfect matching can exist). - check_
counting_ cert - Re-check a counting certificate from scratch: it witnesses UNSAT iff
pigeons > holes.O(1), zero trust in how it was produced — the whole refutation is one inequality. - counting_
certificate - Expose the O(1) counting certificate for any matching-shaped cover, not just literal pigeonhole:
recover the bipartite
(items → slots)structure and certify UNSAT by the full-set Hall bounditems > slots. Fires for pigeonhole and clique-coloring (nvertices,k < ncolors) — the same crush, derived structurally.Nonewhen there is no such bipartite structure or the full set does not overflow the slots (a subset-Hall failure is still caught bydecide_pigeonhole_unsat). - decide_
pigeonhole_ unsat - Decide whether
eis a clean pigeonhole structure that is UNSAT. ReturnstrueONLY when the formula decomposes faithfully into at-least-one rows + fully-encoded (clique) at-most-one columns AND the bipartite matching is infeasible with a RE-VERIFIED Hall witness.falseotherwise — for a non-pigeonhole formula, or a feasible one (the caller falls back to CDCL). Never a falsetrue. - hall_
refutation - The full Hall certificate — the matching symmetry invariant in its complete form. A bipartite
cover is infeasible the moment some subset
Sof items reaches fewer than|S|slots, even when the totals balance and the crudeitems > slotsbound sees nothing. Returns the violating subset (re-checked byis_hall_witness), strictly stronger thancounting_certificate. This is the witness behinddecide_pigeonhole_unsat’s verdict, surfaced.