feat: add 8 Tier 1a reduction rules (#770)#777
Conversation
Implement 8 simple, verified reduction rules from Garey & Johnson: - HamiltonianCircuit → HamiltonianPath (#199): vertex duplication + pendants - KClique → SubgraphIsomorphism (#201): pattern = K_k - Partition → MultiprocessorScheduling (#203): m=2, D=S/2 - HamiltonianPath → IsomorphicSpanningTree (#234): T = P_n - HamiltonianCircuit → BottleneckTravelingSalesman (#259): {1,2}-distances - KClique → ConjunctiveBooleanQuery (#464): k-clique as Boolean CQ - ExactCoverBy3Sets → StaffScheduling (#487): subset-to-schedule encoding - Satisfiability → NAESatisfiability (#753): sentinel variable construction Each rule includes full test coverage (closed-loop, edge cases, extraction). Fixes #199, Fixes #201, Fixes #203, Fixes #234, Fixes #259, Fixes #464, Fixes #487, Fixes #753 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #777 +/- ##
==========================================
+ Coverage 97.79% 97.82% +0.02%
==========================================
Files 582 599 +17
Lines 65454 66337 +883
==========================================
+ Hits 64012 64893 +881
- Misses 1442 1444 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agentic Review ReportStructural Check
All 8 reductions mathematically verified. Forward/backward correctness confirmed. Solution extraction inverts correctly. Example specs validated with concrete instances. Minor findings:
Quality CheckDesign Principles:
Test Quality:
Issues:
Agentic Feature Tests
All 8 rules pass all CLI integration tests. No failures or unexpected behavior. Generated by review-pipeline |
There was a problem hiding this comment.
Pull request overview
Adds eight Tier 1a reduction rules (Garey & Johnson) to the reductions registry, along with canonical example-db specs and unit tests to validate closed-loop correctness and solution extraction.
Changes:
- Implement 8 new
ReduceToreductions (SAT→NAE-SAT, Partition→MPS, HC→HP, HC→BTSP, HP→IST, KClique→SubgraphIsomorphism, KClique→CBQ, X3C→StaffScheduling). - Add focused unit tests per rule (closed-loop, structure checks, extraction, and negative cases).
- Register new rule modules and wire their canonical example specs into
src/rules/mod.rs.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/rules/mod.rs | Registers the new rule modules and includes their canonical example specs in the rule example-db export list. |
| src/rules/satisfiability_naesatisfiability.rs | Implements SAT→NAE-SAT sentinel-variable reduction + example-db spec + test module hook. |
| src/rules/partition_multiprocessorscheduling.rs | Implements Partition→MultiprocessorScheduling restriction-style reduction + example-db spec + test hook. |
| src/rules/kclique_subgraphisomorphism.rs | Implements KClique→SubgraphIsomorphism by using a complete pattern graph K_k + example-db spec + test hook. |
| src/rules/kclique_conjunctivebooleanquery.rs | Implements KClique→CBQ encoding clique as a Boolean conjunctive query + example-db spec + test hook. |
| src/rules/hamiltonianpath_isomorphicspanningtree.rs | Implements HamiltonianPath→IsomorphicSpanningTree via T = P_n + example-db spec + test hook. |
| src/rules/hamiltoniancircuit_hamiltonianpath.rs | Implements HamiltonianCircuit→HamiltonianPath via vertex-duplication + pendant endpoints + example-db spec + test hook. |
| src/rules/hamiltoniancircuit_bottlenecktravelingsalesman.rs | Implements HamiltonianCircuit→BTSP using {1,2}-weights on the complete graph + example-db spec + test hook. |
| src/rules/exactcoverby3sets_staffscheduling.rs | Implements X3C→StaffScheduling subset-to-schedule encoding + example-db spec + test hook. |
| src/unit_tests/rules/satisfiability_naesatisfiability.rs | Unit tests for SAT→NAE-SAT (structure, extraction, edge cases). |
| src/unit_tests/rules/partition_multiprocessorscheduling.rs | Unit tests for Partition→MPS (structure, odd sum, extraction, small cases). |
| src/unit_tests/rules/kclique_subgraphisomorphism.rs | Unit tests for KClique→SubgraphIsomorphism (yes/no cases, k=1/2/3). |
| src/unit_tests/rules/kclique_conjunctivebooleanquery.rs | Unit tests for KClique→CBQ (structure, satisfiable/unsatisfiable, extraction, k=1). |
| src/unit_tests/rules/hamiltonianpath_isomorphicspanningtree.rs | Unit tests for HP→IST (closed-loop, multiple graph families, negative case). |
| src/unit_tests/rules/hamiltoniancircuit_hamiltonianpath.rs | Unit tests for HC→HP (closed-loop, structure, extraction, negative case). |
| src/unit_tests/rules/hamiltoniancircuit_bottlenecktravelingsalesman.rs | Unit tests for HC→BTSP (closed-loop, weight structure, bottleneck gap, extraction). |
| src/unit_tests/rules/exactcoverby3sets_staffscheduling.rs | Unit tests for X3C→StaffScheduling (closed-loop, no-solution, unique-cover, structure). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- HC→HP: special-case n < 3 to avoid panic on empty/tiny graphs - SAT→NAESAT: handle empty clauses (map to fixed unsatisfiable NAE clause) - SAT→NAESAT: guard extract_solution against short configs with assert - SAT→NAESAT test: fix comment (variable 3 → variable 4) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Solver Reachability SummarySource problems (all have existing solver paths — no change needed)
Target problems
Action itemsTwo target problems are sink nodes (no outgoing reductions, unsolvable via ILP). They can still be solved by BruteForce, but ILP reductions would complete the solver coverage:
|
- Extract duplicated edges_to_cycle_order logic from HC→TSP and HC→BTSP into graph_helpers module (-110 lines) - Use SimpleGraph::complete(k) in KClique→SubgraphIsomorphism - Use .edges() directly in KClique→CBQ instead of O(n²) has_edge loop - Replace assert! with graceful fallback in SAT→NAE-SAT extract_solution Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- simplify new graph reductions by using shared graph constructors and a shared KClique selection helper - reduce control-flow and repeated setup in HamiltonianCircuit/Partition-related rule code and tests - add regression coverage for HamiltonianCircuit small-n and Satisfiability empty-clause edge cases - remove the unused example variable warning and align rustfmt config with the stable toolchain
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… entries Complete missing documentation and test coverage for 41 reduction rules shipped across PRs #777, #779, #804, and #972. Check 10: 39 new `test_find_rule_example_*` tests in example_db.rs covering all cross-problem reductions from the four PRs (ILP i32→bool excluded as a same-name variant edge). Check 11: 31 new `#reduction-rule(...)` entries in reductions.typ — 30 for cross-problem reductions (PRs #777, #779, #972) plus 1 for the ILP<i32> → ILP<bool> variant reduction via FBBT + truncated binary encoding. Closes #974 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… rules (#997) * docs: add design spec for proposed reductions Typst note Covers 9 reductions: 2 NP-hardness chain extensions (#973, #198), 4 Tier 1a blocked issues (#379, #380, #888, #822), and 3 Tier 1b blocked issues (#892, #894, #890). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(#974): add 39 example-db lookup tests and 31 paper reduction-rule entries Complete missing documentation and test coverage for 41 reduction rules shipped across PRs #777, #779, #804, and #972. Check 10: 39 new `test_find_rule_example_*` tests in example_db.rs covering all cross-problem reductions from the four PRs (ILP i32→bool excluded as a same-name variant edge). Check 11: 31 new `#reduction-rule(...)` entries in reductions.typ — 30 for cross-problem reductions (PRs #777, #779, #972) plus 1 for the ILP<i32> → ILP<bool> variant reduction via FBBT + truncated binary encoding. Closes #974 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Delete docs/superpowers/specs/2026-03-31-proposed-reductions-note-design.md * docs: add Institute of Science Tokyo affiliation to paper Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: remove accidentally committed docs/superpowers directory Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add worked example for HamiltonianCircuit -> RuralPostman reduction Upgrade the prose-only reduction-rule entry to include data-driven example with load-example binding, pred-commands, three construction steps, and multiplicity note. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for HamiltonianCircuit -> HamiltonianPath reduction Upgrade the prose-only reduction-rule entry with load-example data binding, pred-commands reproducibility block, and a 3-step worked example showing the vertex-splitting construction on a C4 cycle graph. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for HamiltonianCircuit -> BottleneckTravelingSalesman reduction Add data-driven example with load-example binding, pred-commands block, step-by-step construction walkthrough, and solution verification. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for HamiltonianCircuit -> StrongConnectivityAugmentation reduction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add worked example for HamiltonianCircuit -> QuadraticAssignment paper entry Upgrade the prose-only reduction-rule entry to include a data-driven worked example with load-example binding, pred-commands block, and step-by-step construction/verification using the C4 cycle graph fixture. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for Partition -> BinPacking reduction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for ThreePartition -> JobShopScheduling reduction Add data-driven example with load-example binding, pred-commands block, and step-by-step walkthrough showing the m=1 canonical instance with 3 elements, sizes (4,5,6), bound B=15 on 2 machines. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add worked example for Partition → MultiprocessorScheduling reduction Upgrade the prose-only reduction-rule entry to include a data-driven worked example with load-example binding, pred-commands block, and step-by-step verification of the canonical witness. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for ThreePartition -> ResourceConstrainedScheduling reduction Also remove duplicate Partition -> ShortestWeightConstrainedPath entry that caused a label collision. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for ThreePartition -> SequencingWithReleaseTimesAndDeadlines reduction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add worked example for ThreePartition -> FlowShopScheduling reduction Add data-driven example with load-example binding, pred-commands block, and step-by-step walkthrough showing source instance, job construction, separator window mechanism, and end-to-end solution verification. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for KSatisfiability -> KClique reduction Add data-driven worked example with load-example binding, pred-commands reproducibility block, step-by-step construction walkthrough, and end-to-end solution verification for the 3-SAT to k-clique reduction. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for MinimumVertexCover -> MinimumFeedbackArcSet reduction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for Satisfiability -> NAESatisfiability reduction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for ExactCoverBy3Sets -> MaximumSetPacking reduction Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for KSatisfiability -> MinimumVertexCover reduction Also remove duplicate ThreePartition -> FlowShopScheduling entry that caused a duplicate label compilation error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs(paper): add worked example for MaxCut -> MinimumCutIntoBoundedSets reduction Also remove duplicate ThreePartition -> FlowShopScheduling prose entry that was left over from a merge conflict. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove duplicate SAT→NAESatisfiability prose-only entry Leftover from parallel worktree merge — the data-driven entry was placed at line ~10136 by the SAT→NAE agent, but the original prose-only entry at line ~13454 was not cleaned up. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: GiggleLiu <cacate0129@gmail.com>
Summary
Implements 8 simple, verified Tier 1a reduction rules from Garey & Johnson (issue #770):
Each rule includes:
ReduceToimplementation with#[reduction(overhead = {...})]ReductionResultwithextract_solution()Fixes #199, Fixes #201, Fixes #203, Fixes #234, Fixes #259, Fixes #464, Fixes #487, Fixes #753
Test plan
make checkpasses (fmt + clippy + test)🤖 Generated with Claude Code