You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added src/rules/partition_knapsack.rs implementing the Partition -> Knapsack reduction with checked u64 -> i64 conversion, identity solution extraction, and a canonical rule example.
Registered the new rule in src/rules/mod.rs.
Added src/unit_tests/rules/partition_knapsack.rs covering satisfiable closed-loop behavior, target-structure checks, an odd-total unsatisfiable case, and overflow handling.
Added a Partition -> Knapsackreduction-rule entry and worked example in docs/paper/reductions.typ driven from the exported canonical example data.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.58%. Comparing base (669f090) to head (689b133). ⚠️ Report is 1 commits behind head on main.
PASS — impl ReduceTo<Knapsack> for Partition is present.
5
#[cfg(test)] + #[path = ...] test link
PASS — the rule file links ../unit_tests/rules/partition_knapsack.rs.
6
Test file exists
PASS — src/unit_tests/rules/partition_knapsack.rs is present.
7
Closed-loop test present
PASS — test_partition_to_knapsack_closed_loop exercises the round-trip.
8
Registered in rules/mod.rs
PASS — the module and canonical example spec are both registered.
9
Canonical rule example registered
PASS — partition_knapsack::canonical_rule_example_specs() is included in the aggregated rule example registry consumed by src/example_db/rule_builders.rs.
10
Example-db lookup tests exist
PASS — src/unit_tests/example_db.rs covers build_rule_db / find_rule_example, and the suite passes with this rule included.
11
Paper reduction-rule entry
PASS — docs/paper/reductions.typ includes a reduction-rule("Partition", "Knapsack", ...) entry with a worked example.
12
Blacklisted autogenerated files committed
PASS — none of the prohibited generated artifacts are part of the PR diff.
Build Status
make test: PASS
make clippy: PASS
make paper: PASS
Semantic Review
extract_solution correctness: OK — the source and target both use one binary variable per element/item, so the identity mapping is the correct inverse.
Overhead accuracy: OK — reduce_to() creates exactly one knapsack item per partition element, so num_items = num_elements is accurate.
Example quality: OK — the canonical example is tutorial-style, exports both source and target data, and the witness saturates the target capacity.
Paper quality: OK — the proof sketch correctly states the optimization bridge: the knapsack optimum equals S/2 iff the partition instance is satisfiable.
Mathematical correctness: OK — manual tracing and CLI checks on both the canonical satisfiable instance and an odd-total unsatisfiable instance matched the claimed semantics.
Issue Compliance
#
Check
Status
1
Source/target match issue
OK — implemented as Partition -> Knapsack.
2
Reduction algorithm matches
OK — weights and values both copy the source sizes, and capacity is floor(total_sum / 2).
3
Solution extraction matches
OK — the same binary vector is returned, matching the issue’s 1:1 representation note.
4
Correctness preserved
OK — satisfiable instances solve to knapsack value S/2; the odd-total unsatisfiable case remains unsatisfied after extraction.
5
Overhead expressions match
OK — the implemented overhead is num_items = num_elements, as specified in the issue.
6
Example matches
OK — the paper/example-db instance is the worked 3,1,1,2,2,1 example from the issue context.
Summary
12/12 structural checks passed.
6/6 issue compliance checks passed.
No structural or semantic issues found.
Quality Check
Quality Review
Design Principles
DRY: OK — the rule is intentionally minimal and does not duplicate non-trivial logic beyond the required checked cast helper in src/rules/partition_knapsack.rs.
KISS: OK — the implementation mirrors the textbook reduction directly, with no unnecessary abstraction or control-flow complexity.
HC/LC: OK — responsibility is cleanly split between the rule, its tests, and the paper entry.
Test Quality
Naive test detection: OK
The suite checks round-trip correctness, target structure, an unsatisfiable odd-total case, and numeric bound handling.
The CLI/user-path check additionally confirmed the reduction on both the canonical satisfiable example and a custom odd-total unsatisfiable example.
Issues
Critical (Must Fix)
None.
Important (Should Fix)
None.
Minor (Nice to Have)
None.
Summary
No quality issues found in the PR diff.
Agentic Feature Tests
Feature Test Report: problem-reductions
Project type: CLI + library Feature tested:Partition -> Knapsack Profile: ephemeral read-only review run Use Case: A downstream user wants to discover the new reduction from the catalog, generate the canonical example, reduce it to Knapsack, and solve the resulting bundle from the CLI. Expected Outcome: The rule is discoverable from pred list / pred show, canonical examples can be created for both source and target sides, and solving the reduced bundle maps back to a correct Partition witness. Verdict: pass Critical Issues: 0
Summary
Feature
Discoverable
Setup
Works
Expected Outcome Met
Doc Quality
Partition -> Knapsack
yes
yes
yes
yes
good
Per-Feature Details
Partition -> Knapsack
What I tried:
target/debug/pred list --rules and confirmed Partition -> Knapsack appears.
target/debug/pred show Partition and target/debug/pred show Knapsack and confirmed the outgoing/incoming reduction metadata.
target/debug/pred create --example Partition and solved the canonical source instance with brute force.
target/debug/pred create --example Partition --to Knapsack for the source-side rule example.
target/debug/pred create --example Partition --to Knapsack --example-side target for the target-side canonical knapsack instance.
target/debug/pred reduce ... --to Knapsack followed by target/debug/pred solve ... --solver brute-force.
An additional odd-total custom instance (sizes = [2,4,5]) through the same reduce/solve flow.
Discoverability: Good. The new rule is visible in pred list --rules, and pred show Partition documents the outgoing reduction clearly.
Setup: Good. Using the locally built CLI binary in the review worktree required no undocumented steps.
Functionality: Good. The canonical example reduced to a knapsack instance with matching weights/values and capacity 5, and solving the bundle returned a valid partition witness. The odd-total instance returned evaluation: false on the source side while still exposing the target optimum, which is the intended decision-to-optimization behavior.
Expected vs Actual Outcome: Matched.
Blocked steps: None.
Friction points: None specific to this feature.
Doc suggestions: None required from this review run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add the implementation plan for the Partition -> Knapsack reduction pipeline.
Fixes #202