Skip to content

Commit ae1c7aa

Browse files
isPANNGiggleLiu
andauthored
Derive reduction parameter contracts and bound ILP encodings (#1174)
* Make derivable reduction parameters exact * Check every field in exact reduction transforms * Verify exact reduction parameters on randomized instances * Check exact and upper-bound reduction parameters * Document and simplify parameter formula validation * Improve parameter prediction contracts and bound integer ILP reductions * Derive reduction parameter bounds from constructed targets Correct exactness claims, count sparse coefficients by construction block, reject negative flow capacities, and verify metadata using existing behavior inputs and real executors. * Consolidate bounded ILP and parameter prediction stack Squash the combined changes from PRs #1180, #1182, #1183, #1184, and #1185 into #1174. Preserve the complete stack-tip tree so subsequent corrections can be maintained on one branch. * Correct ILP parameter bounds and simplify reduction code * Calibrate parity and universe-size reduction bounds Derive upper bounds from conditional even padding and the set-packing endpoint universe. Preserve the exact edge-to-set count and verify the registered promises in existing parity and isolated-vertex tests. * Remove invalid reduction catalog edges * Add direct binary ILP pipelines for exact-one SAT and graph kernels * Preserve scheduling semantics with compact ILP constructions * Simplify scheduling solution extraction * Tighten ILP nonzero bounds using construction counts * Compact exact reductions and register missing solver pipelines Replace oversized formulations with compact constructions for partition, register, matrix, graph, and ordering problems. Add direct bounded ILP pipelines and reuse exact customized subset-sum and clique-cover solvers. Preserve signed weights and costs, avoid artificial partition-bound overflow, and align overhead contracts, rule targets, tests, and proofs with the resulting constructions. Validated with make check, make paper, independent reduction audits, and CLI solver and extraction round trips. * Remove redundant reduction parameters and derive bounds from model inputs * Fix exact verification bottlenecks in reduction targets * Simplify reduction results and exact solver bookkeeping * fix: bound solver precomputation by small witness budgets * fix: remove needless borrow flagged by current CI clippy * fix: cap solver preprocessing and handle large union chains --------- Co-authored-by: GiggleLiu <cacate0129@gmail.com>
1 parent 9a726f1 commit ae1c7aa

399 files changed

Lines changed: 13851 additions & 5296 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/CLAUDE.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Max<V>, Min<V>, Sum<W>, Or, And, Extremum<V>, ExtremumSense
149149
- `NumericSize` supertrait bundles common numeric bounds (`Clone + Default + PartialOrd + Num + Zero + Bounded + AddAssign + 'static`)
150150

151151
### Parameter Relations
152-
Each reduction declares one rule-level parameter relation using the `Expr` AST in `src/expr.rs`. The `transform` declaration is required:
152+
Each reduction declares explicit per-field parameter relations using the `Expr` AST in `src/expr.rs`. The `transform` declaration is required:
153153
```rust
154154
#[reduction(transform = upper_bound {
155155
num_vertices = "num_vertices + num_clauses",
@@ -159,11 +159,12 @@ impl ReduceTo<Target> for Source { ... }
159159
```
160160
- Expression strings are parsed at compile time by a Pratt parser in the proc macro crate
161161
- Variable names are validated against the source problem's canonical parameter schema
162-
- Use `transform = exact { ... }` when every formula is an equality and `transform = upper_bound { ... }` when every formula is only an upper bound. One expression block cannot mix relations.
162+
- Use `transform = exact { ... }` when every formula is an equality and `transform = upper_bound { ... }` when every formula is only an upper bound. For mixed accuracy, use `transform = { exact { ... }, upper_bound { ... }, unavailable { ... } }`. Every formula RHS uses only registered source parameters; derive target relationships and substitute source expressions before declaring them.
163163
- Use `transform = unavailable { ... }` when no formula is representable, or an auxiliary `unavailable = { ... }` block for omitted target parameters.
164164
- Every target parameter must appear exactly once as a formula or as unavailable with a non-empty reason.
165-
- `ParameterTransform` evaluates and composes formulas with exact rational and arbitrary-precision integer arithmetic. Unsafe upper-bound composition becomes unavailable; it never performs budget pruning or path ranking.
165+
- `ParameterTransform` evaluates and composes formulas with exact rational and arbitrary-precision integer arithmetic. Composition preserves independent fields and their accuracy. An unavailable dependency or unsafe upper-bound substitution makes only the affected field unavailable; it never performs budget pruning or path ranking.
166166
- Concrete instance parameters come from each endpoint instance's `Problem::parameters()` implementation; `ReductionEntry` stores only the symbolic parameter relation.
167+
- Rules producing ILP must target the most specific applicable registered variant: `ILP<bool>` for binary variables, `ILP<i64, i64, Bounded>` for explicit finite integer domains, and general `ILP<i64>` otherwise. Supply finite domains with `ILP::with_variables`; constraint rows alone do not supply bounds to binary encoding. Bounds on auxiliary variables must preserve feasibility and the optimum. The independent `bounds` dimension defaults to `general`; register additional concrete variants only when a reduction needs them.
167168
- `VariantEntry` has both a complexity string and compiled `complexity_eval_fn` — same pattern
168169
- Expressions support: constants, variables, `+`, `-`, `*`, `/`, `^`, `exp()`, `log()`, `sqrt()`, `factorial()`
169170
- Complexity strings must use **concrete numeric values only** (e.g., `"2^(2.372 * num_vertices / 3)"`, not `"2^(omega * num_vertices / 3)"`)
@@ -182,7 +183,7 @@ Reduction graph nodes use variant key-value pairs from `Problem::variant()`:
182183
- Same-name variant relations are explicit `#[reduction]` registrations
183184
- Each primitive reduction is determined by the exact `(source_variant, target_variant)` endpoint pair
184185
- Reduction edges carry `EdgeCapabilities { witness, aggregate, turing }`; graph search defaults to witness mode, aggregate mode is available through `ReductionMode::Aggregate`, and Turing (multi-query) mode via `ReductionMode::Turing`
185-
- `#[reduction]` requires one `transform = exact`, `transform = upper_bound`, or `transform = unavailable` declaration and registers witness/config reductions; aggregate value mappings register through `#[aggregate_reduction]` / `register_aggregate_reduction!` (see Key Patterns); Turing edges (generated by `register_decision_variant!`) and metadata-only edges without an executor use a manual `ReductionEntry`
186+
- `#[reduction]` requires one uniform or mixed `transform` declaration and registers witness/config reductions; aggregate value mappings register through `#[aggregate_reduction]` / `register_aggregate_reduction!` (see Key Patterns); Turing edges (generated by `register_decision_variant!`) and metadata-only edges without an executor use a manual `ReductionEntry`
186187
- `Decision<P> → P` supports both mappings: compare the exact optimum to the bound, and recover a witness only if it meets the bound. `P → Decision<P>` is a Turing edge (binary search over decision bound).
187188

188189
### Extension Points
@@ -316,8 +317,9 @@ The complexity string represents the **worst-case time complexity of the best kn
316317

317318
### Reduction Parameter Relation (`#[reduction(transform = exact|upper_bound {...})]`)
318319
Parameter expressions describe how target problem parameters relate to source problem parameters. To verify correctness:
319-
1. Read the `reduce_to()` implementation and count the actual output sizes
320+
1. Derive parameter bounds from every construction block in `reduce_to()`, including early returns, skipped rows, duplicate terms, and target normalization. Use a simple proved upper bound by default; declare equality only when it holds for every accepted input.
320321
2. Check that each field (e.g., `num_vertices`, `num_edges`, `num_sets`) matches the constructed target problem
321322
3. Watch for common errors: universe elements mismatch (edge indices vs vertex indices), worst-case edge counts in intersection graphs (quadratic, not linear), constant factors in circuit constructions
322323
4. Test with concrete small instances: construct a source problem, run the reduction, and compare target parameters against the formula
323324
5. Ensure there is only one primitive reduction registration for each exact source/target variant pair; wrap shared helpers instead of registering duplicate endpoints
325+
6. Every new rule's `exact` and `upper_bound` fields must be covered by `src/unit_tests/parameter_formula_validation.rs`: evaluate each formula on a valid source instance and compare it with measured target parameters (equal for `exact`, predicted ≥ measured for `upper_bound`). Reuse canonical examples and existing behavior tests to check the derived expressions; passing examples supplement the derivation, never establish its correctness. Metadata-only rules have no executable size check and must be identified separately.

‎.claude/skills/how-to-code/SKILL.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Traits and helpers: `src/rules/traits.rs`, `src/rules/test_helpers.rs`, `src/rul
7979
(composed extractors delegate to the first direct decoder).
8080
- `#[reduction(transform = exact { .. })]`, `upper_bound { .. }`, or `unavailable { .. }`, with an
8181
auxiliary `unavailable = { param = "reason" }` block for unrepresentable target parameters.
82-
Every target parameter appears exactly once. There is no `overhead =` form.
82+
Every target parameter appears exactly once. Mixed accuracy uses `transform = { exact { .. }, upper_bound { .. }, unavailable { .. } }`. Derive bounds by counting each construction block, including normalization and early returns; use equality only when guaranteed across the accepted domain. There is no `overhead =` form.
8383
- `reduce_to(&self) -> Result<Self::Result, ReductionError>`; wrap target construction failures
8484
with `Self::target_construction(e)`, never stringify.
8585
- Aggregate value mapping: `#[crate::aggregate_reduction] impl AggregateReductionResult` on the
@@ -92,7 +92,7 @@ Traits and helpers: `src/rules/traits.rs`, `src/rules/test_helpers.rs`, `src/rul
9292
don't duplicate endpoints.
9393
4. Tests in `src/unit_tests/rules/<source>_<target>.rs`: `test_<source>_to_<target>_closed_loop`
9494
(use `assert_*_round_trip_*` from `test_helpers.rs`), an infeasible instance, target structure
95-
and parameter counts vs the transform, and one test per malformed representation the decoder
95+
and parameter counts vs the transform (reuse existing inputs; the shared executable-rule check lives in `src/unit_tests/parameter_formula_validation.rs`), and one test per malformed representation the decoder
9696
rejects (zero/multiple one-hot bits, duplicate permutation entries, ...). Aggregate edges: test
9797
`extract_value` against `BruteForce::solve` on both sides.
9898
5. Paper `reduction-rule` entry — how-to-write-manual (adapt the how-to-verify proof, don't rewrite).

‎.claude/skills/how-to-verify/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ per (n, m) where full enumeration is infeasible). Seven sections, none empty:
5656
1. symbolic (sympy) check of every overhead formula — "trivial" is no excuse;
5757
2. exhaustive forward + backward: source feasible ⇔ target feasible (optimum preserved);
5858
3. extraction from every feasible target witness (the most skipped section);
59-
4. measured target size vs formula;
59+
4. measured target size vs formula; first derive each bound from the construction, covering branches, omitted rows, and coefficient normalization; equality requires a full-domain argument, not agreement on examples;
6060
5. structural well-formedness of the target (gadget invariants, no degenerate cases);
6161
6. YES example reproduced number-for-number;
6262
7. NO example reproduced, both sides infeasible.

0 commit comments

Comments
 (0)