Commit 9ff62f0
Redefine BMF as exact factorization; fix BicliqueCover semantics; add BMF → BicliqueCover (#1056)
* Redefine BMF as exact Boolean matrix factorization
The Rust BMF model previously minimized Hamming distance between A and B*C
(approximate factorization). This redefines it to the classical exact form:
feasible iff B*C = A, infeasible otherwise, with objective = total number of
1s in B and C (Monson-Pullman-Rees 1995).
Model changes (src/models/algebraic/bmf.rs):
- evaluate() returns Min(None) when B*C != A, else Min(Some(|B|_1 + |C|_1))
- Add total_factor_size() helper
- Fix canonical example: the previous optimal_config was not actually exact
(verified by hand: Hamming distance 2, not 0). New config is a true exact
factorization with total factor size 8.
BMF -> ILP reduction (src/rules/bmf_ilp.rs):
- Drop error variables e_{i,j} and their |A - w| inequalities
- Pin w_{i,j} = A_{i,j} (exact reconstruction)
- Objective changes from sum e_{i,j} to sum b_{i,r} + sum c_{r,j}
- Overhead shrinks: num_vars drops by m*n, num_constraints drops by m*n
BMF -> BicliqueCover reduction intentionally NOT added: the codebase's
BicliqueCover is the OR-cover variant (allows bicliques to cover non-edges),
which is strictly weaker than exact BMF. A closed-loop reduction would
extract invalid (non-exact) BMF configs. The classical equivalence with
biclique cover requires the stronger "sub-biclique-of-G" definition that
BicliqueCover does not currently enforce.
Julia parity fixture for BMF is removed (tests/data/jl/bmf.json) — the old
file encoded Hamming-distance semantics that no longer apply. Related
generator code in scripts/jl/generate_testdata.jl is commented out with a
note explaining the semantics change.
Paper (docs/paper/reductions.typ) is updated: BMF problem definition now
states exact factorization and |B|_1 + |C|_1 objective; BMF -> ILP rule
replaces the error-variable construction with the equality-constrained
formulation. Mentions the Boolean rank / biclique cover number equivalence
in the Extra Remark section.
Two incidental cargo fmt cleanups are included in
partition_into_paths_of_length_2.rs, maximumindependentset_triangular.rs,
and reduction_graph.rs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Enforce classical sub-biclique semantics and add BMF → BicliqueCover
BicliqueCover's `is_valid_cover` previously checked only that every graph
edge is covered by some biclique — it did not forbid a biclique from
containing a non-edge of G. That's the OR-cover / cover-by-rectangles
variant, which disagrees with the docstring (and with the textbook
definition). It's also why the earlier attempt at BMF → BicliqueCover was
unsound: a 2×2 identity at rank 1 was infeasible for exact BMF but
"feasible" for OR-cover via the K_{2,2} pseudo-biclique.
Changes:
- `BicliqueCover::is_valid_cover` now also requires every biclique's
`L_b × R_b` to be a subset of E(G). This aligns implementation with the
docstring and with the paper's constraint `x_{l,b} + y_{r,b} ≤ 1 for
non-edges` (which the paper already described but the code didn't
enforce).
- `BicliqueCover → ILP` adds the `x + y ≤ 1` constraint for every non-edge
and every biclique, matching the paper.
- `test_biclique_problem` updated: `[1,1,1,1]` on a graph with only edge
(0,0) now evaluates to `Min(None)` (it's a pseudo-biclique covering
non-edges).
- Canonical BicliqueCover example switched from the OR-cover optimum
(total size 5) to the correct sub-biclique optimum (total size 6),
matching the paper's worked example exactly.
- Julia parity fixture `tests/data/jl/biclique_cover.json` and its Rust
parity test are dropped; the Julia package (Go6Cf) has the same
OR-cover bug so its fixture would disagree with the fixed Rust
semantics. Generator note explains the divergence.
- New `BMF → BicliqueCover` reduction: matrix-to-biadjacency, rank
passthrough, with `extract_solution` transposing the right-vertex half
from vertex-major to biclique-row-major. Verified by closed-loop tests
on all-ones rank-1, identity rank-2, and an infeasibility test on
identity rank-1 (both problems now infeasible, consistent).
- Paper updated: BicliqueCover problem-def now states the sub-biclique
requirement explicitly; new `reduction-rule("BMF", "BicliqueCover")`
entry added with the Monson–Pullman–Rees equivalence and the variable
layout transpose.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Add BicliqueCover → BMF inverse; drop dominated BicliqueCover → ILP
With exact BMF and sub-biclique BicliqueCover now both in place, the two
models are isomorphic up to a layout transpose. Add the inverse reduction
so the graph is bidirectional, factor the shared transpose into helpers,
and remove the direct BicliqueCover → ILP rule that is strictly dominated
by the two-hop path through BMF.
- `src/rules/bmf_bicliquecover.rs` now exposes `config_bc_to_bmf` and
`config_bmf_to_bc`. The forward reduction's `extract_solution` calls
the former; the new inverse reduction's `extract_solution` calls the
latter. Two helpers, one per direction — same transpose logic, no
duplication.
- `src/rules/bicliquecover_bmf.rs` (new) reduces `BicliqueCover(G, k)` to
`BMF(A_G, k)` by reading off the biadjacency matrix of `G`. Overhead:
`rows = cols = num_vertices` (loose bound, m ≤ m+n and n ≤ m+n),
`rank = rank`.
- The direct `BicliqueCover → ILP` rule (`bicliquecover_ilp.rs` and its
unit tests) is removed. Path search automatically resolves
`pred path BicliqueCover ILP` to the dominating two-hop path
`BicliqueCover → BMF → ILP`, which has the cleaner equality-constrained
BMF → ILP formulation.
- Paper: drop the `reduction-rule("BicliqueCover", "ILP")` entry; keep
the new `reduction-rule("BicliqueCover", "BMF")` alongside the forward
rule.
- New unit tests cover the inverse reduction (structure, closed-loop on
K_{2,2} at rank 1 and identity biadjacency at rank 2, infeasibility at
rank 1) plus a roundtrip test pinning `config_bc_to_bmf ∘ config_bmf_to_bc
= id`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: tighten BMF and BicliqueCover edge cases
- handle rank-zero exact BMF products against the full target matrix
- make the BicliqueCover test helper reject pseudo-bicliques
- include biclique count in complexity and use exact BMF target shape overhead
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ff8ae70 commit 9ff62f0
21 files changed
Lines changed: 638 additions & 433 deletions
File tree
- docs/paper
- scripts/jl
- src
- models
- algebraic
- graph
- rules
- unit_tests
- models
- algebraic
- graph
- rules
- tests
- data/jl
- suites
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5597 | 5597 | | |
5598 | 5598 | | |
5599 | 5599 | | |
5600 | | - | |
| 5600 | + | |
5601 | 5601 | | |
5602 | 5602 | | |
5603 | 5603 | | |
| |||
5609 | 5609 | | |
5610 | 5610 | | |
5611 | 5611 | | |
5612 | | - | |
| 5612 | + | |
5613 | 5613 | | |
5614 | | - | |
| 5614 | + | |
5615 | 5615 | | |
5616 | | - | |
| 5616 | + | |
5617 | 5617 | | |
5618 | 5618 | | |
5619 | 5619 | | |
| |||
5778 | 5778 | | |
5779 | 5779 | | |
5780 | 5780 | | |
5781 | | - | |
| 5781 | + | |
5782 | 5782 | | |
5783 | | - | |
| 5783 | + | |
5784 | 5784 | | |
5785 | 5785 | | |
5786 | 5786 | | |
| |||
14457 | 14457 | | |
14458 | 14458 | | |
14459 | 14459 | | |
14460 | | - | |
14461 | | - | |
14462 | | - | |
14463 | | - | |
14464 | | - | |
14465 | | - | |
14466 | | - | |
14467 | | - | |
14468 | | - | |
14469 | | - | |
14470 | | - | |
14471 | | - | |
14472 | | - | |
14473 | | - | |
14474 | | - | |
14475 | | - | |
14476 | | - | |
14477 | | - | |
14478 | | - | |
14479 | 14460 | | |
14480 | 14461 | | |
14481 | 14462 | | |
| |||
14639 | 14620 | | |
14640 | 14621 | | |
14641 | 14622 | | |
14642 | | - | |
| 14623 | + | |
14643 | 14624 | | |
14644 | | - | |
| 14625 | + | |
14645 | 14626 | | |
14646 | | - | |
| 14627 | + | |
14647 | 14628 | | |
14648 | 14629 | | |
14649 | 14630 | | |
14650 | 14631 | | |
14651 | 14632 | | |
14652 | | - | |
14653 | | - | |
14654 | | - | |
| 14633 | + | |
| 14634 | + | |
14655 | 14635 | | |
14656 | 14636 | | |
14657 | | - | |
| 14637 | + | |
14658 | 14638 | | |
14659 | 14639 | | |
14660 | 14640 | | |
14661 | 14641 | | |
| 14642 | + | |
| 14643 | + | |
| 14644 | + | |
| 14645 | + | |
| 14646 | + | |
| 14647 | + | |
| 14648 | + | |
| 14649 | + | |
| 14650 | + | |
| 14651 | + | |
| 14652 | + | |
| 14653 | + | |
| 14654 | + | |
| 14655 | + | |
| 14656 | + | |
| 14657 | + | |
| 14658 | + | |
| 14659 | + | |
| 14660 | + | |
| 14661 | + | |
14662 | 14662 | | |
14663 | 14663 | | |
14664 | 14664 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
729 | 732 | | |
730 | 733 | | |
731 | 734 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | | - | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
41 | | - | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | | - | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 52 | + | |
| 53 | + | |
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
| |||
161 | 159 | | |
162 | 160 | | |
163 | 161 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
174 | 170 | | |
175 | 171 | | |
176 | 172 | | |
| |||
180 | 176 | | |
181 | 177 | | |
182 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| |||
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
216 | | - | |
217 | | - | |
218 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
| |||
239 | 242 | | |
240 | 243 | | |
241 | 244 | | |
242 | | - | |
243 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
244 | 249 | | |
245 | 250 | | |
246 | 251 | | |
| |||
0 commit comments