|
| 1 | +# Issue 363 Plan: Partition -> IntegralFlowWithMultipliers |
| 2 | + |
| 3 | +Issue: [#363](https://github.com/CodingThrust/problem-reductions/issues/363) |
| 4 | +Title: `[Rule] PARTITION to INTEGRAL FLOW WITH MULTIPLIERS` |
| 5 | + |
| 6 | +## Objective |
| 7 | + |
| 8 | +Implement the witness-preserving reduction `Partition -> IntegralFlowWithMultipliers` using Sahni's 1974 multiplier-flow gadget with the relay bottleneck fix documented in the issue body and comments. The rule must map: |
| 9 | + |
| 10 | +- even-total `Partition` instances to a relay network whose sink inflow is forced to equal `S / 2`, and |
| 11 | +- odd-total instances to a fixed infeasible `IntegralFlowWithMultipliers` instance. |
| 12 | + |
| 13 | +Verification mode: default. No `--no-verify`. |
| 14 | + |
| 15 | +## Reference Notes |
| 16 | + |
| 17 | +- Primary source: Sartaj Sahni, *Computationally Related Problems*, SIAM J. Comput. 3(4):262-279, 1974, Section 2.2 / Fig. 2.2.1 (`sum of subsets -> N(i)`). |
| 18 | +- Catalog source: Garey and Johnson, ND33, `Integral Flow With Multipliers`. |
| 19 | +- Issue comments already resolved the earlier false-positive construction by adding relay vertex `w` and bottleneck arc `(w, t)` with capacity `S / 2`. |
| 20 | + |
| 21 | +## Action Pipeline |
| 22 | + |
| 23 | +This plan follows `.claude/skills/add-rule/SKILL.md` Steps 1-7. |
| 24 | + |
| 25 | +## Batch 1: Steps 1-5.5 (verification, implementation, tests, example-db) |
| 26 | + |
| 27 | +### 1. Mathematical verification |
| 28 | + |
| 29 | +- Re-state the reduction precisely in repository semantics: |
| 30 | + - Source: `Partition` |
| 31 | + - Target: `IntegralFlowWithMultipliers` |
| 32 | + - Witness on source: binary subset vector over `sizes` |
| 33 | + - Witness on target: integral arc-flow vector in graph arc order |
| 34 | +- Verify the two branches: |
| 35 | + - odd total `S`: fixed 3-vertex NO instance with `h(u) = 2`, capacities `(1, 1)`, `R = 1` |
| 36 | + - even total `S`: vertices `s, v_1, ..., v_n, w, t`; arcs `(s, v_i)`, `(v_i, w)`, `(w, t)`; multipliers `h(v_i) = a_i`, `h(w) = 1`; requirement `R = S / 2` |
| 37 | +- Lock the extraction rule: |
| 38 | + - read the `n` source-item arcs `(s, v_i)` |
| 39 | + - map `flow = 1` to selected item and `flow = 0` to unselected item |
| 40 | + - odd branch returns the all-zero source config |
| 41 | + |
| 42 | +### 2. Implement the reduction |
| 43 | + |
| 44 | +- Add `src/rules/partition_integralflowwithmultipliers.rs`. |
| 45 | +- Implement `ReductionPartitionToIntegralFlowWithMultipliers` with: |
| 46 | + - `target: IntegralFlowWithMultipliers` |
| 47 | + - `source_n: usize` |
| 48 | + - `item_arc_count: usize` so extraction can distinguish even vs odd branch reliably |
| 49 | +- Implement `ReduceTo<IntegralFlowWithMultipliers> for Partition`. |
| 50 | +- Construction details: |
| 51 | + - even branch: |
| 52 | + - vertex numbering `0 = s`, `1..=n = v_i`, `n + 1 = w`, `n + 2 = t` |
| 53 | + - arcs in deterministic order: all `(s, v_i)`, then all `(v_i, w)`, then `(w, t)` |
| 54 | + - capacities: `1`, then `a_i`, then `S / 2` |
| 55 | + - multipliers: source/sink placeholders `1`, item multipliers `a_i`, relay multiplier `1` |
| 56 | + - requirement `S / 2` |
| 57 | + - odd branch: |
| 58 | + - fixed graph `s -> u -> t` |
| 59 | + - capacities `[1, 1]` |
| 60 | + - multipliers `[1, 2, 1]` |
| 61 | + - requirement `1` |
| 62 | +- Add exact overhead metadata: |
| 63 | + - `num_vertices = "num_elements + 3"` |
| 64 | + - `num_arcs = "2 * num_elements + 1"` |
| 65 | + - `max_capacity = "total_sum"` |
| 66 | + - `requirement = "total_sum"` |
| 67 | + Notes: |
| 68 | + - these are valid asymptotic upper bounds across both branches; the odd branch is constant size |
| 69 | + - `total_sum` safely upper-bounds both `S / 2` and `max_i a_i` |
| 70 | + |
| 71 | +### 3. Register in `src/rules/mod.rs` |
| 72 | + |
| 73 | +- Add `mod partition_integralflowwithmultipliers;`. |
| 74 | + |
| 75 | +### 4. Write unit tests |
| 76 | + |
| 77 | +- Add `src/unit_tests/rules/partition_integralflowwithmultipliers.rs`. |
| 78 | +- Required coverage: |
| 79 | + - closed-loop YES instance using brute force on target and round-tripping to source |
| 80 | + - even-sum NO instance `{3, 5}` proving the bottleneck removes the earlier false positive |
| 81 | + - odd-sum NO instance `{1, 2}` proving the fixed NO target is infeasible |
| 82 | + - structure test on the worked example `{2, 3, 4, 5, 6, 4}`: |
| 83 | + - vertex count `9` |
| 84 | + - arc order and capacities |
| 85 | + - multipliers |
| 86 | + - requirement `12` |
| 87 | + - extraction test from a hand-written feasible target flow |
| 88 | +- Reuse `assert_satisfaction_round_trip_from_satisfaction_target` if it fits the witness-preserving pattern. |
| 89 | + |
| 90 | +### 5. Add canonical example to `example_db` |
| 91 | + |
| 92 | +- Add a builder in `src/example_db/rule_builders.rs` with id `partition_to_integralflowwithmultipliers`. |
| 93 | +- Use the issue's tutorial instance `A = {2, 3, 4, 5, 6, 4}` and the canonical half-sum witness selecting `{2, 4, 6}`. |
| 94 | +- Ensure the target witness matches the rule's deterministic arc order: |
| 95 | + - source arcs: `[1, 0, 1, 0, 1, 0]` |
| 96 | + - relay arcs: `[2, 0, 4, 0, 6, 0]` |
| 97 | + - bottleneck arc: `[12]` |
| 98 | + |
| 99 | +### 5.5. Local rule-level verification before paper |
| 100 | + |
| 101 | +- Run focused tests for: |
| 102 | + - model feasibility expectations |
| 103 | + - new rule unit tests |
| 104 | + - example-db lookup if needed |
| 105 | +- Fix any witness-ordering or feasibility mismatches before touching paper. |
| 106 | + |
| 107 | +## Batch 2: Step 6 and Step 7 (paper, exports, fixtures, final verification) |
| 108 | + |
| 109 | +### 6. Document in paper |
| 110 | + |
| 111 | +- Add a `reduction-rule("Partition", "IntegralFlowWithMultipliers", ...)` entry to `docs/paper/reductions.typ`. |
| 112 | +- Include: |
| 113 | + - construction summary citing Sahni 1974 / Garey-Johnson ND33 |
| 114 | + - correctness proof with the exact-equality argument: |
| 115 | + - cap `(w, t) <= S / 2` |
| 116 | + - sink requirement `>= S / 2` |
| 117 | + - therefore sink inflow `= S / 2` |
| 118 | + - solution extraction from the unit-capacity source-item arcs |
| 119 | + - explicit odd-total preprocessing branch |
| 120 | +- Add a worked example derived from the canonical example fixture, starting with `pred-commands()`. |
| 121 | + |
| 122 | +### 7. Regenerate exports and verify |
| 123 | + |
| 124 | +- Run the required generators after the rule and paper are in place: |
| 125 | + - `cargo run --example export_graph` |
| 126 | + - `cargo run --example export_schemas` |
| 127 | + - `make regenerate-fixtures` |
| 128 | +- Run default verification commands without `--no-verify`: |
| 129 | + - at minimum `make test clippy` |
| 130 | + - `make paper` |
| 131 | +- Inspect `git status --short` and stage only intended tracked outputs. Ignore generated `docs/src/reductions/` exports if they appear untracked/ignored. |
| 132 | + |
| 133 | +## Expected Deliverables |
| 134 | + |
| 135 | +- New reduction source file and tests |
| 136 | +- Rule registration |
| 137 | +- Canonical example-db entry and regenerated fixture data |
| 138 | +- Paper entry for `Partition -> IntegralFlowWithMultipliers` |
| 139 | +- Updated reduction graph / schema exports |
| 140 | +- Clean implementation commit(s), plan-file removal commit, PR comment, and pushed branch |
0 commit comments