Skip to content

feat: batch implement 17 reduction rules with 14 new models#999

Merged
GiggleLiu merged 26 commits intomainfrom
jg/new-rules-batch1
Apr 4, 2026
Merged

feat: batch implement 17 reduction rules with 14 new models#999
GiggleLiu merged 26 commits intomainfrom
jg/new-rules-batch1

Conversation

@GiggleLiu
Copy link
Copy Markdown
Contributor

Summary

Batch implementation of 17 reduction rules (16 from the original high-confidence batch + #359 after merge) and 14 new problem models. Three rules (#379, #380) are blocked pending a Decision wrapper model (tracked in #998).

All passing make check (fmt + clippy + tests).

Implemented Rules

# Issue Rule New Model?
1 #973 SubsetSum -> Partition No
2 #868 Satisfiability -> NonTautology Yes
3 #844 KColoring -> PartitionIntoCliques Yes
4 #882 3SAT -> Kernel Yes
5 #911 HamiltonianPath -> DegreeConstrainedSpanningTree Yes
6 #382 NAESatisfiability -> SetSplitting Yes
7 #388 ExactCoverBy3Sets -> SubsetProduct Yes
8 #569 SubsetSum -> IntegerExpressionMembership Yes
9 #860 ExactCoverBy3Sets -> MinimumWeightSolutionToLinearEquations Yes
10 #554 3SAT -> SimultaneousIncongruences Yes
11 #471 Partition -> SequencingToMinimizeTardyTaskWeight Yes
12 #481 Partition -> OpenShopScheduling Yes
13 #488 Partition -> ProductionPlanning Yes
14 #912 HamiltonianPath -> IsomorphicSpanningTree Yes
15 #166 NAESatisfiability -> MaxCut No (rule only)
16 #859 ExactCoverBy3Sets -> AlgebraicEquationsOverGF2 Yes
17 #359 HamiltonianPathBetweenTwoVertices -> LongestPath No (added after merge)

Blocked Rules

Issue Rule Reason
#379 MinDomSet -> MinMaxMulticenter Value type mismatch (Min vs Or) - needs Decision wrapper
#380 MinDomSet -> MinSumMulticenter Needs K parameter from optimal dominating set size

Tracked in #998.

Additional Context

Test plan

  • make check passes (fmt + clippy + 4814+ tests)
  • All 17 reduction rules have closed-loop tests
  • All 14 new models have dedicated test files with 3+ tests
  • Canonical example specs registered for all rules and models

🤖 Generated with Claude Code

GiggleLiu and others added 18 commits April 3, 2026 19:16
Implements the classical padding reduction from Garey & Johnson (SP12-SP13).
Handles all three cases: Σ=2T (no padding), Σ>2T (same-side extraction),
and Σ<2T (opposite-side extraction).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…868)

Adds the NonTautology (DNF falsifiability) model with Value=Or, and the
De Morgan negation reduction from Satisfiability. Each CNF clause becomes
a DNF disjunct with flipped literal signs; solution extraction is identity.

Includes CLI/MCP support for NonTautology creation and example-db hooks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ques rule (#844)

Adds the PartitionIntoCliques graph model (Value=Or, partitions vertices
into K cliques) and the complement-graph reduction from KColoring.
Color classes in G become cliques in the complement graph.

Includes CLI support, example-db entries, paper documentation, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds the Kernel model for directed graphs (Value=Or, independent + absorbing
vertex set) and Chvátal's 1973 reduction from KSatisfiability<K3>. Variable
digons encode truth assignments; directed 3-cycles with connection arcs
enforce clause satisfaction via the absorption property.

Includes CLI support, example-db entries, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…#911)

Adds DegreeConstrainedSpanningTree graph model (Value=Or, edge-selection
configs checked for spanning tree + degree bound) and the identity reduction
from HamiltonianPath with K=2. A degree-2 spanning tree is exactly a
Hamiltonian path.

Includes CLI support, example-db entries, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds the SetSplitting (hypergraph 2-colorability) model with Value=Or,
and the reduction from NAESatisfiability. Uses two elements per variable
(positive/negative literal) with pairing subsets to enforce complementary
assignment, plus one subset per clause to enforce non-monochromatic NAE.

Includes CLI support, paper entries, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds SubsetProduct model (Value=Or, binary subset selection with product
check) and the prime-encoding reduction from ExactCoverBy3Sets. Each
universe element gets a distinct prime; each 3-set maps to the product
of its elements' primes. By FTA, subset product equals universe product
iff the selected sets form an exact cover.

Includes CLI support and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…569)

Adds IntegerExpressionMembership (pick-one-per-position sum check with
Value=Or) and the shift-encoding reduction from SubsetSum. Each element
a_i creates choice set {1, a_i+1}; target K = B + n. Picking a_i+1 means
"include element"; sum equals K iff selected elements sum to B.

Includes CLI support, paper entries, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…E rule (#860)

Adds MWSLE algebraic model (Value=Or, binary variables with linear equation
check + sparsity bound) and the incidence-matrix reduction from
ExactCoverBy3Sets. One variable per 3-set, one equation per universe element,
bound K = |U|/3. Exact cover iff equation system has K-sparse solution.

Includes CLI support, paper entries, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds SimultaneousIncongruences algebraic model (Value=Or, find x in [1..N]
satisfying all x mod m_i != r_i) and the CRT-based reduction from
KSatisfiability<K3>. Each variable gets a distinct odd prime, residues 1/2
encode true/false, other residues are forbidden, and each clause adds one
CRT-derived forbidden residue.

Includes CLI support, paper entries, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…MTTW rule (#471)

Adds SequencingToMinimizeTardyTaskWeight model (Value=Min<u64>, Lehmer-coded
permutation schedules) and the common-deadline reduction from Partition.
Each element becomes a task with length=weight=size and deadline=B/2.
On-time tasks decode one partition half.

Includes CLI support and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds OpenShopScheduling model (Value=Min<u64>, Lehmer-coded permutation
schedules with active-schedule decoder) and the Gonzalez-Sahni 1976
reduction from Partition. Uses 3 machines with a special Q-job; makespan
≤3Q iff balanced partition exists.

Includes CLI support and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements the Garey-Johnson-Stockmeyer 1976 reduction. Variable edges
with weight M=2m+1 force complementary partition; clause triangles with
unit weights contribute exactly 2 cut edges per NAE-satisfied clause.
Max cut ≥ nM+2m iff NAE-satisfiable.

Includes paper entry, canonical example, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds IsomorphicSpanningTree graph model (Value=Or, permutation-based
isomorphism check) and the identity reduction from HamiltonianPath with
tree T=P_n. A spanning tree isomorphic to a path is exactly a
Hamiltonian path.

Includes CLI support, updated ILP rule, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds AlgebraicEquationsOverGF2 model (Value=Or, polynomial system over
GF(2) with XOR/AND evaluation) and the Fraenkel-Yesha 1977 reduction
from ExactCoverBy3Sets. Linear equations enforce odd-cover per element;
pairwise product equations forbid double-cover. Together they force
exactly-one cover.

Includes CLI support, paper entries, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds ProductionPlanning model (Value=Or, lot-sizing with setup/production/
inventory costs and a total cost bound) and the Lenstra-Rinnooy Kan-Florian
1978 reduction from Partition. Element items map to production periods;
a terminal demand period consumes S/2; balanced partition iff feasible
production plan within cost bound.

Includes CLI support, paper entries, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# Conflicts:
#	docs/paper/reductions.typ
#	problemreductions-cli/src/cli.rs
#	problemreductions-cli/src/commands/create.rs
#	problemreductions-cli/src/problem_name.rs
#	src/lib.rs
#	src/models/algebraic/algebraic_equations_over_gf2.rs
#	src/models/algebraic/minimum_weight_solution_to_linear_equations.rs
#	src/models/algebraic/mod.rs
#	src/models/algebraic/simultaneous_incongruences.rs
#	src/models/formula/mod.rs
#	src/models/formula/non_tautology.rs
#	src/models/graph/degree_constrained_spanning_tree.rs
#	src/models/graph/kernel.rs
#	src/models/graph/mod.rs
#	src/models/graph/partition_into_cliques.rs
#	src/models/misc/mod.rs
#	src/models/misc/open_shop_scheduling.rs
#	src/models/misc/production_planning.rs
#	src/models/misc/sequencing_to_minimize_tardy_task_weight.rs
#	src/models/misc/subset_product.rs
#	src/models/mod.rs
#	src/models/set/mod.rs
#	src/models/set/set_splitting.rs
#	src/rules/hamiltonianpath_isomorphicspanningtree.rs
#	src/rules/mod.rs
#	src/rules/naesatisfiability_maxcut.rs
#	src/unit_tests/models/algebraic/algebraic_equations_over_gf2.rs
#	src/unit_tests/models/algebraic/minimum_weight_solution_to_linear_equations.rs
#	src/unit_tests/models/algebraic/simultaneous_incongruences.rs
#	src/unit_tests/models/formula/non_tautology.rs
#	src/unit_tests/models/graph/degree_constrained_spanning_tree.rs
#	src/unit_tests/models/graph/kernel.rs
#	src/unit_tests/models/graph/partition_into_cliques.rs
#	src/unit_tests/models/misc/open_shop_scheduling.rs
#	src/unit_tests/models/misc/production_planning.rs
#	src/unit_tests/models/misc/sequencing_to_minimize_tardy_task_weight.rs
#	src/unit_tests/models/misc/subset_product.rs
#	src/unit_tests/models/set/set_splitting.rs
#	src/unit_tests/rules/hamiltonianpath_isomorphicspanningtree.rs
#	src/unit_tests/rules/naesatisfiability_maxcut.rs
…ule (#359)

Copy graph with unit edge weights and same s/t vertices. A Hamiltonian
s-t path has n-1 edges = maximum possible simple path length.
Solution extraction walks selected edges from source to reconstruct
the vertex permutation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2026

Codecov Report

❌ Patch coverage is 98.55269% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.15%. Comparing base (61f059c) to head (bb82d12).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/models/formula/ksat.rs 74.41% 11 Missing ⚠️
...s/hamiltonianpath_degreeconstrainedspanningtree.rs 94.54% 6 Missing ⚠️
src/rules/partition_openshopscheduling.rs 92.10% 6 Missing ⚠️
...rules/ksatisfiability_simultaneousincongruences.rs 97.70% 3 Missing ⚠️
src/rules/exactcoverby3sets_subsetproduct.rs 95.55% 2 Missing ⚠️
src/models/graph/graph_partitioning.rs 98.38% 1 Missing ⚠️
src/models/graph/isomorphic_spanning_tree.rs 98.18% 1 Missing ⚠️
...s/hamiltonianpathbetweentwovertices_longestpath.rs 98.33% 1 Missing ⚠️
src/rules/naesatisfiability_setsplitting.rs 97.87% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #999      +/-   ##
==========================================
+ Coverage   98.12%   98.15%   +0.03%     
==========================================
  Files         858      896      +38     
  Lines       89004    91150    +2146     
==========================================
+ Hits        87338    89472    +2134     
- Misses       1666     1678      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

GiggleLiu and others added 8 commits April 4, 2026 18:04
These were working files from the batch implementation session,
not intended for the repository.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds guidance to consult GitHub issues and derivation documents
as primary sources for mathematical content, rather than inventing proofs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mands

Each reduction-rule entry now includes:
- load-example data bindings and example: true parameter
- Complexity citation (@garey1979, @karp1972, etc.)
- Worked example with pred-commands() reproducibility block
- Step-by-step verification using fixture data

Fixed entry #13 (NAE-SAT → MaxCut): proper @citation.
Fixed entry #18 (GraphPartitioning → MaxCut): completed proof
replacing $= dots$ placeholder with full derivation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The inventory-based registry resolution is non-deterministic across
platforms. On CI, "GraphPartitioning" was resolving to "MaxCut" due to
registration order, causing test_create_graph_partitioning to fail.
Add explicit case-insensitive resolution, matching the pattern used
for other ambiguous problem names.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…phPartitioning)

- KSatisfiability → Kernel: corrected arc count to 2n+6m, rewrote proof
  to allow clause vertices in kernel matching the actual code
- NAESatisfiability → MaxCut: corrected M = m+1 (was 2m+1), fixed example
- GraphPartitioning → MaxCut: completed balance proof via P=|E|+1 penalty

All examples now use load-example() fixture data with pred-commands().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…step verification

Expanded worked examples for: NAE-SAT→SetSplitting, X3C→SubsetProduct,
SubsetSum→IntegerExprMembership, X3C→MWSLE, 3SAT→SimultaneousIncongruences,
Partition→SeqMinTardyTaskWeight, Partition→OpenShopScheduling,
X3C→AlgEqOverGF2, Partition→ProductionPlanning.

Each example now shows construction with actual numbers from load-example()
fixtures and step-by-step witness verification.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@GiggleLiu GiggleLiu merged commit c57a131 into main Apr 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant