Skip to content

Fix #125: [Rule] SubsetSum to ClosestVectorProblem#709

Merged
isPANN merged 5 commits intomainfrom
issue-125
Mar 20, 2026
Merged

Fix #125: [Rule] SubsetSum to ClosestVectorProblem#709
isPANN merged 5 commits intomainfrom
issue-125

Conversation

@GiggleLiu
Copy link
Copy Markdown
Contributor

Summary

Add the plan and implementation for the SubsetSum to ClosestVectorProblem reduction.

Fixes #125

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 98.86364% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.56%. Comparing base (54aca98) to head (395b5a3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...unit_tests/rules/subsetsum_closestvectorproblem.rs 98.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #709   +/-   ##
=======================================
  Coverage   97.56%   97.56%           
=======================================
  Files         377      379    +2     
  Lines       47418    47506   +88     
=======================================
+ Hits        46263    46350   +87     
- Misses       1155     1156    +1     

☔ 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
Copy link
Copy Markdown
Contributor Author

Implementation Summary

Changes

  • Added src/rules/subsetsum_closestvectorproblem.rs with the SubsetSum -> ClosestVectorProblem<i32> reduction, direct solution extraction, required #[reduction(overhead = ...)] metadata, and a canonical example-db witness.
  • Registered the new rule in src/rules/mod.rs.
  • Added src/unit_tests/rules/subsetsum_closestvectorproblem.rs covering the closed-loop round trip, basis/target structure, the issue’s two minimizers, an unsatisfiable instance, and overflow behavior for coefficients that do not fit in i32.
  • Documented the reduction in docs/paper/reductions.typ with a worked example loaded from the exported example fixture.
  • Added the Lagarias-Odlyzko (1985) and Coster et al. (1992) bibliography entries in docs/paper/references.bib.

Deviations from Plan

  • The plan referenced make regenerate-fixtures, but this repo does not define that target. I used the actual fixture export path: cargo run --features "example-db" --example export_examples.
  • The issue describes an arbitrary-integer Subset Sum source, but the existing ClosestVectorProblem variants in this repo are i32 and f64. To keep this PR scoped to a rule (not a model extension), the implementation targets ClosestVectorProblem<i32> and fails fast if any size or target does not fit in i32.

Open Questions

  • If we want this reduction to support arbitrarily large Subset Sum coefficients without a guard, ClosestVectorProblem likely needs a wider exact-integer variant in a separate follow-up.

@GiggleLiu
Copy link
Copy Markdown
Contributor Author

Agentic Review Report

Structural Check

Structural Review: rule subsetsum_closestvectorproblem

Structural Completeness

# Check Status
1 Rule file exists PASS
2 #[reduction(...)] macro present PASS
3 ReductionResult impl present PASS
4 ReduceTo impl present PASS
5 #[cfg(test)] + #[path = ...] test link PASS
6 Rule test file exists PASS
7 Closed-loop test present PASS
8 Registered in src/rules/mod.rs PASS
9 Canonical rule example registered PASS
10 Example-db lookup tests exist PASS
11 Paper reduction-rule entry exists PASS
12 Blacklisted autogenerated files absent from PR diff PASS
13 Deterministic file whitelist FAIL — docs/paper/references.bib is outside the current rule-PR whitelist

Build Status

  • make test: PASS
  • make clippy: PASS
  • make paper: PASS

Semantic Review

  • extract_solution correctness: OK — the CVP bounds are binary, so the target config is already the source selection vector.
  • Overhead accuracy: OK — reduce_to() emits n basis vectors, each of ambient dimension n + 1; verified from the generated bundle JSON and the exported reduction graph.
  • Example quality: OK — the canonical example, unit tests, CLI bundle, and paper example all agree on the (3,7,1,8) / 11 witness.
  • Paper quality: ISSUE — docs/paper/reductions.typ states the reduction for arbitrary ZZ^+ sizes/targets, but the implementation only works when every coefficient fits in i32.

Issue Compliance (linked issue #125)

# Check Status
1 Source/target match issue OK
2 Reduction algorithm matches ISSUE — src/rules/subsetsum_closestvectorproblem.rs:29-55 narrows BigUint inputs to i32 and panics on larger valid instances
3 Solution extraction matches OK
4 Correctness preserved ISSUE — the registered rule is not total for the repo's SubsetSum model (Vec<BigUint>, BigUint)
5 Overhead expressions match OK
6 Example matches OK

Summary

  • 12/13 structural checks passed
  • 4/6 issue compliance checks passed
  • src/rules/subsetsum_closestvectorproblem.rs:29-55 makes the reduction partial over valid SubsetSum inputs by panicking when a coefficient exceeds i32.
  • docs/paper/reductions.typ:4215-4225 overclaims the supported numeric domain relative to the implementation.
  • docs/paper/references.bib is outside the current rule-PR whitelist.

Quality Check

Quality Review

Design Principles

  • DRY: OK — the reduction is small and self-contained, with no duplicated logic across the touched files.
  • KISS: OK — basis construction and solution extraction are direct.
  • HC/LC: OK — rule logic, tests, and paper/documentation remain separated.

Test Quality

  • Naive test detection: ISSUE
    • src/unit_tests/rules/subsetsum_closestvectorproblem.rs:72-78 codifies the large-coefficient path as an expected panic, so the test suite currently blesses a user-visible crash instead of requiring a recoverable unsupported-input error or a total reduction.

Issues

Critical (Must Fix)

  • Valid large-BigUint SubsetSum inputs crash the advertised rule. Reproduced with pred reduce big_subsetsum.json --to ClosestVectorProblem, where big_subsetsum.json contains sizes = [2147483648] and target = 1. The CLI panics at src/rules/subsetsum_closestvectorproblem.rs:32.

Important (Should Fix)

  • docs/paper/reductions.typ:4215-4225 does not disclose the i32 restriction, so the paper theorem currently states a stronger result than the code implements.
  • docs/paper/references.bib trips the current rule-PR whitelist.

Minor (Nice to Have)

  • None.

Summary

  • One critical correctness issue: valid large-BigUint inputs crash the rule through the CLI.
  • One documentation mismatch: the paper states unrestricted integer coefficients.
  • One process exception: bibliography edits are outside the current rule whitelist.

Agentic Feature Tests

Feature Test Report: problemreductions

Date: 2026-03-21
Project type: Rust library + CLI
Features tested: SubsetSum -> ClosestVectorProblem
Profile: ephemeral
Use Case: A downstream CLI user discovers the new rule from the catalog, materializes the canonical example, reduces it, and solves it end-to-end.
Expected Outcome: The new rule is discoverable in pred, canonical examples round-trip correctly, and unsupported inputs are handled without crashing.
Verdict: fail
Critical Issues: 1

Summary

Feature Discoverable Setup Works Expected Outcome Met Doc Quality
SubsetSum -> ClosestVectorProblem yes yes partial no partial

Per-Feature Details

SubsetSum -> ClosestVectorProblem

  • Role: CLI user validating a new direct reduction rule.
  • Use Case: Discover the rule, create the canonical example, reduce it, and solve both source and target through pred.
  • What they tried:
    • pred list --rules
    • pred show SubsetSum
    • pred show ClosestVectorProblem
    • pred create --example SubsetSum --to ClosestVectorProblem
    • pred create --example SubsetSum --to ClosestVectorProblem --example-side target
    • pred solve subsetsum.json --solver brute-force
    • pred reduce subsetsum.json --to ClosestVectorProblem
    • pred solve subsetsum_to_cvp.bundle.json --solver brute-force
    • pred reduce big_subsetsum.json --to ClosestVectorProblem
  • Discoverability: Yes — the rule appears in pred list --rules, and both endpoints show the edge in pred show.
  • Setup: Yes — no extra setup beyond the existing workspace build was needed.
  • Functionality: Partial — the canonical example creation, reduction, target solve, and bundle solve all worked. A valid large-BigUint source instance crashed pred reduce.
  • Expected vs Actual: Partial — the happy path works, but the advertised rule is unusable for the full SubsetSum domain.
  • Blocked steps: None.
  • Friction points: Unsupported numeric range is neither surfaced in pred show nor returned as a handled CLI error.
  • Doc suggestions: Either constrain the documented domain to i32-fit inputs everywhere or widen the target representation so the rule remains total.

Expected vs Actual Outcome

  • Canonical example flow: achieved.
  • Large valid SubsetSum flow: not achieved; pred reduce panicked at src/rules/subsetsum_closestvectorproblem.rs:32.

Issues Found

  • Critical: pred reduce panics on valid SubsetSum JSON with coefficient 2147483648, producing a crash instead of a recoverable error.

Suggestions

  • Replace the expect(...)-based narrowing in the reduction with a recoverable validation path or support a wider exact target representation.
  • Align the paper text and CLI-facing docs with the actual supported numeric domain.
  • If bibliography edits are expected for rule PRs, update scripts/pipeline_checks.py accordingly; otherwise split the bib change.

Generated by review-pipeline

@isPANN isPANN merged commit f3204d5 into main Mar 20, 2026
3 checks passed
@GiggleLiu GiggleLiu deleted the issue-125 branch April 12, 2026 00:50
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.

[Rule] SubsetSum to ClosestVectorProblem

2 participants